/** * Validates the business object data notification actions. This method also trims the notification action parameters. * * @param jobActions the list of notification job actions */ private void validateNotificationActions(List<JobAction> jobActions) { Assert.notEmpty(jobActions, "At least one notification action must be specified."); // Ensure job action isn't a duplicate by using a hash set with lowercase job definition key values for case insensitivity. Set<JobAction> validatedJobActionsSet = new LinkedHashSet<>(); for (JobAction jobAction : jobActions) { Assert.hasText(jobAction.getNamespace(), "A job action namespace must be specified."); jobAction.setNamespace(jobAction.getNamespace().trim()); Assert.hasText(jobAction.getJobName(), "A job action job name must be specified."); jobAction.setJobName(jobAction.getJobName().trim()); // Create a special version of the job action with the relative job definition key values in lowercase. JobAction lowercaseJobDefinitionKey = new JobAction(); lowercaseJobDefinitionKey.setNamespace(jobAction.getNamespace().toLowerCase()); lowercaseJobDefinitionKey.setJobName(jobAction.getJobName().toLowerCase()); if (validatedJobActionsSet.contains(lowercaseJobDefinitionKey)) { throw new IllegalArgumentException( String.format("Duplicate job action {namespace: \"%s\", jobName: \"%s\"} found.", jobAction.getNamespace(), jobAction.getJobName())); } validatedJobActionsSet.add(lowercaseJobDefinitionKey); } }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theNamespace; theNamespace = this.getNamespace(); strategy.appendField(locator, this, "namespace", buffer, theNamespace, (this.namespace!= null)); } { String theJobName; theJobName = this.getJobName(); strategy.appendField(locator, this, "jobName", buffer, theJobName, (this.jobName!= null)); } { String theCorrelationData; theCorrelationData = this.getCorrelationData(); strategy.appendField(locator, this, "correlationData", buffer, theCorrelationData, (this.correlationData!= null)); } return buffer; }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof JobAction) { final JobAction copy = ((JobAction) draftCopy); if (namespaceShouldBeCopiedAndSet == Boolean.TRUE) { String sourceNamespace; sourceNamespace = this.getNamespace(); String copyNamespace = ((String) strategy.copy(LocatorUtils.property(locator, "namespace", sourceNamespace), sourceNamespace, (this.namespace!= null))); copy.setNamespace(copyNamespace); } else { if (namespaceShouldBeCopiedAndSet == Boolean.FALSE) { if (jobNameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceJobName; sourceJobName = this.getJobName(); String copyJobName = ((String) strategy.copy(LocatorUtils.property(locator, "jobName", sourceJobName), sourceJobName, (this.jobName!= null))); copy.setJobName(copyJobName); } else { if (jobNameShouldBeCopiedAndSet == Boolean.FALSE) { if (correlationDataShouldBeCopiedAndSet == Boolean.TRUE) { String sourceCorrelationData; sourceCorrelationData = this.getCorrelationData(); String copyCorrelationData = ((String) strategy.copy(LocatorUtils.property(locator, "correlationData", sourceCorrelationData), sourceCorrelationData, (this.correlationData!= null))); copy.setCorrelationData(copyCorrelationData); } else { if (correlationDataShouldBeCopiedAndSet == Boolean.FALSE) {
/** * Create an instance of {@link JobAction } * */ public JobAction createJobAction() { return new JobAction(); }
@Test public void testCreateStorageUnitNotificationRegistrationDuplicateJobActions() { // Create and persist the relative database entities. notificationRegistrationServiceTestHelper.createDatabaseEntitiesForStorageUnitNotificationRegistrationTesting(); // Try to create a storage unit notification with duplicate job actions. StorageUnitNotificationRegistrationCreateRequest request = new StorageUnitNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name(), new StorageUnitNotificationFilter(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), Arrays.asList(new JobAction(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), CORRELATION_DATA), new JobAction(NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED); try { storageUnitNotificationRegistrationService.createStorageUnitNotificationRegistration(request); fail("Should throw an IllegalArgumentException when create request contains duplicate job actions."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate job action {namespace: \"%s\", jobName: \"%s\"} found.", request.getJobActions().get(1).getNamespace(), request.getJobActions().get(1).getJobName()), e.getMessage()); } }
jobDefinitionDaoTestHelper.createJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName(), String.format("Description of \"%s.%s\" job definition.", jobAction.getNamespace(), jobAction.getJobName()), String.format("%s.%s.%s", jobAction.getNamespace(), jobAction.getJobName(), AbstractServiceTest.ACTIVITI_ID));
JobAction jobAction = new JobAction(); jobActions.add(jobAction); jobAction.setNamespace(notificationJobActionEntity.getJobDefinition().getNamespace().getCode()); jobAction.setJobName(notificationJobActionEntity.getJobDefinition().getName()); jobAction.setCorrelationData(notificationJobActionEntity.getCorrelationData());
public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; }
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
/** * Create an instance of {@link JobAction } * */ public JobAction createJobAction() { return new JobAction(); }
@Test public void testCreateBusinessObjectDataNotificationRegistrationDuplicateJobActions() { // Create and persist the relative database entities. notificationRegistrationServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataNotificationRegistrationTesting(); // Try to create a business object data notification with duplicate job actions. BusinessObjectDataNotificationRegistrationCreateRequest request = new BusinessObjectDataNotificationRegistrationCreateRequest(new NotificationRegistrationKey(NAMESPACE, NOTIFICATION_NAME), NotificationEventTypeEntity.EventTypesBdata.BUS_OBJCT_DATA_STTS_CHG.name(), new BusinessObjectDataNotificationFilter(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, STORAGE_NAME, BDATA_STATUS, BDATA_STATUS_2), Arrays.asList(new JobAction(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase(), CORRELATION_DATA), new JobAction(NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase(), CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED); try { businessObjectDataNotificationRegistrationService.createBusinessObjectDataNotificationRegistration(request); fail("Should throw an IllegalArgumentException when create request contains duplicate job actions."); } catch (IllegalArgumentException e) { assertEquals(String.format("Duplicate job action {namespace: \"%s\", jobName: \"%s\"} found.", request.getJobActions().get(1).getNamespace(), request.getJobActions().get(1).getJobName()), e.getMessage()); } }
jobDefinitionDaoTestHelper.createJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName(), String.format("Description of \"%s.%s\" job definition.", jobAction.getNamespace(), jobAction.getJobName()), String.format("%s.%s.%s", jobAction.getNamespace(), jobAction.getJobName(), AbstractServiceTest.ACTIVITI_ID));
JobAction jobAction = new JobAction(); jobActions.add(jobAction); jobAction.setNamespace(notificationJobActionEntity.getJobDefinition().getNamespace().getCode()); jobAction.setJobName(notificationJobActionEntity.getJobDefinition().getName()); jobAction.setCorrelationData(notificationJobActionEntity.getCorrelationData());
public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; }
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theNamespace; theNamespace = this.getNamespace(); strategy.appendField(locator, this, "namespace", buffer, theNamespace, (this.namespace!= null)); } { String theJobName; theJobName = this.getJobName(); strategy.appendField(locator, this, "jobName", buffer, theJobName, (this.jobName!= null)); } { String theCorrelationData; theCorrelationData = this.getCorrelationData(); strategy.appendField(locator, this, "correlationData", buffer, theCorrelationData, (this.correlationData!= null)); } return buffer; }
/** * Validates the storage unit notification actions. This method also trims the notification action parameters. * * @param jobActions the list of notification job actions */ private void validateNotificationActions(List<JobAction> jobActions) { Assert.notEmpty(jobActions, "At least one notification action must be specified."); // Ensure job action isn't a duplicate by using a hash set with lowercase job definition key values for case insensitivity. Set<JobAction> validatedJobActionsSet = new LinkedHashSet<>(); for (JobAction jobAction : jobActions) { Assert.hasText(jobAction.getNamespace(), "A job action namespace must be specified."); jobAction.setNamespace(jobAction.getNamespace().trim()); Assert.hasText(jobAction.getJobName(), "A job action job name must be specified."); jobAction.setJobName(jobAction.getJobName().trim()); // Create a special version of the job action with the relative job definition key values in lowercase. JobAction lowercaseJobDefinitionKey = new JobAction(); lowercaseJobDefinitionKey.setNamespace(jobAction.getNamespace().toLowerCase()); lowercaseJobDefinitionKey.setJobName(jobAction.getJobName().toLowerCase()); if (validatedJobActionsSet.contains(lowercaseJobDefinitionKey)) { throw new IllegalArgumentException( String.format("Duplicate job action {namespace: \"%s\", jobName: \"%s\"} found.", jobAction.getNamespace(), jobAction.getJobName())); } validatedJobActionsSet.add(lowercaseJobDefinitionKey); } }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof JobAction) { final JobAction copy = ((JobAction) draftCopy); if (namespaceShouldBeCopiedAndSet == Boolean.TRUE) { String sourceNamespace; sourceNamespace = this.getNamespace(); String copyNamespace = ((String) strategy.copy(LocatorUtils.property(locator, "namespace", sourceNamespace), sourceNamespace, (this.namespace!= null))); copy.setNamespace(copyNamespace); } else { if (namespaceShouldBeCopiedAndSet == Boolean.FALSE) { if (jobNameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceJobName; sourceJobName = this.getJobName(); String copyJobName = ((String) strategy.copy(LocatorUtils.property(locator, "jobName", sourceJobName), sourceJobName, (this.jobName!= null))); copy.setJobName(copyJobName); } else { if (jobNameShouldBeCopiedAndSet == Boolean.FALSE) { if (correlationDataShouldBeCopiedAndSet == Boolean.TRUE) { String sourceCorrelationData; sourceCorrelationData = this.getCorrelationData(); String copyCorrelationData = ((String) strategy.copy(LocatorUtils.property(locator, "correlationData", sourceCorrelationData), sourceCorrelationData, (this.correlationData!= null))); copy.setCorrelationData(copyCorrelationData); } else { if (correlationDataShouldBeCopiedAndSet == Boolean.FALSE) {
/** * Create an instance of {@link JobAction } * */ public JobAction createJobAction() { return new JobAction(); }
STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2), Arrays.asList(new JobAction(NAMESPACE, "I_DO_NOT_EXIST", CORRELATION_DATA)), NotificationRegistrationStatusEntity.ENABLED); try assertEquals(String.format("Job definition with namespace \"%s\" and job name \"%s\" doesn't exist.", request.getJobActions().get(0).getNamespace(), request.getJobActions().get(0).getJobName()), e.getMessage());