/** * Trigger business object data and storage unit notification for unregistered business object data invalidation event. * * @param businessObjectDataInvalidateUnregisteredResponse the business object data invalidate unregistered response */ public void triggerNotificationsForInvalidateUnregisteredBusinessObjectData( BusinessObjectDataInvalidateUnregisteredResponse businessObjectDataInvalidateUnregisteredResponse) { for (BusinessObjectData businessObjectData : businessObjectDataInvalidateUnregisteredResponse.getRegisteredBusinessObjectDataList()) { triggerNotificationsForCreateBusinessObjectData(businessObjectData); } }
/** * Trigger business object data and storage unit notification for unregistered business object data invalidation event. * * @param businessObjectDataInvalidateUnregisteredResponse the business object data invalidate unregistered response */ public void triggerNotificationsForInvalidateUnregisteredBusinessObjectData( BusinessObjectDataInvalidateUnregisteredResponse businessObjectDataInvalidateUnregisteredResponse) { for (BusinessObjectData businessObjectData : businessObjectDataInvalidateUnregisteredResponse.getRegisteredBusinessObjectDataList()) { triggerNotificationsForCreateBusinessObjectData(businessObjectData); } }
/** * Creates (i.e. registers) business object data. You may pre-register business object data by setting the status to one of the pre-registration statuses * (UPLOADING, PENDING_VALID, and PROCESSING). <p> Requires WRITE permission on namespace </p> * * @param businessObjectDataCreateRequest the information needed to create the business object data * * @return the created business object data */ @RequestMapping(value = "/businessObjectData", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_BUSINESS_OBJECT_DATA_POST) public BusinessObjectData createBusinessObjectData(@RequestBody BusinessObjectDataCreateRequest businessObjectDataCreateRequest) { BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest); // TODO This should be enhanced such that the notification events are captured by probably as an advice, and these calls are not specified everywhere // in the code. // The calls to notifications is being done in REST layer so that the event transaction (e.g. in this case: create business object data) is committed // and the event data is available for when notification is processed. // With proposed designed, when we go to event publish mode(e.g. create a database record for the event that will be picked up by notification // processing engine), We would want the event transaction to also rollback if event publishing failed. These calls will be moved to service layer. // Trigger notifications. businessObjectDataDaoHelper.triggerNotificationsForCreateBusinessObjectData(businessObjectData); return businessObjectData; }
/** * Creates (i.e. registers) business object data. You may pre-register business object data by setting the status to one of the pre-registration statuses * (UPLOADING, PENDING_VALID, and PROCESSING). <p> Requires WRITE permission on namespace </p> * * @param businessObjectDataCreateRequest the information needed to create the business object data * * @return the created business object data */ @RequestMapping(value = "/businessObjectData", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_BUSINESS_OBJECT_DATA_POST) public BusinessObjectData createBusinessObjectData(@RequestBody BusinessObjectDataCreateRequest businessObjectDataCreateRequest) { BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest); // TODO This should be enhanced such that the notification events are captured by probably as an advice, and these calls are not specified everywhere // in the code. // The calls to notifications is being done in REST layer so that the event transaction (e.g. in this case: create business object data) is committed // and the event data is available for when notification is processed. // With proposed designed, when we go to event publish mode(e.g. create a database record for the event that will be picked up by notification // processing engine), We would want the event transaction to also rollback if event publishing failed. These calls will be moved to service layer. // Trigger notifications. businessObjectDataDaoHelper.triggerNotificationsForCreateBusinessObjectData(businessObjectData); return businessObjectData; }
@Override public void executeImpl(DelegateExecution execution) throws Exception { String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim(); String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataCreateRequest, execution, "BusinessObjectDataCreateRequest").trim(); BusinessObjectDataCreateRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataCreateRequest.class); // Register the data. BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(request); // Trigger notifications. businessObjectDataDaoHelper.triggerNotificationsForCreateBusinessObjectData(businessObjectData); // Set the JSON response as a workflow variable. setJsonResponseAsWorkflowVariable(businessObjectData, execution); setTaskWorkflowVariable(execution, VARIABLE_ID, businessObjectData.getId()); setTaskWorkflowVariable(execution, VARIABLE_VERSION, businessObjectData.getVersion()); setTaskWorkflowVariable(execution, VARIABLE_LATEST_VERSION, businessObjectData.isLatestVersion()); } }
@Override public void executeImpl(DelegateExecution execution) throws Exception { String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim(); String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataCreateRequest, execution, "BusinessObjectDataCreateRequest").trim(); BusinessObjectDataCreateRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataCreateRequest.class); // Register the data. BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(request); // Trigger notifications. businessObjectDataDaoHelper.triggerNotificationsForCreateBusinessObjectData(businessObjectData); // Set the JSON response as a workflow variable. setJsonResponseAsWorkflowVariable(businessObjectData, execution); setTaskWorkflowVariable(execution, VARIABLE_ID, businessObjectData.getId()); setTaskWorkflowVariable(execution, VARIABLE_VERSION, businessObjectData.getVersion()); setTaskWorkflowVariable(execution, VARIABLE_LATEST_VERSION, businessObjectData.isLatestVersion()); } }
@Test public void testCreateBusinessObjectData() { // Create a business object data create request. BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest(); // Create a business object data. BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setId(ID); // Mock the external calls. when(businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest)).thenReturn(businessObjectData); // Call the method under test. BusinessObjectData result = businessObjectDataRestController.createBusinessObjectData(businessObjectDataCreateRequest); // Verify the external calls. verify(businessObjectDataService).createBusinessObjectData(businessObjectDataCreateRequest); verify(businessObjectDataDaoHelper).triggerNotificationsForCreateBusinessObjectData(businessObjectData); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(businessObjectData, result); }