@Test public void unSuccessfulFolderDeclareRequest_shouldNotDeclareRecords() { AcmCmisObjectList acmCmisObjectList = new AcmCmisObjectList(); acmCmisObjectList.setContainerObjectId(123L); acmCmisObjectList.setContainerObjectType("CASE_FILE"); acmCmisObjectList.setFolderId(54321L); AcmContainer acmContainer = new AcmContainer(); rmaConfig.setDeclareFolderRecordOnDeclareRequest(true); expect(mockService.getRmaConfig()).andReturn(rmaConfig); expect(mockAuthentication.getDetails()).andReturn("details").anyTimes(); expect(mockAuthentication.getName()).andReturn("user").anyTimes(); replayAll(); EcmFolderDeclareRequestEvent event = new EcmFolderDeclareRequestEvent(acmCmisObjectList, acmContainer, mockAuthentication); event.setSucceeded(false); event.setUserId("user"); event.setEventDate(new Date()); unit.onApplicationEvent(event); verifyAll(); }
@Override public void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent) { AlfrescoRmaConfig rmaConfig = alfrescoRecordsService.getRmaConfig(); boolean proceed = rmaConfig.getIntegrationEnabled() && rmaConfig.getDeclareFolderRecordOnDeclareRequest(); if (!proceed) { return; } if (!ecmFolderDeclareRequestEvent.isSucceeded()) { log.trace("Returning - folder declaration request was not successful"); return; } if (null != ecmFolderDeclareRequestEvent.getSource()) { AcmCmisObjectList acmCmisObjectList = ecmFolderDeclareRequestEvent.getSource(); getAlfrescoRecordsService().declareAllFilesInFolderAsRecords(acmCmisObjectList, ecmFolderDeclareRequestEvent.getContainer(), ecmFolderDeclareRequestEvent.getEventDate(), ecmFolderDeclareRequestEvent.getParentObjectName()); Long folderId = acmCmisObjectList.getFolderId(); AcmFolder folder = getAcmFolderService().findById(folderId); try { if (folder == null) { throw new AcmObjectNotFoundException(AcmFolderConstants.OBJECT_FOLDER_TYPE, folderId, "Folder not found", null); } else { folder.setStatus(EcmFileConstants.RECORD); getAcmFolderDao().save(folder); log.debug("Status is changed to:[{}] for folder with ID:[{}]", folder.getId(), EcmFileConstants.RECORD); } } catch (Exception e) { log.error("Status change failed for folder with id:[{}]. {}", folderId, e.getMessage(), e); } } }
AcmFolderDeclareRequestListener implements ApplicationListener<EcmFolderDeclareRequestEvent> { @Override public void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent) { AlfrescoRmaConfig rmaConfig = alfrescoRecordsService.getRmaConfig(); boolean proceed = rmaConfig.getIntegrationEnabled() && rmaConfig.getDeclareFolderRecordOnDeclareRequest(); if (!proceed) { return; } if (!ecmFolderDeclareRequestEvent.isSucceeded()) { log.trace("Returning - folder declaration request was not successful"); return; } if (null != ecmFolderDeclareRequestEvent.getSource()) { AcmCmisObjectList acmCmisObjectList = ecmFolderDeclareRequestEvent.getSource(); getAlfrescoRecordsService().declareAllFilesInFolderAsRecords(acmCmisObjectList, ecmFolderDeclareRequestEvent.getContainer(), ecmFolderDeclareRequestEvent.getEventDate(), ecmFolderDeclareRequestEvent.getParentObjectName()); Long folderId = acmCmisObjectList.getFolderId(); AcmFolder folder = getAcmFolderService().findById(folderId); try { if (folder == null) { throw new AcmObjectNotFoundException(AcmFolderConstants.OBJECT_FOLDER_TYPE, folderId, "Folder not found", null); } else { folder.setStatus(EcmFileConstants.RECORD); getAcmFolderDao().save(folder); log.debug("Status is changed to:[{}] for folder with ID:[{}]", folder.getId(), EcmFileConstants.RECORD); } } catch (Exception e) { log.error("Status change failed for folder with id:[{}]. {}", folderId, e.getMessage(), e); } } } }
AcmFolderDeclareRequestListener implements ApplicationListener<EcmFolderDeclareRequestEvent> { @Override public void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent) { AlfrescoRmaConfig rmaConfig = alfrescoRecordsService.getRmaConfig(); boolean proceed = rmaConfig.getIntegrationEnabled() && rmaConfig.getDeclareFolderRecordOnDeclareRequest(); if (!proceed) { return; } if (!ecmFolderDeclareRequestEvent.isSucceeded()) { log.trace("Returning - folder declaration request was not successful"); return; } if (null != ecmFolderDeclareRequestEvent.getSource()) { AcmCmisObjectList acmCmisObjectList = ecmFolderDeclareRequestEvent.getSource(); getAlfrescoRecordsService().declareAllFilesInFolderAsRecords(acmCmisObjectList, ecmFolderDeclareRequestEvent.getContainer(), ecmFolderDeclareRequestEvent.getEventDate(), ecmFolderDeclareRequestEvent.getParentObjectName()); Long folderId = acmCmisObjectList.getFolderId(); AcmFolder folder = getAcmFolderService().findById(folderId); try { if (folder == null) { throw new AcmObjectNotFoundException(AcmFolderConstants.OBJECT_FOLDER_TYPE, folderId, "Folder not found", null); } else { folder.setStatus(EcmFileConstants.RECORD); getAcmFolderDao().save(folder); log.debug("Status is changed to:[{}] for folder with ID:[{}]", folder.getId(), EcmFileConstants.RECORD); } } catch (Exception e) { log.error("Status change failed for folder with id:[{}]. {}", folderId, e.getMessage(), e); } } }  }
AcmFolderDeclareRequestListener implements ApplicationListener<EcmFolderDeclareRequestEvent> { @Override public void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent) { AlfrescoRmaConfig rmaConfig = alfrescoRecordsService.getRmaConfig(); boolean proceed = rmaConfig.getIntegrationEnabled() && rmaConfig.getDeclareFolderRecordOnDeclareRequest(); if (!proceed) { return; } if (!ecmFolderDeclareRequestEvent.isSucceeded()) { log.trace("Returning - folder declaration request was not successful"); return; } if (null != ecmFolderDeclareRequestEvent.getSource()) { AcmCmisObjectList acmCmisObjectList = ecmFolderDeclareRequestEvent.getSource(); getAlfrescoRecordsService().declareAllFilesInFolderAsRecords(acmCmisObjectList, ecmFolderDeclareRequestEvent.getContainer(), ecmFolderDeclareRequestEvent.getEventDate(), ecmFolderDeclareRequestEvent.getParentObjectName()); Long folderId = acmCmisObjectList.getFolderId(); AcmFolder folder = getAcmFolderService().findById(folderId); try { if (folder == null) { throw new AcmObjectNotFoundException(AcmFolderConstants.OBJECT_FOLDER_TYPE, folderId, "Folder not found", null); } else { folder.setStatus(EcmFileConstants.RECORD); getAcmFolderDao().save(folder); log.debug("Status is changed to:[{}] for folder with ID:[{}]", folder.getId(), EcmFileConstants.RECORD); } } catch (Exception e) { log.error("Status change failed for folder with id:[{}]. {}", folderId, e.getMessage(), e); } } }  @Override void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent); AlfrescoRecordsService getAlfrescoRecordsService(); void setAlfrescoRecordsService(AlfrescoRecordsService alfrescoRecordsService); AcmFolderService getAcmFolderService(); void setAcmFolderService(AcmFolderService acmFolderService); AcmFolderDao getAcmFolderDao(); void setAcmFolderDao(AcmFolderDao acmFolderDao); }
AcmFolderDeclareRequestListener implements ApplicationListener<EcmFolderDeclareRequestEvent> { @Override public void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent) { AlfrescoRmaConfig rmaConfig = alfrescoRecordsService.getRmaConfig(); boolean proceed = rmaConfig.getIntegrationEnabled() && rmaConfig.getDeclareFolderRecordOnDeclareRequest(); if (!proceed) { return; } if (!ecmFolderDeclareRequestEvent.isSucceeded()) { log.trace("Returning - folder declaration request was not successful"); return; } if (null != ecmFolderDeclareRequestEvent.getSource()) { AcmCmisObjectList acmCmisObjectList = ecmFolderDeclareRequestEvent.getSource(); getAlfrescoRecordsService().declareAllFilesInFolderAsRecords(acmCmisObjectList, ecmFolderDeclareRequestEvent.getContainer(), ecmFolderDeclareRequestEvent.getEventDate(), ecmFolderDeclareRequestEvent.getParentObjectName()); Long folderId = acmCmisObjectList.getFolderId(); AcmFolder folder = getAcmFolderService().findById(folderId); try { if (folder == null) { throw new AcmObjectNotFoundException(AcmFolderConstants.OBJECT_FOLDER_TYPE, folderId, "Folder not found", null); } else { folder.setStatus(EcmFileConstants.RECORD); getAcmFolderDao().save(folder); log.debug("Status is changed to:[{}] for folder with ID:[{}]", folder.getId(), EcmFileConstants.RECORD); } } catch (Exception e) { log.error("Status change failed for folder with id:[{}]. {}", folderId, e.getMessage(), e); } } }  @Override void onApplicationEvent(EcmFolderDeclareRequestEvent ecmFolderDeclareRequestEvent); AlfrescoRecordsService getAlfrescoRecordsService(); void setAlfrescoRecordsService(AlfrescoRecordsService alfrescoRecordsService); AcmFolderService getAcmFolderService(); void setAcmFolderService(AcmFolderService acmFolderService); AcmFolderDao getAcmFolderDao(); void setAcmFolderDao(AcmFolderDao acmFolderDao);  }