diff --git a/cibseven-direct-provider/.gitignore b/cibseven-direct-provider/.gitignore new file mode 100644 index 000000000..8cdd3077b --- /dev/null +++ b/cibseven-direct-provider/.gitignore @@ -0,0 +1,15 @@ +/target/ +/.settings/ +/.classpath +/.project +/bin/ +/.springBeans +/build/ +/src/main/resources/seven-webclient.yaml + +# IntelliJ +.idea/ +*.iml + +# MacOS +.DS_Store diff --git a/cibseven-direct-provider/pom.xml b/cibseven-direct-provider/pom.xml new file mode 100755 index 000000000..bcf2767bc --- /dev/null +++ b/cibseven-direct-provider/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + + org.cibseven.webapp + cibseven-webclient + 2.2.0-SNAPSHOT + + cibseven-direct-provider + CIB seven webclient direct provider + Services of the direct provider access to the cibseven engine + + + + jakarta.ws.rs + jakarta.ws.rs-api + + + org.cibseven.bpm + cibseven-engine-rest-core-jakarta + ${project.version} + + + org.cibseven.bpm + cibseven-engine + provided + jar + ${project.version} + + + org.cibseven.webapp + cibseven-interfaces + ${project.version} + + + + + diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectActivityProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectActivityProvider.java new file mode 100755 index 000000000..05189a1fa --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectActivityProvider.java @@ -0,0 +1,158 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.history.HistoricActivityInstance; +import org.cibseven.bpm.engine.history.HistoricActivityInstanceQuery; +import org.cibseven.bpm.engine.rest.dto.history.HistoricActivityInstanceDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricActivityInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.ActivityInstanceDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.ActivityInstance; +import org.cibseven.webapp.rest.model.ActivityInstanceHistory; + +public class DirectActivityProvider implements IActivityProvider { + + DirectProviderUtil directProviderUtil; + public DirectActivityProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public ActivityInstance findActivityInstance(String processInstanceId, CIBUser user) { + org.cibseven.bpm.engine.runtime.ActivityInstance activityInstance = null; + try { + activityInstance = directProviderUtil.getProcessEngine(user).getRuntimeService().getActivityInstance(processInstanceId); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage(), e); + } + + if (activityInstance == null) { + throw new NoObjectFoundException(new SystemException("Process instance with id " + processInstanceId + " does not exist")); + } + + ActivityInstanceDto result = ActivityInstanceDto.fromActivityInstance(activityInstance); + return directProviderUtil.convertValue(result, ActivityInstance.class, user); + } + + @Override + public List findActivitiesInstancesHistory(Map queryParams, CIBUser user) { + HistoricActivityInstanceQueryDto queryHistoricActivityInstanceDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, + HistoricActivityInstanceQueryDto.class); + return queryHistoricActivityInstance(queryHistoricActivityInstanceDto, user); + + } + + @Override + public List findActivitiesInstancesHistory(String processInstanceId, CIBUser user) { + HistoricActivityInstanceQueryDto queryHistoricActivityInstanceDto = new HistoricActivityInstanceQueryDto(); + queryHistoricActivityInstanceDto.setProcessInstanceId(processInstanceId); + return queryHistoricActivityInstance(queryHistoricActivityInstanceDto, user); + } + + @Override + public ActivityInstance findActivityInstances(String processInstanceId, CIBUser user) throws SystemException { + + org.cibseven.bpm.engine.runtime.ActivityInstance activityInstance = null; + + try { + activityInstance = directProviderUtil.getProcessEngine(user).getRuntimeService().getActivityInstance(processInstanceId); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage(), e); + } + + if (activityInstance == null) { + throw new NoObjectFoundException(new SystemException("Process instance with id " + processInstanceId + " does not exist")); + } + + ActivityInstanceDto result = ActivityInstanceDto.fromActivityInstance(activityInstance); + return directProviderUtil.convertValue(result, ActivityInstance.class, user); + } + + @Override + public List findActivityInstanceHistory(String processInstanceId, CIBUser user) + throws SystemException { + + HistoricActivityInstanceQueryDto queryHistoricActivityInstanceDto = new HistoricActivityInstanceQueryDto(); + queryHistoricActivityInstanceDto.setProcessInstanceId(processInstanceId); + return queryHistoricActivityInstance(queryHistoricActivityInstanceDto, user); + } + + @Override + public void deleteVariableByExecutionId(String executionId, String variableName, CIBUser user) { + try { + directProviderUtil.getProcessEngine(user).getRuntimeService().removeVariableLocal(executionId, variableName); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot delete %s variable %s: %s", executionId, variableName, e.getMessage()); + throw new SystemException(errorMessage, e); + } + + } + + @Override + public void deleteVariableHistoryInstance(String id, CIBUser user) { + try { + directProviderUtil.getProcessEngine(user).getHistoryService().deleteHistoricVariableInstance(id); + } catch (NotFoundException nfe) { // rewrite status code from bad request + // (400) to not found (404) + throw new SystemException(nfe.getMessage(), nfe); + } + } + + @Override + public Collection findActivitiesProcessDefinitionHistory(String processDefinitionId, + Map params, CIBUser user) { + HistoricActivityInstanceQueryDto queryHistoricActivityInstanceDto = directProviderUtil.getObjectMapper(user).convertValue(params, + HistoricActivityInstanceQueryDto.class); + queryHistoricActivityInstanceDto.setProcessDefinitionId(processDefinitionId); + return queryHistoricActivityInstance(queryHistoricActivityInstanceDto, user); + + } + + private List queryHistoricActivityInstance( + HistoricActivityInstanceQueryDto queryHistoricActivityInstanceDto, CIBUser user) { + queryHistoricActivityInstanceDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricActivityInstanceQuery query = queryHistoricActivityInstanceDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingHistoricActivityInstances = QueryUtil.list(query, null, null); + + List historicActivityInstanceResults = new ArrayList<>(); + for (HistoricActivityInstance historicActivityInstance : matchingHistoricActivityInstances) { + HistoricActivityInstanceDto resultHistoricActivityInstance = new HistoricActivityInstanceDto(); + HistoricActivityInstanceDto.fromHistoricActivityInstance(resultHistoricActivityInstance, historicActivityInstance); + historicActivityInstanceResults.add(directProviderUtil.convertValue(resultHistoricActivityInstance, ActivityInstanceHistory.class, user)); + } + return historicActivityInstanceResults; + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectBatchProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectBatchProvider.java new file mode 100755 index 000000000..1d7e3db60 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectBatchProvider.java @@ -0,0 +1,274 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.cibseven.bpm.engine.BadUserRequestException; +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.batch.BatchQuery; +import org.cibseven.bpm.engine.batch.BatchStatistics; +import org.cibseven.bpm.engine.batch.BatchStatisticsQuery; +import org.cibseven.bpm.engine.batch.history.HistoricBatch; +import org.cibseven.bpm.engine.batch.history.HistoricBatchQuery; +import org.cibseven.bpm.engine.history.CleanableHistoricBatchReport; +import org.cibseven.bpm.engine.history.CleanableHistoricBatchReportResult; +import org.cibseven.bpm.engine.history.SetRemovalTimeSelectModeForHistoricBatchesBuilder; +import org.cibseven.bpm.engine.rest.dto.batch.BatchDto; +import org.cibseven.bpm.engine.rest.dto.batch.BatchQueryDto; +import org.cibseven.bpm.engine.rest.dto.batch.BatchStatisticsDto; +import org.cibseven.bpm.engine.rest.dto.batch.BatchStatisticsQueryDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.CleanableHistoricBatchReportDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.CleanableHistoricBatchReportResultDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.HistoricBatchDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.HistoricBatchQueryDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.removaltime.SetRemovalTimeToHistoricBatchesDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Batch; +import org.cibseven.webapp.rest.model.HistoryBatch; + +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; + +public class DirectBatchProvider implements IBatchProvider { + + DirectProviderUtil directProviderUtil; + + DirectBatchProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection getBatches(Map params, CIBUser user) { + MultivaluedMap multiValueMap = new MultivaluedHashMap<>(); + Integer firstResult = null; + Integer maxResults = null; + for (Entry entry : params.entrySet()) { + if (entry.getKey().equals("firstResult")) + firstResult = Integer.parseInt((String) params.get("firstResult")); + else if (entry.getKey().equals("maxResults")) + maxResults = Integer.parseInt((String) params.get("maxResults")); + else + multiValueMap.put(entry.getKey(), Arrays.asList((String) entry.getValue())); + } + BatchQueryDto queryDto = new BatchQueryDto(directProviderUtil.getObjectMapper(user), multiValueMap); + BatchQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingBatches = QueryUtil.list(query, firstResult, maxResults); + + List batchResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.batch.Batch matchingBatch : matchingBatches) { + batchResults.add(directProviderUtil.convertValue(BatchDto.fromBatch(matchingBatch), Batch.class, user)); + } + batchResults.forEach(batch -> { + + String batchId = batch.getId(); + Map statParams = new HashMap<>(); + statParams.put("batchId", batchId); + + Collection statList = getBatchStatistics(statParams, user); + if (!statList.isEmpty()) { + Batch stats = statList.iterator().next(); + batch.setCompletedJobs(stats.getCompletedJobs()); + batch.setRemainingJobs(stats.getRemainingJobs()); + batch.setFailedJobs(stats.getFailedJobs()); + } + }); + + return batchResults; + } + + @Override + public Collection getBatchStatistics(Map params, CIBUser user) { + MultivaluedMap multiValueMap = new MultivaluedHashMap<>(); + Integer firstResult = null; + Integer maxResults = null; + for (Entry entry : params.entrySet()) { + if (entry.getKey().equals("firstResult")) + firstResult = Integer.parseInt((String) entry.getValue()); + else if (entry.getKey().equals("maxResults")) + maxResults = Integer.parseInt((String) entry.getValue()); + else + multiValueMap.put(entry.getKey(), Arrays.asList((String) entry.getValue())); + } + BatchStatisticsQueryDto queryDto = new BatchStatisticsQueryDto(directProviderUtil.getObjectMapper(user), multiValueMap); + BatchStatisticsQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List batchStatisticsList = QueryUtil.list(query, firstResult, maxResults); + + List statisticsResults = new ArrayList<>(); + for (BatchStatistics batchStatistics : batchStatisticsList) { + statisticsResults.add(directProviderUtil.convertValue(BatchStatisticsDto.fromBatchStatistics(batchStatistics), Batch.class, user)); + } + + return statisticsResults; + } + + @Override + public void deleteBatch(String id, Map params, CIBUser user) { + Boolean cascade = false; + if (params.containsKey("cascade")) + cascade = params.get("cascade").equals("true"); + try { + directProviderUtil.getProcessEngine(user).getManagementService().deleteBatch(id, cascade); + } catch (BadUserRequestException e) { + throw new SystemException("Unable to delete batch with id '" + id + "'", e); + } + } + + @Override + public void setBatchSuspensionState(String id, Map params, CIBUser user) { + Boolean suspended = false; + if (params.containsKey("suspended")) + suspended = params.get("suspended").equals("true"); + + if (suspended) { + try { + directProviderUtil.getProcessEngine(user).getManagementService().suspendBatchById(id); + } catch (BadUserRequestException e) { + throw new SystemException("Unable to suspend batch with id '" + id + "'", e); + } + } else { + try { + directProviderUtil.getProcessEngine(user).getManagementService().activateBatchById(id); + } catch (BadUserRequestException e) { + throw new SystemException("Unable to activate batch with id '" + id + "'", e); + } + } + } + + @Override + public Collection getHistoricBatches(Map params, CIBUser user) { + HistoricBatchQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, HistoricBatchQueryDto.class); + HistoricBatchQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + Integer firstResult = null; + Integer maxResults = null; + for (Entry entry : params.entrySet()) { + if (entry.getKey().equals("firstResult")) + firstResult = Integer.parseInt((String) params.get("firstResult")); + else if (entry.getKey().equals("maxResults")) + maxResults = Integer.parseInt((String) params.get("maxResults")); + } + List matchingBatches = QueryUtil.list(query, firstResult, maxResults); + + List batchResults = new ArrayList<>(); + for (HistoricBatch matchingBatch : matchingBatches) { + batchResults.add(directProviderUtil.convertValue(HistoricBatchDto.fromBatch(matchingBatch), HistoryBatch.class, user)); + } + return batchResults; + } + + @Override + public Long getHistoricBatchCount(Map queryParams, CIBUser user) { + HistoricBatchQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, HistoricBatchQueryDto.class); + HistoricBatchQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + return query.count(); + } + + @Override + public HistoryBatch getHistoricBatchById(String id, CIBUser user) { + HistoricBatch batch = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricBatchQuery().batchId(id).singleResult(); + + if (batch == null) { + throw new NoObjectFoundException(new SystemException("Historic batch with id '" + id + "' does not exist")); + } + + return directProviderUtil.convertValue(HistoricBatchDto.fromBatch(batch), HistoryBatch.class, user); + } + + @Override + public void deleteHistoricBatch(String id, CIBUser user) { + try { + directProviderUtil.getProcessEngine(user).getHistoryService().deleteHistoricBatch(id); + } catch (BadUserRequestException e) { + throw new SystemException("Unable to delete historic batch with id '" + id + "'", e); + } + } + + @Override + public Object setRemovalTime(Map payload, CIBUser user) { + SetRemovalTimeToHistoricBatchesDto dto = directProviderUtil.getObjectMapper(user).convertValue(payload, SetRemovalTimeToHistoricBatchesDto.class); + HistoricBatchQuery historicBatchQuery = null; + + if (dto.getHistoricBatchQuery() != null) { + historicBatchQuery = dto.getHistoricBatchQuery().toQuery(directProviderUtil.getProcessEngine(user)); + } + + SetRemovalTimeSelectModeForHistoricBatchesBuilder builder = directProviderUtil.getProcessEngine(user).getHistoryService().setRemovalTimeToHistoricBatches(); + + if (dto.isCalculatedRemovalTime()) { + builder.calculatedRemovalTime(); + } + + Date removalTime = dto.getAbsoluteRemovalTime(); + if (dto.getAbsoluteRemovalTime() != null) { + builder.absoluteRemovalTime(removalTime); + } + + if (dto.isClearedRemovalTime()) { + builder.clearedRemovalTime(); + } + + builder.byIds(dto.getHistoricBatchIds()); + builder.byQuery(historicBatchQuery); + + org.cibseven.bpm.engine.batch.Batch batch = builder.executeAsync(); + return directProviderUtil.convertValue(BatchDto.fromBatch(batch), Batch.class, user); + } + + @Override + public Object getCleanableBatchReport(Map queryParams, CIBUser user) { + MultivaluedMap multiValueMap = new MultivaluedHashMap<>(); + for (String key : queryParams.keySet()) { + multiValueMap.put(key, Arrays.asList((String) queryParams.get(key))); + } + CleanableHistoricBatchReportDto queryDto = new CleanableHistoricBatchReportDto(directProviderUtil.getObjectMapper(user), multiValueMap); + CleanableHistoricBatchReport query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List reportResult = QueryUtil.list(query, null, null); + + return CleanableHistoricBatchReportResultDto.convert(reportResult); + } + + @Override + public Object getCleanableBatchReportCount(CIBUser user) { + MultivaluedMap multiValueMap = new MultivaluedHashMap<>(); + CleanableHistoricBatchReportDto queryDto = new CleanableHistoricBatchReportDto(directProviderUtil.getObjectMapper(user), multiValueMap); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + CleanableHistoricBatchReport query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + return query.count(); + } + + @Override + public Long getRuntimeBatchCount(Map queryParams, CIBUser user) { + ProcessEngine processEngine = directProviderUtil.getProcessEngine(user); + BatchQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, BatchQueryDto.class); + BatchQuery query = queryDto.toQuery(processEngine); + + return query.count(); + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectDecisionProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectDecisionProvider.java new file mode 100755 index 000000000..cc211270c --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectDecisionProvider.java @@ -0,0 +1,416 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.apache.commons.io.IOUtils; +import org.cibseven.bpm.dmn.engine.DmnDecisionResult; +import org.cibseven.bpm.dmn.engine.DmnDecisionResultEntries; +import org.cibseven.bpm.dmn.engine.DmnEngineException; +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.BadUserRequestException; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.exception.NotValidException; +import org.cibseven.bpm.engine.history.HistoricDecisionInstanceQuery; +import org.cibseven.bpm.engine.history.SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder; +import org.cibseven.bpm.engine.impl.util.IoUtil; +import org.cibseven.bpm.engine.repository.DecisionDefinition; +import org.cibseven.bpm.engine.repository.DecisionDefinitionQuery; +import org.cibseven.bpm.engine.rest.dto.HistoryTimeToLiveDto; +import org.cibseven.bpm.engine.rest.dto.VariableValueDto; +import org.cibseven.bpm.engine.rest.dto.batch.BatchDto; +import org.cibseven.bpm.engine.rest.dto.dmn.EvaluateDecisionDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricDecisionInstanceDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricDecisionInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.DeleteHistoricDecisionInstancesDto; +import org.cibseven.bpm.engine.rest.dto.history.batch.removaltime.SetRemovalTimeToHistoricDecisionInstancesDto; +import org.cibseven.bpm.engine.rest.dto.repository.DecisionDefinitionDiagramDto; +import org.cibseven.bpm.engine.rest.dto.repository.DecisionDefinitionDto; +import org.cibseven.bpm.engine.rest.dto.repository.DecisionDefinitionQueryDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.variable.VariableMap; +import org.cibseven.bpm.engine.variable.Variables; +import org.cibseven.bpm.engine.variable.value.TypedValue; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Decision; +import org.cibseven.webapp.rest.model.HistoricDecisionInstance; + +public class DirectDecisionProvider implements IDecisionProvider { + + DirectProviderUtil directProviderUtil; + + DirectDecisionProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection getDecisionDefinitionList(Map queryParams, CIBUser user) { + DecisionDefinitionQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, DecisionDefinitionQueryDto.class); + List definitions = new ArrayList<>(); + DecisionDefinitionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingDefinitions = QueryUtil.list(query, null, null); + for (DecisionDefinition definition : matchingDefinitions) { + DecisionDefinitionDto def = DecisionDefinitionDto.fromDecisionDefinition(definition); + definitions.add(directProviderUtil.convertValue(def, Decision.class, user)); + } + return definitions; + } + + @Override + public Long getDecisionDefinitionListCount(Map queryParams, CIBUser user) { + DecisionDefinitionQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, DecisionDefinitionQueryDto.class); + DecisionDefinitionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + return query.count(); + } + + @Override + public Decision getDecisionDefinitionByKey(String key, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, null, user); + return directProviderUtil.convertValue(DecisionDefinitionDto.fromDecisionDefinition(decisionDefinition), Decision.class, user); + } + + @Override + public Object getDiagramByKey(String key, CIBUser user) { + return getDiagramByKeyAndTenant(key, null, user); + } + + @Override + public Object evaluateDecisionDefinitionByKey(Map data, String key, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, null, user); + + return evaluateDecisionDefinitionById(decisionDefinition.getId(), data, user); + } + + @Override + public void updateHistoryTTLByKey(Map data, String key, CIBUser user) { + + HistoryTimeToLiveDto historyTimeToLiveDto = directProviderUtil.getObjectMapper(user).convertValue(data, HistoryTimeToLiveDto.class); + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, null, user); + directProviderUtil.getProcessEngine(user).getRepositoryService().updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), + historyTimeToLiveDto.getHistoryTimeToLive()); + } + + @Override + public Decision getDecisionDefinitionByKeyAndTenant(String key, String tenant, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, tenant, user); + DecisionDefinitionDto dto = DecisionDefinitionDto.fromDecisionDefinition(decisionDefinition); + return directProviderUtil.convertValue(dto, Decision.class, user); + } + + @Override + public Object getDiagramByKeyAndTenant(String key, String tenant, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, tenant, user); + return getDiagramByDecisionDefinition(decisionDefinition, user); + } + + @Override + public Object evaluateDecisionDefinitionByKeyAndTenant(Map data, String key, String tenant, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, tenant, user); + + return evaluateDecisionDefinitionById(decisionDefinition.getId(), data, user); + } + + @Override + public void updateHistoryTTLByKeyAndTenant(Map data, String key, String tenant, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, tenant, user); + updateHistoryTTLById(decisionDefinition.getId(), data, user); + } + + @Override + public Object getXmlByKey(String key, CIBUser user) { + return getXmlByKeyAndTenant(key, null, user); + } + + @Override + public Object getXmlByKeyAndTenant(String key, String tenant, CIBUser user) { + DecisionDefinition decisionDefinition = getDecisionDefinitionByKeyAndTenantImpl(key, tenant, user); + return getXmlByDefinitionId(decisionDefinition.getId(), user); + } + + @Override + public Decision getDecisionDefinitionById(String id, Optional extraInfo, CIBUser user) { + DecisionDefinition definition = getDecisionDefinitionById(id, user); + Decision decision = directProviderUtil.convertValue(DecisionDefinitionDto.fromDecisionDefinition(definition), Decision.class, user); + if (extraInfo.isPresent() && extraInfo.get()) { + Map queryParams = new HashMap<>(); + queryParams.put("decisionDefinitionId", definition.getId()); + Long count = getHistoricDecisionInstanceCount(queryParams, user); + decision.setAllInstances(count); + } + return decision; + } + + @Override + public Object getDiagramById(String id, CIBUser user) { + DecisionDefinition definition = getDecisionDefinitionById(id, user); + return getDiagramByDecisionDefinition(definition, user); + } + + @Override + public Object evaluateDecisionDefinitionById(String id, Map data, CIBUser user) { + try { + EvaluateDecisionDto parameters = directProviderUtil.getObjectMapper(user).convertValue(data, EvaluateDecisionDto.class); + Map variables = VariableValueDto.toMap(parameters.getVariables(), directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user)); + DmnDecisionResult decisionResult = directProviderUtil.getProcessEngine(user).getDecisionService().evaluateDecisionById(id) + .variables(variables).evaluate(); + + List> dto = new ArrayList<>(); + + for (DmnDecisionResultEntries entries : decisionResult) { + Map resultEntriesDto = createResultEntriesDto(entries); + dto.add(resultEntriesDto); + } + return dto; + + } catch (AuthorizationException e) { + throw e; + } catch (NotFoundException e) { + String errorMessage = String.format("Cannot evaluate decision %s: %s", id, e.getMessage()); + throw new SystemException(errorMessage, e); + } catch (NotValidException e) { + String errorMessage = String.format("Cannot evaluate decision %s: %s", id, e.getMessage()); + throw new SystemException(errorMessage, e); + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot evaluate decision %s: %s", id, e.getMessage()); + throw new SystemException(errorMessage, e); + } catch (DmnEngineException e) { + String errorMessage = String.format("Cannot evaluate decision %s: %s", id, e.getMessage()); + throw new SystemException(errorMessage, e); + } + } + + @Override + public void updateHistoryTTLById(String id, Map data, CIBUser user) { + HistoryTimeToLiveDto historyTimeToLiveDto = directProviderUtil.getObjectMapper(user).convertValue(data, HistoryTimeToLiveDto.class); + directProviderUtil.getProcessEngine(user).getRepositoryService().updateDecisionDefinitionHistoryTimeToLive(id, historyTimeToLiveDto.getHistoryTimeToLive()); + } + + @Override + public Object getXmlById(String id, CIBUser user) { + return getXmlByDefinitionId(id, user); + } + + @Override + public Collection getDecisionVersionsByKey(String key, Optional lazyLoad, CIBUser user) { + List decisionDefinitions = directProviderUtil.getProcessEngine(user).getRepositoryService().createDecisionDefinitionQuery() + .decisionDefinitionKey(key).withoutTenantId().unlimitedList(); + + if (decisionDefinitions == null || decisionDefinitions.isEmpty()) { + String errorMessage = String.format("No matching decision definition with key: %s and no tenant-id", key); + throw new SystemException(errorMessage); + } + List decisions = new ArrayList<>(); + for (DecisionDefinition decisionDefinition : decisionDefinitions) { + DecisionDefinitionDto decisionDefinitionDto = DecisionDefinitionDto.fromDecisionDefinition(decisionDefinition); + decisions.add(directProviderUtil.convertValue(decisionDefinitionDto, Decision.class, user)); + } + return decisions; + } + + @Override + public Collection getHistoricDecisionInstances(Map queryParams, + CIBUser user) { + HistoricDecisionInstanceQueryDto queryHistoricDecisionInstanceDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, + HistoricDecisionInstanceQueryDto.class); + HistoricDecisionInstanceQuery query = queryHistoricDecisionInstanceDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingHistoricDecisionInstances = QueryUtil + .list(query, null, null); + + List historicDecisionInstanceDtoResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.history.HistoricDecisionInstance historicDecisionInstance : matchingHistoricDecisionInstances) { + HistoricDecisionInstanceDto resultHistoricDecisionInstanceDto = HistoricDecisionInstanceDto + .fromHistoricDecisionInstance(historicDecisionInstance); + historicDecisionInstanceDtoResults + .add(directProviderUtil.convertValue(resultHistoricDecisionInstanceDto, HistoricDecisionInstance.class, user)); + } + return historicDecisionInstanceDtoResults; + } + + @Override + public Long getHistoricDecisionInstanceCount(Map queryParams, CIBUser user) { + HistoricDecisionInstanceQueryDto queryHistoricDecisionInstanceDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, + HistoricDecisionInstanceQueryDto.class); + HistoricDecisionInstanceQuery query = queryHistoricDecisionInstanceDto.toQuery(directProviderUtil.getProcessEngine(user)); + return query.count(); + } + + @Override + public HistoricDecisionInstance getHistoricDecisionInstanceById(String id, Map queryParams, + CIBUser user) { + + HistoricDecisionInstanceQueryDto historicDecisionInstanceQueryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, + HistoricDecisionInstanceQueryDto.class); + historicDecisionInstanceQueryDto.setDecisionInstanceId(id); + HistoricDecisionInstanceQuery query = historicDecisionInstanceQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + org.cibseven.bpm.engine.history.HistoricDecisionInstance instance = query.singleResult(); + + if (instance == null) { + throw new NoObjectFoundException(new SystemException("Historic decision instance with id '" + id + "' does not exist")); + } + + return directProviderUtil.convertValue(HistoricDecisionInstanceDto.fromHistoricDecisionInstance(instance), + HistoricDecisionInstance.class, user); + } + + @Override + public Object deleteHistoricDecisionInstances(Map data, CIBUser user) { + + DeleteHistoricDecisionInstancesDto dto = directProviderUtil.getObjectMapper(user).convertValue(data, DeleteHistoricDecisionInstancesDto.class); + HistoricDecisionInstanceQuery decisionInstanceQuery = null; + if (dto.getHistoricDecisionInstanceQuery() != null) { + decisionInstanceQuery = dto.getHistoricDecisionInstanceQuery().toQuery(directProviderUtil.getProcessEngine(user)); + } + + try { + List historicDecisionInstanceIds = dto.getHistoricDecisionInstanceIds(); + String deleteReason = dto.getDeleteReason(); + org.cibseven.bpm.engine.batch.Batch batch = directProviderUtil.getProcessEngine(user).getHistoryService() + .deleteHistoricDecisionInstancesAsync(historicDecisionInstanceIds, decisionInstanceQuery, deleteReason); + return BatchDto.fromBatch(batch); + } catch (BadUserRequestException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public Object setHistoricDecisionInstanceRemovalTime(Map data, CIBUser user) { + SetRemovalTimeToHistoricDecisionInstancesDto dto = directProviderUtil.getObjectMapper(user).convertValue(data, + SetRemovalTimeToHistoricDecisionInstancesDto.class); + + HistoricDecisionInstanceQuery historicDecisionInstanceQuery = null; + + if (dto.getHistoricDecisionInstanceQuery() != null) { + historicDecisionInstanceQuery = dto.getHistoricDecisionInstanceQuery().toQuery(directProviderUtil.getProcessEngine(user)); + + } + + SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder builder = directProviderUtil.getProcessEngine(user).getHistoryService() + .setRemovalTimeToHistoricDecisionInstances(); + + if (dto.isCalculatedRemovalTime()) { + builder.calculatedRemovalTime(); + + } + + Date removalTime = dto.getAbsoluteRemovalTime(); + if (dto.getAbsoluteRemovalTime() != null) { + builder.absoluteRemovalTime(removalTime); + + } + + if (dto.isClearedRemovalTime()) { + builder.clearedRemovalTime(); + + } + + builder.byIds(dto.getHistoricDecisionInstanceIds()); + builder.byQuery(historicDecisionInstanceQuery); + + if (dto.isHierarchical()) { + builder.hierarchical(); + + } + + org.cibseven.bpm.engine.batch.Batch batch = builder.executeAsync(); + return BatchDto.fromBatch(batch); + } + + private DecisionDefinition getDecisionDefinitionByKeyAndTenantImpl(String key, String tenantId, CIBUser user) { + DecisionDefinitionQuery query = directProviderUtil.getProcessEngine(user).getRepositoryService().createDecisionDefinitionQuery().decisionDefinitionKey(key); + if (tenantId == null) + query.withoutTenantId(); + else + query.tenantIdIn(new String[] { tenantId }); + + DecisionDefinition decisionDefinition = query.latestVersion().singleResult(); + + if (decisionDefinition == null) { + String errorMessage = String.format("No matching decision definition with key: %s and no tenant-id", key); + throw new SystemException(errorMessage); + } + return decisionDefinition; + } + + private Object getXmlByDefinitionId(String definitionId, CIBUser user) { + InputStream decisionModelInputStream = null; + try { + decisionModelInputStream = directProviderUtil.getProcessEngine(user).getRepositoryService().getDecisionModel(definitionId); + + byte[] decisionModel = IoUtil.readInputStream(decisionModelInputStream, "decisionModelDmnXml"); + return DecisionDefinitionDiagramDto.create(definitionId, new String(decisionModel, "UTF-8")); + + } catch (ProcessEngineException | UnsupportedEncodingException e) { + throw new SystemException(e.getMessage(), e); + + } finally { + IoUtil.closeSilently(decisionModelInputStream); + } + } + + private Object getDiagramByDecisionDefinition(DecisionDefinition decisionDefinition, CIBUser user) { + InputStream decisionDiagram = directProviderUtil.getProcessEngine(user).getRepositoryService().getDecisionDiagram(decisionDefinition.getId()); + if (decisionDiagram == null) { + throw new SystemException("Diagram of decision " + decisionDefinition.getId() + " not found."); + } else { + try { + byte[] byteContent = IOUtils.toByteArray(decisionDiagram); + return DecisionDefinitionDiagramDto.create(decisionDefinition.getDiagramResourceName(), new String(byteContent, "UTF-8")); + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } finally { + IoUtil.closeSilently(decisionDiagram); + } + } + } + + private DecisionDefinition getDecisionDefinitionById(String id, CIBUser user) { + + DecisionDefinition definition = null; + try { + definition = directProviderUtil.getProcessEngine(user).getRepositoryService().getDecisionDefinition(id); + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage(), e); + } + return definition; + } + + private Map createResultEntriesDto(DmnDecisionResultEntries entries) { + VariableMap variableMap = Variables.createVariables(); + + for (String key : entries.keySet()) { + TypedValue typedValue = entries.getEntryTyped(key); + variableMap.putValueTyped(key, typedValue); + } + + return VariableValueDto.fromMap(variableMap); + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectDeploymentProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectDeploymentProvider.java new file mode 100755 index 000000000..82dd082a3 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectDeploymentProvider.java @@ -0,0 +1,427 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.RepositoryService; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.exception.NotValidException; +import org.cibseven.bpm.engine.impl.calendar.DateTimeUtil; +import org.cibseven.bpm.engine.impl.util.IoUtil; +import org.cibseven.bpm.engine.repository.DeploymentBuilder; +import org.cibseven.bpm.engine.repository.DeploymentQuery; +import org.cibseven.bpm.engine.repository.DeploymentWithDefinitions; +import org.cibseven.bpm.engine.repository.Resource; +import org.cibseven.bpm.engine.rest.dto.repository.DeploymentDto; +import org.cibseven.bpm.engine.rest.dto.repository.DeploymentQueryDto; +import org.cibseven.bpm.engine.rest.dto.repository.DeploymentResourceDto; +import org.cibseven.bpm.engine.rest.dto.repository.DeploymentWithDefinitionsDto; +import org.cibseven.bpm.engine.rest.dto.repository.RedeploymentDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.Data; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.NoRessourcesFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.exception.WrongDeploymenIdException; +import org.cibseven.webapp.rest.model.Deployment; +import org.cibseven.webapp.rest.model.DeploymentResource; +import org.springframework.core.io.InputStreamResource; +import org.springframework.core.io.InputStreamSource; +import org.springframework.http.MediaType; +import org.springframework.util.MultiValueMap; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; + +public class DirectDeploymentProvider implements IDeploymentProvider{ + + DirectProviderUtil directProviderUtil; + public DirectDeploymentProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + // Required in deployment code + protected static final Map MEDIA_TYPE_MAPPING = new HashMap(); + + static { + MEDIA_TYPE_MAPPING.put("bpmn", MediaType.APPLICATION_XML.toString()); + MEDIA_TYPE_MAPPING.put("cmmn", MediaType.APPLICATION_XML.toString()); + MEDIA_TYPE_MAPPING.put("dmn", MediaType.APPLICATION_XML.toString()); + MEDIA_TYPE_MAPPING.put("json", MediaType.APPLICATION_JSON.toString()); + MEDIA_TYPE_MAPPING.put("xml", MediaType.APPLICATION_XML.toString()); + + MEDIA_TYPE_MAPPING.put("gif", "image/gif"); + MEDIA_TYPE_MAPPING.put("jpeg", "image/jpeg"); + MEDIA_TYPE_MAPPING.put("jpe", "image/jpeg"); + MEDIA_TYPE_MAPPING.put("jpg", "image/jpeg"); + MEDIA_TYPE_MAPPING.put("png", "image/png"); + MEDIA_TYPE_MAPPING.put("svg", "image/svg+xml"); + MEDIA_TYPE_MAPPING.put("tiff", "image/tiff"); + MEDIA_TYPE_MAPPING.put("tif", "image/tiff"); + + MEDIA_TYPE_MAPPING.put("groovy", "text/plain"); + MEDIA_TYPE_MAPPING.put("java", "text/plain"); + MEDIA_TYPE_MAPPING.put("js", "text/plain"); + MEDIA_TYPE_MAPPING.put("php", "text/plain"); + MEDIA_TYPE_MAPPING.put("py", "text/plain"); + MEDIA_TYPE_MAPPING.put("rb", "text/plain"); + + MEDIA_TYPE_MAPPING.put("html", "text/html"); + MEDIA_TYPE_MAPPING.put("txt", "text/plain"); + } + +public final static String DEPLOYMENT_NAME = "deployment-name"; +public final static String DEPLOYMENT_ACTIVATION_TIME = "deployment-activation-time"; +public final static String ENABLE_DUPLICATE_FILTERING = "enable-duplicate-filtering"; +public final static String DEPLOY_CHANGED_ONLY = "deploy-changed-only"; +public final static String DEPLOYMENT_SOURCE = "deployment-source"; +public final static String TENANT_ID = "tenant-id"; + + @Override + public Deployment deployBpmn(MultiValueMap data, MultiValueMap multiFile, + CIBUser user) throws SystemException { + //SevenProvider only adds the first object of each file element to the request + List fileList = new ArrayList<>(); + multiFile.forEach((key, value) -> { + try { + fileList.add(value.get(0)); + } catch (Exception e) { + throw new SystemException(e); + } + }); + DeploymentBuilder deploymentBuilder = extractDeploymentInformation(fileList.toArray(new MultipartFile[0]), data, user); + + if (!deploymentBuilder.getResourceNames().isEmpty()) { + DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult(); + + DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); + + return directProviderUtil.convertValue(deploymentDto, Deployment.class, user); + + } else { + throw new SystemException("No deployment resources contained in the form upload."); + } + } + + @Override + public Long countDeployments(CIBUser user, String nameLike) { + MultivaluedMap queryParams = new MultivaluedHashMap<>(); + if (nameLike != null && !nameLike.isEmpty()) { + queryParams.putSingle("nameLike", nameLike); + } + DeploymentQueryDto queryDto = new DeploymentQueryDto(directProviderUtil.getObjectMapper(user), queryParams); + + DeploymentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + return query.count(); + } + + @Override + public Collection findDeployments(CIBUser user, String nameLike, int firstResult, int maxResults, + String sortBy, String sortOrder) { + MultivaluedMap queryParams = new MultivaluedHashMap<>(); + queryParams.putSingle("sortBy", sortBy); + queryParams.putSingle("sortOrder", sortOrder); + if (nameLike != null && !nameLike.isEmpty()) { + queryParams.putSingle("nameLike", nameLike); + } + + DeploymentQueryDto queryDto = new DeploymentQueryDto(directProviderUtil.getObjectMapper(user), queryParams); + DeploymentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingDeployments = QueryUtil.list(query, firstResult, + maxResults); + List deployments = new ArrayList<>(); + for (org.cibseven.bpm.engine.repository.Deployment deployment : matchingDeployments) { + DeploymentDto def = DeploymentDto.fromDeployment(deployment); + deployments.add(directProviderUtil.convertValue(def, Deployment.class, user)); + } + return deployments; + } + + @Override + public Deployment findDeployment(String deploymentId, CIBUser user) { + org.cibseven.bpm.engine.repository.Deployment deployment = directProviderUtil.getProcessEngine(user).getRepositoryService().createDeploymentQuery() + .deploymentId(deploymentId).singleResult(); + if (deployment == null) { + throw new WrongDeploymenIdException(new SystemException("Deployment with id '" + deploymentId + "' does not exist")); + } + + return directProviderUtil.convertValue(DeploymentDto.fromDeployment(deployment), Deployment.class, user); + } + + @Override + public Collection findDeploymentResources(String deploymentId, CIBUser user) { + List resources = directProviderUtil.getProcessEngine(user).getRepositoryService().getDeploymentResources(deploymentId); + + List deploymentResources = new ArrayList(); + for (Resource resource : resources) { + deploymentResources.add(directProviderUtil.convertValue(DeploymentResourceDto.fromResources(resource), DeploymentResource.class, user)); + } + + if (!deploymentResources.isEmpty()) { + return deploymentResources; + } else { + throw new NoRessourcesFoundException(new SystemException("Deployment resources for deployment id '" + deploymentId + "' do not exist.")); + } + } + + @Override + public Data fetchDataFromDeploymentResource(HttpServletRequest rq, String deploymentId, String resourceId, + String fileName, CIBUser user) { + InputStream resourceAsStream = directProviderUtil.getProcessEngine(user).getRepositoryService().getResourceAsStreamById(deploymentId, resourceId); + if (resourceAsStream != null) { + DeploymentResourceDto resource = getDeploymentResource(resourceId, deploymentId, user); + String name = resource.getName(); + String filename = null; + String mediaType = null; + + if (name != null) { + name = name.replace("\\", "/"); + String[] filenameParts = name.split("/"); + if (filenameParts.length > 0) { + int idx = filenameParts.length - 1; + filename = filenameParts[idx]; + } + + String[] extensionParts = name.split("\\."); + if (extensionParts.length > 0) { + int idx = extensionParts.length - 1; + String extension = extensionParts[idx]; + if (extension != null) { + mediaType = MEDIA_TYPE_MAPPING.get(extension); + } + } + } + + if (filename == null) { + filename = "data"; + } + + if (mediaType == null) { + mediaType = MediaType.APPLICATION_OCTET_STREAM.toString(); + } + + try { + byte[] body = resourceAsStream.readAllBytes(); + if (body == null) + throw new NullPointerException(); + InputStream targetStream = new ByteArrayInputStream(body); + InputStreamSource iso = new InputStreamResource(targetStream); + Data returnValue = new Data(fileName, mediaType, iso, body.length); + return returnValue; + } catch (IOException e) { + throw new SystemException( + "Deployment resource '" + resourceId + "' for deployment id '" + deploymentId + "'could not be read."); + } finally { + IoUtil.closeSilently(resourceAsStream); + } + } else { + throw new SystemException( + "Deployment resource '" + resourceId + "' for deployment id '" + deploymentId + "' does not exist."); + } + } + + @Override + public void deleteDeployment(String deploymentId, Boolean cascade, CIBUser user) throws SystemException { + org.cibseven.bpm.engine.repository.Deployment deployment = directProviderUtil.getProcessEngine(user).getRepositoryService().createDeploymentQuery() + .deploymentId(deploymentId).singleResult(); + if (deployment == null) { + throw new WrongDeploymenIdException(new SystemException("Deployment with id '" + deploymentId + "' do not exist")); + } + + directProviderUtil.getProcessEngine(user).getRepositoryService().deleteDeployment(deploymentId, cascade, false, false); + } + + @Override + public Deployment createDeployment(MultiValueMap data, MultipartFile[] files, CIBUser user) + throws SystemException { + DeploymentBuilder deploymentBuilder = extractDeploymentInformation(files, data, user); + + if (!deploymentBuilder.getResourceNames().isEmpty()) { + DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult(); + DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); + return directProviderUtil.convertValue(deploymentDto, Deployment.class, user); + + } else { + throw new SystemException("No deployment resources contained in the form upload."); + } + } + + @Override + public Deployment redeployDeployment(String deploymentId, Map data, CIBUser user) throws SystemException { + RedeploymentDto redeployment = directProviderUtil.convertValue(data, RedeploymentDto.class, user); + DeploymentWithDefinitions deployment = null; + try { + deployment = tryToRedeploy(deploymentId, redeployment, user); + + } catch (NotValidException|NotFoundException e) { + throw new SystemException(e.getMessage(), e); + } + + DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); + + return directProviderUtil.convertValue(deploymentDto, Deployment.class, user); + } + + private DeploymentWithDefinitions tryToRedeploy(String deploymentId, RedeploymentDto redeployment, CIBUser user) { + ProcessEngine processEngine = directProviderUtil.getProcessEngine(user); + DeploymentBuilder builder = processEngine.getRepositoryService().createDeployment(); + builder.nameFromDeployment(deploymentId); + + org.cibseven.bpm.engine.repository.Deployment deployment = processEngine.getRepositoryService().createDeploymentQuery().deploymentId(deploymentId).singleResult(); + if (deployment == null) { + throw new WrongDeploymenIdException(new SystemException("Deployment with id '" + deploymentId + "' does not exist")); + } + String tenantId = deployment.getTenantId(); + if (tenantId != null) { + builder.tenantId(tenantId); + } + + if (redeployment != null) { + builder = addRedeploymentResources(deploymentId, builder, redeployment); + } else { + builder.addDeploymentResources(deploymentId); + } + + return builder.deployWithResult(); + } + + private DeploymentBuilder extractDeploymentInformation(MultipartFile[] files, MultiValueMap data, CIBUser user) { + DeploymentBuilder deploymentBuilder = directProviderUtil.getProcessEngine(user).getRepositoryService().createDeployment(); + + for (MultipartFile file : files) { + String fileName = file.getOriginalFilename(); + if (fileName != null) { + try { + deploymentBuilder.addInputStream(fileName, new ByteArrayInputStream(file.getBytes())); + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } else { + throw new SystemException( + "No file name found in the deployment resource described by form parameter '" + fileName + "'."); + } + } + String deploymentName = getStringValue(DEPLOYMENT_NAME, data); + if (deploymentName != null) { + deploymentBuilder.name(deploymentName); + } + + String deploymentActivationTime = getStringValue(DEPLOYMENT_ACTIVATION_TIME, data); + if (deploymentActivationTime != null) { + deploymentBuilder.activateProcessDefinitionsOn(DateTimeUtil.parseDate(deploymentActivationTime)); + } + + String deploymentSource = getStringValue(DEPLOYMENT_SOURCE, data); + if (deploymentSource != null) { + deploymentBuilder.source(deploymentSource); + } + + String deploymentTenantId = getStringValue(TENANT_ID, data); + if (deploymentTenantId != null) { + deploymentBuilder.tenantId(deploymentTenantId); + } + + extractDuplicateFilteringForDeployment(data, deploymentBuilder); + return deploymentBuilder; + } + + public DeploymentResourceDto getDeploymentResource(String resourceId, String deploymentId, CIBUser user) { + RepositoryService repositoryService = directProviderUtil.getProcessEngine(user).getRepositoryService(); + List resources = repositoryService.getDeploymentResources(deploymentId); + List deploymentResources = new ArrayList(); + for (Resource resource : resources) { + deploymentResources.add(DeploymentResourceDto.fromResources(resource)); + } + + if (deploymentResources.isEmpty()) { + throw new NoRessourcesFoundException(new SystemException("Deployment resources for deployment id '" + deploymentId + "' do not exist.")); + } + for (DeploymentResourceDto deploymentResource : deploymentResources) { + if (deploymentResource.getId().equals(resourceId)) { + return deploymentResource; + } + } + + throw new SystemException("Deployment resource with resource id '" + resourceId + "' for deployment id '" + + deploymentId + "' does not exist."); + } + + private DeploymentBuilder addRedeploymentResources(String deploymentId, DeploymentBuilder builder, RedeploymentDto redeployment) { + builder.source(redeployment.getSource()); + + List resourceIds = redeployment.getResourceIds(); + List resourceNames = redeployment.getResourceNames(); + + boolean isResourceIdListEmpty = resourceIds == null || resourceIds.isEmpty(); + boolean isResourceNameListEmpty = resourceNames == null || resourceNames.isEmpty(); + + if (isResourceIdListEmpty && isResourceNameListEmpty) { + builder.addDeploymentResources(deploymentId); + + } else { + if (!isResourceIdListEmpty) { + builder.addDeploymentResourcesById(deploymentId, resourceIds); + } + if (!isResourceNameListEmpty) { + builder.addDeploymentResourcesByName(deploymentId, resourceNames); + } + } + return builder; + } + + private void extractDuplicateFilteringForDeployment(MultiValueMap data, DeploymentBuilder deploymentBuilder) { + boolean enableDuplicateFiltering = false; + boolean deployChangedOnly = false; + + String enableDuplicateFilteringValue = getStringValue(ENABLE_DUPLICATE_FILTERING, data); + if (enableDuplicateFilteringValue != null) + enableDuplicateFiltering = Boolean.parseBoolean(enableDuplicateFilteringValue); + + String deployChangedOnlyValue = getStringValue(DEPLOY_CHANGED_ONLY, data); + if (deployChangedOnlyValue != null) + deployChangedOnly = Boolean.parseBoolean(deployChangedOnlyValue); + + // deployChangedOnly overrides the enableDuplicateFiltering setting + if (deployChangedOnly) { + deploymentBuilder.enableDuplicateFiltering(true); + } else if (enableDuplicateFiltering) { + deploymentBuilder.enableDuplicateFiltering(false); + } + } + + private String getStringValue(String key, MultiValueMap data) { + if (data.containsKey(key)) { + List entryData = data.get(key); + if (!entryData.isEmpty() && entryData.get(0) instanceof String) + return (String)entryData.get(0); + } + return null; + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectEngineProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectEngineProvider.java new file mode 100755 index 000000000..b2b61946e --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectEngineProvider.java @@ -0,0 +1,73 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.cibseven.bpm.BpmPlatform; +import org.cibseven.bpm.engine.rest.dto.identity.UserCredentialsDto; +import org.cibseven.bpm.engine.rest.dto.identity.UserDto; +import org.cibseven.bpm.engine.rest.dto.identity.UserProfileDto; +import org.cibseven.bpm.engine.rest.impl.SetupRestServiceImpl; +import org.cibseven.webapp.exception.InvalidUserIdException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Engine; +import org.cibseven.webapp.rest.model.NewUser; + +public class DirectEngineProvider implements IEngineProvider { + + DirectProviderUtil directProviderUtil; + + DirectEngineProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection getProcessEngineNames() { + Set engineNames = BpmPlatform.getProcessEngineService().getProcessEngineNames(); + List results = new ArrayList<>(); + for (String engineName : engineNames) { + results.add(new Engine(engineName)); + } + + return results; + } + + public Boolean requiresSetup(String engine) { + return new SetupRestServiceImpl(engine, directProviderUtil.getObjectMapper(engine)).requiresSetup(); + } + + public void createSetupUser(NewUser user, String engine) throws InvalidUserIdException { + UserDto userDto = new UserDto(); + UserProfileDto profileDto = new UserProfileDto(); + if (user.getProfile() == null || user.getCredentials() == null) + throw new SystemException("User data not provided."); + profileDto.setEmail(user.getProfile().getEmail()); + profileDto.setFirstName(user.getProfile().getFirstName()); + profileDto.setId(user.getProfile().getId()); + profileDto.setLastName(user.getProfile().getLastName()); + userDto.setProfile(profileDto); + UserCredentialsDto userCredentialsDto = new UserCredentialsDto(); + userCredentialsDto.setPassword(user.getCredentials().getPassword()); + userDto.setCredentials(userCredentialsDto); + new SetupRestServiceImpl(engine, directProviderUtil.getObjectMapper(engine)).createUser(userDto); + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectExternalTaskProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectExternalTaskProvider.java new file mode 100755 index 000000000..71c32f9a2 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectExternalTaskProvider.java @@ -0,0 +1,55 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.cibseven.bpm.engine.externaltask.ExternalTaskQuery; +import org.cibseven.bpm.engine.rest.dto.externaltask.ExternalTaskDto; +import org.cibseven.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.ExternalTask; + +public class DirectExternalTaskProvider implements IExternalTaskProvider { + + DirectProviderUtil directProviderUtil; + + DirectExternalTaskProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection getExternalTasks(Map queryParams, CIBUser user) throws SystemException { + ExternalTaskQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, ExternalTaskQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + ExternalTaskQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingTasks = QueryUtil.list(query, null, null); + + List taskResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.externaltask.ExternalTask task : matchingTasks) { + ExternalTaskDto resultInstance = ExternalTaskDto.fromExternalTask(task); + taskResults.add(directProviderUtil.convertValue(resultInstance, ExternalTask.class, user)); + } + return taskResults; + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectFilterProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectFilterProvider.java new file mode 100755 index 000000000..18218dee7 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectFilterProvider.java @@ -0,0 +1,111 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.cibseven.bpm.engine.EntityTypes; +import org.cibseven.bpm.engine.exception.NotValidException; +import org.cibseven.bpm.engine.exception.NullValueException; +import org.cibseven.bpm.engine.filter.FilterQuery; +import org.cibseven.bpm.engine.rest.dto.runtime.FilterDto; +import org.cibseven.bpm.engine.rest.dto.runtime.FilterQueryDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Filter; + +public class DirectFilterProvider implements IFilterProvider{ + + DirectProviderUtil directProviderUtil; + + DirectFilterProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection findFilters(CIBUser user) { + FilterQueryDto filterQueryDto = new FilterQueryDto(); + filterQueryDto.setResourceType("Task"); + FilterQuery query = filterQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingFilters = QueryUtil.list(query, null, null); + + List filters = new ArrayList<>(); + for (org.cibseven.bpm.engine.filter.Filter filter : matchingFilters) { + FilterDto filterDto = FilterDto.fromFilter(filter); + // TODO: itemCount not used? + // if (itemCount != null && itemCount) { + // dto.setItemCount(directProviderUtil.getProcessEngine(user).getFilterService().count(filter.getId())); + // } + filters.add(directProviderUtil.convertValue(filterDto, Filter.class, user)); + } + return filters; + } + + @Override + public Filter createFilter(Filter filter, CIBUser user) { + FilterDto filterDto = directProviderUtil.convertValue(filter, FilterDto.class, user); + String resourceType = filterDto.getResourceType(); + + org.cibseven.bpm.engine.filter.Filter engineFilter; + if (EntityTypes.TASK.equals(resourceType)) { + engineFilter = directProviderUtil.getProcessEngine(user).getFilterService().newTaskFilter(); + } else { + throw new SystemException("Unable to create filter with invalid resource type '" + resourceType + "'"); + } + + try { + filterDto.updateFilter(engineFilter, directProviderUtil.getProcessEngine(user)); + } catch (NotValidException e) { + throw new SystemException("Unable to create filter with invalid content", e); + } + + directProviderUtil.getProcessEngine(user).getFilterService().saveFilter(engineFilter); + + Filter resultFilter = directProviderUtil.convertValue(FilterDto.fromFilter(engineFilter), Filter.class, user); + return resultFilter; + } + + @Override + public void updateFilter(Filter filter, CIBUser user) { + FilterDto filterDto = directProviderUtil.convertValue(filter, FilterDto.class, user); + org.cibseven.bpm.engine.filter.Filter dbFilter = directProviderUtil.getProcessEngine(user).getFilterService().getFilter(filter.getId()); + + if (dbFilter == null) { + throw new SystemException("Requested filter not found: " + filter.getId()); + } + + try { + filterDto.updateFilter(dbFilter, directProviderUtil.getProcessEngine(user)); + } catch (NotValidException e) { + throw new SystemException("Unable to update filter with invalid content", e); + } + directProviderUtil.getProcessEngine(user).getFilterService().saveFilter(dbFilter); + } + + @Override + public void deleteFilter(String filterId, CIBUser user) { + try { + directProviderUtil.getProcessEngine(user).getFilterService().deleteFilter(filterId); + } catch (NullValueException e) { + throw new SystemException("Requested filter not found: " + filterId); + } + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectHistoricVariableInstanceProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectHistoricVariableInstanceProvider.java new file mode 100755 index 000000000..32bb0079f --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectHistoricVariableInstanceProvider.java @@ -0,0 +1,66 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import org.cibseven.bpm.engine.history.HistoricVariableInstance; +import org.cibseven.bpm.engine.history.HistoricVariableInstanceQuery; +import org.cibseven.bpm.engine.rest.dto.history.HistoricVariableInstanceDto; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.VariableHistory; + +public class DirectHistoricVariableInstanceProvider implements IHistoricVariableInstanceProvider { + + DirectProviderUtil directProviderUtil; + public DirectHistoricVariableInstanceProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public VariableHistory getHistoricVariableInstance(String id, boolean deserializeValue, CIBUser user) + throws SystemException, NoObjectFoundException { + VariableHistory variableSerialized = getHistoricVariableInstanceImpl(id, false, user); + VariableHistory variableDeserialized = getHistoricVariableInstanceImpl(id, true, user); + + if (deserializeValue) { + variableDeserialized.setValueSerialized(variableSerialized.getValue()); + variableDeserialized.setValueDeserialized(variableDeserialized.getValue()); + return variableDeserialized; + } else { + variableSerialized.setValueSerialized(variableSerialized.getValue()); + variableSerialized.setValueDeserialized(variableDeserialized.getValue()); + return variableSerialized; + } + } + + private VariableHistory getHistoricVariableInstanceImpl(String id, boolean deserializeValue, CIBUser user) { + HistoricVariableInstanceQuery query = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricVariableInstanceQuery().variableId(id); + if (!deserializeValue) { + query.disableCustomObjectDeserialization(); + } + HistoricVariableInstance variableInstance = query.singleResult(); + if (variableInstance != null) { + VariableHistory result = directProviderUtil.convertValue(HistoricVariableInstanceDto.fromHistoricVariableInstance(variableInstance), + VariableHistory.class, user); + return result; + } else { + throw new NoObjectFoundException(new SystemException(" historic variable with Id '" + id + "' does not exist.")); + } + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectIdentityProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectIdentityProvider.java new file mode 100644 index 000000000..5e598e4a4 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectIdentityProvider.java @@ -0,0 +1,85 @@ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.cibseven.bpm.engine.IdentityService; +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.identity.PasswordPolicyResult; +import org.cibseven.bpm.engine.identity.PasswordPolicyRule; +import org.cibseven.bpm.engine.identity.User; +import org.cibseven.bpm.engine.rest.dto.identity.CheckPasswordPolicyResultDto; +import org.cibseven.bpm.engine.rest.dto.identity.CheckPasswordPolicyRuleDto; +import org.cibseven.bpm.engine.rest.dto.identity.UserProfileDto; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.providers.IIdentityProvider; +import org.cibseven.webapp.providers.IVariableProvider; +import org.cibseven.webapp.rest.model.PasswordPolicyRequest; +import org.cibseven.webapp.rest.model.PasswordPolicyResponse; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class DirectIdentityProvider implements IIdentityProvider { + + DirectProviderUtil directProviderUtil; + public DirectIdentityProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + @Override + public PasswordPolicyResponse validatePasswordPolicy(PasswordPolicyRequest request) throws SystemException { + ProcessEngine processEngine = directProviderUtil.getProcessEngine((CIBUser) null); + //TODO User should be specified to the correct engine + boolean isEnabled = processEngine.getProcessEngineConfiguration().isEnablePasswordPolicy(); + if (!isEnabled) { + throw new SystemException("Password policy is not enabled for the process engine."); + } + + IdentityService identityService = processEngine.getIdentityService(); + + User user = null; + PasswordPolicyRequest.Profile profileDto = request.getProfile(); + if (profileDto != null) { + String id = sanitizeUserId(profileDto.getId()); + user = identityService.newUser(id); + + user.setFirstName(profileDto.getFirstName()); + user.setLastName(profileDto.getLastName()); + user.setEmail(profileDto.getEmail()); + + } + + String candidatePassword = request.getPassword(); + PasswordPolicyResult result = identityService.checkPasswordAgainstPolicy(candidatePassword, user); + + PasswordPolicyResponse response = new PasswordPolicyResponse(); + response.setValid(result.isValid()); + response.setRules(new ArrayList<>()); + + for (PasswordPolicyRule rule : result.getFulfilledRules()) { + Map ruleMap = convertRuleToMap(rule, true); + response.getRules().add(ruleMap); + } + for (PasswordPolicyRule rule : result.getViolatedRules()) { + Map ruleMap = convertRuleToMap(rule, false); + response.getRules().add(ruleMap); + } + + return response; + } + + private Map convertRuleToMap(PasswordPolicyRule ruleDto, boolean fulfilled) { + CheckPasswordPolicyRuleDto rule = new CheckPasswordPolicyRuleDto(ruleDto, fulfilled); + ObjectMapper objectMapper = directProviderUtil.getObjectMapper((CIBUser) null); + return objectMapper.convertValue(rule, new TypeReference>() {}); + } + + protected String sanitizeUserId(String userId) { + return userId != null ? userId : ""; + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectIncidentProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectIncidentProvider.java new file mode 100755 index 000000000..25d910926 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectIncidentProvider.java @@ -0,0 +1,270 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.RuntimeService; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.history.HistoricIncident; +import org.cibseven.bpm.engine.history.HistoricIncidentQuery; +import org.cibseven.bpm.engine.rest.dto.AnnotationDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricIncidentDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricIncidentQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.IncidentDto; +import org.cibseven.bpm.engine.rest.dto.runtime.IncidentQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.RetriesDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.runtime.IncidentQuery; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Incident; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class DirectIncidentProvider implements IIncidentProvider { + + DirectProviderUtil directProviderUtil; + + DirectIncidentProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Long countIncident(Map params, CIBUser user) { + IncidentQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, IncidentQueryDto.class); + IncidentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + return query.count(); + } + + @Override + public Long countHistoricIncident(Map params, CIBUser user) { + HistoricIncidentQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, HistoricIncidentQueryDto.class); + HistoricIncidentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + long count = query.count(); + return count; + } + + @Override + public Collection findIncident(Map params, CIBUser user) { + IncidentQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, IncidentQueryDto.class); + IncidentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List queryResult = QueryUtil.list(query, null, null); + + List incidents = new ArrayList<>(); + for (org.cibseven.bpm.engine.runtime.Incident incident : queryResult) { + IncidentDto dto = IncidentDto.fromIncident(incident); + incidents.add(directProviderUtil.convertValue(dto, Incident.class, user)); + } + RuntimeService runtimeService = directProviderUtil.getProcessEngine(user).getRuntimeService(); + for (Incident incident : incidents) { + if (incident.getId() != null && incident.getRootCauseIncidentId() != null + && !incident.getId().equals(incident.getRootCauseIncidentId())) { + try { + // Fetch the root cause incident + org.cibseven.bpm.engine.runtime.Incident engineIncident = runtimeService.createIncidentQuery().incidentId(incident.getRootCauseIncidentId()) + .singleResult(); + if (engineIncident == null) { + throw new SystemException("No matching incident with id " + incident.getRootCauseIncidentId()); + } + Incident rootCauseIncident = directProviderUtil.convertValue(IncidentDto.fromIncident(engineIncident), Incident.class, user); + + if (rootCauseIncident != null) { + // Map root cause incident data to the specific fields + incident.setCauseIncidentProcessInstanceId(rootCauseIncident.getProcessInstanceId()); + incident.setCauseIncidentProcessDefinitionId(rootCauseIncident.getProcessDefinitionId()); + incident.setCauseIncidentActivityId(rootCauseIncident.getActivityId()); + incident.setCauseIncidentFailedActivityId(rootCauseIncident.getFailedActivityId()); + incident.setRootCauseIncidentProcessInstanceId(rootCauseIncident.getProcessInstanceId()); + incident.setRootCauseIncidentProcessDefinitionId(rootCauseIncident.getProcessDefinitionId()); + incident.setRootCauseIncidentActivityId(rootCauseIncident.getActivityId()); + incident.setRootCauseIncidentFailedActivityId(rootCauseIncident.getFailedActivityId()); + incident.setRootCauseIncidentConfiguration(rootCauseIncident.getConfiguration()); + incident.setRootCauseIncidentMessage(rootCauseIncident.getIncidentMessage()); + } + } catch (Exception e) { + log.warn("Failed to enrich incident with ID: {} and root cause ID: {}", incident.getId(), + incident.getRootCauseIncidentId(), e); + } + } + } + return incidents; + } + + @Override + public List findIncidentByInstanceId(String processInstanceId, CIBUser user) { + return fetchIncidents(null, null, processInstanceId, user); + } + + @Override + public Collection fetchIncidents(String processDefinitionKey, CIBUser user) { + return fetchIncidents(processDefinitionKey, null, null, user); + } + + @Override + public Collection fetchIncidentsByInstanceAndActivityId(String processDefinitionKey, String activityId, + CIBUser user) { + //called only internally + return fetchIncidents(processDefinitionKey, activityId, null, user); + } + + @Override + public void setIncidentAnnotation(String incidentId, Map data, CIBUser user) { + AnnotationDto annotationDto = directProviderUtil.getObjectMapper(user).convertValue(data, AnnotationDto.class); + directProviderUtil.getProcessEngine(user).getRuntimeService().setAnnotationForIncidentById(incidentId, annotationDto.getAnnotation()); + } + + @Override + public void retryExternalTask(String externalTaskId, Map data, CIBUser user) { + RetriesDto dto = directProviderUtil.getObjectMapper(user).convertValue(data, RetriesDto.class); + Integer retries = dto.getRetries(); + + if (retries == null) { + throw new SystemException("The number of retries cannot be null."); + } + + try { + directProviderUtil.getProcessEngine(user).getExternalTaskService().setRetries(externalTaskId, retries); + } catch (NotFoundException e) { + throw new NoObjectFoundException(new SystemException("External task with id " + externalTaskId + " does not exist", e)); + } + } + + @Override + public String findHistoricExternalTaskErrorDetails(String externalTaskId, CIBUser user) { + try { + return directProviderUtil.getProcessEngine(user).getHistoryService().getHistoricExternalTaskLogErrorDetails(externalTaskId); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public Collection findHistoricIncidents(Map params, CIBUser user) { + HistoricIncidentQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, HistoricIncidentQueryDto.class); + HistoricIncidentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List queryResult = QueryUtil.list(query, null, null); + + List historicIncidentDtos = new ArrayList(); + for (HistoricIncident historicIncident : queryResult) { + HistoricIncidentDto dto = HistoricIncidentDto.fromHistoricIncident(historicIncident); + historicIncidentDtos.add(dto); + } + + List incidents = new ArrayList<>(); + // Enrich historic incidents with root cause incident data (same enrichment + // algorithm as current incidents) + for (HistoricIncidentDto incidentDto : historicIncidentDtos) { + Incident incident = directProviderUtil.convertValue(incidentDto, Incident.class, user); + if (incidentDto.getId() != null && incidentDto.getRootCauseIncidentId() != null + && !incidentDto.getId().equals(incidentDto.getRootCauseIncidentId())) { + try { + // For historic incidents, try to fetch the root cause from historic + // incidents first, then from current incidents + HistoricIncidentDto rootCauseIncident = fetchHistoricIncidentById(incidentDto.getRootCauseIncidentId(), user, + directProviderUtil.getObjectMapper(user)); + if (rootCauseIncident != null) { + // Map root cause incident data to the specific fields + incident.setCauseIncidentProcessInstanceId(rootCauseIncident.getProcessInstanceId()); + incident.setCauseIncidentProcessDefinitionId(rootCauseIncident.getProcessDefinitionId()); + incident.setCauseIncidentActivityId(rootCauseIncident.getActivityId()); + incident.setCauseIncidentFailedActivityId(rootCauseIncident.getFailedActivityId()); + incident.setRootCauseIncidentProcessInstanceId(rootCauseIncident.getProcessInstanceId()); + incident.setRootCauseIncidentProcessDefinitionId(rootCauseIncident.getProcessDefinitionId()); + incident.setRootCauseIncidentActivityId(rootCauseIncident.getActivityId()); + incident.setRootCauseIncidentFailedActivityId(rootCauseIncident.getFailedActivityId()); + incident.setRootCauseIncidentConfiguration(rootCauseIncident.getConfiguration()); + incident.setRootCauseIncidentMessage(rootCauseIncident.getIncidentMessage()); + } + } catch (RuntimeException e) { + log.warn("Failed to enrich historic incident with ID: {} and root cause ID: {}", incident.getId(), + incident.getRootCauseIncidentId(), e); + } + } + incidents.add(incident); + } + return incidents; + } + + @Override + public String findExternalTaskErrorDetails(String externalTaskId, CIBUser user) { + try { + return directProviderUtil.getProcessEngine(user).getExternalTaskService().getExternalTaskErrorDetails(externalTaskId); + } catch (NotFoundException e) { + throw new NoObjectFoundException(new SystemException("External task with id " + externalTaskId + " does not exist", e)); + } + } + + @Override + public String findHistoricStacktraceByJobId(String jobId, CIBUser user) { + try { + String stacktrace = directProviderUtil.getProcessEngine(user).getHistoryService().getHistoricJobLogExceptionStacktrace(jobId); + return stacktrace; + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + private List fetchIncidents(String processDefinitionKey, String activityId, + String processInstanceId, CIBUser user) { + IncidentQueryDto queryDto = new IncidentQueryDto(); + queryDto.setActivityId(activityId); + if (processDefinitionKey != null) + queryDto.setProcessDefinitionKeyIn(new String[] { processDefinitionKey }); + queryDto.setProcessInstanceId(processInstanceId); + + IncidentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List queryResult = QueryUtil.list(query, null, null); + + List result = new ArrayList<>(); + for (org.cibseven.bpm.engine.runtime.Incident incident : queryResult) { + IncidentDto dto = IncidentDto.fromIncident(incident); + result.add(directProviderUtil.convertValue(dto, Incident.class, user)); + } + return result; + } + + private HistoricIncidentDto fetchHistoricIncidentById(String incidentId, CIBUser user, ObjectMapper objectMapper) { + Map params = Map.of("incidentId", incidentId); + HistoricIncidentQueryDto queryDto = objectMapper.convertValue(params, HistoricIncidentQueryDto.class); + HistoricIncidentQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List queryResult = QueryUtil.list(query, null, null); + + for (HistoricIncident historicIncident : queryResult) { + HistoricIncidentDto dto = HistoricIncidentDto.fromHistoricIncident(historicIncident); + return dto; + } + // Historic incident not found, return null + return null; + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectJobDefinitionProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectJobDefinitionProvider.java new file mode 100755 index 000000000..bcbca3f36 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectJobDefinitionProvider.java @@ -0,0 +1,142 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.management.JobDefinitionQuery; +import org.cibseven.bpm.engine.management.SetJobRetriesBuilder; +import org.cibseven.bpm.engine.rest.dto.management.JobDefinitionDto; +import org.cibseven.bpm.engine.rest.dto.management.JobDefinitionQueryDto; +import org.cibseven.bpm.engine.rest.dto.management.JobDefinitionSuspensionStateDto; +import org.cibseven.bpm.engine.rest.dto.runtime.JobDefinitionPriorityDto; +import org.cibseven.bpm.engine.rest.dto.runtime.RetriesDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.JobDefinition; + +import com.fasterxml.jackson.core.JsonProcessingException; + +public class DirectJobDefinitionProvider implements IJobDefinitionProvider { + + DirectProviderUtil directProviderUtil; + + DirectJobDefinitionProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection findJobDefinitions(String params, CIBUser user) { + JobDefinitionQueryDto queryDto; + try { + queryDto = directProviderUtil.getObjectMapper(user).readValue(params, JobDefinitionQueryDto.class); + } catch (JsonProcessingException e) { + throw new SystemException(e.getMessage()); + } + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + JobDefinitionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingJobDefinitions = QueryUtil.list(query, null, null); + + List jobDefinitionResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.management.JobDefinition jobDefinition : matchingJobDefinitions) { + JobDefinitionDto result = JobDefinitionDto.fromJobDefinition(jobDefinition); + jobDefinitionResults.add(directProviderUtil.convertValue(result, JobDefinition.class, user)); + } + + return jobDefinitionResults; + } + + @Override + public void suspendJobDefinition(String jobDefinitionId, String param, CIBUser user) { + try { + @SuppressWarnings("unchecked") + Map params = directProviderUtil.getObjectMapper(user).readValue(param, HashMap.class); + JobDefinitionSuspensionStateDto dto = directProviderUtil.getObjectMapper(user).convertValue(params, JobDefinitionSuspensionStateDto.class); + dto.setJobDefinitionId(jobDefinitionId); + dto.updateSuspensionState(directProviderUtil.getProcessEngine(user)); + + } catch (IllegalArgumentException e) { + String message = String.format( + "The suspension state of Job Definition with id %s could not be updated due to: %s", jobDefinitionId, + e.getMessage()); + throw new SystemException(message, e); + } catch (JsonProcessingException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void overrideJobDefinitionPriority(String jobDefinitionId, String param, CIBUser user) { + try { + @SuppressWarnings("unchecked") + Map params = directProviderUtil.getObjectMapper(user).readValue(param, HashMap.class); + JobDefinitionPriorityDto dto = directProviderUtil.getObjectMapper(user).convertValue(params, JobDefinitionPriorityDto.class); + + if (dto.getPriority() != null) { + directProviderUtil.getProcessEngine(user).getManagementService().setOverridingJobPriorityForJobDefinition(jobDefinitionId, dto.getPriority(), + dto.isIncludeJobs()); + } else { + if (dto.isIncludeJobs()) { + throw new SystemException("Cannot reset priority for job definition " + jobDefinitionId + " with includeJobs=true"); + } + directProviderUtil.getProcessEngine(user).getManagementService().clearOverridingJobPriorityForJobDefinition(jobDefinitionId); + } + + } catch (AuthorizationException e) { + throw e; + } catch (JsonProcessingException|ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void retryJobDefinitionById(String id, Map params, CIBUser user) { + RetriesDto dto = directProviderUtil.getObjectMapper(user).convertValue(params, RetriesDto.class); + try { + SetJobRetriesBuilder builder = directProviderUtil.getProcessEngine(user).getManagementService().setJobRetries(dto.getRetries()).jobDefinitionId(id); + if (dto.isDueDateSet()) { + builder.dueDate(dto.getDueDate()); + } + builder.execute(); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public JobDefinition findJobDefinition(String id, CIBUser user) { + + org.cibseven.bpm.engine.management.JobDefinition jobDefinition = directProviderUtil.getProcessEngine(user).getManagementService().createJobDefinitionQuery() + .jobDefinitionId(id).singleResult(); + if (jobDefinition == null) { + throw new NoObjectFoundException(new SystemException("Job Definition with id " + id + " does not exist")); + } + return directProviderUtil.convertValue(JobDefinitionDto.fromJobDefinition(jobDefinition), JobDefinition.class, user); + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectJobProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectJobProvider.java new file mode 100755 index 000000000..bae786958 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectJobProvider.java @@ -0,0 +1,171 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.history.HistoricJobLog; +import org.cibseven.bpm.engine.history.HistoricJobLogQuery; +import org.cibseven.bpm.engine.management.JobDefinitionQuery; +import org.cibseven.bpm.engine.rest.dto.history.HistoricJobLogDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricJobLogQueryDto; +import org.cibseven.bpm.engine.rest.dto.management.JobDefinitionDto; +import org.cibseven.bpm.engine.rest.dto.management.JobDefinitionQueryDto; +import org.cibseven.bpm.engine.rest.dto.management.JobDefinitionSuspensionStateDto; +import org.cibseven.bpm.engine.rest.dto.runtime.JobDuedateDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Job; + +public class DirectJobProvider implements IJobProvider { + + DirectProviderUtil directProviderUtil; + + DirectJobProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection getJobs(Map params, CIBUser user) { + Integer firstResult = null; + Integer maxResults = null; + for (Entry entry : params.entrySet()) { + if (entry.getKey().equals("firstResult")) + firstResult = Integer.parseInt((String) params.get("firstResult")); + else if (entry.getKey().equals("maxResults")) + maxResults = Integer.parseInt((String) params.get("maxResults")); + } + + JobDefinitionQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, JobDefinitionQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + JobDefinitionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingJobDefinitions = QueryUtil.list(query, firstResult, + maxResults); + + List jobDefinitionResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.management.JobDefinition jobDefinition : matchingJobDefinitions) { + JobDefinitionDto result = JobDefinitionDto.fromJobDefinition(jobDefinition); + jobDefinitionResults.add(directProviderUtil.convertValue(result, Job.class, user)); + } + return jobDefinitionResults; + } + + @Override + public void setSuspended(String id, Map params, CIBUser user) { + + JobDefinitionSuspensionStateDto jobDefinitionSuspensionStateDto = directProviderUtil.getObjectMapper(user).convertValue(params, + JobDefinitionSuspensionStateDto.class); + jobDefinitionSuspensionStateDto.setProcessDefinitionId(id); + if (jobDefinitionSuspensionStateDto.getJobDefinitionId() != null) { + String message = "Either processDefinitionId or processDefinitionKey can be set to update the suspension state."; + throw new SystemException(message); + } + + try { + jobDefinitionSuspensionStateDto.updateSuspensionState(directProviderUtil.getProcessEngine(user)); + + } catch (IllegalArgumentException e) { + String message = String.format("Could not update the suspension state of Job Definitions due to: %s", + e.getMessage()); + throw new SystemException(message, e); + } + } + + @Override + public void deleteJob(String id, CIBUser user) { + try { + directProviderUtil.getProcessEngine(user).getManagementService().deleteJob(id); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public Collection getHistoryJobLog(Map params, CIBUser user) { + + HistoricJobLogQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(params, HistoricJobLogQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricJobLogQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + Integer firstResult = null; + Integer maxResults = null; + for (Entry entry : params.entrySet()) { + if (entry.getKey().equals("firstResult")) + firstResult = Integer.parseInt((String) params.get("firstResult")); + else if (entry.getKey().equals("maxResults")) + maxResults = Integer.parseInt((String) params.get("maxResults")); + } + List matchingHistoricJobLogs = QueryUtil.list(query, firstResult, maxResults); + + List results = new ArrayList<>(); + for (HistoricJobLog historicJobLog : matchingHistoricJobLogs) { + HistoricJobLogDto result = HistoricJobLogDto.fromHistoricJobLog(historicJobLog); + results.add(result); + } + return results; + } + + @Override + public String getHistoryJobLogStacktrace(String id, CIBUser user) { + + try { + String stacktrace = directProviderUtil.getProcessEngine(user).getHistoryService().getHistoricJobLogExceptionStacktrace(id); + return stacktrace; + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void changeDueDate(String jobId, Map data, CIBUser user) { + try { + JobDuedateDto dto = directProviderUtil.getObjectMapper(user).convertValue(data,JobDuedateDto.class); + directProviderUtil.getProcessEngine(user).getManagementService().setJobDuedate(jobId, dto.getDuedate(), dto.isCascade()); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void recalculateDueDate(String jobId, Map params, CIBUser user) { + try { + boolean creationDateBased = params.containsKey("creationDateBased") ? + Boolean.parseBoolean((String)params.get("creationDateBased")) : false; + directProviderUtil.getProcessEngine(user).getManagementService().recalculateJobDuedate(jobId, creationDateBased); + } catch (AuthorizationException e) { + throw e; + } catch(NotFoundException e) {// rewrite status code from bad request (400) to not found (404) + throw new SystemException(e.getMessage(), e); + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectProcessProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectProcessProvider.java new file mode 100755 index 000000000..98c7f56c0 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectProcessProvider.java @@ -0,0 +1,964 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.commons.io.IOUtils; +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.BadUserRequestException; +import org.cibseven.bpm.engine.FormService; +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.exception.NullValueException; +import org.cibseven.bpm.engine.form.StartFormData; +import org.cibseven.bpm.engine.history.HistoricActivityStatistics; +import org.cibseven.bpm.engine.history.HistoricActivityStatisticsQuery; +import org.cibseven.bpm.engine.history.HistoricProcessInstance; +import org.cibseven.bpm.engine.history.HistoricProcessInstanceQuery; +import org.cibseven.bpm.engine.impl.form.validator.FormFieldValidationException; +import org.cibseven.bpm.engine.impl.util.IoUtil; +import org.cibseven.bpm.engine.management.ActivityStatistics; +import org.cibseven.bpm.engine.management.ActivityStatisticsQuery; +import org.cibseven.bpm.engine.management.ProcessDefinitionStatistics; +import org.cibseven.bpm.engine.management.ProcessDefinitionStatisticsQuery; +import org.cibseven.bpm.engine.repository.ProcessDefinition; +import org.cibseven.bpm.engine.repository.ProcessDefinitionQuery; +import org.cibseven.bpm.engine.rest.dto.HistoryTimeToLiveDto; +import org.cibseven.bpm.engine.rest.dto.StatisticsResultDto; +import org.cibseven.bpm.engine.rest.dto.VariableValueDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricActivityStatisticsDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricProcessInstanceDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto; +import org.cibseven.bpm.engine.rest.dto.repository.CalledProcessDefinitionDto; +import org.cibseven.bpm.engine.rest.dto.repository.ProcessDefinitionDiagramDto; +import org.cibseven.bpm.engine.rest.dto.repository.ProcessDefinitionDto; +import org.cibseven.bpm.engine.rest.dto.repository.ProcessDefinitionQueryDto; +import org.cibseven.bpm.engine.rest.dto.repository.ProcessDefinitionStatisticsResultDto; +import org.cibseven.bpm.engine.rest.dto.repository.ProcessDefinitionSuspensionStateDto; +import org.cibseven.bpm.engine.rest.dto.runtime.ProcessInstanceDto; +import org.cibseven.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.ProcessInstanceSuspensionStateDto; +import org.cibseven.bpm.engine.rest.dto.runtime.ProcessInstanceWithVariablesDto; +import org.cibseven.bpm.engine.rest.dto.runtime.StartProcessInstanceDto; +import org.cibseven.bpm.engine.rest.dto.runtime.VariableInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.modification.ProcessInstanceModificationInstructionDto; +import org.cibseven.bpm.engine.rest.dto.task.FormDto; +import org.cibseven.bpm.engine.rest.exception.RestException; +import org.cibseven.bpm.engine.rest.impl.history.HistoricActivityStatisticsQueryDto; +import org.cibseven.bpm.engine.rest.util.ApplicationContextPathUtil; +import org.cibseven.bpm.engine.rest.util.EncodingUtil; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.runtime.ProcessInstanceQuery; +import org.cibseven.bpm.engine.runtime.ProcessInstanceWithVariables; +import org.cibseven.bpm.engine.runtime.ProcessInstantiationBuilder; +import org.cibseven.webapp.Data; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.ExpressionEvaluationException; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.exception.UnsupportedTypeException; +import org.cibseven.webapp.rest.model.HistoryProcessInstance; +import org.cibseven.webapp.rest.model.Incident; +import org.cibseven.webapp.rest.model.Process; +import org.cibseven.webapp.rest.model.ProcessDiagram; +import org.cibseven.webapp.rest.model.ProcessInstance; +import org.cibseven.webapp.rest.model.ProcessStart; +import org.cibseven.webapp.rest.model.ProcessStatistics; +import org.cibseven.webapp.rest.model.StartForm; +import org.cibseven.webapp.rest.model.Variable; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; + +public class DirectProcessProvider implements IProcessProvider { + + SevenDirectProvider sevenDirectProvider; + DirectProviderUtil directProviderUtil; + + DirectProcessProvider(DirectProviderUtil directProviderUtil, SevenDirectProvider sevenDirectProvider){ + this.directProviderUtil = directProviderUtil; + this.sevenDirectProvider = sevenDirectProvider; + } + + @Override + public Collection findProcesses(CIBUser user) { + MultivaluedMap queryParameters = new MultivaluedHashMap<>(); + // ProcessProvider adds: "?latestVersion=true&sortBy=name&sortOrder=desc";" + queryParameters.add("latestVersion", "true"); + queryParameters.add("sortBy", "name"); + queryParameters.add("sortOrder", "desc"); + ProcessDefinitionQueryDto queryDto = new ProcessDefinitionQueryDto(directProviderUtil.getObjectMapper(user), queryParameters); + + ProcessDefinitionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingDefinitions = QueryUtil.list(query, null, null); + + List processes = new ArrayList<>(); + for (ProcessDefinition definition : matchingDefinitions) { + ProcessDefinitionDto def = ProcessDefinitionDto.fromProcessDefinition(definition); + processes.add(directProviderUtil.convertValue(def, Process.class, user)); + } + return processes; + } + + @Override + public Collection findProcessesWithInfo(CIBUser user) { + Map queryParams = new HashMap<>(); + queryParams.put("failedJobs", true); + queryParams.put("incidents", true); + Collection statisticsCollection = getProcessStatistics(queryParams, user); + // Group by key and tenant ID to consolidate different versions + List groupedStatistics = sevenDirectProvider.getProcessProvider() + .groupProcessStatisticsByKeyAndTenant(statisticsCollection); + // Build Process objects directly from grouped ProcessStatistics + return groupedStatistics.stream().map(stats -> { + Process process = directProviderUtil.convertValue(stats.getDefinition(), Process.class, user); + + // Set aggregated statistics data + process.setRunningInstances(stats.getInstances()); + // Calculate total incidents from all incident types + long totalIncidents = stats.getIncidents() != null + ? stats.getIncidents().stream().mapToLong(incident -> incident.getIncidentCount()).sum() + : 0L; + process.setIncidents(totalIncidents); + + // Set default values for fields not available in statistics + process.setAllInstances(stats.getInstances()); // Same as running instances for now + process.setCompletedInstances(0L); // Would need separate call to get completed instances + + return process; + }).collect(Collectors.toList()); + + } + + @Override + public List groupProcessStatisticsByKeyAndTenant(Collection processStatistics) { + return groupProcessStatisticsByKeyAndTenantImpl(processStatistics); + } + + public Collection getProcessStatistics(Map queryParams, CIBUser user) { + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + Boolean includeIncidents = getBooleanValueFromObject(queryParams.get("incidents"), objectMapper); + + String includeIncidentsForType = (String) queryParams.get("incidentsForType"); + Boolean includeRootIncidents = getBooleanValueFromObject(queryParams.get("rootIncidents"), objectMapper); + + Boolean includeFailedJobs = getBooleanValueFromObject(queryParams.get("failedJobs"), objectMapper); + if (includeIncidents != null && includeIncidents.booleanValue() && includeIncidentsForType != null + && !includeIncidentsForType.isBlank()) { + throw new SystemException( + "Only one of the query parameter includeIncidents or includeIncidentsForType can be set."); + } + + if (includeIncidents != null && includeIncidents.booleanValue() && includeRootIncidents != null + && includeRootIncidents.booleanValue()) { + throw new SystemException("Only one of the query parameter includeIncidents or includeRootIncidents can be set."); + } + + if (includeRootIncidents != null && includeRootIncidents.booleanValue() && includeIncidentsForType != null + && !includeIncidentsForType.isBlank()) { + throw new SystemException( + "Only one of the query parameter includeRootIncidents or includeIncidentsForType can be set."); + } + + ProcessDefinitionStatisticsQuery query = directProviderUtil.getProcessEngine(user).getManagementService().createProcessDefinitionStatisticsQuery(); + + if (includeFailedJobs != null && includeFailedJobs) { + query.includeFailedJobs(); + } + + if (includeIncidents != null && includeIncidents) { + query.includeIncidents(); + } else if (includeIncidentsForType != null) { + query.includeIncidentsForType(includeIncidentsForType); + } else if (includeRootIncidents != null && includeRootIncidents) { + query.includeRootIncidents(); + } + + List queryResults = query.unlimitedList(); + + Collection processStatistics = new ArrayList<>(); + for (ProcessDefinitionStatistics queryResult : queryResults) { + processStatistics.add(directProviderUtil.getObjectMapper(user).convertValue( + ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult), ProcessStatistics.class)); + } + return processStatistics; + } + + private Boolean getBooleanValueFromObject(Object value, ObjectMapper objectMapper) { + return objectMapper.convertValue(value, Boolean.class); + } + + @Override + public Collection findProcessesWithFilters(String filters, CIBUser user) { + Map filterMap = new HashMap<>(); + String[] splitFilter = filters.split("&"); + for (String params : splitFilter) { + String[] splitValue = params.split("="); + if (splitValue.length > 1) + filterMap.put(splitValue[0], URLDecoder.decode(splitValue[1], Charset.forName("UTF-8"))); + } + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + ProcessDefinitionQueryDto queryDto = objectMapper.convertValue(filterMap, ProcessDefinitionQueryDto.class); + List processes = new ArrayList<>(); + ProcessEngine processEngine = directProviderUtil.getProcessEngine(user); + ProcessDefinitionQuery query = queryDto.toQuery(processEngine); + List matchingDefinitions = QueryUtil.list(query, null, null); + + for (ProcessDefinition definition : matchingDefinitions) { + ProcessDefinitionDto def = ProcessDefinitionDto.fromProcessDefinition(definition); + processes.add(directProviderUtil.convertValue(def, Process.class, user)); + } + for (Process process : processes) { + ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto(); + queryDto.setObjectMapper(objectMapper); + processInstanceQueryDto.setProcessDefinitionId(process.getId()); + process.setRunningInstances(processInstanceQueryDto.toQuery(processEngine).count()); + } + return processes; + } + + @Override + public Process findProcessByDefinitionKey(String key, String tenantId, CIBUser user) { + ProcessDefinitionQuery query = directProviderUtil.getProcessEngine(user).getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(key) + .latestVersion(); + if (tenantId != null) + query.tenantIdIn(new String[] { tenantId }); + else + query.withoutTenantId(); + ProcessDefinition instance = query.singleResult(); + if (instance == null) { + if (tenantId != null) + throw new SystemException("Process instance " + key + " not found with tenantId " + tenantId); + else + throw new SystemException("Process instance not found: " + key); + } + Process process = directProviderUtil.convertValue(ProcessDefinitionDto.fromProcessDefinition(instance), Process.class, user); + return process; + } + + @Override + public Collection findProcessVersionsByDefinitionKey(String key, String tenantId, Optional lazyLoad, + CIBUser user) { + // returns same array but in different order + ProcessDefinitionQueryDto queryDto = new ProcessDefinitionQueryDto(); + queryDto.setKey(key); + if (tenantId != null) + queryDto.setTenantIdIn(Arrays.asList(tenantId)); + else + queryDto.setWithoutTenantId(true); + ProcessDefinitionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List definitions = QueryUtil.list(query, null, null); + List processes = new ArrayList<>(); + for (ProcessDefinition definition : definitions) { + ProcessDefinitionDto def = ProcessDefinitionDto.fromProcessDefinition(definition); + processes.add(directProviderUtil.convertValue(def, Process.class, user)); + } + + if (!lazyLoad.isPresent() || (lazyLoad.isPresent() && !lazyLoad.get())) { + for (Process process : processes) { + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = new HistoricProcessInstanceQueryDto(); + historicProcessInstanceQueryDto.setProcessDefinitionId(process.getId()); + historicProcessInstanceQueryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricProcessInstanceQuery historicProcessInstanceQuery = historicProcessInstanceQueryDto + .toQuery(directProviderUtil.getProcessEngine(user)); + List matchingHistoricProcessInstances = historicProcessInstanceQuery.unlimitedList(); + + process.setAllInstances(matchingHistoricProcessInstances.size()); + + historicProcessInstanceQueryDto.setUnfinished(true); + historicProcessInstanceQuery = historicProcessInstanceQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + matchingHistoricProcessInstances = historicProcessInstanceQuery.unlimitedList(); + + process.setRunningInstances(matchingHistoricProcessInstances.size()); + + historicProcessInstanceQueryDto.setUnfinished(false); + historicProcessInstanceQueryDto.setCompleted(true); + historicProcessInstanceQuery = historicProcessInstanceQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + matchingHistoricProcessInstances = historicProcessInstanceQuery.unlimitedList(); + + process.setCompletedInstances(matchingHistoricProcessInstances.size()); + } + } + return processes; + } + + @Override + public Process findProcessById(String id, Optional extraInfo, CIBUser user) throws SystemException { + ProcessDefinition definition; + try { + definition = directProviderUtil.getProcessEngine(user).getRepositoryService().getProcessDefinition(id); + } catch (ProcessEngineException e) { + throw new SystemException("No matching definition with id " + id, e); + } + + ProcessDefinitionDto definitionDto = ProcessDefinitionDto.fromProcessDefinition(definition); + Process process = directProviderUtil.convertValue(definitionDto, Process.class, user); + if (extraInfo.isPresent() && extraInfo.get()) { + Map filters = new HashMap<>(); + filters.put("processDefinitionId", id); + Long count = countProcessesInstancesHistory(filters, user); + process.setAllInstances(count); + filters.clear(); + filters.put("processDefinitionId", process.getId()); + filters.put("unfinished", true); + count = countProcessesInstancesHistory(filters, user); + process.setRunningInstances(count); + filters.clear(); + filters.put("processDefinitionId", process.getId()); + filters.put("completed", true); + count = countProcessesInstancesHistory(filters, user); + process.setCompletedInstances(count); + } + return process; + } + + @Override + public Collection findProcessesInstances(String key, CIBUser user) { + List result = new ArrayList<>(); + List instances = directProviderUtil.getProcessEngine(user).getRuntimeService().createProcessInstanceQuery() + .processDefinitionKey(key).list(); + + for (org.cibseven.bpm.engine.runtime.ProcessInstance instance : instances) { + ProcessInstanceDto backendDto = ProcessInstanceDto.fromProcessInstance(instance); + ProcessInstance webClientDto = directProviderUtil.convertValue(backendDto, ProcessInstance.class, user); + result.add(webClientDto); + } + return result; + } + + @Override + public ProcessDiagram fetchDiagram(String id, CIBUser user) { + InputStream processModelIn = null; + try { + processModelIn = directProviderUtil.getProcessEngine(user).getRepositoryService().getProcessModel(id); + byte[] processModel = IoUtil.readInputStream(processModelIn, "processModelBpmn20Xml"); + return directProviderUtil.convertValue(ProcessDefinitionDiagramDto.create(id, new String(processModel, "UTF-8")), + ProcessDiagram.class, user); + } catch (AuthorizationException e) { + throw e; + } catch (NotFoundException e) { + throw new SystemException("No matching definition with id " + id, e); + } catch (UnsupportedEncodingException e) { + throw new SystemException(e.getMessage(), e); + } finally { + IoUtil.closeSilently(processModelIn); + } + } + + @Override + public StartForm fetchStartForm(String processDefinitionId, CIBUser user) { + final StartFormData formData; + try { + formData = directProviderUtil.getProcessEngine(user).getFormService().getStartFormData(processDefinitionId); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException("Cannot get start form data for process definition " + processDefinitionId, e); + } + FormDto dto = FormDto.fromFormData(formData); + if ((dto.getKey() == null || dto.getKey().isEmpty()) && dto.getCamundaFormRef() == null) { + if (formData != null && formData.getFormFields() != null && !formData.getFormFields().isEmpty()) { + dto.setKey("embedded:engine://engine/:engine/process-definition/" + processDefinitionId + "/rendered-form"); + } + } + dto.setContextPath( + ApplicationContextPathUtil.getApplicationPathByProcessDefinitionId(directProviderUtil.getProcessEngine(user), processDefinitionId)); + return directProviderUtil.convertValue(dto, StartForm.class, user); + } + + @Override + public Data downloadBpmn(String id, String fileName, CIBUser user) { + + ProcessDiagram diagram = fetchDiagram(id, user); + ByteArrayResource resource = new ByteArrayResource(diagram.getBpmn20Xml().getBytes()); + return new Data(fileName, "application/bpmn+xml", resource, resource.contentLength()); + } + + @Override + public void suspendProcessInstance(String processInstanceId, Boolean suspend, CIBUser user) { + ProcessInstanceSuspensionStateDto processInstanceSuspensionStateDto = new ProcessInstanceSuspensionStateDto(); + processInstanceSuspensionStateDto.setProcessInstanceIds(Arrays.asList(processInstanceId)); + processInstanceSuspensionStateDto.setSuspended(suspend); + processInstanceSuspensionStateDto.updateSuspensionState(directProviderUtil.getProcessEngine(user)); + } + + @Override + public void deleteProcessInstance(String processInstanceId, CIBUser user) { + directProviderUtil.getProcessEngine(user).getRuntimeService().deleteProcessInstance(processInstanceId, null); + } + + @Override + public void suspendProcessDefinition(String processDefinitionId, Boolean suspend, Boolean includeProcessInstances, + String executionDate, CIBUser user) { + + ProcessDefinitionSuspensionStateDto dto = new ProcessDefinitionSuspensionStateDto(); + dto.setProcessDefinitionId(processDefinitionId); + dto.setSuspended(suspend); + dto.setIncludeProcessInstances(includeProcessInstances); + if (executionDate != null) + dto.setExecutionDate(executionDate); + try { + dto.updateSuspensionState(directProviderUtil.getProcessEngine(user)); + + } catch (IllegalArgumentException e) { + String message = String.format("Could not update the suspension state of Process Definitions due to: %s", + e.getMessage()); + throw new SystemException(message, e); + } + } + + @Override + public ProcessStart startProcess(String processDefinitionKey, String tenantId, Map data, CIBUser user) + throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + ProcessDefinitionQuery processDefinitionQuery = directProviderUtil.getProcessEngine(user).getRepositoryService().createProcessDefinitionQuery() + .processDefinitionKey(processDefinitionKey); + if (tenantId != null) + processDefinitionQuery.tenantIdIn(tenantId); + else + processDefinitionQuery.withoutTenantId(); + ProcessDefinition processDefinition = processDefinitionQuery.latestVersion().singleResult(); + + if (processDefinition == null) { + String errorMessage = tenantId != null + ? String.format("No matching process definition with key: %s and tenant-id: %s", processDefinitionKey, tenantId) + : String.format("No matching process definition with key: %s and no tenant-id", processDefinitionKey); + + throw new SystemException(errorMessage); + + } else { + // start the process + ProcessInstanceWithVariables processInstanceWithVariables = null; + // the simple case contains the _locale variable, only + StartProcessInstanceDto startProcessInstanceDto = directProviderUtil.getObjectMapper(user).convertValue(data, StartProcessInstanceDto.class); + try { + processInstanceWithVariables = startProcessInstanceAtActivities(startProcessInstanceDto, + processDefinition.getId(), user); + } catch (AuthorizationException e) { + throw e; + + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinition.getId(), + e.getMessage()); + throw new ExpressionEvaluationException(new UnsupportedTypeException(new RuntimeException(errorMessage, e))); + } + + ProcessInstanceDto result; + if (startProcessInstanceDto.isWithVariablesInReturn()) { + result = ProcessInstanceWithVariablesDto.fromProcessInstance(processInstanceWithVariables); + } else { + result = ProcessInstanceDto.fromProcessInstance(processInstanceWithVariables); + } + + ProcessStart processStart = directProviderUtil.convertValue(result, ProcessStart.class, user); + return processStart; + } + + } + + @Override + public ProcessStart submitForm(String processDefinitionKey, String tenantId, Map data, CIBUser user) + throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + ProcessDefinitionQuery query = directProviderUtil.getProcessEngine(user).getRepositoryService().createProcessDefinitionQuery() + .processDefinitionKey(processDefinitionKey); + if (tenantId != null) + query.tenantIdIn(tenantId); + else + query.withoutTenantId(); + ProcessDefinition processDefinition = query.latestVersion().singleResult(); + + if (processDefinition == null) { + String errorMessage = String.format("No matching process definition with key: %s and tenant-id: %s", + processDefinitionKey, tenantId); + throw new SystemException(errorMessage); + } else { + StartProcessInstanceDto parameters = directProviderUtil.getObjectMapper(user).convertValue(data, StartProcessInstanceDto.class); + org.cibseven.bpm.engine.runtime.ProcessInstance instance = null; + try { + Map variables = VariableValueDto.toMap(parameters.getVariables(), directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user)); + String businessKey = parameters.getBusinessKey(); + if (businessKey != null) { + instance = directProviderUtil.getProcessEngine(user).getFormService().submitStartForm(processDefinition.getId(), businessKey, variables); + } else { + instance = directProviderUtil.getProcessEngine(user).getFormService().submitStartForm(processDefinition.getId(), variables); + } + + } catch (AuthorizationException e) { + throw e; + + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinition.getId(), + e.getMessage()); + throw new ExpressionEvaluationException(new UnsupportedTypeException(new SystemException(errorMessage, e))); + } + + ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance); + + return directProviderUtil.getObjectMapper(user).convertValue(result, ProcessStart.class); + + } + } + + @Override + public Collection findProcessStatistics(String processId, CIBUser user) + throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + ActivityStatisticsQuery query = directProviderUtil.getProcessEngine(user).getManagementService().createActivityStatisticsQuery(processId); + List queryResults = query.unlimitedList(); + + Collection processStatistics = new ArrayList<>(); + for (ActivityStatistics queryResult : queryResults) { + StatisticsResultDto dto = ActivityStatisticsResultDto.fromActivityStatistics(queryResult); + processStatistics.add(directProviderUtil.getObjectMapper(user).convertValue(dto, ProcessStatistics.class)); + } + return processStatistics; + } + + @Override + public Collection findProcessesInstancesHistory(Map filters, + Optional firstResult, Optional maxResults, CIBUser user) { + Boolean fetchIncidents = (Boolean) filters.get("fetchIncidents"); + if (fetchIncidents != null) { + filters.remove("fetchIncidents"); + } + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = directProviderUtil.getObjectMapper(user).convertValue(filters, + HistoricProcessInstanceQueryDto.class); + + historicProcessInstanceQueryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricProcessInstanceQuery query = historicProcessInstanceQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingHistoricProcessInstances = QueryUtil.list(query, + firstResult.isPresent() ? firstResult.get() : null, maxResults.isPresent() ? maxResults.get() : null); + + List historicProcessInstanceResults = new ArrayList(); + for (HistoricProcessInstance historicProcessInstance : matchingHistoricProcessInstances) { + HistoricProcessInstanceDto resultHistoricProcessInstanceDto = HistoricProcessInstanceDto + .fromHistoricProcessInstance(historicProcessInstance); + historicProcessInstanceResults.add(directProviderUtil.convertValue(resultHistoricProcessInstanceDto, HistoryProcessInstance.class, user)); + } + // Check if caller wants incident handling + if (fetchIncidents != null && fetchIncidents) { + String processDefinitionId = (String) filters.get("processDefinitionId"); + if (processDefinitionId != null) { + @SuppressWarnings("unchecked") + List activityIdIn = (List) filters.get("activeActivityIdIn"); + + // Handle case where no processes found with activity filter - fallback + // to incident-based search + if ((historicProcessInstanceResults == null || historicProcessInstanceResults.isEmpty()) && activityIdIn != null + && !activityIdIn.isEmpty()) { + String activityId = activityIdIn.get(0); + Collection incidents = sevenDirectProvider.fetchIncidentsByInstanceAndActivityId(processDefinitionId, activityId, user); + + if (incidents != null && !incidents.isEmpty()) { + Map> incidentsByProcessInstance = incidents.stream() + .collect(Collectors.groupingBy(Incident::getProcessInstanceId)); + + Set processInstanceIds = incidentsByProcessInstance.keySet(); + + // Create new query for process instances with incidents + Map dataIdIn = new HashMap<>(filters); + dataIdIn.put("processInstanceIdIn", processInstanceIds); + dataIdIn.remove("activeActivityIdIn"); // Remove activity filter for + // fallback search + + historicProcessInstanceResults = (List) findProcessesInstancesHistory(dataIdIn, + Optional.ofNullable(null), Optional.ofNullable(null), user); + + // Associate incidents with process instances + historicProcessInstanceResults.forEach( + p -> p.setIncidents(incidentsByProcessInstance.getOrDefault(p.getId(), Collections.emptyList()))); + } + } else if (historicProcessInstanceResults != null) { + // For regular queries, fetch incidents for all returned processes + historicProcessInstanceResults.forEach(p -> { + p.setIncidents(sevenDirectProvider.findIncidentByInstanceId(p.getId(), user)); + }); + } + } + } + return historicProcessInstanceResults; + + } + + @Override + public Collection findProcessesInstancesHistory(String key, Optional active, + Integer firstResult, Integer maxResults, CIBUser user) { + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = new HistoricProcessInstanceQueryDto(); + // historicProcessInstanceQueryDto.setProcessDefinitionId(id); + historicProcessInstanceQueryDto.setProcessDefinitionKey(key); + if (active.isPresent()) + historicProcessInstanceQueryDto.setActive(active.get()); + return queryHistoryProcessInstances(historicProcessInstanceQueryDto, firstResult, maxResults, user); + } + + @Override + public Collection findProcessesInstancesHistoryById(String id, Optional activityId, + Optional active, Integer firstResult, Integer maxResults, String text, CIBUser user) { + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = new HistoricProcessInstanceQueryDto(); + historicProcessInstanceQueryDto.setProcessDefinitionId(id); + if (activityId.isPresent()) + historicProcessInstanceQueryDto.setActivityIdIn(Arrays.asList(activityId.get())); + if (active.isPresent()) + historicProcessInstanceQueryDto.setActive(active.get()); + if (text != "") { + List orQueries = new ArrayList<>(); + HistoricProcessInstanceQueryDto orQuery = new HistoricProcessInstanceQueryDto(); + orQuery.setProcessInstanceBusinessKeyLike("*" + text + "*"); + orQuery.setProcessInstanceId(text); + orQueries.add(orQuery); + historicProcessInstanceQueryDto.setOrQueries(orQueries); + } + + return queryHistoryProcessInstances(historicProcessInstanceQueryDto, firstResult, maxResults, user); + } + + @Override + public Long countProcessesInstancesHistory(Map filters, CIBUser user) { + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = directProviderUtil.getObjectMapper(user).convertValue(filters, + HistoricProcessInstanceQueryDto.class); + historicProcessInstanceQueryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricProcessInstanceQuery query = historicProcessInstanceQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + long count = query.count(); + return count; + } + + @Override + public ProcessInstance findProcessInstance(String processInstanceId, CIBUser user) { + org.cibseven.bpm.engine.runtime.ProcessInstance instance = directProviderUtil.getProcessEngine(user).getRuntimeService().createProcessInstanceQuery() + .processInstanceId(processInstanceId).singleResult(); + if (instance == null) { + throw new NoObjectFoundException(new SystemException("Process instance with id " + processInstanceId + " does not exist")); + } + + ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance); + return directProviderUtil.convertValue(result, ProcessInstance.class, user); + } + + @Override + public Variable fetchProcessInstanceVariable(String processInstanceId, String variableName, boolean deserializeValue, + CIBUser user) throws SystemException { + VariableInstanceQueryDto queryDto = new VariableInstanceQueryDto(); + queryDto.setProcessInstanceIdIn(new String[] { processInstanceId }); + queryDto.setVariableName(variableName); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + + List variablesDeserialized = directProviderUtil.queryVariableInstances(queryDto, null, null, true, user); + List variablesSerialized = directProviderUtil.queryVariableInstances(queryDto, null, null, false, user); + Variable variableDeserialized = variablesDeserialized.size() == 1 ? variablesDeserialized.get(0) : null; + Variable variableSerialized = variablesSerialized.size() == 1 ? variablesSerialized.get(0) : null; + if (variableDeserialized == null || variableSerialized == null) + throw new SystemException("Variable " + variableName + " not found in process instance " + processInstanceId); + if (deserializeValue) { + variableDeserialized.setValueSerialized(variableSerialized.getValue()); + variableDeserialized.setValueDeserialized(variableDeserialized.getValue()); + return variableDeserialized; + } else { + variableSerialized.setValueSerialized(variableSerialized.getValue()); + variableSerialized.setValueDeserialized(variableDeserialized.getValue()); + return variableSerialized; + } + + } + + @Override + public HistoryProcessInstance findHistoryProcessInstanceHistory(String processInstanceId, CIBUser user) { + HistoricProcessInstance instance = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricProcessInstanceQuery() + .processInstanceId(processInstanceId).singleResult(); + if (instance == null) { + throw new NoObjectFoundException(new SystemException("Historic process instance with id " + processInstanceId + " does not exist")); + } + + HistoryProcessInstance historyProcessInstance = directProviderUtil.convertValue( + HistoricProcessInstanceDto.fromHistoricProcessInstance(instance), HistoryProcessInstance.class, user); + ; + return historyProcessInstance; + } + + @Override + public Collection findCalledProcessDefinitions(String processDefinitionId, CIBUser user) { + try { + List calledProcessDefinitionDtos = directProviderUtil.getProcessEngine(user).getRepositoryService() + .getStaticCalledProcessDefinitions(processDefinitionId).stream().map(CalledProcessDefinitionDto::from) + .map(DirectProcessProvider::convertToProcess).collect(Collectors.toList()); + return calledProcessDefinitionDtos; + } catch (NotFoundException e) { + throw new SystemException(e.getMessage()); + } + + } + + public static Process convertToProcess(CalledProcessDefinitionDto dto) { + ObjectMapper objectMapper = new ObjectMapper(); + Map filterDtoMap = objectMapper.convertValue(dto, new TypeReference>() { + }); + return objectMapper.convertValue(filterDtoMap, Process.class); + } + + @Override + public ResponseEntity getDeployedStartForm(String processDefinitionId, CIBUser user) { + try { + InputStream deployedStartForm = directProviderUtil.getProcessEngine(user).getFormService().getDeployedStartForm(processDefinitionId); + byte[] bytes = IOUtils.toByteArray(deployedStartForm); + return ResponseEntity.ok(bytes); + } catch (NotFoundException e) { + throw new SystemException(e.getMessage()); + } catch (NullValueException e) { + throw new SystemException(e.getMessage()); + } catch (AuthorizationException e) { + throw new SystemException(e.getMessage()); + } catch (IOException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void updateHistoryTimeToLive(String id, Map data, CIBUser user) { + HistoryTimeToLiveDto historyTimeToLiveDto = directProviderUtil.getObjectMapper(user).convertValue(data, HistoryTimeToLiveDto.class); + directProviderUtil.getProcessEngine(user).getRepositoryService().updateProcessDefinitionHistoryTimeToLive(id, historyTimeToLiveDto.getHistoryTimeToLive()); + } + + @Override + public void deleteProcessInstanceFromHistory(String id, CIBUser user) { + try { + directProviderUtil.getProcessEngine(user).getHistoryService().deleteHistoricProcessInstance(id); + } catch (BadUserRequestException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void deleteProcessDefinition(String id, Optional cascade, CIBUser user) { + boolean cascadeVal = cascade.orElse(true); + try { + directProviderUtil.getProcessEngine(user).getRepositoryService().deleteProcessDefinition(id, cascadeVal); + } catch (NotFoundException nfe) { + throw new SystemException(nfe.getMessage(), nfe); + } + } + + @Override + public Collection findCurrentProcessesInstances(Map data, CIBUser user) + throws SystemException { + ProcessInstanceQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(data, ProcessInstanceQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + ProcessInstanceQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingInstances = QueryUtil.list(query, null, null); + + List instanceResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.runtime.ProcessInstance instance : matchingInstances) { + ProcessInstanceDto resultInstance = ProcessInstanceDto.fromProcessInstance(instance); + instanceResults.add(directProviderUtil.convertValue(resultInstance, ProcessInstance.class, user)); + } + return instanceResults; + } + + @Override + public Object fetchHistoricActivityStatistics(String id, Map params, CIBUser user) { + MultivaluedMap queryParams = new MultivaluedHashMap<>(); + for (String key : params.keySet()) { + queryParams.put(key, Arrays.asList((String) params.get(key))); + } + + HistoricActivityStatisticsQueryDto historicActivityStatisticsQueryDto = new HistoricActivityStatisticsQueryDto( + directProviderUtil.getObjectMapper(user), id, queryParams); + HistoricActivityStatisticsQuery query = historicActivityStatisticsQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List result = new ArrayList<>(); + List statistics = query.unlimitedList(); + for (HistoricActivityStatistics currentStatistics : statistics) { + result.add(HistoricActivityStatisticsDto.fromHistoricActivityStatistics(currentStatistics)); + } + return result; + } + + private ProcessInstanceWithVariables startProcessInstanceAtActivities(StartProcessInstanceDto dto, + String processDefinitionKey, CIBUser user) { + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + Map processInstanceVariables = VariableValueDto.toMap(dto.getVariables(), directProviderUtil.getProcessEngine(user), + objectMapper); + String businessKey = dto.getBusinessKey(); + String caseInstanceId = dto.getCaseInstanceId(); + + ProcessInstantiationBuilder instantiationBuilder = directProviderUtil.getProcessEngine(user).getRuntimeService().createProcessInstanceById(processDefinitionKey) + .businessKey(businessKey).caseInstanceId(caseInstanceId).setVariables(processInstanceVariables); + + if (dto.getStartInstructions() != null && !dto.getStartInstructions().isEmpty()) { + for (ProcessInstanceModificationInstructionDto instruction : dto.getStartInstructions()) { + instruction.applyTo(instantiationBuilder, directProviderUtil.getProcessEngine(user), objectMapper); + } + } + return instantiationBuilder.executeWithVariablesInReturn(dto.isSkipCustomListeners(), dto.isSkipIoMappings()); + } + + private Collection queryHistoryProcessInstances( + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto, Integer firstResult, Integer maxResults, CIBUser user) { + historicProcessInstanceQueryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + + HistoricProcessInstanceQuery query = historicProcessInstanceQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List matchingHistoricProcessInstances = QueryUtil.list(query, firstResult, maxResults); + + List HistoryProcessInstanceResults = new ArrayList(); + for (HistoricProcessInstance historicProcessInstance : matchingHistoricProcessInstances) { + HistoricProcessInstanceDto resultHistoricProcessInstanceDto = HistoricProcessInstanceDto + .fromHistoricProcessInstance(historicProcessInstance); + HistoryProcessInstanceResults.add(directProviderUtil.convertValue(resultHistoricProcessInstanceDto, HistoryProcessInstance.class, user)); + } + return HistoryProcessInstanceResults; + } + + @Override + public ProcessStart submitForm(String processDefinitionKey, String formResult, CIBUser user) + throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + StartProcessInstanceDto parameters; + try { + parameters = objectMapper.readValue(formResult, StartProcessInstanceDto.class); + } catch (JsonProcessingException e) { + throw new SystemException(e.getMessage(), e); + } + FormService formService = directProviderUtil.getProcessEngine(user).getFormService(); + + org.cibseven.bpm.engine.runtime.ProcessInstance instance = null; + ProcessDefinition processDefinition = directProviderUtil.getProcessEngine(user).getRepositoryService().createProcessDefinitionQuery() + .processDefinitionKey(processDefinitionKey) + .withoutTenantId().latestVersion().singleResult(); + + if (processDefinition == null) { + String errorMessage = String.format("No matching process definition with key: %s", processDefinitionKey); + throw new SystemException(errorMessage); + } + + try { + Map variables = VariableValueDto.toMap(parameters.getVariables(), directProviderUtil.getProcessEngine(user), objectMapper); + String businessKey = parameters.getBusinessKey(); + if (businessKey != null) { + instance = formService.submitStartForm(processDefinition.getId(), businessKey, variables); + } else { + instance = formService.submitStartForm(processDefinition.getId(), variables); + } + } catch (AuthorizationException e) { + throw e; + + } catch (ProcessEngineException|RestException e) { + String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinition.getId(), e.getMessage()); + throw new SystemException(errorMessage, e); + } + + ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance); + return directProviderUtil.convertValue(result, ProcessStart.class, user); + } + + @Override + public ResponseEntity getRenderedForm(String processDefinitionId, Map params, CIBUser user) { + FormService formService = directProviderUtil.getProcessEngine(user).getFormService(); + + Object startForm = formService.getRenderedStartForm(processDefinitionId); + if (startForm != null) { + String content = startForm.toString(); + InputStream stream = new ByteArrayInputStream(content.getBytes(EncodingUtil.DEFAULT_ENCODING)); + try { + return ResponseEntity.ok(IOUtils.toString(stream, Charset.defaultCharset())); + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } + + throw new SystemException("No matching rendered start form for process definition with the id " + processDefinitionId + " found."); + } + + @Override + public Collection findProcessesInstancesRuntime(Map data, + Optional firstResult, Optional maxResults, CIBUser user) { + // the two-call approach (runtime → history) is fundamentally the right design + // since "/process-instance" has runtime-specific filters not available in the history API. + + ProcessInstanceQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(data, ProcessInstanceQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + ProcessInstanceQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingInstances = QueryUtil.list(query, firstResult.orElse(null), maxResults.orElse(null)); + + List instanceResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.runtime.ProcessInstance instance : matchingInstances) { + ProcessInstanceDto resultInstance = ProcessInstanceDto.fromProcessInstance(instance); + instanceResults.add(directProviderUtil.convertValue(resultInstance, ProcessInstance.class, user)); + } + if (instanceResults.isEmpty()) { + return Collections.emptyList(); + } + + // Note: Between the two calls, a runtime instance could complete. + // The history call will still find it (history is permanent), + // but state in the result may be COMPLETED instead of ACTIVE. + // This is usually acceptable but worth being aware of. + + // fetch history for those ids to get full info + Map dataHistory = new HashMap<>(); + dataHistory.put("processInstanceIds", instanceResults); + + Integer firstResult0 = 0; + //TODO: dataHistory as input parameter could be wrong! + Collection historicInstances = findProcessesInstancesHistory(dataHistory, Optional.of(firstResult0), maxResults, user); + // sort [historicInstances] like they are inside [processInstanceIds] + historicInstances = historicInstances.stream() + .sorted(Comparator.comparingInt(h -> instanceResults.indexOf(h.getId()))) + .collect(Collectors.toList()); + + return historicInstances; + } + + @Override + public Long countProcessesInstancesRuntime(Map filters, CIBUser user) { + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = objectMapper.convertValue(filters, + HistoricProcessInstanceQueryDto.class); + ProcessEngine engine = directProviderUtil.getProcessEngine(user); + historicProcessInstanceQueryDto.setObjectMapper(objectMapper); + HistoricProcessInstanceQuery query = historicProcessInstanceQueryDto.toQuery(engine); + return query.count(); + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectProviderUtil.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectProviderUtil.java new file mode 100755 index 000000000..cd0683b82 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectProviderUtil.java @@ -0,0 +1,164 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; + +import org.cibseven.bpm.BpmPlatform; +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.IdentityService; +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.impl.identity.Authentication; +import org.cibseven.bpm.engine.rest.dto.runtime.VariableInstanceDto; +import org.cibseven.bpm.engine.rest.dto.runtime.VariableInstanceQueryDto; +import org.cibseven.bpm.engine.rest.exception.RestException; +import org.cibseven.bpm.engine.rest.mapper.JacksonConfigurator; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.runtime.VariableInstance; +import org.cibseven.bpm.engine.runtime.VariableInstanceQuery; +import org.cibseven.bpm.engine.variable.value.TypedValue; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Variable; +import org.cibseven.webapp.rest.model.VariableHistory; +import org.cibseven.bpm.engine.rest.util.EngineUtil; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class DirectProviderUtil { + + protected Map processEngines = new HashMap<>(); + protected Map objectMappers = new HashMap<>(); + + public DirectProviderUtil() { + } + + protected ProcessEngine getProcessEngine(String processEngineName) { + ProcessEngine processEngine = null; + if (processEngines.containsKey(processEngineName)) + processEngine = processEngines.get(processEngineName); + else { + // either one of the two methods can be used to lookup the process engine - the other might fail for unknown reasons + try { + processEngine = EngineUtil.lookupProcessEngine(processEngineName); + } catch (RestException ex) { + processEngine = BpmPlatform.getProcessEngineService().getProcessEngine(processEngineName); + } finally { + if (processEngine == null) + throw new SystemException("No process engine found with name " + processEngineName); + } + processEngines.put(processEngineName, processEngine); + ObjectMapper objectMapper = new ObjectMapper(); + JacksonConfigurator.configureObjectMapper(objectMapper); + objectMappers.put(processEngineName, objectMapper); + } + return processEngine; + } + + protected ProcessEngine getProcessEngine(CIBUser user) { + return getProcessEngine(getEngineName(user)); + } + + protected ObjectMapper getObjectMapper(CIBUser user) { + String engineName = getEngineName(user); + getProcessEngine(engineName); + return objectMappers.get(engineName); + } + + protected ObjectMapper getObjectMapper(String engineName) { + getProcessEngine(engineName); + return objectMappers.get(engineName); + } + + protected String getEngineName(CIBUser user) { + String processEngineName = user != null ? user.getEngine() : null; + // If engine name is provided and not "default", add it to the path + if (processEngineName == null || processEngineName.isEmpty()) + processEngineName = "default"; + return processEngineName; + } + + /** + * conversion and helper functions + */ + protected T convertValue(Object fromValueDto, Class toValueType, CIBUser user) throws IllegalArgumentException { + ObjectMapper objectMapper = getObjectMapper(user); + Map filterDtoMap = objectMapper.convertValue(fromValueDto, new TypeReference>() { + }); + return objectMapper.convertValue(filterDtoMap, toValueType); + } + + protected V runWithoutAuthorization(Supplier action, CIBUser user) { + IdentityService identityService = getProcessEngine(user).getIdentityService(); + Authentication currentAuthentication = identityService.getCurrentAuthentication(); + try { + identityService.clearAuthentication(); + return action.get(); + } finally { + identityService.setAuthentication(currentAuthentication); + } + } + + public List queryVariableInstances(VariableInstanceQueryDto queryDto, Integer firstResult, + Integer maxResults, boolean deserializeObjectValues, CIBUser user) { + VariableInstanceQuery query = queryDto.toQuery(getProcessEngine(user)); + + // disable binary fetching by default. + query.disableBinaryFetching(); + + // disable custom object fetching by default. Cannot be done to not break + // existing API + if (!deserializeObjectValues) { + query.disableCustomObjectDeserialization(); + } + + List matchingInstances = QueryUtil.list(query, firstResult, + maxResults); + + List instanceResults = new ArrayList<>(); + for (VariableInstance instance : matchingInstances) { + VariableInstanceDto resultInstanceDto = VariableInstanceDto.fromVariableInstance(instance); + VariableHistory resultInstance = convertValue(resultInstanceDto, VariableHistory.class, user); + instanceResults.add(resultInstance); + } + return instanceResults; + } + + public TypedValue getTypedValueForTaskVariable(String taskId, String variableName, boolean deserializeValue, CIBUser user) { + TypedValue value = null; + try { + value = getProcessEngine(user).getTaskService().getVariableTyped(taskId, variableName, deserializeValue); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot get %s variable %s: %s", "task", variableName, e.getMessage()); + throw new SystemException(errorMessage, e); + } + + if (value == null) { + String errorMessage = String.format("%s variable with name %s does not exist", "task", variableName); + throw new SystemException(errorMessage); + } + return value; + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectSystemProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectSystemProvider.java new file mode 100755 index 000000000..89eb190fb --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectSystemProvider.java @@ -0,0 +1,154 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.cibseven.bpm.engine.management.Metrics; +import org.cibseven.bpm.engine.management.MetricsQuery; +import org.cibseven.bpm.engine.rest.dto.converter.DateConverter; +import org.cibseven.bpm.engine.rest.dto.telemetry.TelemetryDataDto; +import org.cibseven.bpm.engine.telemetry.TelemetryData; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.rest.model.Metric; + +import com.fasterxml.jackson.databind.JsonNode; + +public class DirectSystemProvider implements ISystemProvider { + + DirectProviderUtil directProviderUtil; + + DirectSystemProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public JsonNode getTelemetryData(CIBUser user) { + TelemetryData data = directProviderUtil.getProcessEngine(user).getManagementService().getTelemetryData(); + JsonNode node = directProviderUtil.getObjectMapper(user).valueToTree(TelemetryDataDto.fromEngineDto(data)); + return node; + } + + @Override + public Collection getMetrics(Map queryParams, CIBUser user) { + Collection metrics = new ArrayList<>(); + List> queryData = new ArrayList<>(); + List metricNames = Optional.ofNullable(queryParams.get("metrics")).map(Object::toString) + .filter(s -> !s.isEmpty()).map(s -> Arrays.asList(s.split(","))) + .orElse(Arrays.asList("process-instances", "decision-instances", "task-users")); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZ"); + String currentDate = ZonedDateTime.now(ZoneId.systemDefault()).format(formatter); + String groupBy = Optional.ofNullable(queryParams.get("groupBy")).map(Object::toString).orElse("month"); + String subsStartDate = queryParams.get("subscriptionStartDate").toString(); + ZonedDateTime subsStartDateParsed = ZonedDateTime.parse(subsStartDate, formatter); + if (groupBy.equals("year")) { + String prevDate = subsStartDateParsed.minusYears(1).format(formatter); + for (String metric : metricNames) { + queryData.add(createSumParamsMap(metric, subsStartDate, currentDate)); + queryData.add(createSumParamsMap(metric, prevDate, subsStartDate)); + } + } else if (groupBy.equals("month")) { + String startDate = queryParams.get("startDate").toString(); + ZonedDateTime startDateParsed = ZonedDateTime.parse(startDate, formatter); + for (ZonedDateTime stDate = startDateParsed; !stDate.isAfter(subsStartDateParsed); stDate = stDate.plusMonths(1)) { + ZonedDateTime startDayM = stDate.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0) + .withNano(0); + ZonedDateTime endDayM = stDate.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59) + .withNano(999_000_000); + for (String metric : metricNames) { + queryData.add(createSumParamsMap(metric, startDayM.format(formatter), endDayM.format(formatter))); + } + } + } + for (Map params : queryData) { + Metric metricsData = new Metric(); + metricsData.setMetric(params.get("metric").toString()); + ZonedDateTime startDate = ZonedDateTime.parse(params.get("startDate").toString(), formatter); + metricsData.setSubscriptionYear(startDate.getYear()); + if (groupBy.equals("month")) { + metricsData.setSubscriptionMonth(startDate.getMonthValue()); + } + int count = getSum(metricsData.getMetric(), params, user); + metricsData.setSum(count); + metrics.add(metricsData); + } + return metrics; + } + + private int getSum(String metricsName, Map queryParams, CIBUser user) { + DateConverter dateConverter = new DateConverter(); + dateConverter.setObjectMapper(directProviderUtil.getObjectMapper(user)); + + long result = 0; + + if (Metrics.UNIQUE_TASK_WORKERS.equals(metricsName) || Metrics.TASK_USERS.equals(metricsName)) { + result = directProviderUtil.getProcessEngine(user).getManagementService().getUniqueTaskWorkerCount(extractStartDate(queryParams, dateConverter), + extractEndDate(queryParams, dateConverter)); + } else { + MetricsQuery query = directProviderUtil.getProcessEngine(user).getManagementService().createMetricsQuery().name(metricsName); + + applyQueryParams(queryParams, dateConverter, query); + result = query.sum(); + } + return (int) result; + } + + private void applyQueryParams(Map queryParameters, DateConverter dateConverter, MetricsQuery query) { + Date startDate = extractStartDate(queryParameters, dateConverter); + Date endDate = extractEndDate(queryParameters, dateConverter); + if (startDate != null) { + query.startDate(startDate); + } + if (endDate != null) { + query.endDate(endDate); + } + } + + private Date extractEndDate(Map queryParameters, DateConverter dateConverter) { + if (queryParameters.containsKey("endDate")) { + return dateConverter.convertQueryParameterToType((String) queryParameters.get("endDate")); + } + return null; + } + + private Date extractStartDate(Map queryParameters, DateConverter dateConverter) { + if (queryParameters.containsKey("startDate")) { + return dateConverter.convertQueryParameterToType((String) queryParameters.get("startDate")); + } + return null; + } + + private Map createSumParamsMap(String metric, String startDate, String endDate) { + Map params = new HashMap<>(); + params.put("metric", metric); + params.put("startDate", startDate); + params.put("endDate", endDate); + return params; + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectTaskProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectTaskProvider.java new file mode 100755 index 000000000..32eded027 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectTaskProvider.java @@ -0,0 +1,625 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.apache.commons.io.IOUtils; +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.EntityTypes; +import org.cibseven.bpm.engine.FormService; +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.exception.NotFoundException; +import org.cibseven.bpm.engine.exception.NullValueException; +import org.cibseven.bpm.engine.form.CamundaFormRef; +import org.cibseven.bpm.engine.form.FormData; +import org.cibseven.bpm.engine.history.HistoricTaskInstance; +import org.cibseven.bpm.engine.history.HistoricTaskInstanceQuery; +import org.cibseven.bpm.engine.identity.Group; +import org.cibseven.bpm.engine.identity.GroupQuery; +import org.cibseven.bpm.engine.impl.form.validator.FormFieldValidationException; +import org.cibseven.bpm.engine.impl.identity.Authentication; +import org.cibseven.bpm.engine.impl.util.IoUtil; +import org.cibseven.bpm.engine.query.Query; +import org.cibseven.bpm.engine.rest.dto.AbstractQueryDto; +import org.cibseven.bpm.engine.rest.dto.VariableValueDto; +import org.cibseven.bpm.engine.rest.dto.converter.DelegationStateConverter; +import org.cibseven.bpm.engine.rest.dto.converter.StringListConverter; +import org.cibseven.bpm.engine.rest.dto.history.HistoricTaskInstanceDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricTaskInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.StartProcessInstanceDto; +import org.cibseven.bpm.engine.rest.dto.task.CompleteTaskDto; +import org.cibseven.bpm.engine.rest.dto.task.FormDto; +import org.cibseven.bpm.engine.rest.dto.task.TaskBpmnErrorDto; +import org.cibseven.bpm.engine.rest.dto.task.TaskCountByCandidateGroupResultDto; +import org.cibseven.bpm.engine.rest.dto.task.TaskDto; +import org.cibseven.bpm.engine.rest.dto.task.TaskQueryDto; +import org.cibseven.bpm.engine.rest.dto.task.TaskWithAttachmentAndCommentDto; +import org.cibseven.bpm.engine.rest.exception.RestException; +import org.cibseven.bpm.engine.rest.mapper.JacksonConfigurator; +import org.cibseven.bpm.engine.rest.util.ApplicationContextPathUtil; +import org.cibseven.bpm.engine.rest.util.EncodingUtil; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.task.DelegationState; +import org.cibseven.bpm.engine.task.TaskCountByCandidateGroupResult; +import org.cibseven.bpm.engine.task.TaskQuery; +import org.cibseven.bpm.engine.variable.VariableMap; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SubmitDeniedException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.CamundaForm; +import org.cibseven.webapp.rest.model.CandidateGroupTaskCount; +import org.cibseven.webapp.rest.model.IdentityLink; +import org.cibseven.webapp.rest.model.Task; +import org.cibseven.webapp.rest.model.TaskFiltering; +import org.cibseven.webapp.rest.model.TaskForm; +import org.cibseven.webapp.rest.model.TaskHistory; +import org.cibseven.webapp.rest.model.Variable; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class DirectTaskProvider implements ITaskProvider { + + DirectProviderUtil directProviderUtil; + public DirectTaskProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection findTasks(String filter, CIBUser user) { + Map filters = new HashMap<>(); + String[] splitFilter = filter.split("&"); + for (String params : splitFilter) { + String[] splitValue = params.split("="); + if (splitValue.length > 1) + filters.put(splitValue[0], URLDecoder.decode(splitValue[1], Charset.forName("UTF-8"))); + } + return convertTasks(queryTasks(filters, user), user); + } + + @Override + public Integer findTasksCount(@RequestBody Map filters, CIBUser user) { + return queryTasks(filters, user).size(); + } + + @Override + public Collection findTasksByProcessInstance(String processInstanceId, CIBUser user) { + TaskQuery taskQuery = directProviderUtil.getProcessEngine(user).getTaskService().createTaskQuery().processInstanceId(processInstanceId); + List resultList = taskQuery.initializeFormKeys().list(); + return convertTasks(resultList, user); + } + + @Override + public Collection findTasksByProcessInstanceAsignee(Optional processInstanceId, + Optional createdAfter, CIBUser user) { + TaskQueryDto dto = new TaskQueryDto(); + if (createdAfter.isPresent()) { + dto.setCreatedAfter(directProviderUtil.getObjectMapper(user).convertValue(createdAfter.get(), Date.class)); + } + dto.setAssignee(user.getId()); + if (processInstanceId.isPresent()) + dto.setProcessInstanceId(processInstanceId.get()); + TaskQuery taskQuery = dto.toQuery(directProviderUtil.getProcessEngine(user)); + List resultList = taskQuery.initializeFormKeys().list(); + return convertTasks(resultList, user); + + } + + @Override + public Task findTaskById(String id, CIBUser user) { + org.cibseven.bpm.engine.task.Task result = directProviderUtil.getProcessEngine(user).getTaskService().createTaskQuery().taskId(id).initializeFormKeys() + .singleResult(); + if (result == null) + throw new NoObjectFoundException(null); + return directProviderUtil.getObjectMapper(user).convertValue(TaskDto.fromEntity(result), Task.class); + } + + @Override + public void update(Task task, CIBUser user) { + org.cibseven.bpm.engine.task.Task foundTask = directProviderUtil.getProcessEngine(user).getTaskService().createTaskQuery().taskId(task.getId()).initializeFormKeys() + .singleResult(); + + if (foundTask == null) { + throw new NoObjectFoundException(new SystemException("No matching task with id " + task.getId())); + } + + foundTask.setName(task.getName()); + foundTask.setDescription(task.getDescription()); + foundTask.setPriority((int) task.getPriority()); + foundTask.setAssignee(task.getAssignee()); + foundTask.setOwner(task.getOwner()); + + DelegationState state = null; + if (task.getDelegationState() != null) { + DelegationStateConverter converter = new DelegationStateConverter(); + state = converter.convertQueryParameterToType(task.getDelegationState()); + } + foundTask.setDelegationState(state); + + foundTask.setDueDate(directProviderUtil.getObjectMapper(user).convertValue(task.getDue(), Date.class)); + foundTask.setFollowUpDate(directProviderUtil.getObjectMapper(user).convertValue(task.getFollowUp(), Date.class)); + foundTask.setParentTaskId(task.getParentTaskId()); + foundTask.setCaseInstanceId(task.getCaseInstanceId()); + foundTask.setTenantId(task.getTenantId()); + + directProviderUtil.getProcessEngine(user).getTaskService().saveTask(foundTask); + } + + @Override + public void setAssignee(String taskId, String assignee, CIBUser user) { + org.cibseven.bpm.engine.task.Task foundTask = getTaskById(taskId, user); + foundTask.setAssignee(assignee); + directProviderUtil.getProcessEngine(user).getTaskService().saveTask(foundTask); + } + + @Override + public void submit(String taskId, CIBUser user) { + VariableMap variables = null; + directProviderUtil.getProcessEngine(user).getFormService().submitTaskForm(taskId, variables); + } + + @Override + public void submit(Task task, List formResult, CIBUser user) { + Map variables = new HashMap<>(); + for (Variable variable : formResult) { + VariableValueDto variableValueDto = directProviderUtil.convertValue(variable, VariableValueDto.class, user); + variableValueDto.setType(variable.getType()); + variableValueDto.setValue(variable.getValue()); + if (variable.getValueInfo() != null) + variableValueDto.setValueInfo(new HashMap<>(variable.getValueInfo())); + variables.put(variable.getName(), variableValueDto); + } + CompleteTaskDto completeTaskDto = new CompleteTaskDto(); + completeTaskDto.setVariables(variables); + + try { + VariableMap variablesMap = VariableValueDto.toMap(completeTaskDto.getVariables(), directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user)); + directProviderUtil.getProcessEngine(user).getFormService().submitTaskForm(task.getId(), variablesMap); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot submit task form %s: %s", task.getId(), e.getMessage()); + throw new SubmitDeniedException(new SystemException(errorMessage, e)); + } + } + + @Override + public Object formReference(String taskId, CIBUser user) { + List formVariables = null; + String variableNames = "formReference"; + if (variableNames != null) { + StringListConverter stringListConverter = new StringListConverter(); + formVariables = stringListConverter.convertQueryParameterToType(variableNames); + } + boolean deserializeValues = true; + VariableMap startFormVariables = directProviderUtil.getProcessEngine(user).getFormService().getTaskFormVariables(taskId, formVariables, deserializeValues); + Set keys = startFormVariables.keySet(); + if (keys.isEmpty()) + return new String("empty-task"); + else { + return VariableValueDto.fromMap(startFormVariables); + } + } + + @Override + public Object form(String taskId, CIBUser user) { + org.cibseven.bpm.engine.task.Task task = getTaskById(taskId, user); + FormData formData; + try { + formData = directProviderUtil.getProcessEngine(user).getFormService().getTaskFormData(taskId); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException("Cannot get form for task " + taskId, e); + } + + FormDto dto = FormDto.fromFormData(formData); + if (dto.getKey() == null || dto.getKey().isEmpty()) { + if (formData != null && formData.getFormFields() != null && !formData.getFormFields().isEmpty()) { + dto.setKey("embedded:engine://engine/:engine/task/" + taskId + "/rendered-form"); + } + } + if (dto.getKey() == null || dto.getKey().isEmpty()) { + return "empty-task"; + } + + directProviderUtil.runWithoutAuthorization(() -> { + String processDefinitionId = task.getProcessDefinitionId(); + String caseDefinitionId = task.getCaseDefinitionId(); + if (processDefinitionId != null) { + dto.setContextPath( + ApplicationContextPathUtil.getApplicationPathByProcessDefinitionId(directProviderUtil.getProcessEngine(user), processDefinitionId)); + + } else if (caseDefinitionId != null) { + dto.setContextPath( + ApplicationContextPathUtil.getApplicationPathByCaseDefinitionId(directProviderUtil.getProcessEngine(user), caseDefinitionId)); + } + return null; + }, user); + + TaskForm taskForm = new TaskForm(); + CamundaFormRef camundaFormRef = dto.getCamundaFormRef(); + if (camundaFormRef != null) + taskForm.setCamundaFormRef(new CamundaForm(camundaFormRef.getKey(), camundaFormRef.getBinding(), + Integer.toString(camundaFormRef.getVersion()))); + taskForm.setContextPath(dto.getContextPath()); + taskForm.setKey(dto.getKey()); + return taskForm; + + } + + @Override + public Collection findTasksByFilter(TaskFiltering filters, String filterId, CIBUser user, Integer firstResult, + Integer maxResults) { + List entities = executeFilterList(filters, filterId, user, firstResult, maxResults); + + if (entities != null && !entities.isEmpty()) { + List list = convertToDtoList(entities, user); + return list; + } else { + return Collections.emptyList(); + } + } + + @Override + public Integer findTasksCountByFilter(String filterId, CIBUser user, TaskFiltering filters) { + List entities = executeFilterList(filters, filterId, user, null, null); + return entities.size(); + } + + @Override + public Collection findTasksByProcessInstanceHistory(String processInstanceId, CIBUser user) { + List taskHistoryList = new ArrayList<>(); + List results = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricTaskInstanceQuery() + .processInstanceId(processInstanceId).unlimitedList(); + for (HistoricTaskInstance result : results) { + taskHistoryList.add(directProviderUtil.convertValue(HistoricTaskInstanceDto.fromHistoricTaskInstance(result), TaskHistory.class, user)); + } + return taskHistoryList; + } + + @Override + public Collection findTasksByDefinitionKeyHistory(String taskDefinitionKey, String processInstanceId, + CIBUser user) { + List taskHistoryList = new ArrayList<>(); + List results = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricTaskInstanceQuery() + .taskDefinitionKey(taskDefinitionKey).processInstanceId(processInstanceId).unlimitedList(); + for (HistoricTaskInstance result : results) { + taskHistoryList.add(directProviderUtil.convertValue(HistoricTaskInstanceDto.fromHistoricTaskInstance(result), TaskHistory.class, user)); + } + return taskHistoryList; + } + + @Override + public Collection findTasksPost(Map data, CIBUser user) throws SystemException { + TaskQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(data, TaskQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + TaskQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + query.initializeFormKeys(); + List matchingTasks = QueryUtil.list(query, null, null); + + List tasks = new ArrayList<>(); + if (Boolean.TRUE.equals(queryDto.getWithCommentAttachmentInfo())) { + tasks = matchingTasks.stream().map(TaskWithAttachmentAndCommentDto::fromEntity).collect(Collectors.toList()); + } else { + tasks = matchingTasks.stream().map(TaskDto::fromEntity).collect(Collectors.toList()); + } + List resultTasks = new ArrayList<>(); + for (TaskDto matchingTask : tasks) { + resultTasks.add(directProviderUtil.convertValue(matchingTask, Task.class, user)); + } + return resultTasks; + } + + @Override + public Collection findIdentityLink(String taskId, Optional type, CIBUser user) { + List identityLinks = directProviderUtil.getProcessEngine(user).getTaskService().getIdentityLinksForTask(taskId); + + Collection result = new ArrayList<>(); + for (org.cibseven.bpm.engine.task.IdentityLink link : identityLinks) { + if (type.isEmpty() || type.get().equals(link.getType())) { + result.add(new IdentityLink(link.getUserId(), link.getGroupId(), link.getType())); + } + } + return result; + } + + @Override + public void createIdentityLink(String taskId, Map data, CIBUser user) { + String userId = (String) data.get("userId"); + String groupId = (String) data.get("groupId"); + if (userId != null && groupId != null) { + throw new SystemException("Identity Link requires userId or groupId, but not both."); + } + + if (userId == null && groupId == null) { + throw new SystemException("Identity Link requires userId or groupId."); + } + + String type = (String) data.get("type"); + if (userId != null) { + directProviderUtil.getProcessEngine(user).getTaskService().addUserIdentityLink(taskId, userId, type); + } else if (groupId != null) { + directProviderUtil.getProcessEngine(user).getTaskService().addGroupIdentityLink(taskId, groupId, type); + } + } + + @Override + public void deleteIdentityLink(String taskId, Map data, CIBUser user) { + String userId = (String) data.get("userId"); + String groupId = (String) data.get("groupId"); + if (userId != null && groupId != null) { + throw new SystemException("Identity Link requires userId or groupId, but not both."); + } + + if (userId == null && groupId == null) { + throw new SystemException("Identity Link requires userId or groupId."); + } + + String type = (String) data.get("type"); + if (userId != null) { + directProviderUtil.getProcessEngine(user).getTaskService().deleteUserIdentityLink(taskId, userId, type); + } else if (groupId != null) { + directProviderUtil.getProcessEngine(user).getTaskService().deleteGroupIdentityLink(taskId, groupId, type); + } + + } + + @Override + public void handleBpmnError(String taskId, Map data, CIBUser user) throws SystemException { + TaskBpmnErrorDto dto = directProviderUtil.getObjectMapper(user).convertValue(data, TaskBpmnErrorDto.class); + try { + directProviderUtil.getProcessEngine(user).getTaskService().handleBpmnError(taskId, dto.getErrorCode(), dto.getErrorMessage(), + VariableValueDto.toMap(dto.getVariables(), directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user))); + } catch (NotFoundException e) { + throw new SystemException(e.getMessage(), e); + } + } + + @Override + public Collection findTasksByTaskIdHistory(String taskId, CIBUser user) { + List taskHistoryList = new ArrayList<>(); + List results = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId).unlimitedList(); + for (HistoricTaskInstance result : results) { + taskHistoryList.add(directProviderUtil.convertValue(HistoricTaskInstanceDto.fromHistoricTaskInstance(result), TaskHistory.class, user)); + } + return taskHistoryList; + } + + @Override + public ResponseEntity getDeployedForm(String taskId, CIBUser user) { + InputStream form = directProviderUtil.getProcessEngine(user).getFormService().getDeployedTaskForm(taskId); + if (form != null) { + try { + byte[] bytes = IOUtils.toByteArray(form); + ResponseEntity responseEntity = ResponseEntity.ok(bytes); + return responseEntity; + } catch (IOException e) { + throw new SystemException(e.getMessage()); + } finally { + IoUtil.closeSilently(form); + } + } + return ResponseEntity.status(422).build(); + } + + @Override + public Integer findHistoryTasksCount(Map filters, CIBUser user) { + HistoricTaskInstanceQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(filters, HistoricTaskInstanceQueryDto.class); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricTaskInstanceQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + long count = query.count(); + return (int) count; + } + + @Override + public Collection getTaskCountByCandidateGroup(CIBUser user) { + TaskCountByCandidateGroupResultDto reportDto = new TaskCountByCandidateGroupResultDto(); + List results = reportDto.executeTaskCountByCandidateGroupReport(directProviderUtil.getProcessEngine(user)); + Collection resultTaskCount = new ArrayList<>(); + for (TaskCountByCandidateGroupResult result : results) { + resultTaskCount.add(directProviderUtil.convertValue(TaskCountByCandidateGroupResultDto.fromTaskCountByCandidateGroupResultDto(result), + CandidateGroupTaskCount.class, user)); + } + return resultTaskCount; + } + + private Collection convertTasks(Collection engineTasks, CIBUser user) { + List resultList = new ArrayList<>(); + for (org.cibseven.bpm.engine.task.Task engineTask : engineTasks) + resultList.add(directProviderUtil.getObjectMapper(user).convertValue(TaskDto.fromEntity(engineTask), Task.class)); + return resultList; + } + + private List queryTasks(Map filters, CIBUser user) { + ObjectMapper localObjectMapper = new ObjectMapper(); + JacksonConfigurator.configureObjectMapper(localObjectMapper); + localObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + TaskQueryDto dto = localObjectMapper.convertValue(filters, TaskQueryDto.class); + TaskQuery taskQuery = dto.toQuery(directProviderUtil.getProcessEngine(user)); + List taskList = taskQuery.taskInvolvedUser(user.getUserID()).list(); + return taskList; + } + + protected org.cibseven.bpm.engine.task.Task getTaskById(String taskId, CIBUser user) { + org.cibseven.bpm.engine.task.Task foundTask = directProviderUtil.getProcessEngine(user).getTaskService().createTaskQuery().taskId(taskId).initializeFormKeys() + .singleResult(); + if (foundTask == null) { + throw new NoObjectFoundException(new SystemException("No matching task with id " + taskId)); + } + return foundTask; + } + + private List executeFilterList(TaskFiltering filters, String filterId, CIBUser user, Integer firstResult, + Integer maxResults) { + // authentication is required to access the current user while executing the + // query + GroupQuery groupQuery = directProviderUtil.getProcessEngine(user).getIdentityService().createGroupQuery(); + List userGroups = groupQuery.groupMember(user.getId()).orderByGroupName().asc().unlimitedList(); + List groupNames = new ArrayList<>(); + for (Group userGroup : userGroups) + groupNames.add(userGroup.getId()); + + Authentication authentication = new Authentication(user.getId(), groupNames); + directProviderUtil.getProcessEngine(user).getIdentityService().setAuthentication(authentication); + + String extendingQuery; + try { + extendingQuery = filters.json(); + } catch (JsonProcessingException e) { + throw new SystemException("Failed json conversion", e); + } + List entities = executeFilterList(extendingQuery, filterId, firstResult, maxResults, user); + return entities; + } + + private List executeFilterList(String extendingQueryString, String filterId, Integer firstResult, Integer maxResults, CIBUser user) { + Query extendingQuery = convertQuery(extendingQueryString, filterId, user); + try { + if (firstResult != null || maxResults != null) { + if (firstResult == null) { + firstResult = 0; + } + if (maxResults == null) { + maxResults = Integer.MAX_VALUE; + } + return directProviderUtil.getProcessEngine(user).getFilterService().listPage(filterId, extendingQuery, firstResult, maxResults); + } else { + return directProviderUtil.getProcessEngine(user).getFilterService().list(filterId, extendingQuery); + } + } catch (NullValueException e) { + throw new SystemException("Filter not found", e); + } + } + + private Query convertQuery(String queryString, String filterId, CIBUser user) { + if (isEmptyJson(queryString)) { + return null; + } else { + ProcessEngine processEngine = directProviderUtil.getProcessEngine(user); + String resourceType = directProviderUtil.getProcessEngine(user).getFilterService().getFilter(filterId).getResourceType(); + + AbstractQueryDto queryDto = getQueryDtoForQuery(queryString, resourceType, user); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + return queryDto.toQuery(processEngine); + } + } + + private AbstractQueryDto getQueryDtoForQuery(String queryString, String resourceType, CIBUser user) { + try { + if (EntityTypes.TASK.equals(resourceType)) { + return directProviderUtil.getObjectMapper(user).readValue(queryString, TaskQueryDto.class); + } else { + throw new SystemException( + "Queries for resource type '" + resourceType + "' are currently not supported by filters."); + } + } catch (IOException e) { + throw new SystemException("Invalid query for resource type '" + resourceType + "'", e); + } + } + + private List convertToDtoList(List entities, CIBUser user) { + List dtoList = new ArrayList<>(); + for (Object entity : entities) { + dtoList.add(convertToDto(entity, user)); + } + return dtoList; + } + + private Task convertToDto(Object entity, CIBUser user) { + if (entity instanceof org.cibseven.bpm.engine.task.Task) { + return directProviderUtil.convertValue(TaskDto.fromEntity((org.cibseven.bpm.engine.task.Task) entity), Task.class, user); + } else { + throw new SystemException( + "Entities of class '" + entity.getClass().getCanonicalName() + "' are currently not supported by filters."); + } + } + + private boolean isEmptyJson(String jsonString) { + final Pattern EMPTY_JSON_BODY = Pattern.compile("\\s*\\{\\s*\\}\\s*"); + return jsonString == null || jsonString.trim().isEmpty() || EMPTY_JSON_BODY.matcher(jsonString).matches(); + } + + @Override + public void submit(String taskId, String formResult, CIBUser user) { + ProcessEngine engine = directProviderUtil.getProcessEngine(user); + FormService formService = engine.getFormService(); + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + CompleteTaskDto dto; + try { + dto = objectMapper.readValue(formResult, CompleteTaskDto.class); + } catch (JsonProcessingException e) { + throw new SystemException(e.getMessage(), e); + } + + try { + VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper); + if (dto.isWithVariablesInReturn()) { + formService.submitTaskFormWithVariablesInReturn(taskId, variables, false); + } else { + formService.submitTaskForm(taskId, variables); + } + + } catch (RestException|ProcessEngineException e) { + String errorMessage = String.format("Cannot submit task form %s: %s", taskId, e.getMessage()); + throw new SystemException(errorMessage, e); + } + + } + + @Override + public ResponseEntity getRenderedForm(String taskId, Map params, CIBUser user) { + FormService formService = directProviderUtil.getProcessEngine(user).getFormService(); + + Object renderedTaskForm = formService.getRenderedTaskForm(taskId); + if(renderedTaskForm != null) { + String content = renderedTaskForm.toString(); + InputStream stream = new ByteArrayInputStream(content.getBytes(EncodingUtil.DEFAULT_ENCODING)); + try { + return ResponseEntity.ok(IOUtils.toString(stream, Charset.defaultCharset())); + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } + + throw new SystemException("No matching rendered form for task with the id " + taskId + " found."); + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectTenantProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectTenantProvider.java new file mode 100755 index 000000000..761ec0263 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectTenantProvider.java @@ -0,0 +1,131 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.identity.TenantQuery; +import org.cibseven.bpm.engine.rest.dto.identity.TenantDto; +import org.cibseven.bpm.engine.rest.dto.identity.TenantQueryDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Tenant; + +public class DirectTenantProvider implements ITenantProvider { + + DirectProviderUtil directProviderUtil; + + DirectTenantProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection fetchTenants(Map queryParams, CIBUser user) { + TenantQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(queryParams, TenantQueryDto.class); + + TenantQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List tenants = QueryUtil.list(query, null, null); + List tenantList = new ArrayList<>(); + List tennantDtoList = TenantDto.fromTenantList(tenants); + for (TenantDto tennantDto : tennantDtoList) { + tenantList.add(directProviderUtil.convertValue(tennantDto, Tenant.class, user)); + } + return tenantList; + } + + @Override + public Tenant fetchTenant(String tenantId, CIBUser user) { + org.cibseven.bpm.engine.identity.Tenant tenant = findTenantObject(tenantId, user); + TenantDto dto = TenantDto.fromTenant(tenant); + return directProviderUtil.convertValue(dto, Tenant.class, user); + } + + @Override + public void createTenant(Tenant tenant, CIBUser user) { + ensureNotReadOnly(user); + TenantDto tenantDto = directProviderUtil.convertValue(tenant, TenantDto.class, user); + + org.cibseven.bpm.engine.identity.Tenant newTenant = directProviderUtil.getProcessEngine(user).getIdentityService().newTenant(tenantDto.getId()); + tenantDto.update(newTenant); + + directProviderUtil.getProcessEngine(user).getIdentityService().saveTenant(newTenant); + } + + @Override + public void updateTenant(Tenant tenant, CIBUser user) { + ensureNotReadOnly(user); + TenantDto tenantDto = directProviderUtil.convertValue(tenant, TenantDto.class, user); + org.cibseven.bpm.engine.identity.Tenant systemTenant = findTenantObject(tenant.getId(), user); + if (systemTenant == null) { + throw new NoObjectFoundException(new SystemException("Tenant with id " + tenant.getId() + " does not exist")); + } + tenantDto.update(systemTenant); + directProviderUtil.getProcessEngine(user).getIdentityService().saveTenant(systemTenant); + } + + @Override + public void deleteTenant(String tenantId, CIBUser user) { + ensureNotReadOnly(user); + directProviderUtil.getProcessEngine(user).getIdentityService().deleteTenant(tenantId); + } + + @Override + public void addMemberToTenant(String tenantId, String userId, CIBUser user) { + ensureNotReadOnly(user); + directProviderUtil.getProcessEngine(user).getIdentityService().createTenantUserMembership(tenantId, userId); + } + + @Override + public void deleteMemberFromTenant(String tenantId, String userId, CIBUser user) { + ensureNotReadOnly(user); + directProviderUtil.getProcessEngine(user).getIdentityService().deleteTenantUserMembership(tenantId, userId); + } + + @Override + public void addGroupToTenant(String tenantId, String groupId, CIBUser user) { + ensureNotReadOnly(user); + directProviderUtil.getProcessEngine(user).getIdentityService().createTenantGroupMembership(tenantId, groupId); + } + + @Override + public void deleteGroupFromTenant(String tenantId, String groupId, CIBUser user) { + ensureNotReadOnly(user); + directProviderUtil.getProcessEngine(user).getIdentityService().deleteTenantGroupMembership(tenantId, groupId); + } + + private void ensureNotReadOnly(CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + } + + private org.cibseven.bpm.engine.identity.Tenant findTenantObject(String tenantId, CIBUser user) { + try { + return directProviderUtil.getProcessEngine(user).getIdentityService().createTenantQuery().tenantId(tenantId).singleResult(); + + } catch (ProcessEngineException e) { + throw new SystemException("Exception while performing tenant query: " + e.getMessage()); + } + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectUserProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectUserProvider.java new file mode 100755 index 000000000..576c74510 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectUserProvider.java @@ -0,0 +1,594 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import static org.cibseven.webapp.auth.SevenAuthorizationUtils.resourceType; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.authorization.AuthorizationQuery; +import org.cibseven.bpm.engine.authorization.Permissions; +import org.cibseven.bpm.engine.identity.Group; +import org.cibseven.bpm.engine.identity.GroupQuery; +import org.cibseven.bpm.engine.identity.UserQuery; +import org.cibseven.bpm.engine.impl.identity.Authentication; +import org.cibseven.bpm.engine.impl.util.PermissionConverter; +import org.cibseven.bpm.engine.rest.dto.authorization.AuthorizationDto; +import org.cibseven.bpm.engine.rest.dto.authorization.AuthorizationQueryDto; +import org.cibseven.bpm.engine.rest.dto.identity.GroupQueryDto; +import org.cibseven.bpm.engine.rest.dto.identity.UserQueryDto; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.auth.SevenResourceType; +import org.cibseven.webapp.auth.rest.StandardLogin; +import org.cibseven.webapp.exception.InvalidUserIdException; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.Authorization; +import org.cibseven.webapp.rest.model.Authorizations; +import org.cibseven.webapp.rest.model.NewUser; +import org.cibseven.webapp.rest.model.SevenUser; +import org.cibseven.webapp.rest.model.SevenVerifyUser; +import org.cibseven.webapp.rest.model.User; +import org.cibseven.webapp.rest.model.UserGroup; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.ResponseEntity; + +public class DirectUserProvider implements IUserProvider { + + private String userProvider; + private String wildcard; + DirectProviderUtil directProviderUtil; + + public DirectUserProvider(DirectProviderUtil directProviderUtil, String userProvider, String wildcard) { + this.userProvider = userProvider; + this.directProviderUtil = directProviderUtil; + this.wildcard = wildcard; + } + + @Override + public Collection fetchUsers(CIBUser user) throws SystemException { + UserQueryDto queryDto = new UserQueryDto(); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + UserQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + query.userId(user.getId()); + List resultList = QueryUtil.list(query, null, null); + + Collection users = new ArrayList<>(); + for (org.cibseven.bpm.engine.identity.User resultUser : resultList) { + users.add(directProviderUtil.convertValue(resultUser, SevenUser.class, user)); + } + return users; + } + + @Override + public Authorizations getUserAuthorization(String userId, CIBUser user) { + AuthorizationQueryDto queryDto = new AuthorizationQueryDto(); + queryDto.setUserIdIn(new String[] { userId }); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + AuthorizationQuery userQuery = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List userAuthorizationList = QueryUtil.list(userQuery, null, + null); + GroupQuery groupQuery = directProviderUtil.getProcessEngine(user).getIdentityService().createGroupQuery(); + List userGroups = groupQuery.groupMember(userId).orderByGroupName().asc().unlimitedList(); + List listGroups = userGroups.stream().map(Group::getId).collect(Collectors.toList()); + + AuthorizationQueryDto groupIdQueryDto = new AuthorizationQueryDto(); + groupIdQueryDto.setGroupIdIn(listGroups.toArray(new String[0])); + groupIdQueryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + AuthorizationQuery groupIdQuery = groupIdQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List groupIdResultList = QueryUtil.list(groupIdQuery, null, + null); + Collection groupsAuthorizations = createAuthorizationCollection(groupIdResultList); + + AuthorizationQueryDto globalIdQueryDto = new AuthorizationQueryDto(); + globalIdQueryDto.setType(0); + globalIdQueryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + AuthorizationQuery globalIdQuery = globalIdQueryDto.toQuery(directProviderUtil.getProcessEngine(user)); + List globalIdResultList = QueryUtil.list(globalIdQuery, null, + null); + Collection globalAuthorizations = createAuthorizationCollection(globalIdResultList); + + Authorizations auths = new Authorizations(); + Collection userAuthorizations = createAuthorizationCollection(userAuthorizationList); + userAuthorizations.addAll(groupsAuthorizations); + userAuthorizations.addAll(globalAuthorizations); + + auths.setApplication(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.APPLICATION))); + auths.setFilter(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.FILTER))); + auths.setProcessDefinition(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.PROCESS_DEFINITION))); + auths.setProcessInstance(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.PROCESS_INSTANCE))); + auths.setTask(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.TASK))); + auths.setAuthorization(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.AUTHORIZATION))); + auths.setUser(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.USER))); + auths.setGroup(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.GROUP))); + auths.setDecisionDefinition(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.DECISION_DEFINITION))); + auths.setDecisionRequirementsDefinition( + SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.DECISION_REQUIREMENTS_DEFINITION))); + auths.setDeployment(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.DEPLOYMENT))); + // auths.setCaseDefinition(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.CASE_DEFINITION))); + // auths.setCaseInstance(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.CASE_INSTANCE))); + // auths.setJobDefinition(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.JOB_DEFINITION))); + auths.setBatch(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.BATCH))); + auths.setGroupMembership(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.GROUP_MEMBERSHIP))); + auths.setHistoricTask(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.HISTORIC_TASK))); + auths.setHistoricProcessInstance( + SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.HISTORIC_PROCESS_INSTANCE))); + auths.setTenant(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.TENANT))); + auths.setTenantMembership(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.TENANT_MEMBERSHIP))); + auths.setReport(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.REPORT))); + auths.setDashboard(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.DASHBOARD))); + auths.setUserOperationLogCategory( + SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.USER_OPERATION_LOG_CATEGORY))); + auths.setSystem(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.SYSTEM))); + // auths.setMessage(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.MESSAGE))); + // auths.setEventSubscription(SevenProviderBase.filterResources(userAuthorizations, resourceType(SevenResourceType.EVENT_SUBSCRIPTION))); + + return auths; + } + + @Override + public SevenVerifyUser verifyUser(StandardLogin login, CIBUser user) throws SystemException { + if ((login.getUsername() == null || login.getUsername().isBlank()) || + (login.getPassword() == null || login.getPassword().isBlank())) + throw new SystemException("Username and password are required"); + SevenVerifyUser verifyUser = new SevenVerifyUser(); + boolean valid = directProviderUtil.getProcessEngine(user).getIdentityService() + .checkPassword(login.getUsername(), login.getPassword()); + verifyUser.setAuthenticated(valid); + verifyUser.setAuthenticatedUser(login.getUsername()); + return verifyUser; + } + @Override + public Collection findUsers(Optional id, Optional firstName, Optional firstNameLike, + Optional lastName, Optional lastNameLike, Optional email, Optional emailLike, + Optional memberOfGroup, Optional memberOfTenant, Optional idIn, + Optional firstResult, Optional maxResults, Optional sortBy, Optional sortOrder, + Optional likePatternIgnoreCase, CIBUser user) { + String wcard = getWildcard(); + + return getUsers(id, firstName, firstNameLike, lastName, lastNameLike, email, emailLike, memberOfGroup, memberOfTenant, + idIn, firstResult, maxResults, sortBy, sortOrder, wcard, likePatternIgnoreCase, user); + } + + private String getWildcard () { + String wcard = ""; + if (wildcard != null && !wildcard.equals("")) wcard = wildcard; + else { + if (userProvider.equals("org.cibseven.webapp.auth.LdapUserProvider") || userProvider.equals("org.cibseven.webapp.auth.AdfsUserProvider")) { + wcard = "*"; + } else wcard = "%"; + } + return wcard; + } + + @Override + public void createUser(NewUser user, CIBUser flowUser) throws InvalidUserIdException { + User profile = user.getProfile(); + org.cibseven.bpm.engine.identity.User newUser = directProviderUtil.getProcessEngine(flowUser).getIdentityService().newUser(profile.getId()); + newUser.setId(profile.getId()); + newUser.setFirstName(profile.getFirstName()); + newUser.setLastName(profile.getLastName()); + newUser.setEmail(profile.getEmail()); + newUser.setPassword(user.getCredentials().getPassword()); + directProviderUtil.getProcessEngine(flowUser).getIdentityService().saveUser(newUser); + } + + @Override + public void updateUserProfile(String userId, User user, CIBUser flowUser) { + if (directProviderUtil.getProcessEngine(flowUser).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + + org.cibseven.bpm.engine.identity.User dbUser = findUserObject(user.getId(), flowUser); + if (dbUser == null) { + throw new NoObjectFoundException(new SystemException("User with id " + user.getId() + " does not exist")); + } + + dbUser.setId(user.getId()); + dbUser.setFirstName(user.getFirstName()); + dbUser.setLastName(user.getLastName()); + dbUser.setEmail(user.getEmail()); + directProviderUtil.getProcessEngine(flowUser).getIdentityService().saveUser(dbUser); + } + + @Override + public void updateUserCredentials(String userId, Map data, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + Authentication currentAuthentication = directProviderUtil.getProcessEngine(user).getIdentityService().getCurrentAuthentication(); + if (currentAuthentication != null && currentAuthentication.getUserId() != null) { + if (!directProviderUtil.getProcessEngine(user).getIdentityService().checkPassword(currentAuthentication.getUserId(), + (String) data.get("authenticatedUserPassword"))) { + throw new SystemException("The given authenticated user password is not valid."); + } + } + + org.cibseven.bpm.engine.identity.User dbUser = findUserObject(userId, user); + if (dbUser == null) { + throw new NoObjectFoundException(new SystemException("User with id " + user.getId() + " does not exist")); + } + + dbUser.setPassword((String) data.get("password")); + directProviderUtil.getProcessEngine(user).getIdentityService().saveUser(dbUser); + } + + @Override + public void addMemberToGroup(String groupId, String userId, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + directProviderUtil.getProcessEngine(user).getIdentityService().createMembership(userId, groupId); + } + + @Override + public void deleteMemberFromGroup(String groupId, String userId, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + directProviderUtil.getProcessEngine(user).getIdentityService().deleteMembership(userId, groupId); + } + + @Override + public void deleteUser(String userId, CIBUser user) { + directProviderUtil.getProcessEngine(user).getIdentityService().deleteUser(userId); + } + + @Override + public SevenUser getUserProfile(String userId, CIBUser user) { + List users = directProviderUtil.getProcessEngine(user).getIdentityService().createUserQuery().userId(userId).list(); + org.cibseven.bpm.engine.identity.User identityUser = null; + if (users.isEmpty()) { + return null; + } else if (users.size() == 1) { + identityUser = users.get(0); + } else { + identityUser = users.stream().filter(u -> u.getId().equals(userId)).findFirst().orElse(null); + if (identityUser == null) { + identityUser = users.get(0); + } + } + return directProviderUtil.convertValue(identityUser, SevenUser.class, user); + } + + @Override + public Collection findGroups(Optional id, Optional name, Optional nameLike, + Optional type, Optional member, Optional memberOfTenant, Optional sortBy, + Optional sortOrder, Optional firstResult, Optional maxResults, CIBUser user) { + final String wcard = "%"; + GroupQueryDto queryDto = new GroupQueryDto(); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + // set parameters + if (id.isPresent()) + queryDto.setId(id.get()); + if (name.isPresent()) + queryDto.setName(name.get()); + if (nameLike.isPresent()) + queryDto.setNameLike(nameLike.get().replace("*", wcard)); + ; + if (type.isPresent()) + queryDto.setType(type.get()); + if (member.isPresent()) + queryDto.setMember(member.get()); + if (memberOfTenant.isPresent()) + queryDto.setMemberOfTenant(memberOfTenant.get()); + if (sortBy.isPresent()) + queryDto.setSortBy(sortBy.get()); + if (sortOrder.isPresent()) + queryDto.setSortOrder(sortOrder.get().equals("asc") ? "asc" : "desc"); + GroupQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + Integer first = firstResult.isPresent() ? Integer.parseInt(firstResult.get()) : null; + Integer max = maxResults.isPresent() ? Integer.parseInt(maxResults.get()) : null; + List resultList = QueryUtil.list(query, first, max); + + Collection userGroups = createUserGroups(resultList); + return userGroups; + } + + @Override + public void createGroup(UserGroup group, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + Group newGroup = directProviderUtil.getProcessEngine(user).getIdentityService().newGroup(group.getId()); + newGroup.setId(group.getId()); + newGroup.setName(group.getName()); + newGroup.setType(group.getType()); + directProviderUtil.getProcessEngine(user).getIdentityService().saveGroup(newGroup); + } + + @Override + public void updateGroup(String groupId, UserGroup group, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + + Group dbGroup = findGroupObject(groupId, user); + if (dbGroup == null) { + throw new NoObjectFoundException(new SystemException("Group with id " + groupId + " does not exist")); + } + + dbGroup.setId(group.getId()); + dbGroup.setName(group.getName()); + dbGroup.setType(group.getType()); + + directProviderUtil.getProcessEngine(user).getIdentityService().saveGroup(dbGroup); + } + + @Override + public void deleteGroup(String groupId, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getIdentityService().isReadOnly()) { + throw new SystemException("Identity service implementation is read-only."); + } + directProviderUtil.getProcessEngine(user).getIdentityService().deleteGroup(groupId); + } + + @Override + public Collection findAuthorization(Optional id, Optional type, + Optional userIdIn, Optional groupIdIn, Optional resourceType, Optional resourceId, + Optional sortBy, Optional sortOrder, Optional firstResult, Optional maxResults, + CIBUser user) { + AuthorizationQueryDto queryDto = new AuthorizationQueryDto(); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + if (id.isPresent()) + queryDto.setId(id.get()); + if (type.isPresent()) + queryDto.setType(Integer.parseInt(type.get())); + if (userIdIn.isPresent()) + queryDto.setUserIdIn(new String[] { userIdIn.get() }); + if (groupIdIn.isPresent()) + queryDto.setGroupIdIn(new String[] { groupIdIn.get() }); + if (resourceType.isPresent()) + queryDto.setResourceType(Integer.parseInt(resourceType.get())); + if (resourceId.isPresent()) + queryDto.setResourceId(resourceId.get()); + if (sortOrder.isPresent()) + queryDto.setSortOrder(sortOrder.get()); + if (sortOrder.isPresent()) + queryDto.setSortOrder(sortOrder.get()); + Integer firstResultParam = null; + if (firstResult.isPresent()) + firstResultParam = Integer.parseInt(firstResult.get()); + Integer maxResultsParam = null; + if (maxResults.isPresent()) + maxResultsParam = Integer.parseInt(maxResults.get()); + return queryAuthorizations(queryDto, firstResultParam, maxResultsParam, user); + } + + private List queryAuthorizations(AuthorizationQueryDto queryDto, Integer firstResult, + Integer maxResults, CIBUser user) { + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + AuthorizationQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List resultList = QueryUtil.list(query, firstResult, maxResults); + List authorizationDtoList = AuthorizationDto.fromAuthorizationList(resultList, + directProviderUtil.getProcessEngine(user).getProcessEngineConfiguration()); + List authorizationList = new ArrayList<>(); + for (AuthorizationDto authorizationDto : authorizationDtoList) { + authorizationList.add(directProviderUtil.convertValue(authorizationDto, Authorization.class, user)); + } + return authorizationList; + } + + @Override + public ResponseEntity createAuthorization(Authorization authorization, CIBUser user) { + org.cibseven.bpm.engine.authorization.Authorization newAuthorization = directProviderUtil.getProcessEngine(user).getAuthorizationService() + .createNewAuthorization(authorization.getType()); + newAuthorization.setGroupId(authorization.getGroupId()); + newAuthorization.setUserId(authorization.getUserId()); + newAuthorization.setResourceType(authorization.getResourceType()); + newAuthorization.setResourceId(authorization.getResourceId()); + newAuthorization.setPermissions(PermissionConverter.getPermissionsForNames(authorization.getPermissions(), + authorization.getResourceType(), directProviderUtil.getProcessEngine(user).getProcessEngineConfiguration())); + + newAuthorization = directProviderUtil.getProcessEngine(user).getAuthorizationService().saveAuthorization(newAuthorization); + + Authorization resultAuthorization = new Authorization(); + resultAuthorization.setGroupId(newAuthorization.getGroupId()); + resultAuthorization.setId(newAuthorization.getId()); + resultAuthorization.setPermissions(PermissionConverter.getNamesForPermissions(newAuthorization, + newAuthorization.getPermissions(Permissions.values()))); + resultAuthorization.setResourceId(newAuthorization.getResourceId()); + resultAuthorization.setResourceType(newAuthorization.getResourceType()); + resultAuthorization.setType(newAuthorization.getAuthorizationType()); + resultAuthorization.setUserId(newAuthorization.getUserId()); + return ResponseEntity.ok(resultAuthorization); + } + + @Override + public void updateAuthorization(String authorizationId, Map data, CIBUser user) { + org.cibseven.bpm.engine.authorization.Authorization dbAuthorization = directProviderUtil.getProcessEngine(user).getAuthorizationService().createAuthorizationQuery() + .authorizationId(authorizationId).singleResult(); + + if (dbAuthorization == null) { + throw new NoObjectFoundException(new SystemException("Authorization with id " + authorizationId + " does not exist.")); + } + AuthorizationDto authorizationDto = new AuthorizationDto(); + if (data.containsKey("groupId")) + authorizationDto.setGroupId((String) data.get("groupId")); + if (data.containsKey("permissions")) { + List permissionList = (List) data.get("permissions"); + authorizationDto.setPermissions(permissionList.toArray(new String[0])); + } + if (data.containsKey("resourceId")) + authorizationDto.setResourceId((String) data.get("resourceId")); + if (data.containsKey("resourceType")) + authorizationDto.setResourceType((Integer) data.get("resourceType")); + if (data.containsKey("type")) + authorizationDto.setType((Integer) data.get("type")); + if (data.containsKey("userId")) + authorizationDto.setUserId((String) data.get("userId")); + AuthorizationDto.update(authorizationDto, dbAuthorization, directProviderUtil.getProcessEngine(user).getProcessEngineConfiguration()); + // save + directProviderUtil.getProcessEngine(user).getAuthorizationService().saveAuthorization(dbAuthorization); + } + + @Override + public void deleteAuthorization(String authorizationId, CIBUser user) { + directProviderUtil.getProcessEngine(user).getAuthorizationService().deleteAuthorization(authorizationId); + } + + private org.cibseven.bpm.engine.identity.User findUserObject(String id, CIBUser user) { + org.cibseven.bpm.engine.identity.User dbUser = null; + try { + List users = directProviderUtil.getProcessEngine(user).getIdentityService().createUserQuery().userId(id).list(); + + if (users.size() == 1) { + dbUser = users.get(0); + } else if (!users.isEmpty()) { + + dbUser = users.stream().filter(u -> u.getId().equals(id)).findFirst().orElse(null); + + if (dbUser == null) { + dbUser = users.get(0); + } + } + } catch (ProcessEngineException e) { + throw new SystemException("Exception while performing user query: " + e.getMessage()); + } + return dbUser; + } + + private Group findGroupObject(String groupId, CIBUser user) { + try { + return directProviderUtil.getProcessEngine(user).getIdentityService().createGroupQuery().groupId(groupId).singleResult(); + } catch (ProcessEngineException e) { + throw new SystemException("Exception while performing group query: " + e.getMessage()); + } + } + + private Collection getUsers(Optional id, Optional firstName, Optional firstNameLike, + Optional lastName, Optional lastNameLike, Optional email, Optional emailLike, + Optional memberOfGroup, Optional memberOfTenant, Optional idIn, + Optional firstResult, Optional maxResults, Optional sortBy, Optional sortOrder, + String wcard, Optional likePatternIgnoreCase, CIBUser user) { + UserQueryDto queryDto = new UserQueryDto(); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + queryDto.setLikePatternIgnoreCase(likePatternIgnoreCase.orElse(null)); + UserQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + if (memberOfGroup.isPresent()) + query.memberOfGroup(memberOfGroup.get()); + if (memberOfTenant.isPresent()) + query.memberOfTenant(memberOfTenant.get()); + if (sortBy.isPresent()) { + String sortByValue = sortBy.get(); + switch (sortByValue) { + case "userId": + query.orderByUserId(); + break; + case "firstName": + query.orderByUserFirstName(); + break; + case "lastName": + query.orderByUserLastName(); + break; + case "email": + query.orderByUserEmail(); + break; + default: + } + } + if (email.isPresent()) + query.userEmail(email.get()); + if (emailLike.isPresent()) + query.userEmailLike(emailLike.get().replace("*", wcard)); + if (firstName.isPresent()) + query.userFirstName(firstName.get()); + if (firstNameLike.isPresent()) + query.userFirstNameLike(firstNameLike.get().replace("*", wcard)); + if (id.isPresent()) + query.userId(id.get()); + if (lastName.isPresent()) + query.userLastName(lastName.get()); + if (lastNameLike.isPresent()) + query.userLastNameLike(lastNameLike.get().replace("*", wcard)); + Integer first = firstResult.isPresent() ? Integer.parseInt(firstResult.get()) : null; + Integer max = maxResults.isPresent() ? Integer.parseInt(maxResults.get()) : null; + List resultList = QueryUtil.list(query, first, max); + + Collection userCollection = createUsers(resultList); + return userCollection; + } + + private Collection createUsers(List resultList) { + Collection users = new ArrayList<>(); + for (org.cibseven.bpm.engine.identity.User resultUser : resultList) { + User user = new User(); + user.setEmail(resultUser.getEmail()); + user.setFirstName(resultUser.getFirstName()); + user.setId(resultUser.getId()); + user.setLastName(resultUser.getLastName()); + users.add(user); + } + return users; + } + + private Collection createAuthorizationCollection( + List userAuthorizationList) { + Collection resultAuthorization = new ArrayList<>(); + for (org.cibseven.bpm.engine.authorization.Authorization userAuthorization : userAuthorizationList) { + resultAuthorization.add(createAuthorization(userAuthorization)); + } + return resultAuthorization; + } + + private Authorization createAuthorization(org.cibseven.bpm.engine.authorization.Authorization userAuthorization) { + Authorization newUserAuthorization = new Authorization(); + newUserAuthorization.setGroupId(userAuthorization.getGroupId()); + newUserAuthorization.setId(userAuthorization.getId()); + newUserAuthorization.setPermissions(PermissionConverter.getNamesForPermissions(userAuthorization, + userAuthorization.getPermissions(Permissions.values()))); + newUserAuthorization.setResourceId(userAuthorization.getResourceId()); + newUserAuthorization.setResourceType(userAuthorization.getResourceType()); + newUserAuthorization.setType(userAuthorization.getAuthorizationType()); + newUserAuthorization.setUserId(userAuthorization.getUserId()); + return newUserAuthorization; + } + + private Collection createUserGroups(List resultList) { + Collection userGroups = new ArrayList<>(); + for (Group group : resultList) { + userGroups.add(createUserGroup(group)); + } + return userGroups; + } + + private UserGroup createUserGroup(Group group) { + UserGroup userGroup = new UserGroup(); + userGroup.setId(group.getId()); + userGroup.setName(group.getName()); + userGroup.setType(group.getType()); + return userGroup; + } + + @Override + public long countUsers(Map filters, CIBUser user) throws SystemException { + UserQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(filters, UserQueryDto.class); + UserQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + return query.count(); + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectUtilsProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectUtilsProvider.java new file mode 100755 index 000000000..785263dd0 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectUtilsProvider.java @@ -0,0 +1,235 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.MismatchingMessageCorrelationException; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.management.SetJobRetriesBuilder; +import org.cibseven.bpm.engine.rest.dto.VariableValueDto; +import org.cibseven.bpm.engine.rest.dto.message.CorrelationMessageDto; +import org.cibseven.bpm.engine.rest.dto.message.MessageCorrelationResultDto; +import org.cibseven.bpm.engine.rest.dto.message.MessageCorrelationResultWithVariableDto; +import org.cibseven.bpm.engine.rest.dto.runtime.EventSubscriptionDto; +import org.cibseven.bpm.engine.rest.dto.runtime.EventSubscriptionQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.RetriesDto; +import org.cibseven.bpm.engine.rest.exception.RestException; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.runtime.EventSubscriptionQuery; +import org.cibseven.bpm.engine.runtime.MessageCorrelationBuilder; +import org.cibseven.bpm.engine.runtime.MessageCorrelationResult; +import org.cibseven.bpm.engine.runtime.MessageCorrelationResultWithVariables; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.EventSubscription; +import org.cibseven.webapp.rest.model.Message; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class DirectUtilsProvider implements IUtilsProvider { + + DirectProviderUtil directProviderUtil; + + DirectUtilsProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + @Override + public Collection correlateMessage(Map data, CIBUser user) throws SystemException { + CorrelationMessageDto messageDto = directProviderUtil.getObjectMapper(user).convertValue(data, CorrelationMessageDto.class); + if (messageDto.getMessageName() == null) { + throw new SystemException("No message name supplied"); + } + if (messageDto.getTenantId() != null && messageDto.isWithoutTenantId()) { + throw new SystemException("Parameter 'tenantId' cannot be used together with parameter 'withoutTenantId'."); + } + boolean variablesInResultEnabled = messageDto.isVariablesInResultEnabled(); + if (!messageDto.isResultEnabled() && variablesInResultEnabled) { + throw new SystemException( + "Parameter 'variablesInResultEnabled' cannot be used without 'resultEnabled' set to true."); + } + + List resultDtos = new ArrayList<>(); + try { + MessageCorrelationBuilder correlation = createMessageCorrelationBuilder(messageDto, user); + if (!variablesInResultEnabled) { + resultDtos.addAll(correlate(messageDto, correlation)); + } else { + resultDtos.addAll(correlateWithVariablesEnabled(messageDto, correlation)); + } + } catch (RestException e) { + String errorMessage = String.format("Cannot deliver message: %s", e.getMessage()); + throw new SystemException(errorMessage, e); + } catch (MismatchingMessageCorrelationException e) { + throw new SystemException(e); + } + List messageList = new ArrayList<>(); + if (messageDto.isResultEnabled()) { + for (MessageCorrelationResultDto resultDto : resultDtos) { + messageList.add(directProviderUtil.convertValue(resultDto, Message.class, user)); + } + } + return messageList; + } + + public MessageCorrelationBuilder createMessageCorrelationBuilder(CorrelationMessageDto messageDto, CIBUser user) { + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + Map correlationKeys = VariableValueDto.toMap(messageDto.getCorrelationKeys(), directProviderUtil.getProcessEngine(user), + objectMapper); + Map localCorrelationKeys = VariableValueDto.toMap(messageDto.getLocalCorrelationKeys(), directProviderUtil.getProcessEngine(user), + objectMapper); + Map processVariables = VariableValueDto.toMap(messageDto.getProcessVariables(), directProviderUtil.getProcessEngine(user), + objectMapper); + Map processVariablesLocal = VariableValueDto.toMap(messageDto.getProcessVariablesLocal(), + directProviderUtil.getProcessEngine(user), objectMapper); + Map processVariablesToTriggeredScope = VariableValueDto + .toMap(messageDto.getProcessVariablesToTriggeredScope(), directProviderUtil.getProcessEngine(user), objectMapper); + + MessageCorrelationBuilder builder = directProviderUtil.getProcessEngine(user).getRuntimeService().createMessageCorrelation(messageDto.getMessageName()); + + if (processVariables != null) { + builder.setVariables(processVariables); + } + if (processVariablesLocal != null) { + builder.setVariablesLocal(processVariablesLocal); + } + if (processVariablesToTriggeredScope != null) { + builder.setVariablesToTriggeredScope(processVariablesToTriggeredScope); + } + if (messageDto.getBusinessKey() != null) { + builder.processInstanceBusinessKey(messageDto.getBusinessKey()); + } + + if (correlationKeys != null && !correlationKeys.isEmpty()) { + for (java.util.Map.Entry correlationKey : correlationKeys.entrySet()) { + String name = correlationKey.getKey(); + Object value = correlationKey.getValue(); + builder.processInstanceVariableEquals(name, value); + } + } + + if (localCorrelationKeys != null && !localCorrelationKeys.isEmpty()) { + for (java.util.Map.Entry correlationKey : localCorrelationKeys.entrySet()) { + String name = correlationKey.getKey(); + Object value = correlationKey.getValue(); + builder.localVariableEquals(name, value); + } + } + + if (messageDto.getTenantId() != null) { + builder.tenantId(messageDto.getTenantId()); + + } else if (messageDto.isWithoutTenantId()) { + builder.withoutTenantId(); + } + + String processInstanceId = messageDto.getProcessInstanceId(); + if (processInstanceId != null) { + builder.processInstanceId(processInstanceId); + } + + return builder; + } + + @Override + public String findStacktrace(String jobId, CIBUser user) { + try { + String stacktrace = directProviderUtil.getProcessEngine(user).getManagementService().getJobExceptionStacktrace(jobId); + return stacktrace; + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public void retryJobById(String jobId, Map data, CIBUser user) { + RetriesDto dto = directProviderUtil.getObjectMapper(user).convertValue(data, RetriesDto.class); + try { + SetJobRetriesBuilder builder = directProviderUtil.getProcessEngine(user).getManagementService().setJobRetries(dto.getRetries()).jobId(jobId); + if (dto.isDueDateSet()) { + builder.dueDate(dto.getDueDate()); + } + builder.execute(); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public Collection getEventSubscriptions(Optional processInstanceId, + Optional eventType, Optional eventName, CIBUser user) { + EventSubscriptionQueryDto queryDto = new EventSubscriptionQueryDto(); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + if (processInstanceId.isPresent()) + queryDto.setProcessInstanceId(processInstanceId.get()); + if (eventType.isPresent()) + queryDto.setEventType(eventType.get()); + if (eventName.isPresent()) + queryDto.setEventName(eventName.get()); + EventSubscriptionQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + List matchingEventSubscriptions = QueryUtil.list(query, null, + null); + + List eventSubscriptionResults = new ArrayList<>(); + for (org.cibseven.bpm.engine.runtime.EventSubscription eventSubscription : matchingEventSubscriptions) { + EventSubscriptionDto resultEventSubscription = EventSubscriptionDto.fromEventSubscription(eventSubscription); + eventSubscriptionResults.add(directProviderUtil.convertValue(resultEventSubscription, EventSubscription.class, user)); + } + return eventSubscriptionResults; + } + + private List correlate(CorrelationMessageDto messageDto, + MessageCorrelationBuilder correlation) { + List resultDtos = new ArrayList<>(); + if (!messageDto.isAll()) { + MessageCorrelationResult result = correlation.correlateWithResult(); + resultDtos.add(MessageCorrelationResultDto.fromMessageCorrelationResult(result)); + } else { + List results = correlation.correlateAllWithResult(); + for (MessageCorrelationResult result : results) { + resultDtos.add(MessageCorrelationResultDto.fromMessageCorrelationResult(result)); + } + } + return resultDtos; + } + + private List correlateWithVariablesEnabled(CorrelationMessageDto messageDto, + MessageCorrelationBuilder correlation) { + List resultDtos = new ArrayList<>(); + if (!messageDto.isAll()) { + MessageCorrelationResultWithVariables result = correlation.correlateWithResultAndVariables(false); + resultDtos.add(MessageCorrelationResultWithVariableDto.fromMessageCorrelationResultWithVariables(result)); + } else { + List results = correlation.correlateAllWithResultAndVariables(false); + for (MessageCorrelationResultWithVariables result : results) { + resultDtos.add(MessageCorrelationResultWithVariableDto.fromMessageCorrelationResultWithVariables(result)); + } + } + return resultDtos; + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectVariableInstanceProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectVariableInstanceProvider.java new file mode 100755 index 000000000..2ccc43c98 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectVariableInstanceProvider.java @@ -0,0 +1,72 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import org.cibseven.bpm.engine.rest.dto.runtime.VariableInstanceDto; +import org.cibseven.bpm.engine.runtime.VariableInstanceQuery; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.rest.model.VariableInstance; + +public class DirectVariableInstanceProvider implements IVariableInstanceProvider { + + DirectProviderUtil directProviderUtil; + public DirectVariableInstanceProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + + + @Override + public VariableInstance getVariableInstance(String id, boolean deserializeValue, CIBUser user) + throws SystemException, NoObjectFoundException { + VariableInstance variableDeserialized = getVariableInstanceImpl(id, true, user); + VariableInstance variableSerialized = getVariableInstanceImpl(id, false, user); + if (variableDeserialized == null || variableSerialized == null) + throw new SystemException("Variable not found: " + id); + + if (deserializeValue) { + variableDeserialized.setValueSerialized(variableSerialized.getValue()); + variableDeserialized.setValueDeserialized(variableDeserialized.getValue()); + return variableDeserialized; + } else { + variableSerialized.setValueSerialized(variableSerialized.getValue()); + variableSerialized.setValueDeserialized(variableDeserialized.getValue()); + return variableSerialized; + } + } + + private VariableInstance getVariableInstanceImpl(String id, boolean deserializeValue, CIBUser user) + throws SystemException, NoObjectFoundException { + VariableInstanceQuery variableInstanceQuery = directProviderUtil.getProcessEngine(user).getRuntimeService().createVariableInstanceQuery().variableId(id); + // do not fetch byte arrays + variableInstanceQuery.disableBinaryFetching(); + + if (!deserializeValue) { + variableInstanceQuery.disableCustomObjectDeserialization(); + } + org.cibseven.bpm.engine.runtime.VariableInstance variableEngineInstance = variableInstanceQuery.singleResult(); + if (variableEngineInstance != null) { + VariableInstanceDto instanceDto = VariableInstanceDto.fromVariableInstance(variableEngineInstance); + VariableInstance variableInstance = directProviderUtil.convertValue(instanceDto, VariableInstance.class, user); + return variableInstance; + } else { + throw new NoObjectFoundException(new SystemException("Variable with Id '" + id + "' does not exist.")); + } + } + +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectVariableProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectVariableProvider.java new file mode 100755 index 000000000..230feea8d --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/DirectVariableProvider.java @@ -0,0 +1,853 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.io.IOUtils; +import org.cibseven.bpm.engine.AuthorizationException; +import org.cibseven.bpm.engine.FormService; +import org.cibseven.bpm.engine.ProcessEngine; +import org.cibseven.bpm.engine.ProcessEngineException; +import org.cibseven.bpm.engine.history.HistoricVariableInstance; +import org.cibseven.bpm.engine.history.HistoricVariableInstanceQuery; +import org.cibseven.bpm.engine.impl.RuntimeServiceImpl; +import org.cibseven.bpm.engine.repository.ProcessDefinition; +import org.cibseven.bpm.engine.rest.dto.PatchVariablesDto; +import org.cibseven.bpm.engine.rest.dto.VariableValueDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricVariableInstanceDto; +import org.cibseven.bpm.engine.rest.dto.history.HistoricVariableInstanceQueryDto; +import org.cibseven.bpm.engine.rest.dto.runtime.ProcessInstanceDto; +import org.cibseven.bpm.engine.rest.dto.runtime.VariableInstanceQueryDto; +import org.cibseven.bpm.engine.rest.exception.RestException; +import org.cibseven.bpm.engine.rest.util.QueryUtil; +import org.cibseven.bpm.engine.runtime.DeserializationTypeValidator; +import org.cibseven.bpm.engine.variable.VariableMap; +import org.cibseven.bpm.engine.variable.Variables; +import org.cibseven.bpm.engine.variable.impl.type.AbstractValueTypeImpl; +import org.cibseven.bpm.engine.variable.type.FileValueType; +import org.cibseven.bpm.engine.variable.type.ValueType; +import org.cibseven.bpm.engine.variable.value.BytesValue; +import org.cibseven.bpm.engine.variable.value.FileValue; +import org.cibseven.bpm.engine.variable.value.TypedValue; +import org.cibseven.webapp.NamedByteArrayDataSource; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.exception.ExpressionEvaluationException; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.exception.UnexpectedTypeException; +import org.cibseven.webapp.exception.UnsupportedTypeException; +import org.cibseven.webapp.rest.model.ProcessStart; +import org.cibseven.webapp.rest.model.Variable; +import org.cibseven.webapp.rest.model.VariableHistory; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.HttpStatusCodeException; +import org.springframework.web.multipart.MultipartFile; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import jakarta.activation.DataSource; +import jakarta.activation.MimeType; +import jakarta.activation.MimeTypeParseException; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class DirectVariableProvider implements IVariableProvider { + + public static final String DEFAULT_BINARY_VALUE_TYPE = "Bytes"; + + DirectProviderUtil directProviderUtil; + public DirectVariableProvider(DirectProviderUtil directProviderUtil){ + this.directProviderUtil = directProviderUtil; + } + @Override + public void modifyVariableByExecutionId(String executionId, Map data, CIBUser user) + throws SystemException { + PatchVariablesDto patch = directProviderUtil.getObjectMapper(user).convertValue(data, PatchVariablesDto.class); + VariableMap variableModifications = null; + try { + variableModifications = VariableValueDto.toMap(patch.getModifications(), directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user)); + } catch (RestException e) { + String errorMessage = String.format("Cannot modify variables for %s: %s", "modifyVariableByExecutionId", + e.getMessage()); + throw new SystemException(errorMessage, e); + } + + List variableDeletions = patch.getDeletions(); + try { + ((RuntimeServiceImpl) directProviderUtil.getProcessEngine(user).getRuntimeService()).updateVariables(executionId, variableModifications, variableDeletions); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot modify variables for %s %s: %s", "modifyVariableByExecutionId", + executionId, e.getMessage()); + throw new SystemException(errorMessage, e); + } + } + + @Override + public void modifyVariableDataByExecutionId(String executionId, String variableName, MultipartFile data, + String valueType, CIBUser user) throws SystemException { + + try { + if (valueType.equalsIgnoreCase("File") || valueType.equalsIgnoreCase("Bytes")) { + // Handle binary/file data + VariableValueDto valueDto = createVariableValueDto(valueType, data); + try { + TypedValue typedValue = valueDto.toTypedValue(directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user));// creates FileValueImpl + + directProviderUtil.getProcessEngine(user).getRuntimeService().setVariable(executionId, variableName, typedValue); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot put %s variable %s: %s", executionId, variableName, e.getMessage()); + throw new SystemException(errorMessage, e); + } + } else { + // Handle JSON/serialized data + Object object = null; + + if (data.getContentType() != null + && data.getContentType().toLowerCase().contains(MediaType.APPLICATION_JSON.toString())) { + object = deserializeJsonObject(valueType, data.getBytes(), user); + + } else { + throw new SystemException("Unrecognized content type for serialized java type: " + data.getContentType()); + } + + if (object != null) { + directProviderUtil.getProcessEngine(user).getRuntimeService().setVariable(executionId, variableName, Variables.objectValue(object).create()); + } + } + } catch (IOException e) { // from data.getBytes() + throw new UnsupportedTypeException(e); + } + } + + @Override + public Collection fetchProcessInstanceVariables(String processInstanceId, Map data, + CIBUser user) throws SystemException { + data.put("processInstanceIdIn", new String[] { processInstanceId }); + final boolean deserializeValues = data != null && data.containsKey("deserializeValues") + && (Boolean) data.get("deserializeValues"); + if (data != null && data.containsKey("deserializeValues")) + data.remove("deserializeValues"); + + VariableInstanceQueryDto queryDto = directProviderUtil.getObjectMapper(user).convertValue(data, VariableInstanceQueryDto.class); + + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + + List variablesDeserialized = directProviderUtil.queryVariableInstances(queryDto, null, null, true, user); + if (variablesDeserialized.isEmpty()) + return Collections.emptyList(); + List variablesSerialized = directProviderUtil.queryVariableInstances(queryDto, null, null, false, user); + if (variablesSerialized.isEmpty()) + return Collections.emptyList(); + + mergeVariablesValues(variablesDeserialized, variablesSerialized, deserializeValues); + Collection variables = (deserializeValues) ? variablesDeserialized : variablesSerialized; + return variables; + } + + @Override + public ResponseEntity fetchVariableDataByExecutionId(String executionId, String variableName, CIBUser user) + throws NoObjectFoundException, SystemException { + TypedValue typedVariableValue = directProviderUtil.getProcessEngine(user).getRuntimeService().getVariableLocalTyped(executionId, variableName, false); + return getResponseForTypedVariable(typedVariableValue, executionId); + } + + @Override + public Collection fetchProcessInstanceVariablesHistory(String processInstanceId, + Map data, CIBUser user) throws SystemException { + data.put("processInstanceIdIn", new String[] { processInstanceId }); + final boolean deserializeValues = data != null && data.containsKey("deserializeValues") + && (Boolean) data.get("deserializeValues"); + if (data != null && data.containsKey("deserializeValues")) + data.remove("deserializeValues"); + ObjectMapper objectMapper = directProviderUtil.getObjectMapper(user); + HistoricVariableInstanceQueryDto queryDto = objectMapper.convertValue(data, + HistoricVariableInstanceQueryDto.class); + + queryDto.setObjectMapper(objectMapper); + + List variablesDeserialized = queryHistoricVariableInstances(queryDto, objectMapper, null, null, + true, user); + if (variablesDeserialized.isEmpty()) + return Collections.emptyList(); + List variablesSerialized = queryHistoricVariableInstances(queryDto, objectMapper, null, null, + false, user); + if (variablesSerialized.isEmpty()) + return Collections.emptyList(); + + // Get list of variables and merge them + final ArrayList variablesDeserializedTyped = new ArrayList<>(); + if (variablesDeserialized.size() > 0) { + variablesDeserializedTyped.addAll(variablesDeserialized); + } + + final ArrayList variablesSerializedTyped = new ArrayList<>(); + if (variablesSerialized.size() > 0) { + variablesSerializedTyped.addAll(variablesSerialized); + } + + mergeVariablesValues(variablesDeserializedTyped, variablesSerializedTyped, deserializeValues); + + Collection variables = (deserializeValues) ? variablesDeserialized : variablesSerialized; + return variables; + + } + + @Override + public Collection fetchActivityVariablesHistory(String activityInstanceId, CIBUser user) { + HistoricVariableInstanceQueryDto queryDto = new HistoricVariableInstanceQueryDto(); + queryDto.setActivityInstanceIdIn(new String[] { activityInstanceId}); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + return queryHistoricVariableInstances(queryDto, null, null, true, user); + } + + @Override + public Collection fetchActivityVariables(String activityInstanceId, CIBUser user) { + VariableInstanceQueryDto queryDto = new VariableInstanceQueryDto(); + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + queryDto.setActivityInstanceIdIn(new String[] { activityInstanceId }); + List variableInstances = directProviderUtil.queryVariableInstances(queryDto, null, null, true, user); + List historyVariables = new ArrayList<>(); + for (Variable variableInstance : variableInstances) { + historyVariables.add(directProviderUtil.convertValue(variableInstance, VariableHistory.class, user)); + } + return historyVariables; + } + + @Override + public ResponseEntity fetchHistoryVariableDataById(String id, CIBUser user) + throws NoObjectFoundException, SystemException { + HistoricVariableInstanceQuery query = directProviderUtil.getProcessEngine(user).getHistoryService().createHistoricVariableInstanceQuery().variableId(id); + query.disableCustomObjectDeserialization(); + HistoricVariableInstance queryResult = query.singleResult(); + if (queryResult != null) { + TypedValue typedValue = queryResult.getTypedValue(); + return getResponseForTypedVariable(typedValue, id); + } else { + throw new NoObjectFoundException(new SystemException("HistoryVariable with Id '" + id + "' does not exist.")); + } + } + + @Override + public Variable fetchVariable(String taskId, String variableName, boolean deserializeValue, CIBUser user) + throws NoObjectFoundException, SystemException { + Variable variableSerialized = fetchTaskVariableImpl(taskId, variableName, false, user); + Variable variableDeserialized = fetchTaskVariableImpl(taskId, variableName, true, user); + + if (deserializeValue) { + variableDeserialized.setValueSerialized(variableSerialized.getValue()); + variableDeserialized.setValueDeserialized(variableDeserialized.getValue()); + return variableDeserialized; + } else { + variableSerialized.setValueSerialized(variableSerialized.getValue()); + variableSerialized.setValueDeserialized(variableDeserialized.getValue()); + return variableSerialized; + } + } + + @Override + public void deleteVariable(String taskId, String variableName, CIBUser user) + throws NoObjectFoundException, SystemException { + try { + directProviderUtil.getProcessEngine(user).getTaskService().removeVariable(taskId, variableName); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot delete %s variable %s: %s", "task", variableName, e.getMessage()); + throw new SystemException(errorMessage, e); + } + } + + @Override + public Map fetchFormVariables(String taskId, boolean deserializeValues, CIBUser user) + throws NoObjectFoundException, SystemException { + return fetchFormVariables(null, taskId, deserializeValues, user); + } + + @Override + public Map fetchFormVariables(List variableListName, String taskId, boolean deserializeValues, CIBUser user) + throws NoObjectFoundException, SystemException { + VariableMap startFormVariables = directProviderUtil.getProcessEngine(user).getFormService().getTaskFormVariables(taskId, variableListName, deserializeValues); + Map variableDtos = VariableValueDto.fromMap(startFormVariables); + Map variablesMap = new HashMap<>(); + for (Entry e : variableDtos.entrySet()) { + variablesMap.put(e.getKey(), directProviderUtil.convertValue(e.getValue(), Variable.class, user)); + } + return variablesMap; + } + + @Override + public Map fetchProcessFormVariables(String key, boolean deserializeValues, CIBUser user) + throws NoObjectFoundException, SystemException { + List formVariables = null; + + ProcessDefinition processDefinition = directProviderUtil.getProcessEngine(user).getRepositoryService().createProcessDefinitionQuery() + .processDefinitionKey(key).withoutTenantId().latestVersion().singleResult(); + + if (processDefinition == null) { + String errorMessage = String.format("No matching process definition with key: %s and no tenant-id", key); + throw new SystemException(errorMessage); + + } + + VariableMap startFormVariables = directProviderUtil.getProcessEngine(user).getFormService().getStartFormVariables(processDefinition.getId(), formVariables, deserializeValues); + Map variableDtos = VariableValueDto.fromMap(startFormVariables); + Map variablesMap = new HashMap<>(); + for (Entry e : variableDtos.entrySet()) { + variablesMap.put(e.getKey(), directProviderUtil.convertValue(e.getValue(), Variable.class, user)); + } + return variablesMap; + } + + @Override + public NamedByteArrayDataSource fetchVariableFileData(String taskId, String variableName, CIBUser user) + throws NoObjectFoundException, UnexpectedTypeException, SystemException { + try { + byte[] data = null; + String filename = null; + String mimeType = null; + + Variable variable = fetchVariable(taskId, variableName, true, user); + String objectType = variable.getValueInfo().get("objectTypeName"); + if (objectType != null) { + try { + Class clazz = Class.forName(objectType); + + if (DataSource.class.isAssignableFrom(clazz)) { + @SuppressWarnings("unchecked") + DataSource ds = directProviderUtil.getObjectMapper(user).convertValue(variable.getValue(), (Class) clazz); + + return new NamedByteArrayDataSource(ds.getName(), ds.getContentType(), + IOUtils.toByteArray(ds.getInputStream())); + } + } catch (ClassNotFoundException e) { + log.info("Class " + objectType + " could not be loaded!"); + } + } + + filename = variable.getFilename(); + mimeType = variable.getMimeType(); + + TypedValue typedVariableValue = directProviderUtil.getTypedValueForTaskVariable(taskId, variableName, true, user); + // VariableValueDto dto = VariableValueDto.fromTypedValue(value); + if (typedVariableValue instanceof BytesValue || ValueType.BYTES.equals(typedVariableValue.getType())) { + data = (byte[]) typedVariableValue.getValue(); + if (data == null) { + data = new byte[0]; + } + } else if (ValueType.FILE.equals(typedVariableValue.getType())) { + FileValue typedFileValue = (FileValue) typedVariableValue; + try { + data = typedFileValue.getValue() == null ? null : IOUtils.toByteArray(typedFileValue.getValue()); + // status code if bytes==null? + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } else { + throw new SystemException(String.format("Value of variable with id %s is not a binary value.", variableName)); + } + + return new NamedByteArrayDataSource(filename, mimeType, data); + } catch (HttpStatusCodeException e) { + throw SevenProviderBase.wrapException(e, user); + } catch (IOException e) { + throw new SystemException(e); + } + } + + @Override + public void uploadVariableFileData(String taskId, String variableName, MultipartFile data, String valueType, + CIBUser user) throws NoObjectFoundException, SystemException { + try { + setBinaryVariable(data, valueType, null, taskId, null, variableName, user); + } catch (HttpStatusCodeException e) { + throw SevenProviderBase.wrapException(e, user); + } catch (IOException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public ResponseEntity fetchProcessInstanceVariableData(String processInstanceId, String variableName, + CIBUser user) throws NoObjectFoundException, SystemException { + Variable variable = fetchVariableByProcessInstanceId(processInstanceId, variableName, user); + String objectType = variable.getValueInfo().get("objectTypeName"); + if (objectType != null) { + try { + Class clazz = Class.forName(objectType); + + if (DataSource.class.isAssignableFrom(clazz)) { + final ObjectMapper mapper = new ObjectMapper(); + @SuppressWarnings("unchecked") + DataSource ds = mapper.convertValue(variable.getValue(), (Class) clazz); + + return ResponseEntity.ok(IOUtils.toByteArray(ds.getInputStream())); + } + } catch (ClassNotFoundException e) { + log.info("Class " + objectType + " could not be loaded!"); + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } + TypedValue value = null; + try { + value = directProviderUtil.getProcessEngine(user).getRuntimeService().getVariableTyped(processInstanceId, variableName, false); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot get %s variable %s: %s", "processInstance", variableName, + e.getMessage()); + throw new SystemException(errorMessage, e); + } + + if (value == null) { + String errorMessage = String.format("%s variable with name %s does not exist", "processInstance", variableName); + throw new SystemException(errorMessage); + } + if (value instanceof BytesValue || ValueType.BYTES.equals(value.getType())) { + byte[] valueBytes = (byte[]) value.getValue(); + if (valueBytes == null) { + valueBytes = new byte[0]; + } + + ResponseEntity responseEntity = ResponseEntity.ok(valueBytes); + return responseEntity; + } else if (ValueType.FILE.equals(value.getType())) { + FileValue typedFileValue = (FileValue) value; + try { + byte[] bytes = typedFileValue.getValue() == null ? null : IOUtils.toByteArray(typedFileValue.getValue()); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(typedFileValue.getMimeType() != null ? MediaType.valueOf(typedFileValue.getMimeType()) + : MediaType.APPLICATION_OCTET_STREAM); + ResponseEntity responseEntity = ResponseEntity.ok().headers(headers).body(bytes); + return responseEntity; + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } else { + throw new SystemException(String.format("Value of variable with id %s is not a binary value.", variableName)); + } + } + + @Override + public void uploadProcessInstanceVariableFileData(String processInstanceId, String variableName, MultipartFile data, + String valueType, CIBUser user) throws NoObjectFoundException, SystemException { + try { + setBinaryVariable(data, valueType, null, null, processInstanceId, variableName, user); + } catch (HttpStatusCodeException e) { + throw SevenProviderBase.wrapException(e, user); + } catch (IOException e) { + throw new SystemException(e.getMessage()); + } + } + + @Override + public ProcessStart submitStartFormVariables(String processDefinitionId, List formResult, CIBUser user) + throws SystemException { + Map variablesMap = new HashMap<>(); + for (Variable variable : formResult) { + if (variable.getType().equalsIgnoreCase("file")) { + // https://helpdesk.cib.de/browse/BPM4CIB-434 + int lastIndex = variable.getFilename().lastIndexOf(".rtf"); + if ((lastIndex > 0) && ((lastIndex + 4) == variable.getFilename().length())) { + variable.getValueInfo().put("mimeType", "application/rtf"); + } + } + VariableValueDto variableValueDto = directProviderUtil.convertValue(variable, VariableValueDto.class, user); + TypedValue typedValue = variableValueDto.toTypedValue(directProviderUtil.getProcessEngine(user), + directProviderUtil.getObjectMapper(user)); + variablesMap.put(variable.getName(), typedValue); + } + try { + org.cibseven.bpm.engine.runtime.ProcessInstance instance = directProviderUtil.getProcessEngine(user).getFormService().submitStartForm(processDefinitionId, variablesMap); + ProcessInstanceDto processInstanceDto = ProcessInstanceDto.fromProcessInstance(instance); + + ProcessStart result = directProviderUtil.convertValue(processInstanceDto, ProcessStart.class, user); + return result; + } catch (AuthorizationException e) { + throw e; + + } catch (ProcessEngineException|RestException e) { + String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, + e.getMessage()); + throw new ExpressionEvaluationException(new UnsupportedTypeException(new SystemException(errorMessage, e))); + } + } + + @Override + public Variable fetchVariableByProcessInstanceId(String processInstanceId, String variableName, CIBUser user) + throws SystemException { + Variable variableSerialized = fetchVariableByProcessInstanceIdImpl(processInstanceId, variableName, false, user); + Variable variableDeserialized = fetchVariableByProcessInstanceIdImpl(processInstanceId, variableName, true, user); + + variableDeserialized.setValueSerialized(variableSerialized.getValue()); + variableDeserialized.setValueDeserialized(variableDeserialized.getValue()); + return variableDeserialized; + } + + @Override + public void saveVariableInProcessInstanceId(String processInstanceId, List variables, CIBUser user) + throws SystemException { + List deletions = new ArrayList<>(); + Map modifications = new HashMap<>(); + for (Variable variable : variables) { + VariableValueDto variableValueDto = directProviderUtil.convertValue(variable, VariableValueDto.class, user); + variableValueDto.setType(variable.getType()); + variableValueDto.setValue(variable.getValue()); + if (variable.getValueInfo() != null) + variableValueDto.setValueInfo(new HashMap<>(variable.getValueInfo())); + modifications.put(variable.getName(), variableValueDto); + } + updateVariableEntities(processInstanceId, modifications, deletions, user); + } + + @Override + public void submitVariables(String processInstanceId, List formResult, CIBUser user, + String processDefinitionId) throws SystemException { + + List deletions = new ArrayList<>(); + Map modifications = new HashMap<>(); + for (Variable variable : formResult) { + VariableValueDto variableValueDto = directProviderUtil.convertValue(variable, VariableValueDto.class, user); + variableValueDto.setType(variable.getType()); + variableValueDto.setValue(variable.getValue()); + if (variable.getValueInfo() != null) + variableValueDto.setValueInfo(new HashMap<>(variable.getValueInfo())); + modifications.put(variable.getName(), variableValueDto); + } + + updateVariableEntities(processInstanceId, modifications, deletions, user); + + } + + @Override + public Map fetchProcessFormVariablesById(String id, CIBUser user) throws SystemException { + VariableMap startFormVariables = directProviderUtil.getProcessEngine(user).getFormService().getStartFormVariables(id, null, true); + Map resultMap = new HashMap<>(); + Map resultDtoMap = VariableValueDto.fromMap(startFormVariables); + for (Entry resultDtoEntry : resultDtoMap.entrySet()) { + resultMap.put(resultDtoEntry.getKey(), directProviderUtil.convertValue(resultDtoEntry.getValue(), Variable.class, user)); + } + return resultMap; + } + + @Override + public void putLocalExecutionVariable(String executionId, String varName, Map data, CIBUser user) { + try { + VariableValueDto variable = directProviderUtil.getObjectMapper(user).convertValue(data, VariableValueDto.class); + TypedValue typedValue = variable.toTypedValue(directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user)); + directProviderUtil.getProcessEngine(user).getRuntimeService().setVariable(executionId, varName, typedValue); + + } catch (AuthorizationException e) { + throw new SystemException(e.getMessage(), e); + } catch (ProcessEngineException|RestException e) { + throw new SystemException(String.format("Cannot put %s variable %s: %s", "execution", varName, e.getMessage()), e); + } + } + + /* + * puts variable to different targets depending on taskId, processInstanceId, + * ... + */ + private void setBinaryVariable(MultipartFile data, String valueType, String objectType, String taskId, + String processInstanceId, String variableName, CIBUser user) throws IOException { + if (objectType != null) { + Object object = null; + + if (data.getContentType() != null + && data.getContentType().toLowerCase().contains(MediaType.APPLICATION_JSON.toString())) { + + byte[] bytes = IOUtils.toByteArray(data.getResource().getInputStream()); + object = deserializeJsonObject(objectType, bytes, user); + + } else { + throw new SystemException("Unrecognized content type for serialized java type: " + data.getContentType()); + } + + if (object != null) { + if (taskId != null) + directProviderUtil.getProcessEngine(user).getTaskService().setVariable(taskId, variableName, Variables.objectValue(object).create()); + else if (processInstanceId != null) + directProviderUtil.getProcessEngine(user).getRuntimeService().setVariable(processInstanceId, variableName, Variables.objectValue(object).create()); + } + } else { + + String valueTypeName = DEFAULT_BINARY_VALUE_TYPE; + if (valueType != null) { + if (valueType.isBlank()) { + throw new SystemException("Form part with name 'valueType' must have a text/plain value"); + } + + valueTypeName = valueType; + } + VariableValueDto valueDto = createVariableValueDto(valueTypeName, data); + try { + TypedValue typedValue = valueDto.toTypedValue(directProviderUtil.getProcessEngine(user), directProviderUtil.getObjectMapper(user)); + if (taskId != null) + directProviderUtil.getProcessEngine(user).getTaskService().setVariable(taskId, variableName, typedValue); + else if (processInstanceId != null) + directProviderUtil.getProcessEngine(user).getRuntimeService().setVariable(processInstanceId, variableName, typedValue); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot put %s variable %s: %s", "task", variableName, e.getMessage()); + throw new SystemException(errorMessage, e); + } + } + } + + private Object deserializeJsonObject(String className, byte[] data, CIBUser user) { + try { + JavaType type = TypeFactory.defaultInstance().constructFromCanonical(className); + validateType(type, user); + return directProviderUtil.getObjectMapper(user).readValue(new String(data, Charset.forName("UTF-8")), type); + } catch (Exception e) { + throw new SystemException("Could not deserialize JSON object: " + e.getMessage()); + } + } + + // updates execution variables + private void updateVariableEntities(String processInstanceId, Map modifications, + List deletions, CIBUser user) { + VariableMap variableModifications = null; + ProcessEngine processEngine = directProviderUtil.getProcessEngine(user); + try { + variableModifications = VariableValueDto.toMap(modifications, processEngine, directProviderUtil.getObjectMapper(user)); + } catch (RestException e) { + String errorMessage = String.format("Cannot modify variables for %s: %s", "processInstance", e.getMessage()); + throw new SystemException(errorMessage, e); + } + try { + RuntimeServiceImpl runtimeServiceImpl = (RuntimeServiceImpl) processEngine.getRuntimeService(); + runtimeServiceImpl.updateVariables(processInstanceId, variableModifications, deletions); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot modify variables for %s %s: %s", "processInstance", processInstanceId, + e.getMessage()); + throw new SystemException(errorMessage, e); + } + } + + public Variable fetchVariableByProcessInstanceIdImpl(String processInstanceId, String variableName, + boolean deserializeValue, CIBUser user) throws SystemException { + TypedValue value = getTypedValueForProcessInstanceVariable(processInstanceId, variableName, deserializeValue, user); + return directProviderUtil.convertValue(VariableValueDto.fromTypedValue(value), Variable.class, user); + } + + private TypedValue getTypedValueForProcessInstanceVariable(String processInstanceId, String variableName, + boolean deserializeValue, CIBUser user) { + try { + return directProviderUtil.getProcessEngine(user).getRuntimeService().getVariableTyped(processInstanceId, variableName, deserializeValue); + } catch (AuthorizationException e) { + throw e; + } catch (ProcessEngineException e) { + String errorMessage = String.format("Cannot get %s variable %s: %s", "task", variableName, e.getMessage()); + throw new SystemException(errorMessage, e); + } + } + + /** + * Validate the type with the help of the validator in the engine.
+ * Note: when adjusting this method, please also consider adjusting the + * {@code JacksonJsonDataFormatMapper#validateType} in the Engine Spin Plugin + */ + private void validateType(JavaType type, CIBUser user) { + if (directProviderUtil.getProcessEngine(user).getProcessEngineConfiguration().isDeserializationTypeValidationEnabled()) { + DeserializationTypeValidator validator = directProviderUtil.getProcessEngine(user).getProcessEngineConfiguration().getDeserializationTypeValidator(); + if (validator != null) { + List invalidTypes = new ArrayList<>(); + validateType(type, validator, invalidTypes); + if (!invalidTypes.isEmpty()) { + throw new SystemException("The following classes are not whitelisted for deserialization: " + invalidTypes); + } + } + } + } + + private void validateType(JavaType type, DeserializationTypeValidator validator, List invalidTypes) { + if (!type.isPrimitive()) { + if (!type.isArrayType()) { + validateTypeInternal(type, validator, invalidTypes); + } + if (type.isMapLikeType()) { + validateType(type.getKeyType(), validator, invalidTypes); + } + if (type.isContainerType() || type.hasContentType()) { + validateType(type.getContentType(), validator, invalidTypes); + } + } + } + + private void validateTypeInternal(JavaType type, DeserializationTypeValidator validator, List invalidTypes) { + String className = type.getRawClass().getName(); + if (!validator.validate(className) && !invalidTypes.contains(className)) { + invalidTypes.add(className); + } + } + + private ResponseEntity getResponseForTypedVariable(TypedValue typedVariableValue, String id) { + if (typedVariableValue instanceof BytesValue || ValueType.BYTES.equals(typedVariableValue.getType())) { + byte[] valueBytes = (byte[]) typedVariableValue.getValue(); + if (valueBytes == null) { + valueBytes = new byte[0]; + } + ResponseEntity responseEntity = ResponseEntity.ok(valueBytes); + return responseEntity; + } else if (ValueType.FILE.equals(typedVariableValue.getType())) { + FileValue typedFileValue = (FileValue) typedVariableValue; + try { + byte[] bytes = typedFileValue.getValue() == null ? null : IOUtils.toByteArray(typedFileValue.getValue()); + // status code if bytes==null? + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(typedFileValue.getMimeType() != null ? MediaType.valueOf(typedFileValue.getMimeType()) + : MediaType.APPLICATION_OCTET_STREAM); + ResponseEntity responseEntity = ResponseEntity.ok().headers(headers).body(bytes); + return responseEntity; + } catch (IOException e) { + throw new SystemException(e.getMessage(), e); + } + } else { + throw new SystemException(String.format("Value of variable with id %s is not a binary value.", id)); + } + } + + private List queryHistoricVariableInstances(HistoricVariableInstanceQueryDto queryDto, + Integer firstResult, Integer maxResults, boolean deserializeObjectValues, CIBUser user) { + queryDto.setObjectMapper(directProviderUtil.getObjectMapper(user)); + HistoricVariableInstanceQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + query.disableBinaryFetching(); + + if (!deserializeObjectValues) { + query.disableCustomObjectDeserialization(); + } + + List matchingHistoricVariableInstances = QueryUtil.list(query, firstResult, maxResults); + List historicVariableInstanceDtoResults = new ArrayList<>(); + for (HistoricVariableInstance historicVariableInstance : matchingHistoricVariableInstances) { + HistoricVariableInstanceDto resultHistoricVariableInstance = HistoricVariableInstanceDto + .fromHistoricVariableInstance(historicVariableInstance); + historicVariableInstanceDtoResults.add(directProviderUtil.convertValue(resultHistoricVariableInstance, VariableHistory.class, user)); + } + return historicVariableInstanceDtoResults; + } + + private Variable fetchTaskVariableImpl(String taskId, String variableName, boolean deserializeValue, CIBUser user) + throws NoObjectFoundException, SystemException { + TypedValue value = directProviderUtil.getTypedValueForTaskVariable(taskId, variableName, deserializeValue, user); + return directProviderUtil.convertValue(VariableValueDto.fromTypedValue(value), Variable.class, user); + } + + private VariableValueDto createVariableValueDto(String valueTypeName, MultipartFile data) throws IOException { + VariableValueDto valueDto = new VariableValueDto(); + valueDto.setType(valueTypeName); + valueDto.setValue(data.getBytes()); + + String contentType = data.getContentType(); + if (contentType == null) { + contentType = MediaType.APPLICATION_OCTET_STREAM.toString(); + } + + Map valueInfoMap = new HashMap<>(); + valueInfoMap.put(FileValueType.VALUE_INFO_FILE_NAME, data.getResource().getFilename()); + MimeType mimeType = null; + try { + mimeType = new MimeType(contentType); + } catch (MimeTypeParseException e) { + throw new SystemException("Invalid mime type given"); + } + + valueInfoMap.put(FileValueType.VALUE_INFO_FILE_MIME_TYPE, mimeType.getBaseType()); + + String encoding = mimeType.getParameter("encoding"); + if (encoding != null) { + valueInfoMap.put(FileValueType.VALUE_INFO_FILE_ENCODING, encoding); + } + + String transientString = mimeType.getParameter("transient"); + boolean isTransient = Boolean.parseBoolean(transientString); + if (isTransient) { + valueInfoMap.put(AbstractValueTypeImpl.VALUE_INFO_TRANSIENT, isTransient); + } + valueDto.setValueInfo(valueInfoMap); + return valueDto; + } + + private List queryHistoricVariableInstances(HistoricVariableInstanceQueryDto queryDto, + ObjectMapper objectMapper, Integer firstResult, Integer maxResults, boolean deserializeObjectValues, CIBUser user) { + // change to history query!! + HistoricVariableInstanceQuery query = queryDto.toQuery(directProviderUtil.getProcessEngine(user)); + + // disable binary fetching by default. + query.disableBinaryFetching(); + + // disable custom object fetching by default. Cannot be done to not break + // existing API + if (!deserializeObjectValues) { + query.disableCustomObjectDeserialization(); + } + + List matchingInstances = QueryUtil.list(query, firstResult, maxResults); + + List instanceResults = new ArrayList<>(); + for (HistoricVariableInstance instance : matchingInstances) { + HistoricVariableInstanceDto resultInstanceDto = HistoricVariableInstanceDto.fromHistoricVariableInstance(instance); + VariableHistory resultInstance = directProviderUtil.convertValue(resultInstanceDto, VariableHistory.class, user); + instanceResults.add(resultInstance); + } + return instanceResults; + } + + @Override + public Map fetchProcessFormVariables(List variableListName, String key, + boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { + ProcessDefinition processDefinition = directProviderUtil.getProcessEngine(user).getRepositoryService() + .createProcessDefinitionQuery().processDefinitionKey(key).withoutTenantId().latestVersion().singleResult(); + if (processDefinition == null) { + String errorMessage = String.format("No matching process definition with key: %s and no tenant-id", key); + throw new SystemException(errorMessage); + } + + FormService formService = directProviderUtil.getProcessEngine(user).getFormService(); + VariableMap startFormVariables = formService.getStartFormVariables(processDefinition.getId(), variableListName, + deserializeValues); + Map result = new HashMap<>(); + for (String variableName : startFormVariables.keySet()) { + VariableValueDto valueDto = VariableValueDto.fromTypedValue(startFormVariables.getValueTyped(variableName), + false); + result.put(variableName, directProviderUtil.convertValue(valueDto, Variable.class, user)); + } + return result; + } +} diff --git a/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/SevenDirectProvider.java b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/SevenDirectProvider.java new file mode 100755 index 000000000..7d9ca8bb2 --- /dev/null +++ b/cibseven-direct-provider/src/main/java/org/cibseven/webapp/providers/SevenDirectProvider.java @@ -0,0 +1,76 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import org.springframework.beans.factory.annotation.Value; + +import jakarta.annotation.PostConstruct; +import lombok.Getter; + +@Getter +public class SevenDirectProvider implements BpmProvider { + //decides about ldap/adfs + @Value("${cibseven.webclient.user.provider:org.cibseven.webapp.auth.SevenUserProvider}") String sevenUserProvider; + @Value("${cibseven.webclient.users.search.wildcard:}") String wildcard; + // base project providers + private DirectTaskProvider taskProvider = null; + private DirectProcessProvider processProvider = null; + private DirectFilterProvider filterProvider = null; + private DirectDeploymentProvider deploymentProvider = null; + private DirectVariableProvider variableProvider = null; + private DirectActivityProvider activityProvider = null; + private DirectIncidentProvider incidentProvider = null; + private DirectUserProvider userProvider; + private DirectVariableInstanceProvider variableInstanceProvider = null; + private DirectUtilsProvider utilsProvider = null; + private DirectHistoricVariableInstanceProvider historicVariableInstanceProvider = null; + private DirectExternalTaskProvider externalTaskProvider = null; + private DirectDecisionProvider decisionProvider = null; + private DirectJobProvider jobProvider = null; + private DirectJobDefinitionProvider jobDefinitionProvider = null; + private DirectEngineProvider engineProvider = null; + private DirectBatchProvider batchProvider = null; + private DirectTenantProvider tenantProvider = null; + private DirectSystemProvider systemProvider = null; + private DirectIdentityProvider identityProvider = null; + + DirectProviderUtil directProviderUtil = null; + + @PostConstruct + public void init() { + directProviderUtil = new DirectProviderUtil(); + deploymentProvider = new DirectDeploymentProvider(getDirectProviderUtil()); + variableProvider = new DirectVariableProvider(getDirectProviderUtil()); + variableInstanceProvider = new DirectVariableInstanceProvider(getDirectProviderUtil()); + historicVariableInstanceProvider = new DirectHistoricVariableInstanceProvider(getDirectProviderUtil()); + taskProvider = new DirectTaskProvider(getDirectProviderUtil()); + processProvider = new DirectProcessProvider(getDirectProviderUtil(), this); + activityProvider = new DirectActivityProvider(getDirectProviderUtil()); + filterProvider = new DirectFilterProvider(getDirectProviderUtil()); + utilsProvider = new DirectUtilsProvider(getDirectProviderUtil()); + incidentProvider = new DirectIncidentProvider(getDirectProviderUtil()); + jobDefinitionProvider = new DirectJobDefinitionProvider(getDirectProviderUtil()); + userProvider = new DirectUserProvider(getDirectProviderUtil(), sevenUserProvider, wildcard); + decisionProvider = new DirectDecisionProvider(getDirectProviderUtil()); + jobProvider = new DirectJobProvider(getDirectProviderUtil()); + batchProvider = new DirectBatchProvider(getDirectProviderUtil()); + systemProvider = new DirectSystemProvider(getDirectProviderUtil()); + tenantProvider = new DirectTenantProvider(getDirectProviderUtil()); + externalTaskProvider = new DirectExternalTaskProvider(getDirectProviderUtil()); + engineProvider = new DirectEngineProvider(getDirectProviderUtil()); + } +} diff --git a/cibseven-interfaces/.gitignore b/cibseven-interfaces/.gitignore new file mode 100644 index 000000000..8cdd3077b --- /dev/null +++ b/cibseven-interfaces/.gitignore @@ -0,0 +1,15 @@ +/target/ +/.settings/ +/.classpath +/.project +/bin/ +/.springBeans +/build/ +/src/main/resources/seven-webclient.yaml + +# IntelliJ +.idea/ +*.iml + +# MacOS +.DS_Store diff --git a/cibseven-interfaces/pom.xml b/cibseven-interfaces/pom.xml new file mode 100755 index 000000000..1e467fe77 --- /dev/null +++ b/cibseven-interfaces/pom.xml @@ -0,0 +1,116 @@ + + 4.0.0 + + org.cibseven.webapp + cibseven-webclient + 2.2.0-SNAPSHOT + + cibseven-interfaces + CIB seven webclient interfaces + Provider interfaces + + + + + jakarta.servlet + jakarta.servlet-api + provided + + + + jakarta.activation + jakarta.activation-api + + + + org.slf4j + slf4j-api + + + + org.apache.logging.log4j + log4j-slf4j-impl + + + + + io.swagger.core.v3 + swagger-annotations-jakarta + ${swagger-annotations.version} + + + + commons-io + commons-io + ${commons-io.version} + + + + org.cibseven.webapp.auth + common-auth + ${common-auth.version} + + + + org.springframework + spring-core + + + + org.springframework + spring-web + + + + org.springframework + spring-context + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + + + org.apache.httpcomponents.client5 + httpclient5 + + + + jakarta.annotation + jakarta.annotation-api + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.2.5 + + + + integration-test + verify + + + + + + + org/cibseven/webapp/providers/**/*IT.java + + + + + + + diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/Data.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/Data.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/Data.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/Data.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/NamedByteArrayDataSource.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/NamedByteArrayDataSource.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/NamedByteArrayDataSource.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/NamedByteArrayDataSource.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/BaseUserProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/BaseUserProvider.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/BaseUserProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/BaseUserProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/CIBUser.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/CIBUser.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/CIBUser.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/CIBUser.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/JwtTokenSettings.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/JwtTokenSettings.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/JwtTokenSettings.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/JwtTokenSettings.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenAuthorizationUtils.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/SevenAuthorizationUtils.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenAuthorizationUtils.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/SevenAuthorizationUtils.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenResourceType.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/SevenResourceType.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenResourceType.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/auth/SevenResourceType.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/config/EngineRestProperties.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/config/EngineRestProperties.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/config/EngineRestProperties.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/config/EngineRestProperties.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/config/EngineRestSource.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/config/EngineRestSource.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/config/EngineRestSource.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/config/EngineRestSource.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/AccessDeniedException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/AccessDeniedException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/AccessDeniedException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/AccessDeniedException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ApplicationException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ApplicationException.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ApplicationException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ApplicationException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/BatchOperationException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/BatchOperationException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/BatchOperationException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/BatchOperationException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/DmnTransformationException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/DmnTransformationException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/DmnTransformationException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/DmnTransformationException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ExistingGroupRequestException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ExistingGroupRequestException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ExistingGroupRequestException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ExistingGroupRequestException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ExistingUserRequestException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ExistingUserRequestException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ExistingUserRequestException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ExistingUserRequestException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ExpressionEvaluationException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ExpressionEvaluationException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/ExpressionEvaluationException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/ExpressionEvaluationException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/InvalidAttributeValueException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/InvalidAttributeValueException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/InvalidAttributeValueException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/InvalidAttributeValueException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/InvalidUserIdException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/InvalidUserIdException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/InvalidUserIdException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/InvalidUserIdException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/InvalidValueHistoryTimeToLive.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/InvalidValueHistoryTimeToLive.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/InvalidValueHistoryTimeToLive.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/InvalidValueHistoryTimeToLive.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/MissingVariableException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/MissingVariableException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/MissingVariableException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/MissingVariableException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/NoObjectFoundException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/NoObjectFoundException.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/NoObjectFoundException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/NoObjectFoundException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/NoRessourcesFoundException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/NoRessourcesFoundException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/NoRessourcesFoundException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/NoRessourcesFoundException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/OptimisticLockingException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/OptimisticLockingException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/OptimisticLockingException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/OptimisticLockingException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/PasswordPolicyException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/PasswordPolicyException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/PasswordPolicyException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/PasswordPolicyException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/SubmitDeniedException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/SubmitDeniedException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/SubmitDeniedException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/SubmitDeniedException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/SystemException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/SystemException.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/SystemException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/SystemException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/UnexpectedTypeException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/UnexpectedTypeException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/UnexpectedTypeException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/UnexpectedTypeException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/UnsupportedTypeException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/UnsupportedTypeException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/UnsupportedTypeException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/UnsupportedTypeException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/VariableModificationException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/VariableModificationException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/VariableModificationException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/VariableModificationException.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/WrongDeploymenIdException.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/WrongDeploymenIdException.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/exception/WrongDeploymenIdException.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/exception/WrongDeploymenIdException.java diff --git a/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/BpmProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/BpmProvider.java new file mode 100755 index 000000000..949bef716 --- /dev/null +++ b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/BpmProvider.java @@ -0,0 +1,1960 @@ +/* + * Copyright CIB software GmbH and/or licensed to CIB software GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. CIB software licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.cibseven.webapp.providers; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.cibseven.webapp.rest.model.Decision; +import org.cibseven.webapp.Data; +import org.cibseven.webapp.NamedByteArrayDataSource; +import org.cibseven.webapp.auth.CIBUser; +import org.cibseven.webapp.auth.rest.StandardLogin; +import org.cibseven.webapp.exception.ExpressionEvaluationException; +import org.cibseven.webapp.exception.InvalidAttributeValueException; +import org.cibseven.webapp.exception.InvalidUserIdException; +import org.cibseven.webapp.exception.NoObjectFoundException; +import org.cibseven.webapp.exception.SubmitDeniedException; +import org.cibseven.webapp.exception.SystemException; +import org.cibseven.webapp.exception.UnexpectedTypeException; +import org.cibseven.webapp.exception.UnsupportedTypeException; +import org.cibseven.webapp.rest.model.ActivityInstance; +import org.cibseven.webapp.rest.model.ActivityInstanceHistory; +import org.cibseven.webapp.rest.model.Authorization; +import org.cibseven.webapp.rest.model.Authorizations; +import org.cibseven.webapp.rest.model.Batch; +import org.cibseven.webapp.rest.model.CandidateGroupTaskCount; +import org.cibseven.webapp.rest.model.Deployment; +import org.cibseven.webapp.rest.model.DeploymentResource; +import org.cibseven.webapp.rest.model.Engine; +import org.cibseven.webapp.rest.model.EventSubscription; +import org.cibseven.webapp.rest.model.ExternalTask; +import org.cibseven.webapp.rest.model.Filter; +import org.cibseven.webapp.rest.model.HistoricDecisionInstance; +import org.cibseven.webapp.rest.model.HistoryBatch; +import org.cibseven.webapp.rest.model.IdentityLink; +import org.cibseven.webapp.rest.model.Incident; +import org.cibseven.webapp.rest.model.JobDefinition; +import org.cibseven.webapp.rest.model.Job; +import org.cibseven.webapp.rest.model.Message; +import org.cibseven.webapp.rest.model.Metric; +import org.cibseven.webapp.rest.model.NewUser; +import org.cibseven.webapp.rest.model.PasswordPolicyRequest; +import org.cibseven.webapp.rest.model.PasswordPolicyResponse; +import org.cibseven.webapp.rest.model.Process; +import org.cibseven.webapp.rest.model.ProcessDiagram; +import org.cibseven.webapp.rest.model.ProcessInstance; +import org.cibseven.webapp.rest.model.HistoryProcessInstance; +import org.cibseven.webapp.rest.model.ProcessStart; +import org.cibseven.webapp.rest.model.ProcessStatistics; +import org.cibseven.webapp.rest.model.SevenUser; +import org.cibseven.webapp.rest.model.SevenVerifyUser; +import org.cibseven.webapp.rest.model.StartForm; +import org.cibseven.webapp.rest.model.Task; +import org.cibseven.webapp.rest.model.TaskFiltering; +import org.cibseven.webapp.rest.model.TaskHistory; +import org.cibseven.webapp.rest.model.Tenant; +import org.cibseven.webapp.rest.model.User; +import org.cibseven.webapp.rest.model.UserGroup; +import org.cibseven.webapp.rest.model.Variable; +import org.cibseven.webapp.rest.model.VariableHistory; +import org.cibseven.webapp.rest.model.VariableInstance; +import org.springframework.http.ResponseEntity; +import org.springframework.util.MultiValueMap; +import org.springframework.web.multipart.MultipartFile; + +import com.fasterxml.jackson.databind.JsonNode; + +import jakarta.servlet.http.HttpServletRequest; + +public interface BpmProvider { + + IDeploymentProvider getDeploymentProvider(); + IVariableProvider getVariableProvider(); + IVariableInstanceProvider getVariableInstanceProvider(); + IHistoricVariableInstanceProvider getHistoricVariableInstanceProvider(); + ITaskProvider getTaskProvider(); + IProcessProvider getProcessProvider(); + IActivityProvider getActivityProvider(); + IFilterProvider getFilterProvider(); + IUtilsProvider getUtilsProvider(); + IIncidentProvider getIncidentProvider(); + IJobDefinitionProvider getJobDefinitionProvider(); + IUserProvider getUserProvider(); + IDecisionProvider getDecisionProvider(); + IJobProvider getJobProvider(); + IBatchProvider getBatchProvider(); + ISystemProvider getSystemProvider(); + ITenantProvider getTenantProvider(); + IExternalTaskProvider getExternalTaskProvider(); + IEngineProvider getEngineProvider(); + IIdentityProvider getIdentityProvider(); + + /* + +████████ █████ ███████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ███████ ███████ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + default Integer findTasksCount(Map filters, CIBUser user) throws SystemException { + return getTaskProvider().findTasksCount(filters, user); + } + + /** + * Search tasks which belongs to a specific process instance. + * @param processInstanceId filter by process instance id. + * @param user the user performing the search + * @return Fetched tasks. + * @throws SystemException in case of an error. + */ + default Collection findTasksByProcessInstance(String processInstanceId, CIBUser user) throws SystemException { + return getTaskProvider().findTasksByProcessInstance(processInstanceId, user); + } + + /** + * Search tasks which belongs to a specific process instance and a user. + * @param processInstanceId filter by process instance id. + * @param createdAfter filter by creation date. + * @param user the user performing the search + * @return Fetched tasks. + * @throws SystemException in case of an error. + */ + default Collection findTasksByProcessInstanceAsignee(Optional processInstanceId, + Optional createdAfter, CIBUser user) throws SystemException { + return getTaskProvider().findTasksByProcessInstanceAsignee(processInstanceId, createdAfter, user); + } + + /** + * Search task with a specific Id. + * @param taskId filter by task id. + * @param user the user performing the search + * @return Fetched task. + * @throws NoObjectFoundException when the task searched for could not be found. + * @throws SystemException in case of any other error. + */ + default Task findTaskById(String taskId, CIBUser user) throws SystemException { + return getTaskProvider().findTaskById(taskId, user); + } + + /** + * Update task. + * @param task to be updated with the desired values already modified. + * @param user the user performing the update + * @throws SystemException in case of an error. + */ + default void update(Task task, CIBUser user) throws SystemException { + getTaskProvider().update(task, user); + } + + /** + * Set assignee to an specific task. + * @param taskId filter by task id. + * @param assignee to be set as assignee. + * @param user the user performing the update + * @throws SystemException in case of an error. + */ + default void setAssignee(String taskId, String assignee, CIBUser user) throws SystemException { + getTaskProvider().setAssignee(taskId, assignee, user); + } + + /** + * Submit task without saving any variables, because that is done by the + * ui-element-template (in ours). + * + * @param taskId the ID of the task to be submitted. + * @param user the user performing the submission. + * @throws SubmitDeniedException when trying to submit a non-existing task. + * @throws SystemException in case of any other error. + */ + default void submit(String taskId, CIBUser user) throws SystemException, SubmitDeniedException { + getTaskProvider().submit(taskId, user); + } + + /** + * Submit task without saving any variables, because that is done by the ui-element-template (in ours). + * @param taskId the ID of the task to be submitted. + * @param user the user performing the submission. + * @throws SubmitDeniedException when trying to submit a non-existing task. + * @throws SystemException in case of any other error. + */ + default void submit(Task task, List formResult, CIBUser user) throws SystemException, SubmitDeniedException { + getTaskProvider().submit(task, formResult, user); + } + + /** + * Submits a task form to the process engine. + * + * @param taskId the id of the task the form belongs to + * @param formResult serialized form payload (usually JSON) to be submitted + * @param user the user performing the operation + * + * @throws SystemException in case of an error + */ + default void submit(String taskId, String formResult, CIBUser user) throws NoObjectFoundException, SystemException { + getTaskProvider().submit(taskId, formResult, user); + } + + /** + * Fetch form-reference variable from task. + * @param taskId filter by task id. + * @param user the user performing the search + * @return form-reference + * @throws NoObjectFoundException when the searched task could not be found. + * @throws SystemException in case of any other error. + */ + default Object formReference(String taskId, CIBUser user) throws SystemException { + return getTaskProvider().formReference(taskId, user); + } + + /** + * Retrieves the form configuration data associated with a specific task. + * + * @param taskId + * filter by task id. + * @param user + * the user performing the search + * @return TaskForm object containing key, camundaFormRef, and contextPath + * @throws NoObjectFoundException + * when the searched task could not be found. + * @throws SystemException + * in case of any other error. + */ + default Object form(String taskId, CIBUser user) throws SystemException { + return getTaskProvider().form(taskId, user); + } + + /** + * FindTask by filter + * @param filters list of properties which will be use to filter tasks. + * @param filterId to filter task. + * @param firstResult index of the first result to return. + * @param maxResults maximum number of results to return. + * @param user since this call is secured we need the user to authenticate. + * @return Collection of Tasks fetched in the search. + * @throws SystemException in case of an error. + */ + default Collection findTasksByFilter(TaskFiltering filters, String filterId, CIBUser user, Integer firstResult, Integer maxResults) throws SystemException { + return getTaskProvider().findTasksByFilter(filters, filterId, user, firstResult, maxResults); + } + + /** + * Find Tasks count by filter + * @param filterId to filter task. + * @param filters list of properties which will be use to filter tasks. + * @param user since this call is secured we need the user to authenticate. + * @return Collection of Tasks fetched in the search. + * @throws SystemException in case of an error. + */ + default Integer findTasksCountByFilter(String filterId, CIBUser user, TaskFiltering filters) throws SystemException { + return getTaskProvider().findTasksCountByFilter(filterId, user, filters); + } + + /** + * Search tasks which belongs to a specific process instance. + * The tasks found belongs to the history, they have other attributes and finished tasks + * are also fetched. + * @param processInstanceId filter by process instance id. + * @param user the user performing the search + * @return Fetched tasks. + * @throws SystemException in case of an error. + */ + default Collection findTasksByProcessInstanceHistory(String processInstanceId, CIBUser user) throws SystemException { + return getTaskProvider().findTasksByProcessInstanceHistory(processInstanceId, user); + } + + /** + * Search tasks which belongs to a specific process instance and filtered by a definition key. + * The tasks found belongs to the history, they have other attributes and finished tasks + * are also fetched. + * @param processInstanceId filter by process instance id. + * @param taskDefinitionKey restrict to tasks that have the given key. + * @param user the user performing the search + * @return Fetched tasks. + * @throws SystemException in case of an error. + */ + default Collection findTasksByDefinitionKeyHistory(String taskDefinitionKey, String processInstanceId, CIBUser user) throws SystemException { + return getTaskProvider().findTasksByDefinitionKeyHistory(taskDefinitionKey, processInstanceId, user); + } + + /** + * Required by OFDKA + * Queries for tasks that fulfill a given filter. This method is slightly more powerful than the Get Tasks method because it allows + * filtering by multiple process or task variables of types String, Number or Boolean. + * @param data variables to apply search. + * @param user the user performing the search. + * @return Collection tasks fetched in the search. + * @throws SystemException in case of an error. + */ + default Collection findTasksPost(Map data, CIBUser user) throws SystemException { + return getTaskProvider().findTasksPost(data, user); + } + + /** + * Identity links, e.g. to get the candidates user or groups of a task. + * + * @param taskId the ID of the task. + * @param type Filter by the type of links to include. e.g. "candidate". + * @param user the user performing the query. + * @return Collection of Identity Links. + */ + default Collection findIdentityLink(String taskId, Optional type, CIBUser user) { + return getTaskProvider().findIdentityLink(taskId, type, user); + } + + /** + * Create identity links, e.g., to set the candidates user or groups of a task. + * + * @param taskId the ID of the task. + * @param data a map containing the type of the identity link and group or user ID. + * @param user the user performing the operation. + * @throws SystemException in case of any other error. + */ + default void createIdentityLink(String taskId, Map data, CIBUser user) throws SystemException { + getTaskProvider().createIdentityLink(taskId, data, user); + } + + /** + * Delete identity links, e.g., to remove the candidates user or groups of a task. + * + * @param taskId the ID of the task. + * @param type a map containing the type of the identity link to be removed. + * @param user the user performing the operation. + * @throws SystemException in case of any other error. + */ + default void deleteIdentityLink(String taskId, Map data, CIBUser user) throws SystemException { + getTaskProvider().deleteIdentityLink(taskId, data, user); + } + + /** + * Reports a business error in the context of a running task by id. The error code must be specified to identify the BPMN error handler. + * @param taskId filter by task id. + * @param data variables for the BPMN error reporting. + * @param user the user performing the operation. + * @throws SystemException in case of any other error. + */ + default void handleBpmnError(String taskId, Map data, CIBUser user) throws SystemException { + getTaskProvider().handleBpmnError(taskId, data, user); + } + + default Collection findTasksByTaskIdHistory(String taskId, CIBUser user) throws SystemException { + return getTaskProvider().findTasksByTaskIdHistory(taskId, user); + } + + default ResponseEntity getDeployedForm(String taskId, CIBUser user) throws SystemException { + return getTaskProvider().getDeployedForm(taskId, user); + } + + default ResponseEntity getRenderedForm(String taskId, Map params, CIBUser user) { + return getTaskProvider().getRenderedForm(taskId, params, user); + } + default Integer findHistoryTasksCount(Map filters, CIBUser user) throws SystemException { + return getTaskProvider().findHistoryTasksCount(filters, user); + } + + default Collection getTaskCountByCandidateGroup(CIBUser user) { + return getTaskProvider().getTaskCountByCandidateGroup(user); + } + + /** + * Search tasks, which contains specified filter. + * + * @param filter applied in the search + * @param user the user performing the search + * @return Collection tasks fetched in the search. + * @throws SystemException in case of an error. + */ + default Collection findTasks(String filter, CIBUser user) throws SystemException { + return getTaskProvider().findTasks(filter, user); + } + +/* + +███████ ██ ██ ████████ ███████ ██████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +█████ ██ ██ ██ █████ ██████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + /** + * Search filters. + * @param user the user performing the query. + * @return Collection of Filters fetched in the search. + * @throws SystemException in case of an error. + */ + default Collection findFilters(CIBUser user) throws SystemException { + return getFilterProvider().findFilters(user); + } + + /** + * Create filter. + * @param filter to be created. + * @param user the user performing the creation. + * @throws SystemException in case of an error. + */ + default Filter createFilter(Filter filter, CIBUser user) throws SystemException { + return getFilterProvider().createFilter(filter, user); + } + + /** + * Update filter. + * @param filter to be updated. + * @param user the user performing the update. + * @throws NoObjectFoundException when the filter to be changed could not be found. + * @throws SystemException in case of any other error. + */ + default void updateFilter(Filter filter, CIBUser user) throws SystemException, NoObjectFoundException { + getFilterProvider().updateFilter(filter, user); + } + + /** + * Delete filter. + * @param filterId the ID of the filter to be deleted. + * @param user the user performing the deletion. + * @throws SystemException in case of an error. + */ + default void deleteFilter(String filterId, CIBUser user) throws SystemException { + getFilterProvider().deleteFilter(filterId, user); + } + +/* + +██████ ███████ ██████ ██ ██████ ██ ██ ███ ███ ███████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ █████ ██████ ██ ██ ██ ████ ██ ████ ██ █████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██████ ███████ ██ ███████ ██████ ██ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + /** + * Deploy process-bpmn. + * @param data metadata of the diagram to be deployed (deployment-name, deployment-source, deploy-changed-only). + * @param file of the diagram to be deployed. + * @param user the user performing the deployment. + * @return Deployment information. + * @throws SystemException in case of any other error. + */ + default Deployment deployBpmn(MultiValueMap data, MultiValueMap file, CIBUser user) throws SystemException { + return getDeploymentProvider().deployBpmn(data, file, user); + } + + /** + * Retrieves number of all deployments with provided query. + * @param user the user performing the search. + * @return Fetched deployments. + * @throws SystemException in case of any other error. + */ + default Long countDeployments(CIBUser user, String nameLike) throws SystemException { + return getDeploymentProvider().countDeployments(user, nameLike); + } + + /** + * Retrieves all deployments matched with provided query. + * @param user the user performing the search. + * @return Fetched deployments. + * @throws SystemException in case of any other error. + */ + default Collection findDeployments(CIBUser user, String nameLike, int firstResult, int maxResults, String sortBy, String sortOrder) throws SystemException { + return getDeploymentProvider().findDeployments(user, nameLike, firstResult, maxResults, sortBy, sortOrder); + } + + /** + * Retrieves all deployment resources of a given deployment. + * @param deploymentId the ID of the deployment. + * @param user the user performing the query. + * @return Fetched deployment resources. + * @throws SystemException in case of any other error. + */ + default Deployment findDeployment(String deploymentId, CIBUser user) throws SystemException { + return getDeploymentProvider().findDeployment(deploymentId, user); + } + + /** + * Search deployment with a specific Id. + * @param deploymentId the ID of the deployment. + * @return Fetched deployment. + * @throws SystemException in case of any other error. + */ + default Collection findDeploymentResources(String deploymentId, CIBUser user) throws SystemException { + return getDeploymentProvider().findDeploymentResources(deploymentId, user); + } + + /** + * Retrieves the binary content of a deployment resource for the given deployment by id. + * @param rq the HTTP request. + * @param deploymentId the ID of the deployment. + * @param resourceId the ID of the resource. + * @param fileName the name of the file. + * @param user the authenticated user. + * @return resource data. + * @throws SystemException in case of any other error. + */ + default Data fetchDataFromDeploymentResource(HttpServletRequest rq, String deploymentId, String resourceId, String fileName, CIBUser user) throws SystemException { + return getDeploymentProvider().fetchDataFromDeploymentResource(rq, deploymentId, resourceId, fileName, user); + } + + /** + * Delete deployment by an Id. + * @param deploymentId the ID of the deployment. + * @param cascade whether to cascade the deletion. + * @param user the user performing the deletion. + * @throws SystemException in case of any other error. + */ + default void deleteDeployment(String deploymentId, Boolean cascade, CIBUser user) throws SystemException { + getDeploymentProvider().deleteDeployment(deploymentId, cascade, user); + } + + /** + * Creates a new deployment using the Camunda REST API. + * + * @param data the deployment parameters (deployment-name, deployment-source, tenant-id, etc.) + * @param files the files to deploy (DMN, BPMN, etc.) + * @param user the user creating the deployment + * @return the created deployment + * @throws SystemException in case of an error + */ + default Deployment createDeployment(MultiValueMap data, MultipartFile[] files, CIBUser user) throws SystemException { + return getDeploymentProvider().createDeployment(data, files, user); + } + + /** + * Redeploy an existing deployment. + * For every contained decision or process definition a new version will be created. + * + * @param id the ID of the deployment to redeploy + * @param data the redeployment parameters (tenantId, source, resourceIds, resourceNames) + * @param user the user performing the redeployment + * @return the newly created deployment + * @throws SystemException in case of an error + */ + default Deployment redeployDeployment(String id, Map data, CIBUser user) throws SystemException { + return getDeploymentProvider().redeployDeployment(id, data, user); + } + +/* + + █████ ██████ ████████ ██ ██ ██ ██ ████████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ██ ██ ██ ██ ██ ██ ██ ████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ ██████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + /** + * Search activity that belong to a process instance. + * @param processInstanceId filter by process instance id. + * @param user the user performing the search + * @return Fetched activity. + * @throws NoObjectFoundException when the searched process instance could not be found. + * @throws SystemException in case of any other error. + */ + default ActivityInstance findActivityInstance(String processInstanceId, CIBUser user) throws SystemException, NoObjectFoundException { + return getActivityProvider().findActivityInstance(processInstanceId, user); + } + + /** + * Queries for historic activity instances that fulfill the given parameters. + * The activities found belong to the history. + * @param queryParams a map of parameters to filter the query. + * @param user the user performing the query. + * @return Fetched Historic Activity Instances. + * @throws InvalidAttributeValueException when the tenant of a task could not be changed or when the delegation state of a task should be changed to an invalid value. + * @throws SystemException in case of any other error. + */ + default List findActivitiesInstancesHistory(Map queryParams, CIBUser user) throws SystemException, InvalidAttributeValueException { + return getActivityProvider().findActivitiesInstancesHistory(queryParams, user); + } + + /** + * Search activities instances that belong to a process instance. The activities found belongs + * to the history, they have other attributes and activities from finished processes are also fetched. + * @param processInstanceId filter by process instance id. + * @param user the user performing the search + * @return Fetched Activity Instance. + * @throws InvalidAttributeValueException when the tenant of a task could not be changed or when the delegation state of a task should be changed to an invalid value. + * @throws SystemException in case of any other error. + */ + default List findActivitiesInstancesHistory(String processInstanceId, CIBUser user) throws SystemException, InvalidAttributeValueException { + return getActivityProvider().findActivitiesInstancesHistory(processInstanceId, user); + } + + /*UI Element templates methods migrated*/ + + default ActivityInstance findActivityInstances(String processInstanceId, CIBUser user) throws SystemException { + return getActivityProvider().findActivityInstances(processInstanceId, user); + } + + default List findActivityInstanceHistory(String processInstanceId, CIBUser user) throws SystemException { + return getActivityProvider().findActivityInstanceHistory(processInstanceId, user); + } + + default void deleteVariableByExecutionId(String executionId, String variableName, CIBUser user) { + getActivityProvider().deleteVariableByExecutionId(executionId, variableName, user); + } + + default void deleteVariableHistoryInstance(String id, CIBUser user) { + getActivityProvider().deleteVariableHistoryInstance(id, user); + } + + default Collection findActivitiesProcessDefinitionHistory(String processDefinitionId, Map params, CIBUser user) { + return getActivityProvider().findActivitiesProcessDefinitionHistory(processDefinitionId, params, user); + } + +/* + +██ ██ ███████ ███████ ██████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ ███████ █████ ██████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██████ ███████ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + /** + * Get authorizations, filtered by userId and groups in which user belongs. + * @param userId filter user identification (username). + * @param user the user performing the search + * @return Fetched bpmn + * @throws SystemException in case of an error. + */ + default Authorizations getUserAuthorization(String userId, CIBUser user) throws SystemException { + return getUserProvider().getUserAuthorization(userId, user); + } + + default Collection fetchUsers(CIBUser user) throws SystemException { + return getUserProvider().fetchUsers(user); + } + + /** + * + * @param username login user + * @param password login password + * @param user the calling user + * @return verification + * @throws SystemException + */ + default SevenVerifyUser verifyUser(StandardLogin login, CIBUser user) throws SystemException { + return getUserProvider().verifyUser(login, user); + } + + /** + * The following methods related to the Admin Section. + * They are all created but need first to check if those are used in webclient. If not we should remove them from here. + * IMPORTANT: Methods related to users/groups need to check if they are allowed to be created or removed (LDAP or Camunda) + * then it only make sense to use them when SevenProvider is selected. + */ + + /** + * Get users by id, .... + * + * @param id, // Filter by the id of the user. + * @param firstName, // Filter by the firstname of the user. + * @param firstNameLike, // Filter by the firstname that the parameter is a substring of. + * @param lastName, // Filter by the lastname of the user. + * @param lastNameLike, // Filter by the lastname that the parameter is a substring of. + * @param email , // Filter by the email of the user. + * @param emailLike, // Filter by the email that the parameter is a substring of. + * @param memberOfGroup, // Filter for users which are members of the given group. + * @param memberOfTenant , // Filter for users which are members of the given tenant. + * + * @param user CIBSevenUser + * @return Collection of Users. + */ + default Collection findUsers(Optional id, Optional firstName, Optional firstNameLike, Optional lastName, Optional lastNameLike, + Optional email, Optional emailLike, Optional memberOfGroup, Optional memberOfTenant, Optional idIn, + Optional firstResult, Optional maxResults, Optional sortBy, Optional sortOrder, Optional likePatternIgnoreCase, CIBUser user) { + return getUserProvider().findUsers(id, firstName, firstNameLike, lastName, lastNameLike, email, emailLike, memberOfGroup, memberOfTenant, idIn, firstResult, maxResults, sortBy, sortOrder, likePatternIgnoreCase, user); + } + + /** + * Get the count of users in the system with optional filters. + * + * @param filters the filters to apply (e.g., memberOfGroup). Can be null or empty for no filtering. + * @param user the user performing the operation. + * @return the count of users matching the filters. + */ + default long countUsers(Map filters, CIBUser user) { + return getUserProvider().countUsers(filters, user); + } + + /** + * Create a new user. + * + * @param user the new user to be created. + * @param flowUser the user performing the creation. + * @throws InvalidUserIdException when the user ID is invalid. + */ + default void createUser(NewUser user, CIBUser flowUser) throws InvalidUserIdException { + getUserProvider().createUser(user, flowUser); + } + + /** + * Updates a user’s profile. + * + * @param userId the ID of the user to be updated. + * @param user the user to Update. + * @param flowUser the user performing the update. + */ + default void updateUserProfile(String userId, User user, CIBUser flowUser) { + getUserProvider().updateUserProfile(userId, user, flowUser); + } + + /** + * Updates a user’s credentials (password). + * + * @param userId the ID of the user to be updated. + * @param data Request Body + * A JSON object with the following properties: + * Name Type Description + * password String The user's new password. + * authenticatedUserPassword String The password of the authenticated user who changes the password of the user (i.e., the user with passed id as path parameter). + * @param user the user performing the update. + */ + default void updateUserCredentials(String userId, Map data, CIBUser user) { + getUserProvider().updateUserCredentials(userId, data, user); + } + + /** + * Get groups by id, .... + * + * @param id // Filter by the id of the group. + * @param name // Filter by the name of the group. + * @param nameLike // Filter by the name that the parameter is a substring of. + * @param type // Filter by the type of the group. + * @param member // Only retrieve groups which the given user id is a member of. + * @param memberOfTenant // Only retrieve groups which are members of the given tenant. + * @param sortBy // Sort the results lexicographically by a given criterion. Valid values are id, name and type. Must be used in conjunction with the sortOrder parameter. + * @param sortOrder // Sort the results in a given order. Values may be asc for ascending order or desc for descending order. Must be used in conjunction with the sortBy parameter. + * @param firstResult // Pagination of results. Specifies the index of the first result to return. + * @param maxResults // Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left. + * + * @param user the user performing the search. + * @return Collection of User Groups. + */ + default Collection findGroups(Optional id, Optional name, Optional nameLike, Optional type, + Optional member, Optional memberOfTenant, Optional sortBy, Optional sortOrder, Optional firstResult, + Optional maxResults, CIBUser user) { + return getUserProvider().findGroups(id, name, nameLike, type, member, memberOfTenant, sortBy, sortOrder, firstResult, maxResults, user); + } + + /** + * Create a group. + * + * @param group the group to be created. + * @param user the user performing the creation. + */ + default void createGroup(UserGroup group, CIBUser user) { + getUserProvider().createGroup(group, user); + } + + /** + * Updates a group. + * + * @param groupId the ID of the group to be updated. + * @param group the group to be updated. + * @param user the user performing the update. + */ + default void updateGroup(String groupId, UserGroup group, CIBUser user) { + getUserProvider().updateGroup(groupId, group, user); + } + + /** + * Deletes a group by id. + * + * @param groupId the ID of the group to be deleted. + * @param user the user performing the deletion. + */ + default void deleteGroup(String groupId, CIBUser user) { + getUserProvider().deleteGroup(groupId, user); + } + + /** + * Get Authorization by id, .... + * + * @param id // Filter by the id. + * @param type // Filter by authorization type. (0=global, 1=grant, 2=revoke). See the User Guide for more information about authorization types. + * @param userIdIn // Filter by a comma-separated list of userIds. + * @param groupIdIn // Filter by a comma-separated list of groupIds. + * @param resourceType // Filter by an integer representation of the resource type. See the User Guide for a list of integer representations of resource types. + * @param resourceId // Filter by resource id. * @param sortBy, // Sort the results lexicographically by a given criterion. Valid values are id, name and type. Must be used in conjunction with the sortOrder parameter. + * @param sortBy // Sort the results lexicographically by a given criterion. Valid values are id, name and type. Must be used in conjunction with the sortOrder parameter. + * @param sortOrder // Sort the results in a given order. Values may be asc for ascending order or desc for descending order. Must be used in conjunction with the sortBy parameter. + * @param firstResult // Pagination of results. Specifies the index of the first result to return. + * @param maxResults // Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left. + * @param user the user performing the search. + * @return Collection of Authorizations. + */ + default Collection findAuthorization(Optional id, Optional type, Optional userIdIn, Optional groupIdIn, + Optional resourceType, Optional resourceId, Optional sortBy, Optional sortOrder, Optional firstResult, + Optional maxResults, CIBUser user) { + return getUserProvider().findAuthorization(id, type, userIdIn, groupIdIn, resourceType, resourceId, sortBy, sortOrder, firstResult, maxResults, user); + } + + /** + * Create an authorization. + * + * @param authorization the authorization to be created. + * @param user the user performing the creation. + * @return ResponseEntity containing the created authorization. + */ + default ResponseEntity createAuthorization(Authorization authorization, CIBUser user) { + return getUserProvider().createAuthorization(authorization, user); + } + + /** + * Update an authorization by id. + * + * @param authorizationId the ID of the authorization to be updated. + * @param data the data to update. + * @param user the user performing the update. + */ + default void updateAuthorization(String authorizationId, Map data, CIBUser user) { + getUserProvider().updateAuthorization(authorizationId, data, user); + } + + /** + * Deletes an authorization by id. + * + * @param authorizationId the ID of the authorization to be deleted. + * @param user the user performing the deletion. + */ + default void deleteAuthorization(String authorizationId, CIBUser user) { + getUserProvider().deleteAuthorization(authorizationId, user); + } + +/* + +██ ██ █████ ██████ ██ █████ ██████ ██ ███████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ ███████ ██████ ██ ███████ ██████ ██ █████ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ████ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ███████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + +/** + * Modify a variable in the Process Instance. + * @param executionId Id of the execution. + * @param data to be updated. + * @param user User who is modifying the variable. + * @throws SystemException in case of any other error. + */ + default void modifyVariableByExecutionId(String executionId, Map data, CIBUser user) throws SystemException { + getVariableProvider().modifyVariableByExecutionId(executionId, data, user); + } + + /** + * Modify a variable data in the Process Instance. + * @param executionId the ID of the execution. + * @param variableName the name of the variable. + * @param data the file containing the data to be updated. + * @param valueType the type of the variable. Enum with the possible values: "File", "Bytes". + * @param user the user modifying the variable. + * @throws SystemException in case of any other error. + */ + default void modifyVariableDataByExecutionId(String executionId, String variableName, MultipartFile data, String valueType, CIBUser user) throws SystemException { + getVariableProvider().modifyVariableDataByExecutionId(executionId, variableName, data, valueType, user); + } + + /** + * Fetch a variables from a process instance. + * @param processInstanceId Id of the instance. + * @param data a map of parameters to filter the query. + * @param user User who is fetching the variables. + * @return Data. + * @throws SystemException in case of any other error. + */ + default Collection fetchProcessInstanceVariables(String processInstanceId, Map data, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchProcessInstanceVariables(processInstanceId, data, user); + } + + /** + * Fetch a variable data in the Process Instance. + * @param executionId Id of the execution. + * @param variableName Name of the variable. + * @param user User who is fetching the variable. + * @return Data. + * @throws SystemException in case of any other error. + */ + default ResponseEntity fetchVariableDataByExecutionId(String executionId, String variableName, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchVariableDataByExecutionId(executionId, variableName, user); + } + + /** + * Fetch a variable data in from the process history. + * @param id Id of the variable. + * @param user User who is modifying the variable. + * @return Data. + * @throws SystemException in case of any other error. + */ + default ResponseEntity fetchHistoryVariableDataById(String id, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchHistoryVariableDataById(id, user); + } + + /** + * Fetch variables from a specific process instance. + * The variables found belong to the history, they have other attributes, and variables from finished process instances are also fetched. + * @param processInstanceId filter by process instance id. + * @param data a map of parameters to filter the query. + * @param user the user performing the search + * @return Fetched variables. + * @throws SystemException in case of an error. + */ + default Collection fetchProcessInstanceVariablesHistory(String processInstanceId, Map data, CIBUser user) throws SystemException { + return getVariableProvider().fetchProcessInstanceVariablesHistory(processInstanceId, data, user); + } + + /** + * Fetch variables from a specific activity. + * The variables found belongs to the history, they have other attributes + * and variables from finished activities are also fetched. + * @param activityInstanceId filter by activity instance id. + * @param user the user performing the search + * @return Fetched variables. + * @throws SystemException in case of an error. + */ + default Collection fetchActivityVariablesHistory(String activityInstanceId, CIBUser user) throws SystemException { + return getVariableProvider().fetchActivityVariablesHistory(activityInstanceId, user); +} + + /** + * Fetch variables from a specific activity. + * @param activityInstanceId filter by activity instance id. + * @param user the user performing the search + * @return Fetched variables. + * @throws SystemException in case of an error. + */ + default Collection fetchActivityVariables(String activityInstanceId, CIBUser user) throws SystemException { + return getVariableProvider().fetchActivityVariables(activityInstanceId, user); + } + + default Variable fetchVariable(String taskId, String variableName, + boolean deserializeValue, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchVariable(taskId, variableName, deserializeValue, user); + } + + default void deleteVariable(String taskId, String variableName, CIBUser user) throws NoObjectFoundException, SystemException { + getVariableProvider().deleteVariable(taskId, variableName, user); + } + + default Map fetchFormVariables(String taskId, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchFormVariables(taskId, deserializeValues, user); + } + + default Map fetchFormVariables(List variableListName, String taskId, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchFormVariables(variableListName, taskId, deserializeValues, user); + } + + default Map fetchProcessFormVariables(String key, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchProcessFormVariables(key, deserializeValues, user); + } + + default Map fetchProcessFormVariables(List variableListName, String key, boolean deserializeValues, CIBUser user) + throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchProcessFormVariables(variableListName, key, deserializeValues, user); + } + + default NamedByteArrayDataSource fetchVariableFileData(String taskId, String variableName, CIBUser user) throws NoObjectFoundException, UnexpectedTypeException, SystemException { + return getVariableProvider().fetchVariableFileData(taskId, variableName, user); + } + + default void uploadVariableFileData(String taskId, String variableName, MultipartFile data, String valueType, CIBUser user) throws NoObjectFoundException, SystemException { + getVariableProvider().uploadVariableFileData(taskId, variableName, data, valueType, user); + } + + default ResponseEntity fetchProcessInstanceVariableData(String processInstanceId, String variableName, + CIBUser user) throws NoObjectFoundException, SystemException { + return getVariableProvider().fetchProcessInstanceVariableData(processInstanceId, variableName, user); + } + + default void uploadProcessInstanceVariableFileData(String processInstanceId, String variableName, MultipartFile data, String valueType, CIBUser user) throws NoObjectFoundException, SystemException { + getVariableProvider().uploadProcessInstanceVariableFileData(processInstanceId, variableName, data, valueType, user); + } + + default ProcessStart submitStartFormVariables(String processDefinitionId, List formResult, CIBUser user) throws SystemException { + return getVariableProvider().submitStartFormVariables(processDefinitionId, formResult, user); + } + + default Variable fetchVariableByProcessInstanceId(String processInstanceId, String variableName, CIBUser user) throws SystemException { + return getVariableProvider().fetchVariableByProcessInstanceId(processInstanceId, variableName, user); + } + + default void saveVariableInProcessInstanceId(String processInstanceId, List variables, CIBUser user) throws SystemException { + getVariableProvider().saveVariableInProcessInstanceId(processInstanceId, variables, user); + } + + default void submitVariables(String processInstanceId, List formResult, CIBUser user, String processDefinitionId) throws SystemException { + getVariableProvider().submitVariables(processInstanceId, formResult, user, processDefinitionId); + } + + default Map fetchProcessFormVariablesById(String id, CIBUser user) throws SystemException { + return getVariableProvider().fetchProcessFormVariablesById(id, user); + } + + default void putLocalExecutionVariable(String executionId, String varName, Map data, CIBUser user) { + getVariableProvider().putLocalExecutionVariable(executionId, varName, data, user); + } + +/* + +██████ ███████ ██████ ██ ███████ ██ ██████ ███ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ █████ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██████ ███████ ██████ ██ ███████ ██ ██████ ██ ████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + default Collection getDecisionDefinitionList(Map queryParams, CIBUser user) { + return getDecisionProvider().getDecisionDefinitionList(queryParams, user); + } + + default Long getDecisionDefinitionListCount(Map queryParams, CIBUser user) { + return getDecisionProvider().getDecisionDefinitionListCount(queryParams, user); + } + + default Decision getDecisionDefinitionByKey(String key, CIBUser user) { + return getDecisionProvider().getDecisionDefinitionByKey(key, user); + } + + default Object getDiagramByKey(String key, CIBUser user) { + return getDecisionProvider().getDiagramByKey(key, user); + } + + default Object evaluateDecisionDefinitionByKey(Map data, String key, CIBUser user) { + return getDecisionProvider().evaluateDecisionDefinitionByKey(data, key, user); + } + + default void updateHistoryTTLByKey(Map data, String key, CIBUser user) { + getDecisionProvider().updateHistoryTTLByKey(data, key, user); + } + + default Object getDiagramByKeyAndTenant(String key, String tenant, CIBUser user) { + return getDecisionProvider().getDiagramByKeyAndTenant(key, tenant, user); + } + + default Object evaluateDecisionDefinitionByKeyAndTenant(Map data, String key, String tenant, CIBUser user) { + //TODO: not implemented in DecisionProvider + //interface should contain parameters like evaluateDecisionDefinitionByKey + return getDecisionProvider().evaluateDecisionDefinitionByKeyAndTenant(data, key, tenant, user); + } + + default void updateHistoryTTLByKeyAndTenant(Map data, String key, String tenant, CIBUser user) { + //TODO: not implemented in DecisionProvider + //interface should contain parameters like HistoryTTLByKey + getDecisionProvider().updateHistoryTTLByKeyAndTenant(data, key, tenant, user); + } + + default Object getXmlByKey(String key, CIBUser user) { + return getDecisionProvider().getXmlByKey(key, user); + } + + default Object getXmlByKeyAndTenant(String key, String tenant, CIBUser user) { + return getDecisionProvider().getXmlByKeyAndTenant(key, tenant, user); + } + + default Decision getDecisionDefinitionByKeyAndTenant(String key, String tenant, CIBUser user) { + return getDecisionProvider().getDecisionDefinitionByKeyAndTenant(key, tenant, user); + } + + default Decision getDecisionDefinitionById(String id, Optional extraInfo, CIBUser user) { + return getDecisionProvider().getDecisionDefinitionById(id, extraInfo, user); + } + + default Object getDiagramById(String id, CIBUser user) { + return getDecisionProvider().getDiagramById(id, user); + } + + default Object evaluateDecisionDefinitionById(String id, Map data, CIBUser user) { + //TODO: not implemented in DecisionProvider + return getDecisionProvider().evaluateDecisionDefinitionById(id, data, user); + } + + default void updateHistoryTTLById(String id, Map data, CIBUser user) { + getDecisionProvider().updateHistoryTTLById(id, data, user); + } + + default Object getXmlById(String id, CIBUser user) throws SystemException { + return getDecisionProvider().getXmlById(id, user); + } + + default Collection getDecisionVersionsByKey(String key, Optional lazyLoad, CIBUser user) { + return getDecisionProvider().getDecisionVersionsByKey(key, lazyLoad, user); + } + + default Collection getHistoricDecisionInstances(Map queryParams, CIBUser user) { + return getDecisionProvider().getHistoricDecisionInstances(queryParams, user); + } + + default Long getHistoricDecisionInstanceCount(Map queryParams, CIBUser user) { + return getDecisionProvider().getHistoricDecisionInstanceCount(queryParams, user); + } + + default HistoricDecisionInstance getHistoricDecisionInstanceById(String id, Map queryParams, CIBUser user) { + return getDecisionProvider().getHistoricDecisionInstanceById(id, queryParams, user); + } + + default Object deleteHistoricDecisionInstances(Map data, CIBUser user) { + return getDecisionProvider().deleteHistoricDecisionInstances(data, user); + } + + default Object setHistoricDecisionInstanceRemovalTime(Map data, CIBUser user) { + return getDecisionProvider().setHistoricDecisionInstanceRemovalTime(data, user); + } + +/* + + ██ ██████ ██████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + █████ ██████ ██████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + default Collection findJobDefinitions(String params, CIBUser user) { + return getJobDefinitionProvider().findJobDefinitions(params, user); + } + + default void suspendJobDefinition(String jobDefinitionId, String params, CIBUser user) { + getJobDefinitionProvider().suspendJobDefinition(jobDefinitionId, params, user); + } + + default void overrideJobDefinitionPriority(String jobDefinitionId, String params, CIBUser user) { + getJobDefinitionProvider().overrideJobDefinitionPriority(jobDefinitionId, params, user); + } + + default void retryJobDefinitionById(String id, Map params, CIBUser user) { + getJobDefinitionProvider().retryJobDefinitionById(id, params, user); + } + + default Collection getJobs(Map params, CIBUser user) { + return getJobProvider().getJobs(params, user); + } + + default void setSuspended(String id, Map params, CIBUser user) { + getJobProvider().setSuspended(id, params, user); + } + + default void deleteJob(String id, CIBUser user) { + getJobProvider().deleteJob(id, user); + } + + default JobDefinition findJobDefinition(String id, CIBUser user) { + return getJobDefinitionProvider().findJobDefinition(id, user); + } + + default Collection getHistoryJobLog(Map params, CIBUser user) { + return getJobProvider().getHistoryJobLog(params, user); + } + + default String getHistoryJobLogStacktrace(String id, CIBUser user) { + return getJobProvider().getHistoryJobLogStacktrace(id, user); + } + + default void changeDueDate(String id, Map data, CIBUser user) { + getJobProvider().changeDueDate(id, data, user); + } + + default void recalculateDueDate(String id, Map params, CIBUser user) { + getJobProvider().recalculateDueDate(id, params, user); + } + +/* + +██████ █████ ████████ ██████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██████ ███████ ██ ██ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██████ ██ ██ ██ ██████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + default Collection getBatches(Map params, CIBUser user) { + return getBatchProvider().getBatches(params, user); + } + + default Collection getBatchStatistics(Map params, CIBUser user) { + return getBatchProvider().getBatchStatistics(params, user); + } + + default void deleteBatch(String id, Map params, CIBUser user) { + getBatchProvider().deleteBatch(id, params, user); + } + + default void setBatchSuspensionState(String id, Map params, CIBUser user) { + getBatchProvider().setBatchSuspensionState(id, params, user); + } + + default Collection getHistoricBatches(Map params, CIBUser user) { + return getBatchProvider().getHistoricBatches(params, user); + } + + default Long getRuntimeBatchCount(Map queryParams, CIBUser user) { + return getBatchProvider().getRuntimeBatchCount(queryParams, user); + } + + default Long getHistoricBatchCount(Map queryParams, CIBUser user) { + return getBatchProvider().getHistoricBatchCount(queryParams, user); + } + + default HistoryBatch getHistoricBatchById(String id, CIBUser user) { + return getBatchProvider().getHistoricBatchById(id, user); + } + + default void deleteHistoricBatch(String id, CIBUser user) { + getBatchProvider().deleteHistoricBatch(id, user); + } + + default Object setRemovalTime(Map payload, CIBUser user) { + return getBatchProvider().setRemovalTime(payload, user); + } + + default Object getCleanableBatchReport(Map queryParams, CIBUser user) { + return getBatchProvider().getCleanableBatchReport(queryParams, user); + } + + default Object getCleanableBatchReportCount(CIBUser user) { + return getBatchProvider().getCleanableBatchReportCount(user); + } + +/* + +███████ ██ ██ ███████ ████████ ███████ ███ ███ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ████ ███████ ██ █████ ██ ████ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + default JsonNode getTelemetryData(CIBUser user) { + return getSystemProvider().getTelemetryData(user); + } + + default Collection getMetrics(Map queryParams, CIBUser user) { + return getSystemProvider().getMetrics(queryParams, user); + } + +/* + +██ ██ █████ ██████ ██ █████ ██████ ██ ███████ ██ ███ ██ ███████ ████████ █████ ███ ██ ██████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ ███████ ██████ ██ ███████ ██████ ██ █████ ██ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ████ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ███████ ██ ██ ████ ███████ ██ ██ ██ ██ ████ ██████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + // Variable Instance method + /** + * Retrieves a variable instance by its ID. + * @param id The ID of the variable instance + * @param deserializeValue Whether to deserialize the variable value or not + * @param user the user performing the search + * @return Variable instance details + * @throws SystemException in case of an error + * @throws NoObjectFoundException when the variable instance could not be found + */ + default VariableInstance getVariableInstance(String id, boolean deserializeValue, CIBUser user) throws SystemException, NoObjectFoundException { + return getVariableInstanceProvider().getVariableInstance(id, deserializeValue, user); + } + +/* + +██ ██ ██ ███████ ████████ ██████ ██████ ██ ██████ ██ ██ █████ ██████ ██ █████ ██████ ██ ███████ ██ ███ ██ ███████ ████████ █████ ███ ██ ██████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ██ ███████ ██ ██ ██ ██████ ██ ██ ██ ██ ███████ ██████ ██ ███████ ██████ ██ █████ ██ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +██ ██ ██ ███████ ██ ██████ ██ ██ ██ ██████ ████ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ███████ ██ ██ ████ ███████ ██ ██ ██ ██ ████ ██████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + /** + * Retrieves a historic variable instance by its ID. + * @param id The ID of the historic variable instance + * @param deserializeValue Whether to deserialize the variable value or not + * @param user the user performing the search + * @return Historic variable instance details + * @throws SystemException in case of an error + * @throws NoObjectFoundException when the historic variable instance could not be found + */ + default VariableHistory getHistoricVariableInstance(String id, boolean deserializeValue, CIBUser user) throws SystemException, NoObjectFoundException { + return getHistoricVariableInstanceProvider().getHistoricVariableInstance(id, deserializeValue, user); + } + +/* + +███████ ██ ██ ████████ ███████ ██████ ███ ██ █████ ██ ████████ █████ ███████ ██ ██ ██ ██████ ██████ +██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +█████ ███ ██ █████ ██████ ██ ██ ██ ███████ ██ ██ ███████ ███████ █████ ██ ██ ██ ██ ███ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ██ ██ ██ ███████ ██ ██ ██ ████ ██ ██ ███████ ██ ██ ██ ███████ ██ ██ ███████ ██████ ██████ + +*/ + + /** + * Get external tasks based on query parameters + * + * @param queryParams Query parameters for filtering external tasks + * @param user the user performing the operation + * @return Collection of external tasks + * @throws SystemException in case of an error + */ + default Collection getExternalTasks(Map queryParams, CIBUser user) throws SystemException { + return getExternalTaskProvider().getExternalTasks(queryParams, user); + } + + /* + + ██████ ██████ ██████ ██████ ███████ ███████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██████ ██████ ██ ██ ██ █████ ███████ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ██ ██████ ██████ ███████ ███████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + /** + * Search processes. + * @param user the user performing the search + * @return Fetched processes. + * @throws InvalidAttributeValueException when searching for processes with at least one invalid parameter value. + * @throws SystemException in case of any other error. + */ + default Collection findProcesses(CIBUser user) throws SystemException { + return getProcessProvider().findProcesses(user); + } + + /** + * Search processes with number of process instances and incidents. + * @param user the user performing the search + * @return Fetched processes. + * @throws InvalidAttributeValueException when searching for processes with at least one invalid parameter value. + * @throws SystemException in case of any other error. + */ + default Collection findProcessesWithInfo(CIBUser user) throws SystemException { + return getProcessProvider().findProcessesWithInfo(user); + } + + /** + * Search processes. + * @param filters filters to be applied. + * @param user the user performing the search + * @return Fetched processes. + * @throws InvalidAttributeValueException when searching for processes with at least one invalid parameter value. + * @throws SystemException in case of any other error. + */ + default Collection findProcessesWithFilters(String filters, CIBUser user) throws SystemException { + return getProcessProvider().findProcessesWithFilters(filters, user); + } + + /** + * Search process with a specific Key. + * @param processKey filter by process definition key. + * @param tenantId + * @param user since this call is secured we need the user to authenticate. + * @return Fetched process. + * @throws SystemException in case of an error. + */ + default Process findProcessByDefinitionKey(String key, String tenantId, CIBUser user) throws SystemException { + return getProcessProvider().findProcessByDefinitionKey(key, tenantId, user); + } + + /** + * Search processes (diferents versions) with a specific Key. + * @param processKey filter by process definition key. + * @param tenantId + * @param lazyLoad parameter to decide if load all the data or the minimum necessary. + * @param user since this call is secured we need the user to authenticate. + * @return Fetched process. + * @throws SystemException in case of an error. + */ + default Collection findProcessVersionsByDefinitionKey(String key, String tenantId, Optional lazyLoad, CIBUser user) throws SystemException { + return getProcessProvider().findProcessVersionsByDefinitionKey(key, tenantId, lazyLoad, user); + } + + /** + * Search process with a specific Id. + * @param id filter by process definition id. + * @param extraInfo parameter to specify if more data will be loaded. + * @param user the user performing the query. + * @return Fetched process. + * @throws SystemException in case of an error. + */ + default Process findProcessById(String id, Optional extraInfo, CIBUser user) throws SystemException { + return getProcessProvider().findProcessById(id, extraInfo, user); + } + + /** + * Search processes instances with a specific process key. + * @param key the process key to filter by. + * @param user the user performing the search + * @return Fetched processes instances. + * @throws SystemException in case of an error. + */ + default Collection findProcessesInstances(String key, CIBUser user) throws SystemException { + return getProcessProvider().findProcessesInstances(key, user); + } + + /** + * Fetch process diagram, a xml that contains the specification to render the diagram. + * @param processDefinitionId filter by process definition id. + * @param user the user performing the search + * @return process diagram xml that contains diagram to be render. + * @throws NoObjectFoundException when the process definition searched for could not be found. + * @throws SystemException in case of any other error. + */ + default ProcessDiagram fetchDiagram(String processDefinitionId, CIBUser user) throws SystemException { + return getProcessProvider().fetchDiagram(processDefinitionId, user); + } + + /** + * Fetch start-form to start a process + * @param processDefinitionId of the process to be started. + * @param user the user performing the search + * @return Startform variables and formReference. + * @throws NoObjectFoundException when trying to find start form data of a non-existing process definition. + * @throws SystemException in case of any other error. + */ + default StartForm fetchStartForm(String processDefinitionId, CIBUser user) throws SystemException { + return getProcessProvider().fetchStartForm(processDefinitionId, user); + } + + /** + * Download bpmn from a process definition id. + * @param processDefinitionId filter by process definition id. + * @param fileName name of the file content the bpmn. + * @param user the user performing the download + * @return Fetched bpmn + * @throws SystemException in case of an error. + */ + default Data downloadBpmn(String processDefinitionId, String fileName, CIBUser user) throws SystemException { + return getProcessProvider().downloadBpmn(processDefinitionId, fileName, user); + } + + /** + * Activate/Suspend process instance by ID. + * @param processInstanceId instance id to be suspended or activated. + * @param suspend if true, the process instance will be activated if false process will be suspended. + * @param user the user performing the operation. + * @throws SystemException in case of other error. + */ + default void suspendProcessInstance(String processInstanceId, Boolean suspend, CIBUser user) throws SystemException { + getProcessProvider().suspendProcessInstance(processInstanceId, suspend, user); + } + + /** + * Delete process instance by ID. + * @param processInstanceId instance id to be deleted. + * @param user the user performing the deletion. + * @throws NoObjectFoundException when the filter to be changed could not be found. + * @throws SystemException in case of any other error. + */ + default void deleteProcessInstance(String processInstanceId, CIBUser user) throws SystemException { + getProcessProvider().deleteProcessInstance(processInstanceId, user); + } + + /** + * Activate/Suspend process instance by ID. + * @param processDefinitionId definition id to be suspended or activated. + * @param suspend if true, the process will be activated if false process will be suspended. + * @param includeProcessInstances indicates whether to activate or suspend also all process instances of the given process definition + * @param executionDate The date on which the given process definition will be activated or suspended ej. 2013-01-23T14:42:45. yyyy-MM-dd'T'HH:mm:ss, + * If null, the suspension state of the given process definition is updated immediately. + * @param user the user performing the operation. + * @throws SystemException in case of other error. + * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. + * @throws NoObjectFoundException when the filter to be changed could not be found. + */ + default void suspendProcessDefinition(String processDefinitionId, Boolean suspend, Boolean includeProcessInstances, String executionDate, CIBUser user) throws SystemException { + getProcessProvider().suspendProcessDefinition(processDefinitionId, suspend, includeProcessInstances, executionDate, user); + } + + /** + * Start process. + * @param processDefinitionKey of the process to be started. + * @param tenantId the tenant ID. + * @param data variables to start process. + * @param user the user starting the process. + * @return information about the process started. + * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. + * @throws ExpressionEvaluationException when . + * @throws SystemException in case of any other error. + */ + default ProcessStart startProcess(String processDefinitionKey, String tenantId, Map data, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + return getProcessProvider().startProcess(processDefinitionKey, tenantId, data, user); + } + + /** + * Submit form with variables. + * @param processDefinitionKey of the process to be started. + * @param tenantId the tenant ID. + * @param data variables to submit. + * @param user the user submitting the form. + * @return information about the process started. + * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. + * @throws ExpressionEvaluationException when . + * @throws SystemException in case of any other error. + */ + default ProcessStart submitForm(String processDefinitionKey, String tenantId, Map data, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + return getProcessProvider().submitForm(processDefinitionKey, tenantId, data, user); + } + + /** + * Submit a form to start a process with the given key. + * + * @param key the process definition key + * @param formResult the form submission data as a JSON string + * @param user the authenticated user submitting the form + * @return information about the started process instance + * @throws UnsupportedTypeException when a variable value type is not supported by the engine + * @throws ExpressionEvaluationException when an expression in the process definition cannot be evaluated + * @throws SystemException in case of any other error + */ + default ProcessStart submitForm(String key, String formResult, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + return getProcessProvider().submitForm(key, formResult, user); + } + + /** + * Search statistics from a process. + * @param processId filter by process id. + * @param user the user performing the search + * @return Fetched processes instances. + * @throws SystemException in case of an error. + */ + default Collection findProcessStatistics(String processId, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { + return getProcessProvider().findProcessStatistics(processId, user); + } + + /** + * Search statistics for all processes. + * @param queryParams query parameters to filter the search + * @param user the user performing the search + * @return Fetched processes instances. + * @throws SystemException in case of an error. + */ + default Collection getProcessStatistics(Map queryParams, CIBUser user) throws SystemException { + return getProcessProvider().getProcessStatistics(queryParams, user); + } + + /** + * Queries for historic process instances that fulfill the given parameters. + * @param filters is a map of parameters to filter query. Parameters firstResult and maxResults are used for pagination. + * @param user the user performing the query. + * @return Fetched processes instances. + * @throws SystemException in case of an error. + */ + default Collection findProcessesInstancesHistory(Map filters, + Optional firstResult, Optional maxResults, CIBUser user) throws SystemException { + return getProcessProvider().findProcessesInstancesHistory(filters, firstResult, maxResults, user); + } + + /** + * Search processes instances with a specific process key (in the history). + * @param key the process key to filter by. + * @param active true means that unfinished processes will be fetched, false means only finished processes will be fetched. + * @param firstResult index of the first result to return. + * @param maxResults maximum number of results to return. + * @param user the user performing the query. + * @return Fetched process instances. + * @throws SystemException in case of an error. + */ + default Collection findProcessesInstancesHistory(String key, Optional active, + Integer firstResult, Integer maxResults, CIBUser user) throws SystemException { + return getProcessProvider().findProcessesInstancesHistory(key, active, firstResult, maxResults, user); + } + + /** + * Queries for historic process instances that fulfill the given parameters. + * @param id the ID of the process instance. + * @param activityId optional activity ID to filter the query. + * @param active optional flag to filter active or inactive instances. + * @param firstResult index of the first result to return. + * @param maxResults maximum number of results to return. + * @param text additional text filter for the query. + * @param user the user performing the query. + * @return Fetched process instances. + * @throws SystemException in case of an error. + */ + default Collection findProcessesInstancesHistoryById(String id, Optional activityId, Optional active, + Integer firstResult, Integer maxResults, String text, CIBUser user) throws SystemException { + return getProcessProvider().findProcessesInstancesHistoryById(id, activityId, active, firstResult, maxResults, text, user); + } + + default Long countProcessesInstancesHistory(Map filters, CIBUser user) { + return getProcessProvider().countProcessesInstancesHistory(filters, user); + } + + default Long countProcessesInstancesRuntime(Map filters, CIBUser user) { + return getProcessProvider().countProcessesInstancesRuntime(filters, user); + } + + /** + * Required by OFDKA + * Search process instance with a specific process instance id. + * @param processInstanceId filter by process instance id. + * @param user the user performing the search. + * @return Fetched process instance. + * @throws NoObjectFoundException when the process instance searched for could not be found. + * @throws SystemException in case of any other error. + */ + default ProcessInstance findProcessInstance(String processInstanceId, CIBUser user) throws SystemException { + return getProcessProvider().findProcessInstance(processInstanceId, user); + } + + /** + * Required by OFDKA + * Retrieves a variable of a given process instance by id. + * @param processInstanceId filter by process instance id. + * @param variableName variable name. + * @param deserializeValue whether to deserialize the variable value. Default: true. + * @param user the user performing the search. + * @return Fetched variables. + * @throws SystemException in case of an error. + */ + default Variable fetchProcessInstanceVariable(String processInstanceId, String variableName, boolean deserializeValue, CIBUser user) throws SystemException { + return getProcessProvider().fetchProcessInstanceVariable(processInstanceId, variableName, deserializeValue, user); + } + + /** + * Search process instance with a specific process instance id. + * @param processInstanceId filter by process instance id. + * @param user the user performing the search + * @return Fetched process instance. + * @throws NoObjectFoundException when the process instance searched for could not be found. + * @throws SystemException in case of any other error. + */ + default HistoryProcessInstance findHistoryProcessInstanceHistory(String processInstanceId, CIBUser user) throws SystemException { + return getProcessProvider().findHistoryProcessInstanceHistory(processInstanceId, user); + } + + default Collection findCalledProcessDefinitions(String processDefinitionId, CIBUser user) throws SystemException { + return getProcessProvider().findCalledProcessDefinitions(processDefinitionId, user); + } + + default ResponseEntity getDeployedStartForm(String processDefinitionId, CIBUser user) throws SystemException { + return getProcessProvider().getDeployedStartForm(processDefinitionId, user); + } + + default ResponseEntity getRenderedStartForm(String processDefinitionId, Map params, CIBUser user) { + return getProcessProvider().getRenderedForm(processDefinitionId, params, user); + } + + default void updateHistoryTimeToLive(String id, Map data, CIBUser user) throws SystemException { + getProcessProvider().updateHistoryTimeToLive(id, data, user); + } + + default void deleteProcessInstanceFromHistory(String id, CIBUser user) throws SystemException { + getProcessProvider().deleteProcessInstanceFromHistory(id, user); + } + + default void deleteProcessDefinition(String id, Optional cascade, CIBUser user) throws SystemException { + getProcessProvider().deleteProcessDefinition(id, cascade, user); + } + + /** + * Search processes instances by filter. + * @param data a map of parameters to filter the query. + * @param user the user performing the query. + * @return Fetched processes instances. + * @throws SystemException in case of an error. + */ + default Collection findCurrentProcessesInstances(Map data, CIBUser user) + throws SystemException { + return getProcessProvider().findCurrentProcessesInstances(data, user); + } + + + default Collection findProcessesInstancesRuntime(Map data, Optional firstResult, Optional maxResults, CIBUser user) throws SystemException { + return getProcessProvider().findProcessesInstancesRuntime(data, firstResult, maxResults, user); + } + + /** + * Fetch historic activity statistics for a given process definition ID. + * + * @param id the ID of the process definition + * @param params query parameters to filter statistics (e.g., canceled, finished, incidents) + * @param user the user performing the operation + * @return a list or map containing the historic activity statistics + * @throws SystemException in case of an error + */ + default Object fetchHistoricActivityStatistics(String id, Map params, CIBUser user) throws SystemException { + return getProcessProvider().fetchHistoricActivityStatistics(id, params, user); + } + + /** + * Fetch incidents for an specific process. + * @param processDefinitionKey of the process to fetch incidents. + * @param user the user performing the search. + * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. + * @throws SystemException in case of any other error. + */ + default Collection fetchIncidents(String processDefinitionKey, CIBUser user) throws SystemException { + return getIncidentProvider().fetchIncidents(processDefinitionKey, user); + } + + /* + + ██ ██ ████████ ██ ██ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ██ ██ ██ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██████ ██ ██ ███████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + /** + * Correlates a message to the process engine to either trigger a message start event or an intermediate message catching event. + * @param data variables to start process. + * @param user the user performing the correlation. + * @return Collection of correlated messages. + * @throws SystemException in case of any other error. + */ + default Collection correlateMessage(Map data, CIBUser user) throws SystemException { + return getUtilsProvider().correlateMessage(data, user); + } + + /** + * Add user to a group. + * + * @param groupId the ID of the group. + * @param userId the ID of the user to be added. + * @param user the user performing the operation. + */ + default void addMemberToGroup(String groupId, String userId, CIBUser user) throws SystemException { + getUserProvider().addMemberToGroup(groupId, userId, user); + } + + /** + * Delete user from a group. + * + * @param groupId the ID of the group. + * @param userId the ID of the user to be removed. + * @param user the user performing the operation. + */ + default void deleteMemberFromGroup(String groupId, String userId, CIBUser user) throws SystemException { + getUserProvider().deleteMemberFromGroup(groupId, userId, user); + } + + /** + * Deletes a user by id. + * + * @param userId the ID of the user to be deleted. + * @param user the user performing the deletion. + */ + default void deleteUser(String userId, CIBUser user) throws SystemException { + getUserProvider().deleteUser(userId, user); + } + + /** + * Get user by id. + * + * @param userId the ID of the user to be fetched. + * @param user the user performing the search. + * @return SevenUser object containing user profile information. + */ + default SevenUser getUserProfile(String userId, CIBUser user) throws SystemException { + return getUserProvider().getUserProfile(userId, user); + } + + default void retryJobById(String jobId, Map data, CIBUser user) throws SystemException { + getUtilsProvider().retryJobById(jobId, data, user); + } + + default String findStacktrace(String jobId, CIBUser user) { + return getUtilsProvider().findStacktrace(jobId, user); + } + + /* + + ██ ███ ██ ██████ ██ ██████ ███████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ████ ██████ ██ ██████ ███████ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + +*/ + + default Long countIncident(Map params, CIBUser user) throws SystemException { + return getIncidentProvider().countIncident(params, user); + } + + default Long countHistoricIncident(Map params, CIBUser user) throws SystemException { + return getIncidentProvider().countHistoricIncident(params, user); + } + + default Collection findIncident(Map params, CIBUser user) throws SystemException { + return getIncidentProvider().findIncident(params, user); + } + + default List findIncidentByInstanceId(String processInstanceId, CIBUser user) throws SystemException { + return getIncidentProvider().findIncidentByInstanceId(processInstanceId, user); + } + + default Collection fetchIncidentsByInstanceAndActivityId(String processDefinitionKey, String activityId, CIBUser user) throws SystemException { + return getIncidentProvider().fetchIncidentsByInstanceAndActivityId(processDefinitionKey, activityId, user); + } + + default void setIncidentAnnotation(String incidentId, Map data, CIBUser user) { + getIncidentProvider().setIncidentAnnotation(incidentId, data, user); + } + + default String findExternalTaskErrorDetails(String externalTaskId, CIBUser user) throws SystemException { + return getIncidentProvider().findExternalTaskErrorDetails(externalTaskId, user); + } + + default String findHistoricExternalTaskErrorDetails(String externalTaskId, CIBUser user) throws SystemException { + return getIncidentProvider().findHistoricExternalTaskErrorDetails(externalTaskId, user); + } + + default void retryExternalTask(String externalTaskId, Map data, CIBUser user) { + getIncidentProvider().retryExternalTask(externalTaskId, data, user); + } + + default Collection findHistoricIncidents(Map params, CIBUser user) throws SystemException { + return getIncidentProvider().findHistoricIncidents(params, user); + } + + default String findHistoricStacktraceByJobId(String jobId, CIBUser user) throws SystemException { + return getIncidentProvider().findHistoricStacktraceByJobId(jobId, user); + } + + /** + * Required by OFDKA + * Queries for event subscriptions that fulfill given parameters. + * The size of the result set can be retrieved by using the Get Event Subscriptions count method. + * @param processInstanceId filter by process instance id. + * @param eventType filter by event type. + * @param eventName filter by event name. + * @param user the user performing the search. + * @return Collection event subscriptions fetched in the search. + */ + default Collection getEventSubscriptions(Optional processInstanceId, + Optional eventType, Optional eventName, CIBUser user) throws SystemException { + return getUtilsProvider().getEventSubscriptions(processInstanceId, eventType, eventName, user); + } + + /* + + ████████ ███████ ███ ██ █████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ██ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ █████ ██ ██ ██ ███████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ███████ ██ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + */ + + default Collection fetchTenants(Map queryParams, CIBUser user) throws SystemException { + return getTenantProvider().fetchTenants(queryParams, user); + } + + default Tenant fetchTenant(String tenantId, CIBUser user) throws SystemException { + return getTenantProvider().fetchTenant(tenantId, user); + } + + default void createTenant(Tenant tenant, CIBUser user) throws SystemException { + getTenantProvider().createTenant(tenant, user); + } + + default void updateTenant(Tenant tenant, CIBUser user) throws SystemException { + getTenantProvider().updateTenant(tenant, user); + } + + default void deleteTenant(String tenantId, CIBUser user) throws SystemException { + getTenantProvider().deleteTenant(tenantId, user); + } + + default void addMemberToTenant(String tenantId, String userId, CIBUser user) throws SystemException { + getTenantProvider().addMemberToTenant(tenantId, userId, user); + } + + default void deleteMemberFromTenant(String tenantId, String userId, CIBUser user) throws SystemException { + getTenantProvider().deleteMemberFromTenant(tenantId, userId, user); + } + + default void addGroupToTenant(String tenantId, String groupId, CIBUser user) throws SystemException { + getTenantProvider().addGroupToTenant(tenantId, groupId, user); + } + + default void deleteGroupFromTenant(String tenantId, String groupId, CIBUser user) throws SystemException { + getTenantProvider().deleteGroupFromTenant(tenantId, groupId, user); + } + +/* + +███████ ███ ██ ██████ ██ ███ ██ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ +██ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +█████ ██ ██ ██ ██ ███ ██ ██ ██ ██ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ +██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ██ ████ ██████ ██ ██ ████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + */ + + /** + * Get the names of all process engines available on the engine. + * + * @return a collection of engine objects containing name information + * @throws SystemException in case of an error + */ + + default Collection getProcessEngineNames() throws SystemException { + return getEngineProvider().getProcessEngineNames(); + } + + /** + * Determine whether an initial user needs to be created + * + * @return true if admin group is available and write access is set + * @throws SystemException in case of an error + */ + default Boolean requiresSetup(String engine) { + return getEngineProvider().requiresSetup(engine); + } + + /** + * Creates a new initial user assigned to the also created admin group. + * + * @param user the new user to be created. + * @throws InvalidUserIdException when the user ID is invalid. + */ + default void createSetupUser(NewUser user, String engine) throws InvalidUserIdException { + getEngineProvider().createSetupUser(user, engine); + } + + /* + + ██ ██████ ███████ ███ ██ ████████ ██ ████████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ + ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + ██ ██████ ███████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ + + */ + + default PasswordPolicyResponse validatePasswordPolicy(PasswordPolicyRequest request) throws SystemException { + return getIdentityProvider().validatePasswordPolicy(request); + } + +} \ No newline at end of file diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IActivityProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IActivityProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IActivityProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IActivityProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IBatchProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IBatchProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IBatchProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IBatchProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IDecisionProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IDecisionProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IDecisionProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IDecisionProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IDeploymentProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IDeploymentProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IDeploymentProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IDeploymentProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IEngineProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IEngineProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IEngineProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IEngineProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IExternalTaskProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IExternalTaskProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IExternalTaskProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IExternalTaskProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IFilterProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IFilterProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IFilterProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IFilterProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IHistoricVariableInstanceProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IHistoricVariableInstanceProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IHistoricVariableInstanceProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IHistoricVariableInstanceProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IIdentityProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IIdentityProvider.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IIdentityProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IIdentityProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IIncidentProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IIncidentProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IIncidentProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IIncidentProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IJobDefinitionProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IJobDefinitionProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IJobDefinitionProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IJobDefinitionProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IJobProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IJobProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IJobProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IJobProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IProcessProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IProcessProvider.java old mode 100644 new mode 100755 similarity index 74% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IProcessProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IProcessProvider.java index 6154e8ca1..a7bf06031 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IProcessProvider.java +++ b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IProcessProvider.java @@ -17,9 +17,12 @@ package org.cibseven.webapp.providers; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; import org.cibseven.webapp.Data; import org.cibseven.webapp.auth.CIBUser; @@ -36,6 +39,9 @@ import org.cibseven.webapp.rest.model.Variable; import org.springframework.http.ResponseEntity; +import org.cibseven.webapp.rest.model.IncidentInfo; +import org.cibseven.webapp.rest.model.KeyTenant; + public interface IProcessProvider { public Collection findProcesses(CIBUser user); @@ -71,6 +77,7 @@ public Collection findProcessesInstancesHistoryById(Stri public Collection findCalledProcessDefinitions(String processDefinitionId, CIBUser user); public ResponseEntity getDeployedStartForm(String processDefinitionId, CIBUser user); public ResponseEntity getRenderedForm(String processDefinitionId, Map params, CIBUser user); + public void updateHistoryTimeToLive(String id, Map data, CIBUser user); public void deleteProcessInstanceFromHistory(String id, CIBUser user); public void deleteProcessDefinition(String id, Optional cascade, CIBUser user); @@ -78,4 +85,42 @@ public Collection findProcessesInstancesHistoryById(Stri public Long countProcessesInstancesRuntime(Map filters, CIBUser user); public Object fetchHistoricActivityStatistics(String id, Map params, CIBUser user); -} + default List groupProcessStatisticsByKeyAndTenantImpl(Collection processStatistics) { + return processStatistics.stream() + .collect(Collectors.groupingBy( + stat -> new KeyTenant(stat.getDefinition().getKey(), stat.getDefinition().getTenantId()) + )) + .values() + .stream() + .map(group -> { + ProcessStatistics result = new ProcessStatistics(); + + // Sort by version descending and use the latest version's definition + ProcessStatistics latestVersion = group.stream() + .max(Comparator.comparing(stat -> stat.getDefinition().getVersion())) + .orElse(group.iterator().next()); + + result.setDefinition(latestVersion.getDefinition()); + result.setId(latestVersion.getId()); + + // Aggregate instances and failed jobs + result.setInstances(group.stream().mapToLong(ProcessStatistics::getInstances).sum()); + result.setFailedJobs(group.stream().mapToLong(ProcessStatistics::getFailedJobs).sum()); + + // Aggregate incidents + long totalIncidentCount = group.stream() + .flatMap(stat -> stat.getIncidents().stream()) + .mapToLong(IncidentInfo::getIncidentCount) + .sum(); + + IncidentInfo totalIncident = new IncidentInfo(); + totalIncident.setIncidentType("all"); + totalIncident.setIncidentCount(totalIncidentCount); + + result.setIncidents(Collections.singletonList(totalIncident)); + + return result; + }) + .collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ISystemProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/ISystemProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ISystemProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/ISystemProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ITaskProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/ITaskProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ITaskProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/ITaskProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ITenantProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/ITenantProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ITenantProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/ITenantProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IUserProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IUserProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IUserProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IUserProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IUtilsProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IUtilsProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IUtilsProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IUtilsProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IVariableInstanceProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IVariableInstanceProvider.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IVariableInstanceProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IVariableInstanceProvider.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IVariableProvider.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IVariableProvider.java old mode 100644 new mode 100755 similarity index 80% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IVariableProvider.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IVariableProvider.java index cf1931a4b..5a5776dad --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/IVariableProvider.java +++ b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/IVariableProvider.java @@ -58,5 +58,45 @@ public ResponseEntity fetchProcessInstanceVariableData(String processIns public void submitVariables(String processInstanceId, List formResult, CIBUser user, String processDefinitionId) throws SystemException; public Map fetchProcessFormVariablesById(String id, CIBUser user) throws SystemException; public void putLocalExecutionVariable(String executionId, String varName, Map data, CIBUser user); - + default public void mergeVariablesValues( + Collection variablesDeserialized, + Collection variablesSerialized, + boolean deserializeValues) { + + if (variablesDeserialized == null) { + return; + } + + if (variablesSerialized == null) { + return; + } + + Collection variables = (deserializeValues) ? variablesDeserialized : variablesSerialized; + variables.forEach(variable -> { + String name = variable.getName(); + + // Skip variables with null names to avoid NullPointerException + if (name == null) { + return; + } + + Variable variableSerialized = (!deserializeValues) ? variable : variablesSerialized.stream() + .filter(v -> v.getName() != null && v.getName().equals(name)) + .findFirst() + .orElse(null); + if (variableSerialized != null) { + variable.setValueSerialized(variableSerialized.getValue()); + } + + Variable variableDeserialized = (deserializeValues) ? variable : variablesDeserialized.stream() + .filter(v -> v.getName() != null && v.getName().equals(name)) + .findFirst() + .orElse(null); + if (variableDeserialized != null) { + variable.setValueDeserialized(variableDeserialized.getValue()); + } + }); + } + + } \ No newline at end of file diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProviderBase.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/SevenProviderBase.java similarity index 99% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProviderBase.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/SevenProviderBase.java index cc1c7a81a..8e9a5ed8c 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProviderBase.java +++ b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/SevenProviderBase.java @@ -429,7 +429,7 @@ protected RestTemplate createPatchRestTemplate() { } - protected Collection filterResources(Collection authorizations, int resourceType) { + public static Collection filterResources(Collection authorizations, int resourceType) { Set resourceFilter = Arrays.asList(resourceType).stream().collect(Collectors.toSet()); return authorizations.stream().filter(authorization -> resourceFilter.contains(authorization.getResourceType())).collect(Collectors.toList()); } diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/utils/URLUtils.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/utils/URLUtils.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/utils/URLUtils.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/providers/utils/URLUtils.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/CustomRestTemplate.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/CustomRestTemplate.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/CustomRestTemplate.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/CustomRestTemplate.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/RestTemplateConfiguration.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/RestTemplateConfiguration.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/RestTemplateConfiguration.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/RestTemplateConfiguration.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ActivityInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ActivityInstance.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ActivityInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ActivityInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceHistory.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceHistory.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceHistory.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceHistory.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceIncident.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceIncident.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceIncident.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ActivityInstanceIncident.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Authorization.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Authorization.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Authorization.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Authorization.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Authorizations.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Authorizations.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Authorizations.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Authorizations.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Batch.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Batch.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Batch.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Batch.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/CamundaForm.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/CamundaForm.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/CamundaForm.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/CamundaForm.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/CandidateGroupTaskCount.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/CandidateGroupTaskCount.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/CandidateGroupTaskCount.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/CandidateGroupTaskCount.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Credentials.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Credentials.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Credentials.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Credentials.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Decision.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Decision.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Decision.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Decision.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Deployment.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Deployment.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Deployment.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Deployment.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/DeploymentResource.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/DeploymentResource.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/DeploymentResource.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/DeploymentResource.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Engine.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Engine.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Engine.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Engine.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/EventSubscription.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/EventSubscription.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/EventSubscription.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/EventSubscription.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ExternalTask.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ExternalTask.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ExternalTask.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ExternalTask.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Filter.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Filter.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Filter.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Filter.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/FilterCriterias.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/FilterCriterias.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/FilterCriterias.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/FilterCriterias.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/FilterProperties.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/FilterProperties.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/FilterProperties.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/FilterProperties.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/FilterVariable.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/FilterVariable.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/FilterVariable.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/FilterVariable.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInputInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInputInstance.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInputInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInputInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInstance.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionOutputInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionOutputInstance.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionOutputInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoricDecisionOutputInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoryBatch.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoryBatch.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoryBatch.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoryBatch.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoryProcessInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoryProcessInstance.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/HistoryProcessInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/HistoryProcessInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/IdentityLink.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/IdentityLink.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/IdentityLink.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/IdentityLink.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Incident.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Incident.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Incident.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Incident.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/IncidentInfo.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/IncidentInfo.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/IncidentInfo.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/IncidentInfo.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Job.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Job.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Job.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Job.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/JobDefinition.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/JobDefinition.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/JobDefinition.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/JobDefinition.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/KeyTenant.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/KeyTenant.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/KeyTenant.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/KeyTenant.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Message.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Message.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Message.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Message.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Metric.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Metric.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Metric.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Metric.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/NewUser.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/NewUser.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/NewUser.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/NewUser.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyRequest.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyRequest.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyRequest.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyRequest.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyResponse.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyResponse.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyResponse.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/PasswordPolicyResponse.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Process.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Process.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Process.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Process.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessDefinitionInfo.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessDefinitionInfo.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessDefinitionInfo.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessDefinitionInfo.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessDiagram.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessDiagram.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessDiagram.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessDiagram.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessInstance.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessStart.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessStart.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessStart.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessStart.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessStatistics.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessStatistics.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessStatistics.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessStatistics.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessVariablesCriteria.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessVariablesCriteria.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/ProcessVariablesCriteria.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/ProcessVariablesCriteria.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/SevenUser.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/SevenUser.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/SevenUser.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/SevenUser.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/SevenVerifyUser.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/SevenVerifyUser.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/SevenVerifyUser.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/SevenVerifyUser.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/StartForm.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/StartForm.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/StartForm.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/StartForm.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Task.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Task.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Task.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Task.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskFilterQuery.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskFilterQuery.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskFilterQuery.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskFilterQuery.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskFiltering.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskFiltering.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskFiltering.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskFiltering.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskForm.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskForm.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskForm.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskForm.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskHistory.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskHistory.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskHistory.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskHistory.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskSorting.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskSorting.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TaskSorting.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TaskSorting.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Tenant.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Tenant.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Tenant.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Tenant.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TransitionInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TransitionInstance.java old mode 100644 new mode 100755 similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/TransitionInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/TransitionInstance.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/User.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/User.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/User.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/User.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/UserGroup.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/UserGroup.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/UserGroup.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/UserGroup.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Variable.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Variable.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/Variable.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/Variable.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/VariableHistory.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/VariableHistory.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/VariableHistory.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/VariableHistory.java diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/VariableInstance.java b/cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/VariableInstance.java similarity index 100% rename from cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/model/VariableInstance.java rename to cibseven-interfaces/src/main/java/org/cibseven/webapp/rest/model/VariableInstance.java diff --git a/cibseven-webclient-core/pom.xml b/cibseven-webclient-core/pom.xml index fc710d30e..5fd2853cd 100644 --- a/cibseven-webclient-core/pom.xml +++ b/cibseven-webclient-core/pom.xml @@ -233,6 +233,16 @@ logback-classic test + + org.cibseven.webapp + cibseven-interfaces + ${project.version} + + + org.cibseven.webapp + cibseven-direct-provider + ${project.version} + diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenUserProvider.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenUserProvider.java index 7224c4ae1..d31129cf3 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenUserProvider.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/auth/SevenUserProvider.java @@ -51,15 +51,11 @@ public class SevenUserProvider extends BaseUserProvider { @Value("${cibseven.webclient.engineRest.url:./}") String cibsevenUrl; - @Autowired BpmProvider provider; - SevenProvider sevenProvider; + @Autowired BpmProvider bpmProvider; @PostConstruct public void init() { settings = new JwtTokenSettings(secret, validMinutes, prolongMinutes); - if (provider instanceof SevenProvider) - sevenProvider = (SevenProvider) provider; - else throw new SystemException("SevenUserProvider expects a SevenProvider"); checkKey(); } @@ -67,18 +63,19 @@ public void init() { public CIBUser login(StandardLogin login, HttpServletRequest rq) { try { CIBUser user = new CIBUser(login.getUsername()); + EngineTokenUtils.setEngineFromRequest(user, rq); // Get the appropriate token settings for this engine TokenSettings tokenSettings = EngineTokenUtils.getSettingsForEngine( user.getEngine(), engineRestProperties, getSettings(), validMinutes, prolongMinutes); - SevenVerifyUser sevenVerifyUser = sevenProvider.verifyUser(login, user); + SevenVerifyUser sevenVerifyUser = bpmProvider.verifyUser(login, user); if (sevenVerifyUser.isAuthenticated()) { // Token is needed for the next request (/user/xxx/profile) user.setAuthToken(createToken(tokenSettings, true, false, user)); - SevenUser cUser = sevenProvider.getUserProfile(user.getId(), user); + SevenUser cUser = bpmProvider.getUserProfile(user.getId(), user); user.setUserID(cUser.getId()); user.setDisplayName(cUser.getFirstName() + " " + cUser.getLastName()); // Token is created for the second time to include the display name diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/BpmProvider.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/BpmProvider.java deleted file mode 100644 index 582bf1e29..000000000 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/BpmProvider.java +++ /dev/null @@ -1,1273 +0,0 @@ -/* - * Copyright CIB software GmbH and/or licensed to CIB software GmbH - * under one or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information regarding copyright - * ownership. CIB software licenses this file to you under the Apache License, - * Version 2.0; you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.cibseven.webapp.providers; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import org.cibseven.webapp.rest.model.Decision; -import org.cibseven.webapp.Data; -import org.cibseven.webapp.NamedByteArrayDataSource; -import org.cibseven.webapp.auth.CIBUser; -import org.cibseven.webapp.exception.ExpressionEvaluationException; -import org.cibseven.webapp.exception.InvalidAttributeValueException; -import org.cibseven.webapp.exception.InvalidUserIdException; -import org.cibseven.webapp.exception.NoObjectFoundException; -import org.cibseven.webapp.exception.SubmitDeniedException; -import org.cibseven.webapp.exception.SystemException; -import org.cibseven.webapp.exception.UnexpectedTypeException; -import org.cibseven.webapp.exception.UnsupportedTypeException; -import org.cibseven.webapp.rest.model.ActivityInstance; -import org.cibseven.webapp.rest.model.ActivityInstanceHistory; -import org.cibseven.webapp.rest.model.Authorization; -import org.cibseven.webapp.rest.model.Authorizations; -import org.cibseven.webapp.rest.model.Batch; -import org.cibseven.webapp.rest.model.CandidateGroupTaskCount; -import org.cibseven.webapp.rest.model.Deployment; -import org.cibseven.webapp.rest.model.DeploymentResource; -import org.cibseven.webapp.rest.model.Engine; -import org.cibseven.webapp.rest.model.EventSubscription; -import org.cibseven.webapp.rest.model.ExternalTask; -import org.cibseven.webapp.rest.model.Filter; -import org.cibseven.webapp.rest.model.HistoricDecisionInstance; -import org.cibseven.webapp.rest.model.HistoryBatch; -import org.cibseven.webapp.rest.model.IdentityLink; -import org.cibseven.webapp.rest.model.Incident; -import org.cibseven.webapp.rest.model.JobDefinition; -import org.cibseven.webapp.rest.model.Job; -import org.cibseven.webapp.rest.model.Message; -import org.cibseven.webapp.rest.model.Metric; -import org.cibseven.webapp.rest.model.NewUser; -import org.cibseven.webapp.rest.model.PasswordPolicyRequest; -import org.cibseven.webapp.rest.model.PasswordPolicyResponse; -import org.cibseven.webapp.rest.model.Process; -import org.cibseven.webapp.rest.model.ProcessDiagram; -import org.cibseven.webapp.rest.model.ProcessInstance; -import org.cibseven.webapp.rest.model.HistoryProcessInstance; -import org.cibseven.webapp.rest.model.ProcessStart; -import org.cibseven.webapp.rest.model.ProcessStatistics; -import org.cibseven.webapp.rest.model.SevenUser; -import org.cibseven.webapp.rest.model.StartForm; -import org.cibseven.webapp.rest.model.Task; -import org.cibseven.webapp.rest.model.TaskFiltering; -import org.cibseven.webapp.rest.model.TaskHistory; -import org.cibseven.webapp.rest.model.Tenant; -import org.cibseven.webapp.rest.model.User; -import org.cibseven.webapp.rest.model.UserGroup; -import org.cibseven.webapp.rest.model.Variable; -import org.cibseven.webapp.rest.model.VariableHistory; -import org.cibseven.webapp.rest.model.VariableInstance; -import org.springframework.http.ResponseEntity; -import org.springframework.util.MultiValueMap; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.multipart.MultipartFile; - -import com.fasterxml.jackson.databind.JsonNode; - -import io.jsonwebtoken.security.Password; -import jakarta.servlet.http.HttpServletRequest; - -public interface BpmProvider { - - /** - * Search tasks, which contains specified filter. - * @param filter applied in the search - * @param user the user performing the search - * @return Collection tasks fetched in the search. - * @throws SystemException in case of an error. - */ - Collection findTasks(String filter, CIBUser user) throws SystemException; - - /** - * Search tasks which belongs to a specific process instance. - * @param processInstanceId filter by process instance id. - * @param user the user performing the search - * @return Fetched tasks. - * @throws SystemException in case of an error. - */ - Collection findTasksByProcessInstance(String processInstanceId, CIBUser user) throws SystemException; - - /** - * Search tasks which belongs to a specific process instance and a user. - * @param processInstanceId filter by process instance id. - * @param createdAfter filter by creation date. - * @param user the user performing the search - * @return Fetched tasks. - * @throws SystemException in case of an error. - */ - Collection findTasksByProcessInstanceAsignee(Optional processInstanceId, Optional createdAfter, CIBUser user) throws SystemException; - - /** - * Search tasks which belongs to a specific process instance. - * The tasks found belongs to the history, they have other attributes and finished tasks - * are also fetched. - * @param processInstanceId filter by process instance id. - * @param user the user performing the search - * @return Fetched tasks. - * @throws SystemException in case of an error. - */ - Collection findTasksByProcessInstanceHistory(String processInstanceId, CIBUser user) throws SystemException; - - /** - * Search tasks which belongs to a specific process instance and filtered by a definition key. - * The tasks found belongs to the history, they have other attributes and finished tasks - * are also fetched. - * @param processInstanceId filter by process instance id. - * @param taskDefinitionKey restrict to tasks that have the given key. - * @param user the user performing the search - * @return Fetched tasks. - * @throws SystemException in case of an error. - */ - Collection findTasksByDefinitionKeyHistory(String taskDefinitionKey, String processInstanceId, CIBUser user) throws SystemException; - - /** - * Search task with a specific Id. - * @param taskId filter by task id. - * @param user the user performing the search - * @return Fetched task. - * @throws NoObjectFoundException when the task searched for could not be found. - * @throws SystemException in case of any other error. - */ - Task findTaskById(String taskId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Search activity that belong to a process instance. - * @param processInstanceId filter by process instance id. - * @param user the user performing the search - * @return Fetched activity. - * @throws NoObjectFoundException when the searched process instance could not be found. - * @throws SystemException in case of any other error. - */ - ActivityInstance findActivityInstance(String processInstanceId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Queries for historic activity instances that fulfill the given parameters. - * The activities found belong to the history. - * @param queryParams a map of parameters to filter the query. - * @param user the user performing the query. - * @return Fetched Historic Activity Instances. - * @throws InvalidAttributeValueException when the tenant of a task could not be changed or when the delegation state of a task should be changed to an invalid value. - * @throws SystemException in case of any other error. - */ - Collection findActivitiesInstancesHistory(Map queryParams, CIBUser user) throws SystemException, InvalidAttributeValueException; - - /** - * Search activities instances that belong to a process instance. The activities found belongs - * to the history, they have other attributes and activities from finished processes are also fetched. - * @param processInstanceId filter by process instance id. - * @param user the user performing the search - * @return Fetched Activity Instance. - * @throws InvalidAttributeValueException when the tenant of a task could not be changed or when the delegation state of a task should be changed to an invalid value. - * @throws SystemException in case of any other error. - */ - Collection findActivitiesInstancesHistory(String processInstanceId, CIBUser user) throws SystemException, InvalidAttributeValueException; - - /** - * Fetch variables from a specific activity. - * The variables found belongs to the history, they have other attributes - * and variables from finished activities are also fetched. - * @param activityInstanceId filter by activity instance id. - * @param user the user performing the search - * @return Fetched variables. - * @throws SystemException in case of an error. - */ - Collection fetchActivityVariablesHistory(String activityInstanceId, CIBUser user) throws SystemException; - - /** - * Fetch variables from a specific activity. - * @param activityInstanceId filter by activity instance id. - * @param user the user performing the search - * @return Fetched variables. - * @throws SystemException in case of an error. - */ - Collection fetchActivityVariables(String activityInstanceId, CIBUser user) throws SystemException; - - /** - * Update task. - * @param task to be updated with the desired values already modified. - * @param user the user performing the update - * @throws SystemException in case of an error. - */ - void update(Task task, CIBUser user) throws SystemException; - - /** - * Set assignee to an specific task. - * @param taskId filter by task id. - * @param assignee to be set as assignee. - * @param user the user performing the update - * @throws SystemException in case of an error. - */ - void setAssignee(String taskId, String assignee, CIBUser user) throws SystemException; - - /** - * Submit task without saving any variables, because that is done by the ui-element-template (in ours). - * @param taskId the ID of the task to be submitted. - * @param user the user performing the submission. - * @throws SubmitDeniedException when trying to submit a non-existing task. - * @throws SystemException in case of any other error. - */ - void submit(String taskId, CIBUser user) throws SystemException, SubmitDeniedException; - - /** - * Fetch form-reference variable from task. - * @param taskId filter by task id. - * @param user the user performing the search - * @return form-reference - * @throws NoObjectFoundException when the searched task could not be found. - * @throws SystemException in case of any other error. - */ - Object formReference(String taskId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Retrieves the form configuration data associated with a specific task. - * @param taskId filter by task id. - * @param user the user performing the search - * @return TaskForm object containing key, camundaFormRef, and contextPath - * @throws NoObjectFoundException when the searched task could not be found. - * @throws SystemException in case of any other error. - */ - Object form(String taskId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Search processes. - * @param user the user performing the search - * @return Fetched processes. - * @throws InvalidAttributeValueException when searching for processes with at least one invalid parameter value. - * @throws SystemException in case of any other error. - */ - Collection findProcesses(CIBUser user) throws SystemException, InvalidAttributeValueException; - - /** - * Search processes with number of process instances and incidents. - * @param user the user performing the search - * @return Fetched processes. - * @throws InvalidAttributeValueException when searching for processes with at least one invalid parameter value. - * @throws SystemException in case of any other error. - */ - Collection findProcessesWithInfo(CIBUser user) throws SystemException, InvalidAttributeValueException; - - /** - * Search processes. - * @param filters filters to be applied. - * @param user the user performing the search - * @return Fetched processes. - * @throws InvalidAttributeValueException when searching for processes with at least one invalid parameter value. - * @throws SystemException in case of any other error. - */ - Collection findProcessesWithFilters(String filters, CIBUser user) throws SystemException, InvalidAttributeValueException; - - /** - * Search process with a specific Key. - * @param processKey filter by process definition key. - * @param tenantId - * @param user since this call is secured we need the user to authenticate. - * @return Fetched process. - * @throws SystemException in case of an error. - */ - Process findProcessByDefinitionKey(String processKey, String tenantId, CIBUser user) throws SystemException; - - /** - * Search processes (diferents versions) with a specific Key. - * @param processKey filter by process definition key. - * @param tenantId - * @param lazyLoad parameter to decide if load all the data or the minimum necessary. - * @param user since this call is secured we need the user to authenticate. - * @return Fetched process. - * @throws SystemException in case of an error. - */ - Collection findProcessVersionsByDefinitionKey(String processKey, String tenantId, Optional lazyLoad, CIBUser user) throws SystemException; - - /** - * Search process with a specific Id. - * @param id filter by process definition id. - * @param extraInfo parameter to specify if more data will be loaded. - * @param user the user performing the query. - * @return Fetched process. - * @throws SystemException in case of an error. - */ - Process findProcessById(String id, Optional extraInfo, CIBUser user) throws SystemException; - - /** - * Queries for historic process instances that fulfill the given parameters. - * @param filters is a map of parameters to filter query. Parameters firstResult and maxResults are used for pagination. - * @param user the user performing the query. - * @return Fetched processes instances. - * @throws SystemException in case of an error. - */ - Collection findProcessesInstancesHistory(Map filters, Optional firstResult, Optional maxResults, CIBUser user) throws SystemException; - - /** - * Search processes instances with a specific process key (in the history). - * @param key the process key to filter by. - * @param active true means that unfinished processes will be fetched, false means only finished processes will be fetched. - * @param firstResult index of the first result to return. - * @param maxResults maximum number of results to return. - * @param user the user performing the query. - * @return Fetched process instances. - * @throws SystemException in case of an error. - */ - Collection findProcessesInstancesHistory(String key, Optional active, Integer firstResult, Integer maxResults, CIBUser user) throws SystemException; - - /** - * Search processes instances with a specific process key. - * @param key the process key to filter by. - * @param user the user performing the search - * @return Fetched processes instances. - * @throws SystemException in case of an error. - */ - Collection findProcessesInstances(String key, CIBUser user) throws SystemException; - - /** - * Search statistics from a process. - * @param id filter by process id. - * @param user the user performing the search - * @return Fetched processes instances. - * @throws SystemException in case of an error. - */ - Collection findProcessStatistics(String id, CIBUser user) throws SystemException; - /** - * Search statistics for all processes. - * @param queryParams query parameters to filter the search - * @param user the user performing the search - * @return Fetched processes instances. - * @throws SystemException in case of an error. - */ - public Collection getProcessStatistics(Map queryParams, CIBUser user) throws SystemException; - - /** - * Search processes instances by filter. - * @param data a map of parameters to filter the query. - * @param user the user performing the query. - * @return Fetched processes instances. - * @throws SystemException in case of an error. - */ - Collection findCurrentProcessesInstances(Map data, CIBUser user) throws SystemException; - - Collection findProcessesInstancesRuntime(Map data, Optional firstResult, Optional maxResults, CIBUser user) throws SystemException; - - /** - * Search process instance with a specific process instance id. - * @param processInstanceId filter by process instance id. - * @param user the user performing the search - * @return Fetched process instance. - * @throws NoObjectFoundException when the process instance searched for could not be found. - * @throws SystemException in case of any other error. - */ - HistoryProcessInstance findHistoryProcessInstanceHistory(String processInstanceId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * FindTask by filter - * @param filters list of properties which will be use to filter tasks. - * @param filterId to filter task. - * @param firstResult index of the first result to return. - * @param maxResults maximum number of results to return. - * @param user since this call is secured we need the user to authenticate. - * @return Collection of Tasks fetched in the search. - * @throws SystemException in case of an error. - */ - Collection findTasksByFilter(TaskFiltering filters, String filterId, CIBUser user, Integer firstResult, Integer maxResults) throws SystemException; - - /** - * Find Tasks count by filter - * @param filterId to filter task. - * @param filters list of properties which will be use to filter tasks. - * @param user since this call is secured we need the user to authenticate. - * @return Collection of Tasks fetched in the search. - * @throws SystemException in case of an error. - */ - Integer findTasksCountByFilter(String filterId, CIBUser user, TaskFiltering filters) throws SystemException; - - /** - * Fetch process diagram, a xml that contains the specification to render the diagram. - * @param processDefinitionId filter by process definition id. - * @param user the user performing the search - * @return process diagram xml that contains diagram to be render. - * @throws NoObjectFoundException when the process definition searched for could not be found. - * @throws SystemException in case of any other error. - */ - ProcessDiagram fetchDiagram(String processDefinitionId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Fetch variables from a specific process instance. - * The variables found belong to the history, they have other attributes, and variables from finished process instances are also fetched. - * @param processInstanceId filter by process instance id. - * @param data a map of parameters to filter the query. - * @param user the user performing the search - * @return Fetched variables. - * @throws SystemException in case of an error. - */ - Collection fetchProcessInstanceVariablesHistory(String processInstanceId, Map data, CIBUser user) - throws SystemException; - - /** - * Fetch start-form to start a process - * @param processDefinitionId of the process to be started. - * @param user the user performing the search - * @return Startform variables and formReference. - * @throws NoObjectFoundException when trying to find start form data of a non-existing process definition. - * @throws SystemException in case of any other error. - */ - StartForm fetchStartForm(String processDefinitionId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Download bpmn from a process definition id. - * @param processDefinitionId filter by process definition id. - * @param fileName name of the file content the bpmn. - * @param user the user performing the download - * @return Fetched bpmn - * @throws SystemException in case of an error. - */ - Data downloadBpmn(String processDefinitionId, String fileName, CIBUser user) throws SystemException; - - /** - * Get authorizations, filtered by userId and groups in which user belongs. - * @param userId filter user identification (username). - * @param user the user performing the search - * @return Fetched bpmn - * @throws SystemException in case of an error. - */ - Authorizations getUserAuthorization(String userId, CIBUser user) throws SystemException; - - /** - * Search filters. - * @param user the user performing the query. - * @return Collection of Filters fetched in the search. - * @throws SystemException in case of an error. - */ - Collection findFilters(CIBUser user) throws SystemException; - - /** - * Create filter. - * @param filter to be created. - * @param user the user performing the creation. - * @throws SystemException in case of an error. - */ - Filter createFilter(Filter filter, CIBUser user) throws SystemException; - - /** - * Update filter. - * @param filter to be updated. - * @param user the user performing the update. - * @throws NoObjectFoundException when the filter to be changed could not be found. - * @throws SystemException in case of any other error. - */ - void updateFilter(Filter filter, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Delete filter. - * @param filterId the ID of the filter to be deleted. - * @param user the user performing the deletion. - * @throws SystemException in case of an error. - */ - void deleteFilter(String filterId, CIBUser user) throws SystemException; - - /** - * Activate/Suspend process instance by ID. - * @param processInstanceId instance id to be suspended or activated. - * @param suspend if true, the process instance will be activated if false process will be suspended. - * @param user the user performing the operation. - * @throws SystemException in case of other error. - */ - void suspendProcessInstance(String processInstanceId, Boolean suspend, CIBUser user) throws SystemException; - - /** - * Activate/Suspend process instance by ID. - * @param processDefinitionId definition id to be suspended or activated. - * @param suspend if true, the process will be activated if false process will be suspended. - * @param includeProcessInstances indicates whether to activate or suspend also all process instances of the given process definition - * @param executionDate The date on which the given process definition will be activated or suspended ej. 2013-01-23T14:42:45. yyyy-MM-dd'T'HH:mm:ss, - * If null, the suspension state of the given process definition is updated immediately. - * @param user the user performing the operation. - * @throws SystemException in case of other error. - * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. - * @throws NoObjectFoundException when the filter to be changed could not be found. - */ - void suspendProcessDefinition(String processDefinitionId, Boolean suspend, Boolean includeProcessInstances, String executionDate, CIBUser user) throws SystemException, UnsupportedTypeException, NoObjectFoundException; - - /** - * Delete process instance by ID. - * @param processInstanceId instance id to be deleted. - * @param user the user performing the deletion. - * @throws NoObjectFoundException when the filter to be changed could not be found. - * @throws SystemException in case of any other error. - */ - void deleteProcessInstance(String processInstanceId, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Fetch incidents for an specific process. - * @param processDefinitionKey of the process to fetch incidents. - * @param user the user performing the search. - * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. - * @throws SystemException in case of any other error. - */ - Collection fetchIncidents(String processDefinitionKey, CIBUser user) throws SystemException, UnsupportedTypeException; - - /** - * Deploy process-bpmn. - * @param data metadata of the diagram to be deployed (deployment-name, deployment-source, deploy-changed-only). - * @param file of the diagram to be deployed. - * @param user the user performing the deployment. - * @return Deployment information. - * @throws SystemException in case of any other error. - */ - Deployment deployBpmn(MultiValueMap data, MultiValueMap file, CIBUser user) throws SystemException; - - /** - * Start process. - * @param processDefinitionKey of the process to be started. - * @param tenantId the tenant ID. - * @param data variables to start process. - * @param user the user starting the process. - * @return information about the process started. - * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. - * @throws ExpressionEvaluationException when . - * @throws SystemException in case of any other error. - */ - ProcessStart startProcess(String processDefinitionKey, String tenantId, Map data, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException; - - /** - * Correlates a message to the process engine to either trigger a message start event or an intermediate message catching event. - * @param data variables to start process. - * @param user the user performing the correlation. - * @return Collection of correlated messages. - * @throws SystemException in case of any other error. - */ - Collection correlateMessage(Map data, CIBUser user) throws SystemException; - - /** - * Submit form with variables. - * @param processDefinitionKey of the process to be started. - * @param tenantId the tenant ID. - * @param data variables to submit. - * @param user the user submitting the form. - * @return information about the process started. - * @throws UnsupportedTypeException when a process instance cannot be created because of an unsupported value type or an invalid expression used in the process definition. - * @throws ExpressionEvaluationException when . - * @throws SystemException in case of any other error. - */ - ProcessStart submitForm(String processDefinitionKey, String tenantId, Map data, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException; - - /** - * Submit a form to start a process with the given key. - * - * @param key the process definition key - * @param formResult the form submission data as a JSON string - * @param user the authenticated user submitting the form - * @return information about the started process instance - * @throws UnsupportedTypeException when a variable value type is not supported by the engine - * @throws ExpressionEvaluationException when an expression in the process definition cannot be evaluated - * @throws SystemException in case of any other error - */ - ProcessStart submitForm(String key, String formResult, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException; - - /** - * Modify a variable in the Process Instance. - * @param executionId Id of the execution. - * @param data to be updated. - * @param user User who is modifying the variable. - * @throws SystemException in case of any other error. - */ - void modifyVariableByExecutionId(String executionId, Map data, CIBUser user) throws SystemException; - - /** - * Modify a variable data in the Process Instance. - * @param executionId the ID of the execution. - * @param variableName the name of the variable. - * @param data the file containing the data to be updated. - * @param valueType the type of the variable. Enum with the possible values: "File", "Bytes". - * @param user the user modifying the variable. - * @throws SystemException in case of any other error. - */ - void modifyVariableDataByExecutionId(String executionId, String variableName, MultipartFile data, String valueType, CIBUser user) throws SystemException; - - /** - * Fetch a variables from a process instance. - * @param processInstanceId Id of the instance. - * @param data a map of parameters to filter the query. - * @param user User who is fetching the variables. - * @return Data. - * @throws SystemException in case of any other error. - */ - Collection fetchProcessInstanceVariables(String processInstanceId, Map data, CIBUser user) - throws NoObjectFoundException, SystemException; - - /** - * Fetch a variable data in the Process Instance. - * @param executionId Id of the execution. - * @param variableName Name of the variable. - * @param user User who is fetching the variable. - * @return Data. - * @throws SystemException in case of any other error. - */ - ResponseEntity fetchVariableDataByExecutionId(String executionId, String variableName, CIBUser user) throws NoObjectFoundException, SystemException; - - /** - * Fetch a variable data in from the process history. - * @param id Id of the variable. - * @param user User who is modifying the variable. - * @return Data. - * @throws SystemException in case of any other error. - */ - ResponseEntity fetchHistoryVariableDataById(String id, CIBUser user) throws NoObjectFoundException, SystemException; - - /** - * Retrieves number of all deployments with provided query. - * @param user the user performing the search. - * @return Fetched deployments. - * @throws SystemException in case of any other error. - */ - Long countDeployments(CIBUser user, String nameLike) throws SystemException; - - /** - * Retrieves all deployments matched with provided query. - * @param user the user performing the search. - * @return Fetched deployments. - * @throws SystemException in case of any other error. - */ - Collection findDeployments(CIBUser user, String nameLike, int firstResult, int maxResults, String sortBy, String sortOrder) throws SystemException; - - /** - * Retrieves all deployment resources of a given deployment. - * @param deploymentId the ID of the deployment. - * @param user the user performing the query. - * @return Fetched deployment resources. - * @throws SystemException in case of any other error. - */ - Deployment findDeployment(String deploymentId, CIBUser user) throws SystemException; - - /** - * Search deployment with a specific Id. - * @param deploymentId the ID of the deployment. - * @return Fetched deployment. - * @throws SystemException in case of any other error. - */ - Collection findDeploymentResources(String deploymentId, CIBUser user) throws SystemException; - - /** - * Retrieves the binary content of a deployment resource for the given deployment by id. - * @param rq the HTTP request. - * @param deploymentId the ID of the deployment. - * @param resourceId the ID of the resource. - * @param fileName the name of the file. - * @param user the authenticated user. - * @return resource data. - * @throws SystemException in case of any other error. - */ - Data fetchDataFromDeploymentResource(HttpServletRequest rq, String deploymentId, String resourceId, String fileName, CIBUser user) throws SystemException; - - /** - * Delete deployment by an Id. - * @param deploymentId the ID of the deployment. - * @param cascade whether to cascade the deletion. - * @param user the user performing the deletion. - * @throws SystemException in case of any other error. - */ - void deleteDeployment(String deploymentId, Boolean cascade, CIBUser user) throws SystemException; - - /** - * Creates a new deployment using the Camunda REST API. - * - * @param data the deployment parameters (deployment-name, deployment-source, tenant-id, etc.) - * @param files the files to deploy (DMN, BPMN, etc.) - * @param user the user creating the deployment - * @return the created deployment - * @throws SystemException in case of an error - */ - Deployment createDeployment(MultiValueMap data, MultipartFile[] files, CIBUser user) throws SystemException; - - /** - * Redeploy an existing deployment. - * For every contained decision or process definition a new version will be created. - * - * @param id the ID of the deployment to redeploy - * @param data the redeployment parameters (tenantId, source, resourceIds, resourceNames) - * @param user the user performing the redeployment - * @return the newly created deployment - * @throws SystemException in case of an error - */ - Deployment redeployDeployment(String id, Map data, CIBUser user) throws SystemException; - - /** - * Identity links, e.g. to get the candidates user or groups of a task. - * - * @param taskId the ID of the task. - * @param type Filter by the type of links to include. e.g. "candidate". - * @param user the user performing the query. - * @return Collection of Identity Links. - */ - Collection findIdentityLink(String taskId, Optional type, CIBUser user); - - /** - * Create identity links, e.g., to set the candidates user or groups of a task. - * - * @param taskId the ID of the task. - * @param type a map containing the type of the identity link and group or user ID. - * @param user the user performing the operation. - * @throws SystemException in case of any other error. - */ - void createIdentityLink(String taskId, Map type, CIBUser user) throws SystemException; - - /** - * Delete identity links, e.g., to remove the candidates user or groups of a task. - * - * @param taskId the ID of the task. - * @param type a map containing the type of the identity link to be removed. - * @param user the user performing the operation. - * @throws SystemException in case of any other error. - */ - void deleteIdentityLink(String taskId, Map type, CIBUser user) throws SystemException; - - /** - * The following methods related to the Admin Section. - * They are all created but need first to check if those are used in webclient. If not we should remove them from here. - * IMPORTANT: Methods related to users/groups need to check if they are allowed to be created or removed (LDAP or Camunda) - * then it only make sense to use them when SevenProvider is selected. - */ - - /** - * Get users by id, .... - * - * @param id, // Filter by the id of the user. - * @param firstName, // Filter by the firstname of the user. - * @param firstNameLike, // Filter by the firstname that the parameter is a substring of. - * @param lastName, // Filter by the lastname of the user. - * @param lastNameLike, // Filter by the lastname that the parameter is a substring of. - * @param email , // Filter by the email of the user. - * @param emailLike, // Filter by the email that the parameter is a substring of. - * @param memberOfGroup, // Filter for users which are members of the given group. - * @param memberOfTenant , // Filter for users which are members of the given tenant. - * - * @param user CIBSevenUser - * @return Collection of Users. - */ - Collection findUsers(Optional id, Optional firstName, Optional firstNameLike, Optional lastName, - Optional lastNameLike, Optional email, Optional emailLike, Optional memberOfGroup, Optional memberOfTenant, - Optional idIn, Optional firstResult, Optional maxResult, - Optional sortBy, Optional sortOrder, Optional likePatternIgnoreCase, CIBUser user); - - /** - * Get the count of users in the system with optional filters. - * - * @param filters the filters to apply (e.g., memberOfGroup). Can be null or empty for no filtering. - * @param user the user performing the operation. - * @return the count of users matching the filters. - */ - long countUsers(Map filters, CIBUser user); - - /** - * Create a new user. - * - * @param user the new user to be created. - * @param flowUser the user performing the creation. - * @throws InvalidUserIdException when the user ID is invalid. - */ - void createUser(NewUser user, CIBUser flowUser) throws InvalidUserIdException; - - /** - * Updates a user’s profile. - * - * @param userId the ID of the user to be updated. - * @param user the user to Update. - * @param flowUser the user performing the update. - */ - void updateUserProfile(String userId, User user, CIBUser flowUser); - - /** - * Add user to a group. - * - * @param groupId the ID of the group. - * @param userId the ID of the user to be added. - * @param flowUser the user performing the operation. - */ - void addMemberToGroup(String groupId, String userId, CIBUser flowUser); - - /** - * Delete user from a group. - * - * @param groupId the ID of the group. - * @param userId the ID of the user to be removed. - * @param flowUser the user performing the operation. - */ - void deleteMemberFromGroup(String groupId, String userId, CIBUser flowUser); - - /** - * Updates a user’s credentials (password). - * - * @param userId the ID of the user to be updated. - * @param data Request Body - * A JSON object with the following properties: - * Name Type Description - * password String The user's new password. - * authenticatedUserPassword String The password of the authenticated user who changes the password of the user (i.e., the user with passed id as path parameter). - * @param user the user performing the update. - */ - void updateUserCredentials(String userId, Map data, CIBUser user); - - - /** - * Deletes a user by id. - * - * @param userId the ID of the user to be deleted. - * @param user the user performing the deletion. - */ - void deleteUser(String userId, CIBUser user); - - /** - * Get groups by id, .... - * - * @param id, // Filter by the id of the group. - * @param name, // Filter by the name of the group. - * @param nameLike, // Filter by the name that the parameter is a substring of. - * @param type, // Filter by the type of the group. - * @param member, // Only retrieve groups which the given user id is a member of. - * @param memberOfTenant, // Only retrieve groups which are members of the given tenant. - * @param sortBy, // Sort the results lexicographically by a given criterion. Valid values are id, name and type. Must be used in conjunction with the sortOrder parameter. - * @param sortOrder, // Sort the results in a given order. Values may be asc for ascending order or desc for descending order. Must be used in conjunction with the sortBy parameter. - * @param firstResult, // Pagination of results. Specifies the index of the first result to return. - * @param maxResults, // Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left. - * - * @param user the user performing the search. - * @return Collection of User Groups. - */ - Collection findGroups(Optional id, Optional name, Optional nameLike, Optional type, Optional member, - Optional memberOfTenant, Optional sortBy, Optional sortOrder, Optional firstResult, Optional maxResults, - CIBUser user); - - /** - * Create a group. - * - * @param group the group to be created. - * @param user the user performing the creation. - */ - void createGroup(UserGroup group, CIBUser user); - - /** - * Updates a group. - * - * @param groupId the ID of the group to be updated. - * @param group the group to be updated. - * @param user the user performing the update. - */ - void updateGroup(String groupId, UserGroup group, CIBUser user); - - /** - * Deletes a group by id. - * - * @param groupId the ID of the group to be deleted. - * @param user the user performing the deletion. - */ - void deleteGroup(String groupId, CIBUser user); - - /** - * Get Authorization by id, .... - * - * @param id, // Filter by the id. - * @param type, // Filter by authorization type. (0=global, 1=grant, 2=revoke). See the User Guide for more information about authorization types. - * @param userIdIn, // Filter by a comma-separated list of userIds. - * @param groupIdIn, // Filter by a comma-separated list of groupIds. - * @param resourceType, // Filter by an integer representation of the resource type. See the User Guide for a list of integer representations of resource types. - * @param resourceId, // Filter by resource id. * @param sortBy, // Sort the results lexicographically by a given criterion. Valid values are id, name and type. Must be used in conjunction with the sortOrder parameter. - * @param sortBy, // Sort the results lexicographically by a given criterion. Valid values are id, name and type. Must be used in conjunction with the sortOrder parameter. - * @param sortOrder, // Sort the results in a given order. Values may be asc for ascending order or desc for descending order. Must be used in conjunction with the sortBy parameter. - * @param firstResult, // Pagination of results. Specifies the index of the first result to return. - * @param maxResults, // Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left. - * @param user the user performing the search. - * @return Collection of Authorizations. - */ - Collection findAuthorization(Optional id, Optional type, Optional userIdIn,Optional groupIdIn, - Optional resourceType, Optional resourceId, Optional sortBy, Optional sortOrder, Optional firstResult,Optional maxResults, - CIBUser user); - - /** - * Create an authorization. - * - * @param authorization the authorization to be created. - * @param user the user performing the creation. - * @return ResponseEntity containing the created authorization. - */ - ResponseEntity createAuthorization(Authorization authorization, CIBUser user); - - /** - * Update an authorization by id. - * - * @param authorizationId the ID of the authorization to be updated. - * @param data the data to update. - * @param user the user performing the update. - */ - void updateAuthorization(String authorizationId, Map data, CIBUser user); - - /** - * Deletes an authorization by id. - * - * @param authorizationId the ID of the authorization to be deleted. - * @param user the user performing the deletion. - */ - void deleteAuthorization(String authorizationId, CIBUser user); - - /** - * Queries for historic process instances that fulfill the given parameters. - * @param id the ID of the process instance. - * @param activityId optional activity ID to filter the query. - * @param active optional flag to filter active or inactive instances. - * @param firstResult index of the first result to return. - * @param maxResults maximum number of results to return. - * @param text additional text filter for the query. - * @param user the user performing the query. - * @return Fetched process instances. - * @throws SystemException in case of an error. - */ - Collection findProcessesInstancesHistoryById(String id, Optional activityId, Optional active, Integer firstResult, Integer maxResults, String text, CIBUser user) throws SystemException; - - Long countProcessesInstancesHistory(Map filters, CIBUser user); - Long countProcessesInstancesRuntime(Map filters, CIBUser user); - - /** - * Get user by id. - * - * @param userId the ID of the user to be fetched. - * @param user the user performing the search. - * @return SevenUser object containing user profile information. - */ - SevenUser getUserProfile(String userId, CIBUser user); - - void submitVariables(String processInstanceId, List variables, CIBUser user, String processDefinitionId) throws SystemException; - - Collection findCalledProcessDefinitions(String processDefinitionId, CIBUser user); - - /*UI Element templates methods migrated*/ - - ActivityInstance findActivityInstances(String processInstanceId, CIBUser user) throws SystemException; - - List findActivityInstanceHistory(String processInstanceId, CIBUser user) - throws SystemException; - - Variable fetchVariable(String taskId, String variableName, boolean deserialize, CIBUser user) - throws NoObjectFoundException, SystemException; - - void deleteVariable(String taskId, String variableName, CIBUser user) - throws NoObjectFoundException, SystemException; - - Map fetchFormVariables(String taskId, boolean deserializeValues, CIBUser user) - throws NoObjectFoundException, SystemException; - - Map fetchFormVariables(List variableListName, String taskId, boolean deserializeValues, CIBUser user) - throws NoObjectFoundException, SystemException; - - Map fetchProcessFormVariables(String key, boolean deserializeValues, CIBUser user) - throws NoObjectFoundException, SystemException; - - Map fetchProcessFormVariables(List variableListName, String key, boolean deserializeValues, CIBUser user) - throws NoObjectFoundException, SystemException; - - NamedByteArrayDataSource fetchVariableFileData(String taskId, String variableName, CIBUser user) - throws NoObjectFoundException, UnexpectedTypeException, SystemException; - - void uploadVariableFileData(String taskId, String variableName, MultipartFile data, String valueType, CIBUser user) - throws NoObjectFoundException, SystemException; - - ResponseEntity fetchProcessInstanceVariableData(String processInstanceId, String variableName, - CIBUser user) throws NoObjectFoundException, SystemException; - - void uploadProcessInstanceVariableFileData(String processInstanceId, String variableName, MultipartFile data, String valueType, CIBUser user) - throws NoObjectFoundException, SystemException; - - Variable fetchVariableByProcessInstanceId( - String processInstanceId, String variableName, CIBUser user) - throws SystemException; - - ProcessStart submitStartFormVariables(String processDefinitionId, List formResult, CIBUser user) - throws SystemException; - - void saveVariableInProcessInstanceId(String processInstanceId, List variables, CIBUser user) throws SystemException; - - Map fetchProcessFormVariablesById(String id, CIBUser user) throws SystemException; - - void retryJobById(String jobId, Map data, CIBUser user); - - String findExternalTaskErrorDetails(String externalTaskId, CIBUser user); - - String findHistoricExternalTaskErrorDetails(String externalTaskId, CIBUser user); - - Collection findHistoricIncidents(Map params, CIBUser user); - - String findHistoricStacktraceByJobId(String jobId, CIBUser user); - - void retryExternalTask(String externalTaskId, Map data, CIBUser user); - - void setIncidentAnnotation(String incidentId, Map data, CIBUser user); - - /** - * Submit task with saving variables. - * @param task the task to be submitted. - * @param formResult the variables to be saved. - * @param user the user performing the submission. - * @throws SubmitDeniedException when trying to submit a non-existing task. - * @throws SystemException in case of any other error. - */ - void submit(Task task, List formResult, CIBUser user) throws SystemException, SubmitDeniedException; - - /** - * Submits a task form to the process engine. - * - * @param taskId the id of the task the form belongs to - * @param formResult serialized form payload (usually JSON) to be submitted - * @param user the user performing the operation - * - * @throws SystemException in case of an error - */ - void submit(String taskId, String formResult, CIBUser user) throws NoObjectFoundException, SystemException; - - Long countIncident(Map params, CIBUser user); - Long countHistoricIncident(Map params, CIBUser user); - - Collection findIncident(Map params, CIBUser user); - - List findIncidentByInstanceId(String processInstanceId, CIBUser user); - - Collection fetchIncidentsByInstanceAndActivityId(String processDefinitionKey, String activityId, CIBUser user); - - String findStacktrace(String jobId, CIBUser user); - - /** - * Required by OFDKA - * Queries for tasks that fulfill a given filter. This method is slightly more powerful than the Get Tasks method because it allows - * filtering by multiple process or task variables of types String, Number or Boolean. - * @param data variables to apply search. - * @param user the user performing the search. - * @return Collection tasks fetched in the search. - * @throws SystemException in case of an error. - */ - Collection findTasksPost(Map data, CIBUser user) throws SystemException; - - /** - * Required by OFDKA - * Search process instance with a specific process instance id. - * @param processInstanceId filter by process instance id. - * @param user the user performing the search. - * @return Fetched process instance. - * @throws NoObjectFoundException when the process instance searched for could not be found. - * @throws SystemException in case of any other error. - */ - ProcessInstance findProcessInstance(String processInstanceId, CIBUser user); - - /** - * Required by OFDKA - * Retrieves a variable of a given process instance by id. - * @param processInstanceId filter by process instance id. - * @param variableName variable name. - * @param deserializeValue whether to deserialize the variable value. Default: true. - * @param user the user performing the search. - * @return Fetched variables. - * @throws SystemException in case of an error. - */ - Variable fetchProcessInstanceVariable(String processInstanceId, String variableName, boolean deserializeValue, - CIBUser user) throws SystemException; - - - /** - * Required by OFDKA - * Queries for event subscriptions that fulfill given parameters. - * The size of the result set can be retrieved by using the Get Event Subscriptions count method. - * @param processInstanceId filter by process instance id. - * @param eventType filter by event type. - * @param eventName filter by event name. - * @param user the user performing the search. - * @return Collection event subscriptions fetched in the search. - */ - Collection getEventSubscriptions(Optional processInstanceId, Optional eventType, - Optional eventName, CIBUser user); - - - Integer findTasksCount(Map filters, CIBUser user); - - /** - * Reports a business error in the context of a running task by id. The error code must be specified to identify the BPMN error handler. - * @param taskId filter by task id. - * @param data variables for the BPMN error reporting. - * @param user the user performing the operation. - * @throws SystemException in case of any other error. - */ - void handleBpmnError(String taskId, Map data, CIBUser user) throws SystemException; - - Collection findTasksByTaskIdHistory(String taskId, CIBUser user); - - ResponseEntity getDeployedForm(String taskId, CIBUser user); - - ResponseEntity getRenderedForm(String taskId, Map params, CIBUser user); - - ResponseEntity getDeployedStartForm(String processDefinitionId, CIBUser user); - - ResponseEntity getRenderedStartForm(String processDefinitionId, Map params, CIBUser user); - - void updateHistoryTimeToLive(String id, Map data, CIBUser user); - - void deleteProcessInstanceFromHistory(String id, CIBUser user); - - void deleteProcessDefinition(String id, Optional cascade, CIBUser user); - - void deleteVariableByExecutionId(String executionId, String variableName, CIBUser user); - - void deleteVariableHistoryInstance(String id, CIBUser user); - - void putLocalExecutionVariable(String executionId, String varName, Map data, CIBUser user); - - Collection findActivitiesProcessDefinitionHistory(String processDefinitionId, - Map params, CIBUser user); - - Collection findJobDefinitions(String params, CIBUser user); - void suspendJobDefinition(String jobDefinitionId, String params, CIBUser user); - void overrideJobDefinitionPriority(String jobDefinitionId, String params, CIBUser user); - JobDefinition findJobDefinition(String id, CIBUser user); - void retryJobDefinitionById(String id, Map params, CIBUser user); - - Collection getDecisionDefinitionList(Map queryParams, CIBUser user); - Long getDecisionDefinitionListCount(Map queryParams, CIBUser user); - Decision getDecisionDefinitionByKey(String key, CIBUser user); - Object getDiagramByKey(String key, CIBUser user); - Object evaluateDecisionDefinitionByKey(Map data, String key, CIBUser user); - void updateHistoryTTLByKey(Map data, String key, CIBUser user); - - Decision getDecisionDefinitionByKeyAndTenant(String key, String tenant, CIBUser user); - Object getDiagramByKeyAndTenant(String key, String tenant, CIBUser user); - Object evaluateDecisionDefinitionByKeyAndTenant(Map data, String key, String tenant, CIBUser user); - void updateHistoryTTLByKeyAndTenant(Map data, String key, String tenant, CIBUser user); - Object getXmlByKey(String key, CIBUser user); - Object getXmlByKeyAndTenant(String key, String tenant, CIBUser user); - Decision getDecisionDefinitionById(String id, Optional extraInfo, CIBUser user); - Object getDiagramById(String id, CIBUser user); - Object evaluateDecisionDefinitionById(String id, Map data, CIBUser user); - void updateHistoryTTLById(String id, Map data, CIBUser user); - Object getXmlById(String id, CIBUser user); - - Collection getDecisionVersionsByKey(String key, Optional lazyLoad, CIBUser user); - - Collection getHistoricDecisionInstances(Map queryParams, CIBUser user); - Long getHistoricDecisionInstanceCount(Map queryParams, CIBUser user); - HistoricDecisionInstance getHistoricDecisionInstanceById(String id, Map queryParams, CIBUser user); - Object deleteHistoricDecisionInstances(Map body, CIBUser user); - Object setHistoricDecisionInstanceRemovalTime(Map body, CIBUser user); - - Collection getJobs(Map params, CIBUser user); - void setSuspended(String id, Map data, CIBUser user); - void deleteJob(String id, CIBUser user); - Collection getHistoryJobLog(Map params, CIBUser user); - String getHistoryJobLogStacktrace(String id, CIBUser user); - void changeDueDate(String id, Map data, CIBUser user); - void recalculateDueDate(String id, Map params, CIBUser user); - Integer findHistoryTasksCount(Map filters, CIBUser user); - - Collection getTaskCountByCandidateGroup(CIBUser user); - - Collection getBatches(Map params, CIBUser user); - Collection getBatchStatistics(Map params, CIBUser user); - void deleteBatch(String id, Map params, CIBUser user); - void setBatchSuspensionState(String id, Map params, CIBUser user); - Collection getHistoricBatches(Map params, CIBUser user); - Long getRuntimeBatchCount(Map queryParams, CIBUser user); - Long getHistoricBatchCount(Map queryParams, CIBUser user); - HistoryBatch getHistoricBatchById(String id, CIBUser user); - void deleteHistoricBatch(String id, CIBUser user); - Object setRemovalTime(Map payload, CIBUser user); - Object getCleanableBatchReport(Map queryParams, CIBUser user); - Object getCleanableBatchReportCount(CIBUser user); - - JsonNode getTelemetryData(CIBUser user); - Collection getMetrics(Map queryParams, CIBUser user); - - Collection fetchTenants(Map queryParams, CIBUser user); - Tenant fetchTenant(String tenantId, CIBUser user); - void createTenant(Tenant tenant, CIBUser user); - void updateTenant(Tenant tenant, CIBUser user); - void deleteTenant(String tenantId, CIBUser user); - void addMemberToTenant(String tenantId, String userId, CIBUser user); - void deleteMemberFromTenant(String tenantId, String userId, CIBUser user); - void addGroupToTenant(String tenantId, String groupId, CIBUser user); - void deleteGroupFromTenant(String tenantId, String groupId, CIBUser user); - - // Variable Instance method - /** - * Retrieves a variable instance by its ID. - * @param id The ID of the variable instance - * @param deserializeValue Whether to deserialize the variable value or not - * @param user the user performing the search - * @return Variable instance details - * @throws SystemException in case of an error - * @throws NoObjectFoundException when the variable instance could not be found - */ - VariableInstance getVariableInstance(String id, boolean deserializeValue, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Retrieves a historic variable instance by its ID. - * @param id The ID of the historic variable instance - * @param deserializeValue Whether to deserialize the variable value or not - * @param user the user performing the search - * @return Historic variable instance details - * @throws SystemException in case of an error - * @throws NoObjectFoundException when the historic variable instance could not be found - */ - VariableHistory getHistoricVariableInstance(String id, boolean deserializeValue, CIBUser user) throws SystemException, NoObjectFoundException; - - /** - * Get external tasks based on query parameters - * - * @param queryParams Query parameters for filtering external tasks - * @param user the user performing the operation - * @return Collection of external tasks - * @throws SystemException in case of an error - */ - Collection getExternalTasks(Map queryParams, CIBUser user) throws SystemException; - - /** - * Fetch historic activity statistics for a given process definition ID. - * - * @param id the ID of the process definition - * @param params query parameters to filter statistics (e.g., canceled, finished, incidents) - * @param user the user performing the operation - * @return a list or map containing the historic activity statistics - * @throws SystemException in case of an error - */ - Object fetchHistoricActivityStatistics(String id, Map params, CIBUser user); - - /** - * Get the names of all process engines available on the engine. - * - * @return a collection of engine objects containing name information - * @throws SystemException in case of an error - */ - Collection getProcessEngineNames(); - - /** - * Determine whether an initial user needs to be created - * - * @return true if admin group is available and write access is set - * @throws SystemException in case of an error - */ - Boolean requiresSetup(String engine); - - /** - * Creates a new initial user assigned to the also created admin group. - * - * @param user the new user to be created. - * @throws InvalidUserIdException when the user ID is invalid. - */ - void createSetupUser(NewUser user, String engine) throws InvalidUserIdException; - - PasswordPolicyResponse validatePasswordPolicy(PasswordPolicyRequest request) throws SystemException; - -} diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/DecisionProvider.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/DecisionProvider.java index 4a2556d62..9c5dac6b0 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/DecisionProvider.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/DecisionProvider.java @@ -128,8 +128,8 @@ public Object getDiagramById(String id, CIBUser user) { @Override public Object evaluateDecisionDefinitionById(String id, Map data, CIBUser user) { - // TODO Auto-generated method stub - return null; + String url = getEngineRestUrl(user) + "/decision-definition/" + id + "/evaluate"; + return ((ResponseEntity) doPost(url, data, null, user)).getBody(); } @Override diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ProcessProvider.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ProcessProvider.java index 948adf422..c9b2ba6f0 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ProcessProvider.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/ProcessProvider.java @@ -591,45 +591,10 @@ public void deleteProcessDefinition(String id, Optional cascade, CIBUse * @param processStatistics Collection of ProcessStatistics to group * @return List of grouped ProcessStatistics with aggregated values */ - @Override public List groupProcessStatisticsByKeyAndTenant(Collection processStatistics) { - return processStatistics.stream() - .collect(Collectors.groupingBy( - stat -> new KeyTenant(stat.getDefinition().getKey(), stat.getDefinition().getTenantId()) - )) - .values() - .stream() - .map(group -> { - ProcessStatistics result = new ProcessStatistics(); - - // Sort by version descending and use the latest version's definition - ProcessStatistics latestVersion = group.stream() - .max(Comparator.comparing(stat -> stat.getDefinition().getVersion())) - .orElse(group.get(0)); - - result.setDefinition(latestVersion.getDefinition()); - result.setId(latestVersion.getId()); - - // Aggregate instances and failed jobs - result.setInstances(group.stream().mapToLong(ProcessStatistics::getInstances).sum()); - result.setFailedJobs(group.stream().mapToLong(ProcessStatistics::getFailedJobs).sum()); - - // Aggregate incidents - long totalIncidentCount = group.stream() - .flatMap(stat -> stat.getIncidents().stream()) - .mapToLong(IncidentInfo::getIncidentCount) - .sum(); - - IncidentInfo totalIncident = new IncidentInfo(); - totalIncident.setIncidentType("all"); - totalIncident.setIncidentCount(totalIncidentCount); - - result.setIncidents(Collections.singletonList(totalIncident)); - - return result; - }) - .collect(Collectors.toList()); + return groupProcessStatisticsByKeyAndTenantImpl(processStatistics); } + @Override public Object fetchHistoricActivityStatistics(String id, Map params, CIBUser user) { String url = URLUtils.buildUrlWithParams(getEngineRestUrl(user) + "/history/process-definition/" + id + "/statistics", params); diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProvider.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProvider.java index ca7bfc6fc..8569a619f 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProvider.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/SevenProvider.java @@ -16,75 +16,13 @@ */ package org.cibseven.webapp.providers; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import org.cibseven.webapp.Data; -import org.cibseven.webapp.NamedByteArrayDataSource; -import org.cibseven.webapp.auth.CIBUser; -import org.cibseven.webapp.auth.rest.StandardLogin; -import org.cibseven.webapp.exception.ExpressionEvaluationException; -import org.cibseven.webapp.exception.InvalidUserIdException; -import org.cibseven.webapp.exception.NoObjectFoundException; -import org.cibseven.webapp.exception.SystemException; -import org.cibseven.webapp.exception.UnexpectedTypeException; -import org.cibseven.webapp.exception.UnsupportedTypeException; -import org.cibseven.webapp.rest.model.ActivityInstance; -import org.cibseven.webapp.rest.model.ActivityInstanceHistory; -import org.cibseven.webapp.rest.model.Authorization; -import org.cibseven.webapp.rest.model.Authorizations; -import org.cibseven.webapp.rest.model.Batch; -import org.cibseven.webapp.rest.model.CandidateGroupTaskCount; -import org.cibseven.webapp.rest.model.Decision; -import org.cibseven.webapp.rest.model.Deployment; -import org.cibseven.webapp.rest.model.DeploymentResource; -import org.cibseven.webapp.rest.model.Engine; -import org.cibseven.webapp.rest.model.EventSubscription; -import org.cibseven.webapp.rest.model.ExternalTask; -import org.cibseven.webapp.rest.model.Filter; -import org.cibseven.webapp.rest.model.HistoricDecisionInstance; -import org.cibseven.webapp.rest.model.HistoryBatch; -import org.cibseven.webapp.rest.model.HistoryProcessInstance; -import org.cibseven.webapp.rest.model.IdentityLink; -import org.cibseven.webapp.rest.model.Incident; -import org.cibseven.webapp.rest.model.Job; -import org.cibseven.webapp.rest.model.JobDefinition; -import org.cibseven.webapp.rest.model.Message; -import org.cibseven.webapp.rest.model.Metric; -import org.cibseven.webapp.rest.model.NewUser; -import org.cibseven.webapp.rest.model.PasswordPolicyRequest; -import org.cibseven.webapp.rest.model.PasswordPolicyResponse; -import org.cibseven.webapp.rest.model.Process; -import org.cibseven.webapp.rest.model.ProcessDiagram; -import org.cibseven.webapp.rest.model.ProcessInstance; -import org.cibseven.webapp.rest.model.ProcessStart; -import org.cibseven.webapp.rest.model.ProcessStatistics; -import org.cibseven.webapp.rest.model.SevenUser; -import org.cibseven.webapp.rest.model.SevenVerifyUser; -import org.cibseven.webapp.rest.model.StartForm; -import org.cibseven.webapp.rest.model.Task; -import org.cibseven.webapp.rest.model.TaskFiltering; -import org.cibseven.webapp.rest.model.TaskHistory; -import org.cibseven.webapp.rest.model.Tenant; -import org.cibseven.webapp.rest.model.User; -import org.cibseven.webapp.rest.model.UserGroup; -import org.cibseven.webapp.rest.model.Variable; -import org.cibseven.webapp.rest.model.VariableHistory; -import org.cibseven.webapp.rest.model.VariableInstance; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.util.MultiValueMap; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.multipart.MultipartFile; - -import com.fasterxml.jackson.databind.JsonNode; -import jakarta.servlet.http.HttpServletRequest; +import lombok.Getter; +@Getter public class SevenProvider extends SevenProviderBase implements BpmProvider { - @Autowired private IDeploymentProvider deploymentProvider; + @Autowired private IDeploymentProvider deploymentProvider; @Autowired private IVariableProvider variableProvider; @Autowired private IVariableInstanceProvider variableInstanceProvider; @Autowired private IHistoricVariableInstanceProvider historicVariableInstanceProvider; @@ -103,1243 +41,5 @@ public class SevenProvider extends SevenProviderBase implements BpmProvider { @Autowired private ITenantProvider tenantProvider; @Autowired private IExternalTaskProvider externalTaskProvider; @Autowired private IEngineProvider engineProvider; - @Autowired private IdentityProvider identityProvider; - - - /* - - ████████ █████ ███████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ███████ ███████ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection findTasks(String filter, CIBUser user) { - return taskProvider.findTasks(filter, user); - } - - @Override - public Integer findTasksCount(@RequestBody Map filters, CIBUser user) { - return taskProvider.findTasksCount(filters, user); - } - - @Override - public Collection findTasksByProcessInstance(String processInstanceId, CIBUser user) { - return taskProvider.findTasksByProcessInstance(processInstanceId, user); - } - - @Override - public Collection findTasksByProcessInstanceAsignee(Optional processInstanceId, Optional createdAfter, CIBUser user) { - return taskProvider.findTasksByProcessInstanceAsignee(processInstanceId, createdAfter, user); - } - - @Override - public Task findTaskById(String id, CIBUser user) { - return taskProvider.findTaskById(id, user); - } - - - @Override - public void update(Task task, CIBUser user) { - taskProvider.update(task, user); - } - - @Override - public void setAssignee(String taskId, String assignee, CIBUser user) { - taskProvider.setAssignee(taskId, assignee, user); - } - - @Override - public void submit(String taskId, CIBUser user) { - taskProvider.submit(taskId, user); - } - - @Override - public void submit(Task task, List formResult, CIBUser user) { - taskProvider.submit(task, formResult, user);; - } - - @Override - public void submit(String taskId, String formResult, CIBUser user) { - taskProvider.submit(taskId, formResult, user); - } - - @Override - public Object formReference(String taskId, CIBUser user) { - return taskProvider.formReference(taskId, user); - } - - @Override - public Object form(String taskId, CIBUser user) { - return taskProvider.form(taskId, user); - } - - @Override - public Collection findTasksByFilter(TaskFiltering filters, String filterId, CIBUser user, Integer firstResult, Integer maxResults) { - return taskProvider.findTasksByFilter(filters, filterId, user, firstResult, maxResults); - } - - @Override - public Integer findTasksCountByFilter(String filterId, CIBUser user, TaskFiltering filters) { - return taskProvider.findTasksCountByFilter(filterId, user, filters); - } - - @Override - public Collection findTasksByProcessInstanceHistory(String processInstanceId, CIBUser user) { - return taskProvider.findTasksByProcessInstanceHistory(processInstanceId, user); - } - - @Override - public Collection findTasksByDefinitionKeyHistory(String taskDefinitionKey, String processInstanceId, CIBUser user) { - return taskProvider.findTasksByDefinitionKeyHistory(taskDefinitionKey, processInstanceId, user); - } - - @Override - public Collection findTasksPost(Map data, CIBUser user) throws SystemException { - return taskProvider.findTasksPost(data, user); - } - - @Override - public Collection findIdentityLink(String taskId, Optional type, CIBUser user) { - return taskProvider.findIdentityLink(taskId, type, user); - } - - @Override - public void createIdentityLink(String taskId, Map data, CIBUser user) { - taskProvider.createIdentityLink(taskId, data, user); - } - - @Override - public void deleteIdentityLink(String taskId, Map data, CIBUser user) { - taskProvider.deleteIdentityLink(taskId, data, user); - } - - @Override - public void handleBpmnError(String taskId, Map data, CIBUser user) throws SystemException { - taskProvider.handleBpmnError(taskId, data, user); - } - - @Override - public Collection findTasksByTaskIdHistory(String taskId, CIBUser user) { - return taskProvider.findTasksByTaskIdHistory(taskId, user); - } - - @Override - public ResponseEntity getDeployedForm(String taskId, CIBUser user) { - return taskProvider.getDeployedForm(taskId, user); - } - - @Override - public ResponseEntity getRenderedForm(String taskId, Map params, CIBUser user) { - return taskProvider.getRenderedForm(taskId, params, user); - } - - @Override - public Integer findHistoryTasksCount(Map filters, CIBUser user) { - return taskProvider.findHistoryTasksCount(filters, user); - } - - @Override - public Collection getTaskCountByCandidateGroup(CIBUser user) { - return taskProvider.getTaskCountByCandidateGroup(user); - } - - /* - - ██████ ██████ ██████ ██████ ███████ ███████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ██████ ██ ██ ██ █████ ███████ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██ ██████ ██████ ███████ ███████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection findProcesses(CIBUser user) { - return processProvider.findProcesses(user); - } - - @Override - public Collection findProcessesWithInfo(CIBUser user) { - return processProvider.findProcessesWithInfo(user); - } - - @Override - public Collection findProcessesWithFilters(String filters, CIBUser user) { - return processProvider.findProcessesWithFilters(filters, user); - } - - @Override - public Process findProcessByDefinitionKey(String key, String tenantId, CIBUser user) { - return processProvider.findProcessByDefinitionKey(key, tenantId, user); - } - - @Override - public Collection findProcessVersionsByDefinitionKey(String key, String tenantId, Optional lazyLoad, CIBUser user) { - return processProvider.findProcessVersionsByDefinitionKey(key, tenantId, lazyLoad, user); - } - - @Override - public Process findProcessById(String id, Optional extraInfo, CIBUser user) throws SystemException { - return processProvider.findProcessById(id, extraInfo, user); - } - - @Override - public Collection findProcessesInstances(String key, CIBUser user) { - return processProvider.findProcessesInstances(key, user); - } - - @Override - public ProcessDiagram fetchDiagram(String id, CIBUser user) { - return processProvider.fetchDiagram(id, user); - } - - @Override - public StartForm fetchStartForm(String processDefinitionId, CIBUser user) { - return processProvider.fetchStartForm(processDefinitionId, user); - } - - @Override - public Data downloadBpmn(String id, String fileName, CIBUser user) { - return processProvider.downloadBpmn(id, fileName, user); - } - - @Override - public void suspendProcessInstance(String processInstanceId, Boolean suspend, CIBUser user) { - processProvider.suspendProcessInstance(processInstanceId, suspend, user); - } - - @Override - public void deleteProcessInstance(String processInstanceId, CIBUser user) { - processProvider.deleteProcessInstance(processInstanceId, user); - } - - @Override - public void suspendProcessDefinition(String processDefinitionId, Boolean suspend, Boolean includeProcessInstances, String executionDate, CIBUser user) { - processProvider.suspendProcessDefinition(processDefinitionId, suspend, includeProcessInstances, executionDate, user); - } - - @Override - public ProcessStart startProcess(String processDefinitionKey, String tenantId, Map data, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { - return processProvider.startProcess(processDefinitionKey, tenantId, data, user); - } - - @Override - public ProcessStart submitForm(String processDefinitionKey, String tenantId, Map data, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { - // Used by Webdesk - return processProvider.submitForm(processDefinitionKey, tenantId, data, user); - } - - @Override - public ProcessStart submitForm(String key, String formResult, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { - return processProvider.submitForm(key, formResult, user); - } - - @Override - public Collection findProcessStatistics(String processId, CIBUser user) throws SystemException, UnsupportedTypeException, ExpressionEvaluationException { - return processProvider.findProcessStatistics(processId, user); - } - - @Override - public Collection getProcessStatistics(Map queryParams, CIBUser user) { - return processProvider.getProcessStatistics(queryParams, user); - } - - @Override - public Collection findProcessesInstancesHistory(Map filters, - Optional firstResult, Optional maxResults, CIBUser user) { - return processProvider.findProcessesInstancesHistory(filters, firstResult, maxResults, user); - } - - @Override - public Collection findProcessesInstancesHistory(String key, Optional active, - Integer firstResult, Integer maxResults, CIBUser user) { - return processProvider.findProcessesInstancesHistory(key, active, firstResult, maxResults, user); - } - - @Override - public Collection findProcessesInstancesHistoryById(String id, Optional activityId, Optional active, - Integer firstResult, Integer maxResults, String text, CIBUser user) { - return processProvider.findProcessesInstancesHistoryById(id, activityId, active, firstResult, maxResults, text, user); - } - - @Override - public Long countProcessesInstancesHistory(Map filters, CIBUser user) { - return processProvider.countProcessesInstancesHistory(filters, user); - } - - @Override - public Long countProcessesInstancesRuntime(Map filters, CIBUser user) { - return processProvider.countProcessesInstancesRuntime(filters, user); - } - - @Override - public ProcessInstance findProcessInstance(String processInstanceId, CIBUser user) { - return processProvider.findProcessInstance(processInstanceId, user); - } - - @Override - public Variable fetchProcessInstanceVariable(String processInstanceId, String variableName, boolean deserializeValue, CIBUser user) throws SystemException { - return processProvider.fetchProcessInstanceVariable(processInstanceId, variableName, deserializeValue, user); - } - - @Override - public HistoryProcessInstance findHistoryProcessInstanceHistory(String processInstanceId, CIBUser user) { - return processProvider.findHistoryProcessInstanceHistory(processInstanceId, user); - } - - @Override - public Collection findCalledProcessDefinitions(String processDefinitionId, CIBUser user) { - return processProvider.findCalledProcessDefinitions(processDefinitionId, user); - } - - @Override - public ResponseEntity getDeployedStartForm(String processDefinitionId, CIBUser user) { - return processProvider.getDeployedStartForm(processDefinitionId, user); - } - - @Override - public ResponseEntity getRenderedStartForm(String processDefinitionId, Map params, CIBUser user) { - return processProvider.getRenderedForm(processDefinitionId, params, user); - } - - @Override - public void updateHistoryTimeToLive(String id, Map data, CIBUser user) { - processProvider.updateHistoryTimeToLive(id, data, user); - } - - @Override - public void deleteProcessInstanceFromHistory(String id, CIBUser user) { - processProvider.deleteProcessInstanceFromHistory(id, user); - } - - @Override - public void deleteProcessDefinition(String id, Optional cascade, CIBUser user) { - processProvider.deleteProcessDefinition(id, cascade, user); - } - - @Override - public Collection findCurrentProcessesInstances(Map data, CIBUser user) - throws SystemException { - return processProvider.findCurrentProcessesInstances(data, user); - } - - @Override - public Collection findProcessesInstancesRuntime(Map data, Optional firstResult, Optional maxResults, CIBUser user) throws SystemException { - return processProvider.findProcessesInstancesRuntime(data, firstResult, maxResults, user); - } - - @Override - public Object fetchHistoricActivityStatistics(String id, Map params, CIBUser user) { - return processProvider.fetchHistoricActivityStatistics(id, params, user); - } - - /* - - ███████ ██ ██ ████████ ███████ ██████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - █████ ██ ██ ██ █████ ██████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection findFilters(CIBUser user) { - return filterProvider.findFilters(user); - } - - @Override - public Filter createFilter(Filter filter, CIBUser user) { - return filterProvider.createFilter(filter, user); - } - - @Override - public void updateFilter(Filter filter, CIBUser user) { - filterProvider.updateFilter(filter, user); - } - - @Override - public void deleteFilter(String filterId, CIBUser user) { - filterProvider.deleteFilter(filterId, user); - } - - /* - - ██████ ███████ ██████ ██ ██████ ██ ██ ███ ███ ███████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ █████ ██████ ██ ██ ██ ████ ██ ████ ██ █████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ███████ ██ ███████ ██████ ██ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Deployment deployBpmn(MultiValueMap data, MultiValueMap file, CIBUser user) throws SystemException { - return deploymentProvider.deployBpmn(data, file, user); - - } - - @Override - public Long countDeployments(CIBUser user, String nameLike) { - return deploymentProvider.countDeployments(user, nameLike); - } - - @Override - public Collection findDeployments(CIBUser user, String nameLike, int firstResult, int maxResults, String sortBy, String sortOrder) { - return deploymentProvider.findDeployments(user, nameLike, firstResult, maxResults, sortBy, sortOrder); - } - - @Override - public Deployment findDeployment(String deploymentId, CIBUser user) { - return deploymentProvider.findDeployment(deploymentId, user); - } - - @Override - public Collection findDeploymentResources(String deploymentId, CIBUser user) { - return deploymentProvider.findDeploymentResources(deploymentId, user); - } - - @Override - public Data fetchDataFromDeploymentResource(HttpServletRequest rq, String deploymentId, String resourceId, String fileName, CIBUser user) { - return deploymentProvider.fetchDataFromDeploymentResource(rq, deploymentId, resourceId, fileName, user); - } - - @Override - public void deleteDeployment(String deploymentId, Boolean cascade, CIBUser user) throws SystemException { - deploymentProvider.deleteDeployment(deploymentId, cascade, user); - } - - /* - - █████ ██████ ████████ ██ ██ ██ ██ ████████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ███████ ██ ██ ██ ██ ██ ██ ██ ████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public ActivityInstance findActivityInstance(String processInstanceId, CIBUser user) { - return activityProvider.findActivityInstance(processInstanceId, user); - } - - @Override - public List findActivitiesInstancesHistory(Map queryParams, CIBUser user) { - return activityProvider.findActivitiesInstancesHistory(queryParams, user); - } - - @Override - public List findActivitiesInstancesHistory(String processInstanceId, CIBUser user) { - return activityProvider.findActivitiesInstancesHistory(processInstanceId, user); - } - - @Override - public ActivityInstance findActivityInstances(String processInstanceId, CIBUser user) throws SystemException { - return activityProvider.findActivityInstances(processInstanceId, user); - } - - @Override - public List findActivityInstanceHistory(String processInstanceId, CIBUser user) throws SystemException { - return activityProvider.findActivityInstanceHistory(processInstanceId, user); - } - - @Override - public void deleteVariableByExecutionId(String executionId, String variableName, CIBUser user) { - activityProvider.deleteVariableByExecutionId(executionId, variableName, user); - } - - @Override - public void deleteVariableHistoryInstance(String id, CIBUser user) { - activityProvider.deleteVariableHistoryInstance(id, user); - } - - /* - - ██ ██ ████████ ██ ██ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██ ██ ██ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ██ ██ ███████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection correlateMessage(Map data, CIBUser user) throws SystemException { - return utilsProvider.correlateMessage(data, user); - } - - @Override - public String findStacktrace(String jobId, CIBUser user) { - return utilsProvider.findStacktrace(jobId, user); - } - - @Override - public String findExternalTaskErrorDetails(String externalTaskId, CIBUser user) { - return incidentProvider.findExternalTaskErrorDetails(externalTaskId, user); - } - - @Override - public String findHistoricExternalTaskErrorDetails(String externalTaskId, CIBUser user) { - return incidentProvider.findHistoricExternalTaskErrorDetails(externalTaskId, user); - } - - @Override - public Collection findHistoricIncidents(Map params, CIBUser user) { - return incidentProvider.findHistoricIncidents(params, user); - } - - @Override - public String findHistoricStacktraceByJobId(String jobId, CIBUser user) { - return incidentProvider.findHistoricStacktraceByJobId(jobId, user); - } - - @Override - public void retryJobById(String jobId, Map data, CIBUser user) { - utilsProvider.retryJobById(jobId, data, user); - } - - @Override - public void retryExternalTask(String externalTaskId, Map data, CIBUser user) { - incidentProvider.retryExternalTask(externalTaskId, data, user); - } - - @Override - public Collection getEventSubscriptions(Optional processInstanceId, - Optional eventType, Optional eventName, CIBUser user) { - return utilsProvider.getEventSubscriptions(processInstanceId, eventType, eventName, user); - } - - /* - - ██ ██ ███████ ███████ ██████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ███████ █████ ██████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ███████ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Authorizations getUserAuthorization(String userId, CIBUser user) { - return userProvider.getUserAuthorization(userId, user); - } - - public long countUsers(Map filters, CIBUser user) throws SystemException { - return userProvider.countUsers(filters, user); - } - - public Collection fetchUsers(CIBUser user) throws SystemException { - return userProvider.fetchUsers(user); - } - - public SevenVerifyUser verifyUser(StandardLogin login, CIBUser user) throws SystemException { - return userProvider.verifyUser(login, user); - } - - @Override - public Collection findUsers(Optional id, Optional firstName, Optional firstNameLike, Optional lastName, Optional lastNameLike, - Optional email, Optional emailLike, Optional memberOfGroup, Optional memberOfTenant, Optional idIn, - Optional firstResult, Optional maxResults, Optional sortBy, Optional sortOrder, - Optional likePatternIgnoreCase, CIBUser user) { - return userProvider.findUsers(id, firstName, firstNameLike, lastName, lastNameLike, email, emailLike, memberOfGroup, memberOfTenant, idIn, firstResult, maxResults, sortBy, sortOrder, likePatternIgnoreCase, user); - } - - @Override - public void createUser(NewUser user, CIBUser flowUser) throws InvalidUserIdException { - userProvider.createUser(user, flowUser); - } - - @Override - public void updateUserProfile(String userId, User user, CIBUser flowUser) { - userProvider.updateUserProfile(userId, user, flowUser); - } - - @Override - public void updateUserCredentials(String userId, Map data, CIBUser user) { - userProvider.updateUserCredentials(userId, data, user); - } - - @Override - public void addMemberToGroup(String groupId, String userId, CIBUser user) { - userProvider.addMemberToGroup(groupId, userId, user); - } - - @Override - public void deleteMemberFromGroup(String groupId, String userId, CIBUser user) { - userProvider.deleteMemberFromGroup(groupId, userId, user); - } - - @Override - public void deleteUser(String userId, CIBUser user) { - userProvider.deleteUser(userId, user); - } - - @Override - public SevenUser getUserProfile(String userId, CIBUser user) { - return userProvider.getUserProfile(userId, user); - } - - @Override - public Collection findGroups(Optional id, Optional name, Optional nameLike, Optional type, - Optional member, Optional memberOfTenant, Optional sortBy, Optional sortOrder, Optional firstResult, - Optional maxResults, CIBUser user) { - return userProvider.findGroups(id, name, nameLike, type, member, memberOfTenant, sortBy, sortOrder, firstResult, maxResults, user); - } - - @Override - public void createGroup(UserGroup group, CIBUser user) { - userProvider.createGroup(group, user); - } - - @Override - public void updateGroup(String groupId, UserGroup group, CIBUser user) { - userProvider.updateGroup(groupId, group, user); - } - - @Override - public void deleteGroup(String groupId, CIBUser user) { - userProvider.deleteGroup(groupId, user); - } - - @Override - public Collection findAuthorization(Optional id, Optional type, Optional userIdIn, Optional groupIdIn, - Optional resourceType, Optional resourceId, Optional sortBy, Optional sortOrder, Optional firstResult, - Optional maxResults, CIBUser user) { - return userProvider.findAuthorization(id, type, userIdIn, groupIdIn, resourceType, resourceId, sortBy, sortOrder, firstResult, maxResults, user); - } - - @Override - public ResponseEntity createAuthorization(Authorization authorization, CIBUser user) { - return userProvider.createAuthorization(authorization, user); - } - - @Override - public void updateAuthorization(String authorizationId, Map data, CIBUser user) { - userProvider.updateAuthorization(authorizationId, data, user); - } - - @Override - public void deleteAuthorization(String authorizationId, CIBUser user) { - userProvider.deleteAuthorization(authorizationId, user); - } - - /* - - ██ ███ ██ ██████ ██ ██████ ███████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ████ ██████ ██ ██████ ███████ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Long countIncident(Map params, CIBUser user) { - return incidentProvider.countIncident(params, user); - } - - @Override - public Long countHistoricIncident(Map params, CIBUser user) { - return incidentProvider.countHistoricIncident(params, user); - } - - @Override - public Collection findIncident(Map params, CIBUser user) { - return incidentProvider.findIncident(params, user); - } - - @Override - public List findIncidentByInstanceId(String processInstanceId, CIBUser user) { - return incidentProvider.findIncidentByInstanceId(processInstanceId, user); - } - - @Override - public Collection fetchIncidents(String processDefinitionKey, CIBUser user) { - return incidentProvider.fetchIncidents(processDefinitionKey, user); - } - - @Override - public Collection fetchIncidentsByInstanceAndActivityId(String processDefinitionKey, String activityId, CIBUser user) { - return incidentProvider.fetchIncidentsByInstanceAndActivityId(processDefinitionKey, activityId, user); - } - - @Override - public void setIncidentAnnotation(String incidentId, Map data, CIBUser user) { - incidentProvider.setIncidentAnnotation(incidentId, data, user); - } - - /* - - ██ ██ █████ ██████ ██ █████ ██████ ██ ███████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ███████ ██████ ██ ███████ ██████ ██ █████ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ████ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ███████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public void modifyVariableByExecutionId(String executionId, Map data, CIBUser user) throws SystemException { - variableProvider.modifyVariableByExecutionId(executionId, data, user); - } - - @Override - public void modifyVariableDataByExecutionId(String executionId, String variableName, MultipartFile data, String valueType, CIBUser user) throws SystemException { - variableProvider.modifyVariableDataByExecutionId(executionId, variableName, data, valueType, user); - } - - @Override - public Collection fetchProcessInstanceVariables(String processInstanceId, Map data, CIBUser user) throws SystemException { - return variableProvider.fetchProcessInstanceVariables(processInstanceId, data, user); - } - - @Override - public ResponseEntity fetchVariableDataByExecutionId(String executionId, String variableName, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchVariableDataByExecutionId(executionId, variableName, user); - } - - @Override - public Collection fetchProcessInstanceVariablesHistory(String processInstanceId, Map data, CIBUser user) throws SystemException { - return variableProvider.fetchProcessInstanceVariablesHistory(processInstanceId, data, user); - } - - @Override - public Collection fetchActivityVariablesHistory(String activityInstanceId, CIBUser user) { - return variableProvider.fetchActivityVariablesHistory(activityInstanceId, user); - } - - @Override - public Collection fetchActivityVariables(String activityInstanceId, CIBUser user) { - return variableProvider.fetchActivityVariables(activityInstanceId, user); - } - - @Override - public ResponseEntity fetchHistoryVariableDataById(String id, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchHistoryVariableDataById(id, user); - } - - @Override - public Variable fetchVariable(String taskId, String variableName, - boolean deserializeValue, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchVariable(taskId, variableName, deserializeValue, user); - } - - @Override - public void deleteVariable(String taskId, String variableName, CIBUser user) throws NoObjectFoundException, SystemException { - variableProvider.deleteVariable(taskId, variableName, user); - } - - @Override - public Map fetchFormVariables(String taskId, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchFormVariables(taskId, deserializeValues, user); - } - - @Override - public Map fetchFormVariables(List variableListName, String taskId, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchFormVariables(variableListName, taskId, deserializeValues, user); - } - - @Override - public Map fetchProcessFormVariables(String key, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchProcessFormVariables(key, deserializeValues, user); - } - - @Override - public Map fetchProcessFormVariables(List variableListName, String key, boolean deserializeValues, CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchProcessFormVariables(variableListName, key, deserializeValues, user); - } - - @Override - public NamedByteArrayDataSource fetchVariableFileData(String taskId, String variableName, CIBUser user) throws NoObjectFoundException, UnexpectedTypeException, SystemException { - return variableProvider.fetchVariableFileData(taskId, variableName, user); - } - - @Override - public void uploadVariableFileData(String taskId, String variableName, MultipartFile data, String valueType, CIBUser user) throws NoObjectFoundException, SystemException { - variableProvider.uploadVariableFileData(taskId, variableName, data, valueType, user); - } - - @Override - public ResponseEntity fetchProcessInstanceVariableData(String processInstanceId, String variableName, - CIBUser user) throws NoObjectFoundException, SystemException { - return variableProvider.fetchProcessInstanceVariableData(processInstanceId, variableName, user); - } - - @Override - public void uploadProcessInstanceVariableFileData(String processInstanceId, String variableName, MultipartFile data, String valueType, CIBUser user) throws NoObjectFoundException, SystemException { - variableProvider.uploadProcessInstanceVariableFileData(processInstanceId, variableName, data, valueType, user); - } - - @Override - public ProcessStart submitStartFormVariables(String processDefinitionId, List formResult, CIBUser user) throws SystemException { - return variableProvider.submitStartFormVariables(processDefinitionId, formResult, user); - } - - @Override - public Variable fetchVariableByProcessInstanceId(String processInstanceId, String variableName, CIBUser user) throws SystemException { - return variableProvider.fetchVariableByProcessInstanceId(processInstanceId, variableName, user); - } - - @Override - public void saveVariableInProcessInstanceId(String processInstanceId, List variables, CIBUser user) throws SystemException { - variableProvider.saveVariableInProcessInstanceId(processInstanceId, variables, user); - } - - @Override - public void submitVariables(String processInstanceId, List formResult, CIBUser user, String processDefinitionId) throws SystemException { - variableProvider.submitVariables(processInstanceId, formResult, user, processDefinitionId); - } - - @Override - public Map fetchProcessFormVariablesById(String id, CIBUser user) throws SystemException { - return variableProvider.fetchProcessFormVariablesById(id, user); - } - - @Override - public void putLocalExecutionVariable(String executionId, String varName, Map data, CIBUser user) { - variableProvider.putLocalExecutionVariable(executionId, varName, data, user); - } - - @Override - public Collection findActivitiesProcessDefinitionHistory(String processDefinitionId, Map params, CIBUser user) { - return activityProvider.findActivitiesProcessDefinitionHistory(processDefinitionId, params, user); - } - - /* - - ██████ ███████ ██████ ██ ███████ ██ ██████ ███ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ █████ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ███████ ██████ ██ ███████ ██ ██████ ██ ████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection getDecisionDefinitionList(Map queryParams, CIBUser user) { - return decisionProvider.getDecisionDefinitionList(queryParams, user); - } - - - @Override - public Long getDecisionDefinitionListCount(Map queryParams, CIBUser user) { - return decisionProvider.getDecisionDefinitionListCount(queryParams, user); - } - - @Override - public Decision getDecisionDefinitionByKey(String key, CIBUser user) { - return decisionProvider.getDecisionDefinitionByKey(key, user); - } - - @Override - public Object getDiagramByKey(String key, CIBUser user) { - return decisionProvider.getDiagramByKey(key, user); - } - - @Override - public Object evaluateDecisionDefinitionByKey(Map data, String key, CIBUser user) { - return decisionProvider.evaluateDecisionDefinitionByKey(data, key, user); - } - - @Override - public void updateHistoryTTLByKey(Map data, String key, CIBUser user) { - decisionProvider.updateHistoryTTLByKey(data, key, user); - } - - @Override - public Decision getDecisionDefinitionByKeyAndTenant(String key, String tenant, CIBUser user) { - return decisionProvider.getDecisionDefinitionByKeyAndTenant(key, tenant, user); - } - - @Override - public Object getDiagramByKeyAndTenant(String key, String tenant, CIBUser user) { - return decisionProvider.getDiagramByKeyAndTenant(key, tenant, user); - } - - @Override - public Object evaluateDecisionDefinitionByKeyAndTenant(Map data, String key, String tenant, CIBUser user) { - return decisionProvider.evaluateDecisionDefinitionByKeyAndTenant(data, key, tenant, user); - } - - @Override - public void updateHistoryTTLByKeyAndTenant(Map data, String key, String tenant, CIBUser user) { - decisionProvider.updateHistoryTTLByKeyAndTenant(data, key, tenant, user); - } - - @Override - public Object getXmlByKey(String key, CIBUser user) { - return decisionProvider.getXmlByKey(key, user); - } - - @Override - public Object getXmlByKeyAndTenant(String key, String tenant, CIBUser user) { - return decisionProvider.getXmlByKeyAndTenant(key, tenant, user); - } - - @Override - public Decision getDecisionDefinitionById(String id, Optional extraInfo, CIBUser user) { - return decisionProvider.getDecisionDefinitionById(id, extraInfo, user); - } - - @Override - public Object getDiagramById(String id, CIBUser user) { - return decisionProvider.getDiagramById(id, user); - } - - @Override - public Object evaluateDecisionDefinitionById(String id, Map data, CIBUser user) { - return decisionProvider.evaluateDecisionDefinitionById(id, data, user); - } - - @Override - public void updateHistoryTTLById(String id, Map data, CIBUser user) { - decisionProvider.updateHistoryTTLById(id, data, user); - } - - @Override - public Object getXmlById(String id, CIBUser user) { - return decisionProvider.getXmlById(id, user); - } - - @Override - public Collection getDecisionVersionsByKey(String key, Optional lazyLoad, CIBUser user) { - return decisionProvider.getDecisionVersionsByKey(key, lazyLoad, user); - } - - @Override - public Collection getHistoricDecisionInstances(Map queryParams, CIBUser user){ - return decisionProvider.getHistoricDecisionInstances(queryParams, user); - } - - @Override - public Long getHistoricDecisionInstanceCount(Map queryParams, CIBUser user){ - return decisionProvider.getHistoricDecisionInstanceCount(queryParams, user); - } - - @Override - public HistoricDecisionInstance getHistoricDecisionInstanceById(String id, Map queryParams, CIBUser user){ - return decisionProvider.getHistoricDecisionInstanceById(id, queryParams, user); - } - - @Override - public Object deleteHistoricDecisionInstances(Map data, CIBUser user){ - return decisionProvider.deleteHistoricDecisionInstances(data, user); - } - - @Override - public Object setHistoricDecisionInstanceRemovalTime(Map data, CIBUser user){ - return decisionProvider.setHistoricDecisionInstanceRemovalTime(data, user); - } - - /* - - ██ ██████ ██████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - █████ ██████ ██████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection findJobDefinitions(String params, CIBUser user) { - return jobDefinitionProvider.findJobDefinitions(params, user); - } - - @Override - public void suspendJobDefinition(String jobDefinitionId, String params, CIBUser user) { - jobDefinitionProvider.suspendJobDefinition(jobDefinitionId, params, user); - } - - @Override - public void overrideJobDefinitionPriority(String jobDefinitionId, String params, CIBUser user) { - jobDefinitionProvider.overrideJobDefinitionPriority(jobDefinitionId, params, user); - } - - @Override - public void retryJobDefinitionById(String id, Map params, CIBUser user) { - jobDefinitionProvider.retryJobDefinitionById(id, params, user); - } - - @Override - public Collection getJobs(Map params, CIBUser user) { - return jobProvider.getJobs(params, user); - } - - @Override - public void setSuspended(String id, Map params, CIBUser user) { - jobProvider.setSuspended(id, params, user); - } - - @Override - public void deleteJob(String id, CIBUser user) { - jobProvider.deleteJob(id, user); - } - - @Override - public JobDefinition findJobDefinition(String id, CIBUser user) { - return jobDefinitionProvider.findJobDefinition(id, user); - } - - @Override - public Collection getHistoryJobLog(Map params, CIBUser user) { - return jobProvider.getHistoryJobLog(params, user); - } - - @Override - public String getHistoryJobLogStacktrace(String id, CIBUser user) { - return jobProvider.getHistoryJobLogStacktrace(id, user); - } - - @Override - public void changeDueDate(String id, Map data, CIBUser user) { - jobProvider.changeDueDate(id, data, user); - } - - @Override - public void recalculateDueDate(String id, Map params, CIBUser user) { - jobProvider.recalculateDueDate(id, params, user); - } - - /* - - ██████ █████ ████████ ██████ ██ ██ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ███████ ██ ██ ███████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ██ ██ ██ ██████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection getBatches(Map params, CIBUser user) { - return batchProvider.getBatches(params, user); - } - - @Override - public Collection getBatchStatistics(Map params, CIBUser user) { - return batchProvider.getBatchStatistics(params, user); - } - - @Override - public void deleteBatch(String id, Map params, CIBUser user) { - batchProvider.deleteBatch(id, params, user); - } - - @Override - public void setBatchSuspensionState(String id, Map params, CIBUser user) { - batchProvider.setBatchSuspensionState(id, params, user); - } - - @Override - public Collection getHistoricBatches(Map params, CIBUser user) { - return batchProvider.getHistoricBatches(params, user); - } - - @Override - public Long getRuntimeBatchCount(Map queryParams, CIBUser user) { - return batchProvider.getRuntimeBatchCount(queryParams, user); - } - - @Override - public Long getHistoricBatchCount(Map queryParams, CIBUser user) { - return batchProvider.getHistoricBatchCount(queryParams, user); - } - - @Override - public HistoryBatch getHistoricBatchById(String id, CIBUser user) { - return batchProvider.getHistoricBatchById(id, user); - } - - @Override - public void deleteHistoricBatch(String id, CIBUser user) { - batchProvider.deleteHistoricBatch(id, user); - } - - @Override - public Object setRemovalTime(Map payload, CIBUser user) { - return batchProvider.setRemovalTime(payload, user); - } - - @Override - public Object getCleanableBatchReport(Map queryParams, CIBUser user) { - return batchProvider.getCleanableBatchReport(queryParams, user); - } - - @Override - public Object getCleanableBatchReportCount(CIBUser user) { - return batchProvider.getCleanableBatchReportCount(user); - } - - /* - - ███████ ██ ██ ███████ ████████ ███████ ███ ███ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ███████ ████ ███████ ██ █████ ██ ████ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ███████ ██ ███████ ██ ███████ ██ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public JsonNode getTelemetryData(CIBUser user) { - return systemProvider.getTelemetryData(user); - } - - @Override - public Collection getMetrics(Map queryParams, CIBUser user) { - return systemProvider.getMetrics(queryParams, user); - } - - /* - - ████████ ███████ ███ ██ █████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ █████ ██ ██ ██ ███████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ███████ ██ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection fetchTenants(Map queryParams, CIBUser user) { - return tenantProvider.fetchTenants(queryParams, user); - } - - @Override - public Tenant fetchTenant(String tenantId, CIBUser user) { - return tenantProvider.fetchTenant(tenantId, user); - } - - @Override - public void createTenant(Tenant tenant, CIBUser user) { - tenantProvider.createTenant(tenant, user); - } - - @Override - public void updateTenant(Tenant tenant, CIBUser user) { - tenantProvider.updateTenant(tenant, user); - } - @Override - public void deleteTenant(String tenantId, CIBUser user) { - tenantProvider.deleteTenant(tenantId, user); - } - - @Override - public void addMemberToTenant(String tenantId, String userId, CIBUser user) { - tenantProvider.addMemberToTenant(tenantId, userId, user); - } - - @Override - public void deleteMemberFromTenant(String tenantId, String userId, CIBUser user) { - tenantProvider.deleteMemberFromTenant(tenantId, userId, user); - } - - @Override - public void addGroupToTenant(String tenantId, String groupId, CIBUser user) { - tenantProvider.addGroupToTenant(tenantId, groupId, user); - } - - @Override - public void deleteGroupFromTenant(String tenantId, String groupId, CIBUser user) { - tenantProvider.deleteGroupFromTenant(tenantId, groupId, user); - } - - /* - - ██ ██ █████ ██████ ██ █████ ██████ ██ ███████ ██ ███ ██ ███████ ████████ █████ ███ ██ ██████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ███████ ██████ ██ ███████ ██████ ██ █████ ██ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ████ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ███████ ██ ██ ████ ███████ ██ ██ ██ ██ ████ ██████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public VariableInstance getVariableInstance(String id, boolean deserializeValue, CIBUser user) throws SystemException, NoObjectFoundException { - return variableInstanceProvider.getVariableInstance(id, deserializeValue, user); - } - - /* - - ██ ██ ██ ███████ ████████ ██████ ██████ ██ ██████ ██ ██ █████ ██████ ██ █████ ██████ ██ ███████ ██ ███ ██ ███████ ████████ █████ ███ ██ ██████ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ███████ ██ ███████ ██ ██ ██ ██████ ██ ██ ██ ██ ███████ ██████ ██ ███████ ██████ ██ █████ ██ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ ██ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ ██ ███████ ██ ██████ ██ ██ ██ ██████ ████ ██ ██ ██ ██ ██ ██ ██ ██████ ███████ ███████ ██ ██ ████ ███████ ██ ██ ██ ██ ████ ██████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - @Override - public VariableHistory getHistoricVariableInstance(String id, boolean deserializeValue, CIBUser user) throws SystemException, NoObjectFoundException { - return historicVariableInstanceProvider.getHistoricVariableInstance(id, deserializeValue, user); - } - - /* - - ███████ ██ ██ ████████ ███████ ██████ ███ ██ █████ ██ ████████ █████ ███████ ██ ██ ██ ██████ ██████ - ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - █████ ███ ██ █████ ██████ ██ ██ ██ ███████ ██ ██ ███████ ███████ █████ ██ ██ ██ ██ ███ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ███████ ██ ██ ██ ███████ ██ ██ ██ ████ ██ ██ ███████ ██ ██ ██ ███████ ██ ██ ███████ ██████ ██████ - - */ - - @Override - public Collection getExternalTasks(Map queryParams, CIBUser user) throws SystemException { - return externalTaskProvider.getExternalTasks(queryParams, user); - } - - /* - - ██████ ███████ ██████ ██ ██████ ██ ██ ███ ███ ███████ ███ ██ ████████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██ ██ █████ ██████ ██ ██ ██ ████ ██ ████ ██ █████ ██ ██ ██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ██████ ███████ ██ ███████ ██████ ██ ██ ██ ███████ ██ ████ ██ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Deployment createDeployment(MultiValueMap data, MultipartFile[] files, CIBUser user) throws SystemException { - return deploymentProvider.createDeployment(data, files, user); - } - - @Override - public Deployment redeployDeployment(String id, Map data, CIBUser user) throws SystemException { - return deploymentProvider.redeployDeployment(id, data, user); - } - - /* - - ███████ ███ ██ ██████ ██ ███ ██ ███████ ██████ ██████ ██████ ██ ██ ██ ██████ ███████ ██████ - ██ ████ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - █████ ██ ██ ██ ██ ███ ██ ██ ██ ██ █████ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ █████ ██████ - ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ - ███████ ██ ████ ██████ ██ ██ ████ ███████ ██ ██ ██ ██████ ████ ██ ██████ ███████ ██ ██ - - */ - - @Override - public Collection getProcessEngineNames() { - return engineProvider.getProcessEngineNames(); - } - - @Override - public Boolean requiresSetup(String engine) { - return engineProvider.requiresSetup(engine); - } - - @Override - public void createSetupUser(NewUser user, String engine) throws InvalidUserIdException { - engineProvider.createSetupUser(user, engine); - } - @Override - public PasswordPolicyResponse validatePasswordPolicy(PasswordPolicyRequest request) throws SystemException { - return identityProvider.validatePasswordPolicy(request); - } + @Autowired private IIdentityProvider identityProvider; } diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/VariableProvider.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/VariableProvider.java index 61ef5d0b3..7bb85a8a5 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/VariableProvider.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/providers/VariableProvider.java @@ -99,46 +99,6 @@ public void modifyVariableDataByExecutionId(String executionId, String variableN } } - private void mergeVariablesValues( - Collection variablesDeserialized, - Collection variablesSerialized, - boolean deserializeValues) { - - if (variablesDeserialized == null) { - return; - } - - if (variablesSerialized == null) { - return; - } - - Collection variables = (deserializeValues) ? variablesDeserialized : variablesSerialized; - variables.forEach(variable -> { - String name = variable.getName(); - - // Skip variables with null names to avoid NullPointerException - if (name == null) { - return; - } - - Variable variableSerialized = (!deserializeValues) ? variable : variablesSerialized.stream() - .filter(v -> v.getName() != null && v.getName().equals(name)) - .findFirst() - .orElse(null); - if (variableSerialized != null) { - variable.setValueSerialized(variableSerialized.getValue()); - } - - Variable variableDeserialized = (deserializeValues) ? variable : variablesDeserialized.stream() - .filter(v -> v.getName() != null && v.getName().equals(name)) - .findFirst() - .orElse(null); - if (variableDeserialized != null) { - variable.setValueDeserialized(variableDeserialized.getValue()); - } - }); - } - @Override public Collection fetchProcessInstanceVariables(String processInstanceId, Map data, CIBUser user) throws SystemException { diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AdminService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AdminService.java index b5a2c7c8f..2e27b26ff 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AdminService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AdminService.java @@ -29,7 +29,6 @@ import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Authorization; import org.cibseven.webapp.rest.model.NewUser; import org.cibseven.webapp.rest.model.User; @@ -57,12 +56,8 @@ public class AdminService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("AdminService expects a BpmProvider"); } @Operation( diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AnalyticsService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AnalyticsService.java index a66567998..9391c3b21 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AnalyticsService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/AnalyticsService.java @@ -26,11 +26,9 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; import org.cibseven.webapp.providers.IProcessProvider; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Analytics; import org.cibseven.webapp.rest.model.AnalyticsInfo; import org.cibseven.webapp.rest.model.Decision; @@ -59,13 +57,7 @@ public class AnalyticsService extends BaseService implements InitializingBean { @Autowired IProcessProvider processProvider; - SevenProvider sevenProvider; - public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else - throw new SystemException("AnalyticsService expects a BpmProvider"); } @Operation(summary = "Get analytics for processes, decisions and human Tasks", description = "Return: Analytics") @@ -141,7 +133,7 @@ public Analytics getAnalytics(Locale loc, CIBUser user) { analytics.setDeploymentsCount(deploymentsCount); } - final Long runtimeBatchCount = sevenProvider.getRuntimeBatchCount(new HashMap<>(), user); + final Long runtimeBatchCount = bpmProvider.getRuntimeBatchCount(new HashMap<>(), user); analytics.setBatchesCount(runtimeBatchCount != null ? runtimeBatchCount : 0L); return analytics; diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/BatchService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/BatchService.java index 23a9f7ae5..9c27927e6 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/BatchService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/BatchService.java @@ -22,10 +22,8 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Batch; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -37,12 +35,8 @@ public class BatchService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("BatchService expects a BpmProvider"); } @GetMapping diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/DecisionService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/DecisionService.java index c0387ca44..cf947e49c 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/DecisionService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/DecisionService.java @@ -25,9 +25,7 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Decision; import org.springframework.beans.factory.InitializingBean; import org.springframework.http.ResponseEntity; @@ -66,12 +64,7 @@ @RestController("WebclientDecisionService") @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/decision") public class DecisionService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; - public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("DecisionService expects a BpmProvider"); } @Operation( diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ExternalTaskService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ExternalTaskService.java index a86ca6799..dc32bb0c3 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ExternalTaskService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ExternalTaskService.java @@ -21,24 +21,18 @@ import java.util.Map; import org.cibseven.webapp.auth.CIBUser; -import org.cibseven.webapp.exception.SystemException; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.ExternalTask; import org.springframework.beans.factory.InitializingBean; import org.springframework.web.bind.annotation.*; + import jakarta.servlet.http.HttpServletRequest; @RestController("WebclientExternalTaskService") @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/external-tasks") public class ExternalTaskService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else - throw new SystemException("ExternalTaskService expects a BpmProvider"); } @GetMapping diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoricVariableInstanceService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoricVariableInstanceService.java index 2abaf3ad7..ea45f39f1 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoricVariableInstanceService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoricVariableInstanceService.java @@ -18,9 +18,7 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.VariableHistory; import org.springframework.beans.factory.InitializingBean; import org.springframework.web.bind.annotation.GetMapping; @@ -52,12 +50,7 @@ @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/history/variable-instance") public class HistoricVariableInstanceService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; - public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("HistoricVariableInstanceService expects a SevenProvider"); } @Operation( diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoryBatchService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoryBatchService.java index c6b36a7a9..4503e2d83 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoryBatchService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/HistoryBatchService.java @@ -22,10 +22,8 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.HistoryBatch; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -39,12 +37,8 @@ public class HistoryBatchService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("HistoryBatchService expects a BpmProvider"); } diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/IncidentService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/IncidentService.java index 427f7832b..40fcad685 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/IncidentService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/IncidentService.java @@ -20,14 +20,10 @@ import java.util.Locale; import java.util.Map; -import jakarta.servlet.http.HttpServletRequest; - import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Incident; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -44,6 +40,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.servlet.http.HttpServletRequest; @ApiResponses({ @ApiResponse(responseCode = "500", description = "An unexpected system error occured"), @@ -55,13 +52,8 @@ public class IncidentService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else - throw new SystemException("IncidentService expects a BpmProvider"); } @Operation(summary = "Get number of incidents", description = "Return: Number of incidents") @@ -70,7 +62,7 @@ public void afterPropertiesSet() { public Long countIncident(@RequestParam Map params, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.PROCESS_INSTANCE, PermissionConstants.READ_ALL); - return sevenProvider.countIncident(params, user); + return bpmProvider.countIncident(params, user); } @Operation(summary = "Get number of historic incidents", description = "Return: Number of incidents") @@ -79,7 +71,7 @@ public Long countIncident(@RequestParam Map params, HttpServletR public Long countHistoricIncident(@RequestParam Map params, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.HISTORIC_PROCESS_INSTANCE, PermissionConstants.READ_ALL); - return sevenProvider.countHistoricIncident(params, user); + return bpmProvider.countHistoricIncident(params, user); } @Operation(summary = "Get incident/s", description = "Return: Collection of incident/s") @@ -88,7 +80,7 @@ public Long countHistoricIncident(@RequestParam Map params, Http public Collection findIncident(@RequestParam Map params, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.PROCESS_INSTANCE, PermissionConstants.READ_ALL); - return sevenProvider.findIncident(params, user); + return bpmProvider.findIncident(params, user); } @Operation(summary = "Get stack trace", description = "Return: Stacktrace") @@ -99,7 +91,7 @@ public String findStacktrace( Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); - return sevenProvider.findStacktrace(jobId, user); + return bpmProvider.findStacktrace(jobId, user); } @Operation(summary = "Get external task error details", description = "Return: Error details") @@ -109,7 +101,7 @@ public String findExternalTaskErrorDetails( @Parameter(description = "External Task Id") @PathVariable String externalTaskId, Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); - return sevenProvider.findExternalTaskErrorDetails(externalTaskId, user); + return bpmProvider.findExternalTaskErrorDetails(externalTaskId, user); } @Operation(summary = "Get historic external task error details", description = "Return: Historic error details") @@ -119,7 +111,7 @@ public String findHistoricExternalTaskErrorDetails( @Parameter(description = "External Task Id") @PathVariable String externalTaskId, Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); - return sevenProvider.findHistoricExternalTaskErrorDetails(externalTaskId, user); + return bpmProvider.findHistoricExternalTaskErrorDetails(externalTaskId, user); } @Operation(summary = "Get historic incidents", description = "Return: Collection of historic incidents") @@ -128,7 +120,7 @@ public String findHistoricExternalTaskErrorDetails( public Collection findHistoricIncidents(@RequestParam Map params, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.PROCESS_INSTANCE, PermissionConstants.READ_ALL); - return sevenProvider.findHistoricIncidents(params, user); + return bpmProvider.findHistoricIncidents(params, user); } @Operation(summary = "Get historic stack trace by job id", description = "Return: Historic stacktrace") @@ -138,7 +130,7 @@ public String findHistoricStacktraceByJobId( @Parameter(description = "Job Id") @PathVariable String jobId, Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); - return sevenProvider.findHistoricStacktraceByJobId(jobId, user); + return bpmProvider.findHistoricStacktraceByJobId(jobId, user); } @Operation(summary = "Increment job retries by job id", description = "Return: void") @@ -149,7 +141,7 @@ public ResponseEntity retryJobByID( @RequestBody Map data, Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); - sevenProvider.retryJobById(jobId, data, user); + bpmProvider.retryJobById(jobId, data, user); // return 204 No Content, no body return ResponseEntity.noContent().build(); } @@ -163,7 +155,7 @@ public ResponseEntity retryExternalTask( Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.PROCESS_INSTANCE, PermissionConstants.UPDATE_ALL); - sevenProvider.retryExternalTask(externalTaskId, data, user); + bpmProvider.retryExternalTask(externalTaskId, data, user); // return 204 No Content, no body return ResponseEntity.noContent().build(); } diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobDefinitionService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobDefinitionService.java index 27f55cbdc..bbd76b896 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobDefinitionService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobDefinitionService.java @@ -18,18 +18,24 @@ import java.util.Collection; import java.util.Map; + import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; import org.cibseven.webapp.exception.AccessDeniedException; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.JobDefinition; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -43,12 +49,8 @@ public class JobDefinitionService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("JobDefinitionService expects a BpmProvider"); } @Operation( diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobService.java index ebd84acf2..ee677c1e0 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/JobService.java @@ -21,25 +21,20 @@ import java.util.Map; import org.cibseven.webapp.auth.CIBUser; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Job; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; + import jakarta.servlet.http.HttpServletRequest; @RestController @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/job") public class JobService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("JobService expects a BpmProvider"); } @PostMapping diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessDefinitionService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessDefinitionService.java index 8915551f7..9601ef722 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessDefinitionService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessDefinitionService.java @@ -22,9 +22,7 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.ProcessStart; import org.cibseven.webapp.rest.model.StartForm; import org.cibseven.webapp.rest.model.Variable; @@ -49,13 +47,9 @@ @RestController @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/process-definition") public class ProcessDefinitionService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; - + @Override public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("ProcessDefinitionService expects a BpmProvider"); } @Operation( diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessService.java index 1b6adb09d..d12b5da34 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/ProcessService.java @@ -17,6 +17,7 @@ package org.cibseven.webapp.rest; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -24,8 +25,6 @@ import java.util.Map; import java.util.Optional; -import java.nio.charset.StandardCharsets; - import org.cibseven.webapp.Data; import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; @@ -35,7 +34,6 @@ import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.logger.TaskLogger; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.ActivityInstance; import org.cibseven.webapp.rest.model.Deployment; import org.cibseven.webapp.rest.model.DeploymentResource; @@ -63,6 +61,8 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -71,7 +71,6 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.core.MediaType; -import com.fasterxml.jackson.databind.ObjectMapper; @ApiResponses({ @ApiResponse(responseCode = "500", description = "An unexpected system error occured"), @@ -80,12 +79,7 @@ @RestController @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/process") public class ProcessService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; - public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("ProcessService expects a BpmProvider"); } @Operation( @@ -648,7 +642,7 @@ public ProcessInstance findProcessInstance( Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.PROCESS_INSTANCE, PermissionConstants.READ_ALL); - return sevenProvider.findProcessInstance(processInstanceId, user); + return bpmProvider.findProcessInstance(processInstanceId, user); } //Requested by OFDKA @@ -674,7 +668,7 @@ public ResponseEntity findProcessInstanceVariableData( checkPermission(user, SevenResourceType.PROCESS_DEFINITION, PermissionConstants.READ_INSTANCE_VARIABLE_ALL); // Get the variable data from the provider - ResponseEntity response = sevenProvider.fetchProcessInstanceVariableData(processInstanceId, variableName, user); + ResponseEntity response = bpmProvider.fetchProcessInstanceVariableData(processInstanceId, variableName, user); // If contentType is provided, set preview headers if (contentType.isPresent() && !contentType.get().isEmpty()) { @@ -705,7 +699,7 @@ public ResponseEntity uploadProcessInstanceVariableFileData( checkPermission(user, SevenResourceType.PROCESS_DEFINITION, PermissionConstants.UPDATE_INSTANCE_VARIABLE_ALL); final String valueTypeStr = valueType.orElse("File"); // Enum: "Bytes" "File" try { - sevenProvider.uploadProcessInstanceVariableFileData(processInstanceId, variableName, data, valueTypeStr, user); + bpmProvider.uploadProcessInstanceVariableFileData(processInstanceId, variableName, data, valueTypeStr, user); return ResponseEntity.noContent().build(); } catch (Exception e) { if (e instanceof NoObjectFoundException) { @@ -728,7 +722,7 @@ public Variable findProcessInstanceVariable( CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.PROCESS_DEFINITION, PermissionConstants.READ_INSTANCE_VARIABLE_ALL); boolean deserialize = (deserializeValue == null) || (deserializeValue != null && deserializeValue == true); - return sevenProvider.fetchProcessInstanceVariable(processInstanceId, variableName, deserialize, user); + return bpmProvider.fetchProcessInstanceVariable(processInstanceId, variableName, deserialize, user); } @Operation( @@ -746,7 +740,7 @@ public Variable fetchChatComments( try { boolean deserializeValue = (deserialize == null) || (deserialize != null && deserialize == "true"); - return sevenProvider.fetchProcessInstanceVariable(processInstanceId, "chatComments", deserializeValue, user); + return bpmProvider.fetchProcessInstanceVariable(processInstanceId, "chatComments", deserializeValue, user); } catch(NoObjectFoundException e) { return null; } @@ -768,7 +762,7 @@ public Variable fetchStatusDataset( try { boolean deserializeValue = (deserialize == null) || (deserialize != null && deserialize == "true"); - return sevenProvider.fetchProcessInstanceVariable(processInstanceId, "_statusDataset", deserializeValue, user); + return bpmProvider.fetchProcessInstanceVariable(processInstanceId, "_statusDataset", deserializeValue, user); } catch(NoObjectFoundException e) { return null; } @@ -807,7 +801,7 @@ public Collection getEventSubscriptions( @Parameter(description = "Event name") @RequestParam Optional eventName, Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); - return sevenProvider.getEventSubscriptions(processInstanceId, eventType, eventName, user); + return bpmProvider.getEventSubscriptions(processInstanceId, eventType, eventName, user); } @Operation( @@ -883,7 +877,7 @@ public ResponseEntity fetchVariableByProcessInstanceId(@PathVariable S @SuppressWarnings("unchecked") protected ResponseEntity generateErrorResponse(String message, HttpStatus status) { - ResponseEntity response = new ResponseEntity<>(message, status); + ResponseEntity response = ResponseEntity.status(status).body(message); return (ResponseEntity) response; } diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/SystemService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/SystemService.java index e2b655cb7..a74507077 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/SystemService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/SystemService.java @@ -20,9 +20,7 @@ import java.util.Map; import org.cibseven.webapp.auth.CIBUser; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Metric; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -44,15 +42,11 @@ public class SystemService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; @Autowired private CustomRestTemplate restTemplate; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("SystemService expects a BpmProvider"); } @GetMapping("/telemetry/data") diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TaskService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TaskService.java index 1a8961997..4bcfe29c9 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TaskService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TaskService.java @@ -16,14 +16,13 @@ */ package org.cibseven.webapp.rest; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; -import java.nio.charset.StandardCharsets; - import org.cibseven.webapp.NamedByteArrayDataSource; import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; @@ -33,7 +32,6 @@ import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.logger.TaskLogger; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.CandidateGroupTaskCount; import org.cibseven.webapp.rest.model.IdentityLink; import org.cibseven.webapp.rest.model.Task; @@ -51,6 +49,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.databind.ObjectMapper; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -66,18 +66,13 @@ @RestController("WebclientTaskService") @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}") public class TaskService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; - @Autowired private CustomRestTemplate restTemplate; - + @Value("${cibseven.webclient.engineRest.url:./}") private String cibsevenUrl; - + public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("TaskService expects a BpmProvider"); } /* @@ -96,7 +91,7 @@ public Integer findTasksCount( @RequestBody Map filters, Locale loc, CIBUser user) { checkPermission(user, SevenResourceType.TASK, PermissionConstants.READ_ALL); - return sevenProvider.findTasksCount(filters, user); + return bpmProvider.findTasksCount(filters, user); } //Not used @@ -359,7 +354,7 @@ public Collection findTasksPost( Locale loc, HttpServletRequest rq) { CIBUser user = checkAuthorization(rq, true); checkPermission(user, SevenResourceType.TASK, PermissionConstants.READ_ALL); - return sevenProvider.findTasksPost(data, user); + return bpmProvider.findTasksPost(data, user); } @Operation( @@ -459,7 +454,7 @@ public ResponseEntity submitVariables(@PathVariable String taskId, @Requ @SuppressWarnings("unchecked") protected ResponseEntity generateErrorResponse(String message, HttpStatus status) { - ResponseEntity response = new ResponseEntity<>(message, status); + ResponseEntity response = ResponseEntity.status(status).body(message); return (ResponseEntity) response; } diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TenantService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TenantService.java index d72788c16..f0abecb2f 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TenantService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/TenantService.java @@ -20,9 +20,7 @@ import java.util.Map; import org.cibseven.webapp.auth.CIBUser; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.BpmProvider; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.Tenant; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -48,12 +46,8 @@ public class TenantService extends BaseService implements InitializingBean { @Autowired BpmProvider bpmProvider; - SevenProvider sevenProvider; public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("TenantService expects a BpmProvider"); } @GetMapping diff --git a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/VariableInstanceService.java b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/VariableInstanceService.java index 3dc204d27..faa047a5f 100644 --- a/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/VariableInstanceService.java +++ b/cibseven-webclient-core/src/main/java/org/cibseven/webapp/rest/VariableInstanceService.java @@ -18,9 +18,7 @@ import org.cibseven.webapp.auth.CIBUser; import org.cibseven.webapp.auth.SevenResourceType; -import org.cibseven.webapp.exception.SystemException; import org.cibseven.webapp.providers.PermissionConstants; -import org.cibseven.webapp.providers.SevenProvider; import org.cibseven.webapp.rest.model.VariableInstance; import org.springframework.beans.factory.InitializingBean; import org.springframework.web.bind.annotation.GetMapping; @@ -52,12 +50,7 @@ @RequestMapping("${cibseven.webclient.services.basePath:/services/v1}" + "/variable-instance") public class VariableInstanceService extends BaseService implements InitializingBean { - SevenProvider sevenProvider; - public void afterPropertiesSet() { - if (bpmProvider instanceof SevenProvider) - sevenProvider = (SevenProvider) bpmProvider; - else throw new SystemException("VariableInstanceService expects a SevenProvider"); } @Operation( diff --git a/pom.xml b/pom.xml index cef32f4a2..d3b9d40b0 100644 --- a/pom.xml +++ b/pom.xml @@ -88,8 +88,10 @@ You may obtain a copy of the License at + cibseven-interfaces cibseven-webclient-web cibseven-webclient-core + cibseven-direct-provider cibseven-webclient-web-sb4