private void validateDisplayName(final ApplicationUpdater updater) throws UpdateException { if (updater.getFields().keySet().contains(ApplicationField.DISPLAY_NAME)) { final String displayName = (String) updater.getFields().get(ApplicationField.DISPLAY_NAME); if (displayName == null || displayName.trim().isEmpty()) { throw new UpdateException("The application display name can not be null or empty"); } } }
protected void verifyTypeOfNewDataValue(final SDataInstance sDataInstance, final Serializable dataValue, ClassLoader classLoader) throws UpdateException { final String dataClassName = sDataInstance.getClassName(); Class<?> dataClass; try { dataClass = classLoader.loadClass(dataClassName); } catch (final ClassNotFoundException e) { throw new UpdateException(e); } if (!dataClass.isInstance(dataValue)) { final UpdateException e = new UpdateException("The type of new value [" + dataValue.getClass().getName() + "] is not compatible with the type of the data."); e.setDataName(sDataInstance.getName()); e.setDataClassName(dataClassName); throw e; } }
private void validateDisplayName(final ApplicationUpdater updater) throws UpdateException { if (updater.getFields().keySet().contains(ApplicationField.DISPLAY_NAME)) { final String displayName = (String) updater.getFields().get(ApplicationField.DISPLAY_NAME); if (displayName == null || displayName.trim().isEmpty()) { throw new UpdateException("The application display name can not be null or empty"); } } }
protected void verifyTypeOfNewDataValue(final SDataInstance sDataInstance, final Serializable dataValue, ClassLoader classLoader) throws UpdateException { final String dataClassName = sDataInstance.getClassName(); Class<?> dataClass; try { dataClass = classLoader.loadClass(dataClassName); } catch (final ClassNotFoundException e) { throw new UpdateException(e); } if (!dataClass.isInstance(dataValue)) { final UpdateException e = new UpdateException("The type of new value [" + dataValue.getClass().getName() + "] is not compatible with the type of the data."); e.setDataName(sDataInstance.getName()); e.setDataClassName(dataClassName); throw e; } }
private void handleResult(final Map<String, TaskResult<Void>> result) throws UpdateException { for (final Entry<String, TaskResult<Void>> entry : result.entrySet()) { if (entry.getValue().isError()) { throw new UpdateException("There is at least one exception on the node " + entry.getKey(), entry.getValue().getThrowable()); } if (entry.getValue().isTimeout()) { throw new UpdateException("There is at least one timeout after " + entry.getValue().getTimeout() + " " + entry.getValue().getTimeunit() + " on the node " + entry.getKey()); } } }
private void handleResult(final Map<String, TaskResult<Void>> result) throws UpdateException { for (final Entry<String, TaskResult<Void>> entry : result.entrySet()) { if (entry.getValue().isError()) { throw new UpdateException("There is at least one exception on the node " + entry.getKey(), entry.getValue().getThrowable()); } if (entry.getValue().isTimeout()) { throw new UpdateException("There is at least one timeout after " + entry.getValue().getTimeout() + " " + entry.getValue().getTimeunit() + " on the node " + entry.getKey()); } } }
@Override public void updateDueDateOfTask(final long userTaskId, final Date dueDate) throws UpdateException { final ActivityInstanceService activityInstanceService = getTenantAccessor().getActivityInstanceService(); try { final SetExpectedEndDate updateProcessInstance = new SetExpectedEndDate(activityInstanceService, userTaskId, dueDate); updateProcessInstance.execute(); } catch (final SFlowNodeNotFoundException e) { throw new UpdateException(e); } catch (final SBonitaException e) { throw new UpdateException(e); } }
@Override public void update(final String platformCommandName, final CommandUpdater updater) throws UpdateException { if (updater == null || updater.getFields().isEmpty()) { throw new UpdateException("The update descriptor does not contain field updates"); } final PlatformServiceAccessor platformAccessor = getPlatformServiceAccessor(); final PlatformCommandService platformCommandService = platformAccessor.getPlatformCommandService(); try { final UpdateSPlatformCommand updatePlatformCommand = new UpdateSPlatformCommand(platformCommandService, platformCommandName, updater); updatePlatformCommand.execute(); } catch (final SCommandNotFoundException scnfe) { throw new UpdateException(scnfe); } catch (final SBonitaException e) { throw new UpdateException(e); } }
@Override public void update(final String platformCommandName, final CommandUpdater updater) throws UpdateException { if (updater == null || updater.getFields().isEmpty()) { throw new UpdateException("The update descriptor does not contain field updates"); } final PlatformServiceAccessor platformAccessor = getPlatformServiceAccessor(); final PlatformCommandService platformCommandService = platformAccessor.getPlatformCommandService(); try { final UpdateSPlatformCommand updatePlatformCommand = new UpdateSPlatformCommand(platformCommandService, platformCommandName, updater); updatePlatformCommand.execute(); } catch (final SCommandNotFoundException scnfe) { throw new UpdateException(scnfe); } catch (final SBonitaException e) { throw new UpdateException(e); } }
protected void updateTenant(final PlatformService platformService, final STenantUpdateBuilder descriptor, final STenant tenant) throws UpdateException { try { platformService.updateTenant(tenant, descriptor.done()); } catch (final SBonitaException e) { throw new UpdateException("Could not update the tenant pause mode", e); } }
protected void updateTenant(final PlatformService platformService, final STenantUpdateBuilder descriptor, final STenant tenant) throws UpdateException { try { platformService.updateTenant(tenant, descriptor.done()); } catch (final SBonitaException e) { throw new UpdateException("Could not update the tenant pause mode", e); } }
@Override public void updateDueDateOfTask(final long userTaskId, final Date dueDate) throws UpdateException { final ActivityInstanceService activityInstanceService = getTenantAccessor().getActivityInstanceService(); try { final SetExpectedEndDate updateProcessInstance = new SetExpectedEndDate(activityInstanceService, userTaskId, dueDate); updateProcessInstance.execute(); } catch (final SFlowNodeNotFoundException e) { throw new UpdateException(e); } catch (final SBonitaException e) { throw new UpdateException(e); } }
@Override public void assignUserTask(final long userTaskId, final long userId) throws UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final ActivityInstanceService activityInstanceService = tenantAccessor.getActivityInstanceService(); try { final AssignOrUnassignUserTask assignUserTask = new AssignOrUnassignUserTask(userId, userTaskId, activityInstanceService, tenantAccessor.getFlowNodeStateManager().getStateBehaviors()); assignUserTask.execute(); } catch (final SUserNotFoundException sunfe) { throw new UpdateException(sunfe); } catch (final SActivityInstanceNotFoundException sainfe) { throw new UpdateException(sainfe); } catch (final SBonitaException sbe) { throw new UpdateException(sbe); } }
@Override public void assignUserTask(final long userTaskId, final long userId) throws UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final ActivityInstanceService activityInstanceService = tenantAccessor.getActivityInstanceService(); try { final AssignOrUnassignUserTask assignUserTask = new AssignOrUnassignUserTask(userId, userTaskId, activityInstanceService, tenantAccessor.getFlowNodeStateManager().getStateBehaviors()); assignUserTask.execute(); } catch (final SUserNotFoundException sunfe) { throw new UpdateException(sunfe); } catch (final SActivityInstanceNotFoundException sainfe) { throw new UpdateException(sainfe); } catch (final SBonitaException sbe) { throw new UpdateException(sbe); } }
@Override public void updateProcessDataInstances(final long processInstanceId, final Map<String, Serializable> dataNameValues) throws UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DataInstanceService dataInstanceService = tenantAccessor.getDataInstanceService(); final ParentContainerResolver parentContainerResolver = tenantAccessor.getParentContainerResolver(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { final ClassLoader processClassLoader = getProcessInstanceClassloader(tenantAccessor, processInstanceId); Thread.currentThread().setContextClassLoader(processClassLoader); final List<String> dataNames = new ArrayList<>(dataNameValues.keySet()); final List<SDataInstance> sDataInstances = dataInstanceService.getDataInstances(dataNames, processInstanceId, DataInstanceContainer.PROCESS_INSTANCE.toString(), parentContainerResolver); updateDataInstances(sDataInstances, dataNameValues, processClassLoader); } catch (final SBonitaException e) { throw new UpdateException(e); } catch (final ClassNotFoundException e) { throw new UpdateException(e); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } }
@Override public void updateProcessDataInstances(final long processInstanceId, final Map<String, Serializable> dataNameValues) throws UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final DataInstanceService dataInstanceService = tenantAccessor.getDataInstanceService(); final ParentContainerResolver parentContainerResolver = tenantAccessor.getParentContainerResolver(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { final ClassLoader processClassLoader = getProcessInstanceClassloader(tenantAccessor, processInstanceId); Thread.currentThread().setContextClassLoader(processClassLoader); final List<String> dataNames = new ArrayList<>(dataNameValues.keySet()); final List<SDataInstance> sDataInstances = dataInstanceService.getDataInstances(dataNames, processInstanceId, DataInstanceContainer.PROCESS_INSTANCE.toString(), parentContainerResolver); updateDataInstances(sDataInstances, dataNameValues, processClassLoader); } catch (final SBonitaException e) { throw new UpdateException(e); } catch (final ClassNotFoundException e) { throw new UpdateException(e); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } }
private void validateToken(final ApplicationUpdater updater) throws UpdateException { if (updater.getFields().keySet().contains(ApplicationField.TOKEN)) { final String token = (String) updater.getFields().get(ApplicationField.TOKEN); ValidationStatus validationStatus = tokenValidator.validate(token); if (!validationStatus.isValid()) { throw new UpdateException(validationStatus.getMessage()); } } }
private void validateToken(final ApplicationUpdater updater) throws UpdateException { if (updater.getFields().keySet().contains(ApplicationField.TOKEN)) { final String token = (String) updater.getFields().get(ApplicationField.TOKEN); ValidationStatus validationStatus = tokenValidator.validate(token); if (!validationStatus.isValid()) { throw new UpdateException(validationStatus.getMessage()); } } }
private SHumanTaskInstance getSHumanTaskInstance(final long userTaskId) throws SFlowNodeNotFoundException, SFlowNodeReadException, UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final SFlowNodeInstance flowNodeInstance = tenantAccessor.getActivityInstanceService().getFlowNodeInstance(userTaskId); if (!(flowNodeInstance instanceof SHumanTaskInstance)) { throw new UpdateException("The identifier does not refer to a human task"); } return (SHumanTaskInstance) flowNodeInstance; }
@Override public void setActivityStateById(final long activityInstanceId, final int stateId) throws UpdateException { try { getTenantAccessor().getFlowNodeExecutor().setStateByStateId(activityInstanceId, stateId); } catch (final SBonitaException e) { throw new UpdateException(e); } }