@Test public void updateXml_whenFormFileNotFound_thenDoNotUpdateEcmFile() throws Exception { AcmContainerEntity entity = createMock(AcmContainerEntity.class); AcmContainer container = new AcmContainer(); container.setId(500L); container.setAttachmentFolder(new AcmFolder()); container.getAttachmentFolder().setId(250L); expect(entity.getContainer()).andReturn(container).atLeastOnce(); expect(mockEcmFileDao.findForContainerAttachmentFolderAndFileType(container.getId(), container.getAttachmentFolder().getId(), unit.getFormName() + "_xml")).andReturn(null); replayAll(); unit.updateXML(entity, mockAuthentication, entity.getClass()); verifyAll(); }
@Override public void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c) { if (entity != null) { EcmFile ecmFile = getEcmFile(entity, getFormName().toLowerCase()); if (ecmFile != null) { Object form = null; String existingXml = ""; if (ecmFile.getId() != null) { try { existingXml = getEcmFileService().download(ecmFile.getId()); form = convertFromXMLToObject(cleanXML(existingXml), c); } catch (AcmUserActionFailedException e) { LOG.error("Cannot download file with id={}", ecmFile.getId()); } } form = convertToFrevvoForm(entity, form); if (form != null) { String xml = convertFromObjectToXML(form); Diff diff = DiffBuilder.compare(Input.fromString(xml)) .withTest(Input.fromString(existingXml)) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build(); if (diff.hasDifferences()) { updateXML(xml, ecmFile, auth); } } } } }
FrevvoFormAbstractService implements FrevvoFormService { @Override public void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c) { if (entity != null) { EcmFile ecmFile = getEcmFile(entity, getFormName().toLowerCase()); if (ecmFile != null) { Object form = null; String existingXml = ""; if (ecmFile.getId() != null) { try { existingXml = getEcmFileService().download(ecmFile.getId()); form = convertFromXMLToObject(cleanXML(existingXml), c); } catch (AcmUserActionFailedException e) { LOG.error("Cannot download file with id={}", ecmFile.getId()); } } form = convertToFrevvoForm(entity, form); if (form != null) { String xml = convertFromObjectToXML(form); Diff diff = DiffBuilder.compare(Input.fromString(xml)) .withTest(Input.fromString(existingXml)) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build(); if (diff.hasDifferences()) { updateXML(xml, ecmFile, auth); } } } } } }
FrevvoFormAbstractService implements FrevvoFormService { @Override public void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c) { if (entity != null) { EcmFile ecmFile = getEcmFile(entity, getFormName().toLowerCase()); if (ecmFile != null) { Object form = null; String existingXml = ""; if (ecmFile.getId() != null) { try { existingXml = getEcmFileService().download(ecmFile.getId()); form = convertFromXMLToObject(cleanXML(existingXml), c); } catch (AcmUserActionFailedException e) { LOG.error("Cannot download file with id={}", ecmFile.getId()); } } form = convertToFrevvoForm(entity, form); if (form != null) { String xml = convertFromObjectToXML(form); Diff diff = DiffBuilder.compare(Input.fromString(xml)) .withTest(Input.fromString(existingXml)) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build(); if (diff.hasDifferences()) { updateXML(xml, ecmFile, auth); } } } } }  }
FrevvoFormAbstractService implements FrevvoFormService { @Override public void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c) { if (entity != null) { EcmFile ecmFile = getEcmFile(entity, getFormName().toLowerCase()); if (ecmFile != null) { Object form = null; String existingXml = ""; if (ecmFile.getId() != null) { try { existingXml = getEcmFileService().download(ecmFile.getId()); form = convertFromXMLToObject(cleanXML(existingXml), c); } catch (AcmUserActionFailedException e) { LOG.error("Cannot download file with id={}", ecmFile.getId()); } } form = convertToFrevvoForm(entity, form); if (form != null) { String xml = convertFromObjectToXML(form); Diff diff = DiffBuilder.compare(Input.fromString(xml)) .withTest(Input.fromString(existingXml)) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build(); if (diff.hasDifferences()) { updateXML(xml, ecmFile, auth); } } } } }  @Override Object init(); @Override JSONObject createResponse(Object object); abstract Object convertToFrevvoForm(Object obj, Object form); @Override Map<String, Object> getProperties(); @Override void setProperties(Map<String, Object> properties); @Override HttpServletRequest getRequest(); @Override void setRequest(HttpServletRequest request); @Override Authentication getAuthentication(); @Override void setAuthentication(Authentication authentication); @Override AuthenticationTokenService getAuthenticationTokenService(); @Override void setAuthenticationTokenService(AuthenticationTokenService authenticationTokenService); @Override UserDao getUserDao(); @Override void setUserDao(UserDao userDao); String findFolderId(AcmContainer container, String objectType, Long id); @Override String findCmisFolderId(Long folderId, AcmContainer container, String objectType, Long objectId); String findFolderIdForAttachments(AcmContainer container, String objectType, Long id); @Override UserActionDao getUserActionDao(); @Override void setUserActionDao(UserActionDao userActionDao); @Override EcmFileService getEcmFileService(); @Override void setEcmFileService(EcmFileService ecmFileService); @Override String getServletContextPath(); @Override void setServletContextPath(String servletContextPath); Object convertFromXMLToObject(String xml, Class<?> c); String convertFromObjectToXML(Object obj); @Override void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c); void updateXMLAttachment(MultiValueMap<String, MultipartFile> attachments, String formName, Object form); MultiValueMap<String, MultipartFile> updateFileName(String newName, String type,
            MultiValueMap<String, MultipartFile> attachments); UploadedFiles saveAttachments(MultiValueMap<String, MultipartFile> attachments, String targetCmisFolderId,
            String parentObjectType, Long parentObjectId); UploadedFiles saveAttachments(String fileType, MultiValueMap<String, MultipartFile> attachments, String targetCmisFolderId,
            String parentObjectType, Long parentObjectId); EcmFile getEcmFile(AcmContainerEntity entity, String formName); String cleanXML(String xml); List<String> convertToList(String source, String delimiter); List<String> getStandardLookupEntries(String lookupName); FrevvoForm populateEditInformation(FrevvoForm form, AcmContainer container, String formName); String getDocUriParameter(String parameterName); String getDocUriParameters(); Strings getOwningGroups(String owningGroupType, String formName); Map<String, String> getParticipantsPrivilegeTypes(List<String> participantTypes, String formName); String getAttachmentFileType(Object form); @Override String getUserIpAddress(); @Override void setUserIpAddress(String userIpAddress); EcmFileDao getEcmFileDao(); void setEcmFileDao(EcmFileDao ecmFileDao); AcmUserActionExecutor getUserActionExecutor(); void setUserActionExecutor(AcmUserActionExecutor userActionExecutor); MuleContextManager getMuleContextManager(); void setMuleContextManager(MuleContextManager muleContextManager); ObjectAssociationDao getObjectAssociationDao(); void setObjectAssociationDao(ObjectAssociationDao objectAssociationDao); FunctionalAccessService getFunctionalAccessService(); void setFunctionalAccessService(FunctionalAccessService functionalAccessService); SearchResults getSearchResults(); void setSearchResults(SearchResults searchResults); AcmPluginManager getAcmPluginManager(); void setAcmPluginManager(AcmPluginManager acmPluginManager); Gson getGson(); void setGson(Gson gson); FolderAndFilesUtils getFolderAndFilesUtils(); void setFolderAndFilesUtils(FolderAndFilesUtils folderAndFilesUtils); AcmFolderService getAcmFolderService(); void setAcmFolderService(AcmFolderService acmFolderService); LookupDao getLookupDao(); void setLookupDao(LookupDao lookupDao); TranslationService getTranslationService(); void setTranslationService(TranslationService translationService); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); }
FrevvoFormAbstractService implements FrevvoFormService { @Override public void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c) { if (entity != null) { EcmFile ecmFile = getEcmFile(entity, getFormName().toLowerCase()); if (ecmFile != null) { Object form = null; String existingXml = ""; if (ecmFile.getId() != null) { try { existingXml = getEcmFileService().download(ecmFile.getId()); form = convertFromXMLToObject(cleanXML(existingXml), c); } catch (AcmUserActionFailedException e) { LOG.error("Cannot download file with id={}", ecmFile.getId()); } } form = convertToFrevvoForm(entity, form); if (form != null) { String xml = convertFromObjectToXML(form); Diff diff = DiffBuilder.compare(Input.fromString(xml)) .withTest(Input.fromString(existingXml)) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)) .build(); if (diff.hasDifferences()) { updateXML(xml, ecmFile, auth); } } } } }  @Override Object init(); @Override JSONObject createResponse(Object object); abstract Object convertToFrevvoForm(Object obj, Object form); @Override Map<String, Object> getProperties(); @Override void setProperties(Map<String, Object> properties); @Override HttpServletRequest getRequest(); @Override void setRequest(HttpServletRequest request); @Override Authentication getAuthentication(); @Override void setAuthentication(Authentication authentication); @Override AuthenticationTokenService getAuthenticationTokenService(); @Override void setAuthenticationTokenService(AuthenticationTokenService authenticationTokenService); @Override UserDao getUserDao(); @Override void setUserDao(UserDao userDao); String findFolderId(AcmContainer container, String objectType, Long id); @Override String findCmisFolderId(Long folderId, AcmContainer container, String objectType, Long objectId); String findFolderIdForAttachments(AcmContainer container, String objectType, Long id); @Override UserActionDao getUserActionDao(); @Override void setUserActionDao(UserActionDao userActionDao); @Override EcmFileService getEcmFileService(); @Override void setEcmFileService(EcmFileService ecmFileService); @Override String getServletContextPath(); @Override void setServletContextPath(String servletContextPath); Object convertFromXMLToObject(String xml, Class<?> c); String convertFromObjectToXML(Object obj); @Override void updateXML(AcmContainerEntity entity, Authentication auth, Class<?> c); void updateXMLAttachment(MultiValueMap<String, MultipartFile> attachments, String formName, Object form); MultiValueMap<String, MultipartFile> updateFileName(String newName, String type,
            MultiValueMap<String, MultipartFile> attachments); UploadedFiles saveAttachments(MultiValueMap<String, MultipartFile> attachments, String targetCmisFolderId,
            String parentObjectType, Long parentObjectId); UploadedFiles saveAttachments(String fileType, MultiValueMap<String, MultipartFile> attachments, String targetCmisFolderId,
            String parentObjectType, Long parentObjectId); EcmFile getEcmFile(AcmContainerEntity entity, String formName); String cleanXML(String xml); List<String> convertToList(String source, String delimiter); List<String> getStandardLookupEntries(String lookupName); FrevvoForm populateEditInformation(FrevvoForm form, AcmContainer container, String formName); String getDocUriParameter(String parameterName); String getDocUriParameters(); Strings getOwningGroups(String owningGroupType, String formName); Map<String, String> getParticipantsPrivilegeTypes(List<String> participantTypes, String formName); String getAttachmentFileType(Object form); @Override String getUserIpAddress(); @Override void setUserIpAddress(String userIpAddress); EcmFileDao getEcmFileDao(); void setEcmFileDao(EcmFileDao ecmFileDao); AcmUserActionExecutor getUserActionExecutor(); void setUserActionExecutor(AcmUserActionExecutor userActionExecutor); MuleContextManager getMuleContextManager(); void setMuleContextManager(MuleContextManager muleContextManager); ObjectAssociationDao getObjectAssociationDao(); void setObjectAssociationDao(ObjectAssociationDao objectAssociationDao); FunctionalAccessService getFunctionalAccessService(); void setFunctionalAccessService(FunctionalAccessService functionalAccessService); SearchResults getSearchResults(); void setSearchResults(SearchResults searchResults); AcmPluginManager getAcmPluginManager(); void setAcmPluginManager(AcmPluginManager acmPluginManager); Gson getGson(); void setGson(Gson gson); FolderAndFilesUtils getFolderAndFilesUtils(); void setFolderAndFilesUtils(FolderAndFilesUtils folderAndFilesUtils); AcmFolderService getAcmFolderService(); void setAcmFolderService(AcmFolderService acmFolderService); LookupDao getLookupDao(); void setLookupDao(LookupDao lookupDao); TranslationService getTranslationService(); void setTranslationService(TranslationService translationService); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter);  }