@Test public void testSetUIActivityData() throws Exception { ConversationState conversationState = new ConversationState(new Identity("root")); ConversationState.setCurrent(conversationState); Map<String, String> activityParameters = new HashMap<>(); activityParameters.put("REPOSITORY", "repository"); activityParameters.put("WORKSPACE", "collaboration"); activityParameters.put("DOCPATH", "/sites/intranet/web contents/site artifacts/announcements/test1.txt"); NodeLocation nodeLocationWithoutUUID = new NodeLocation("repository", "collaboration","/sites/intranet/web contents/site artifacts/announcements/test1.txt",null ); NodeLocation nodeLocationWithUUID = new NodeLocation("repository", "collaboration","/sites/intranet/web contents/site artifacts/announcements/test1.txt","c036fb997f0001016364ca764f61b4d1" ); Node file1 = mock(Node.class); Node intranetNode = mock(Node.class); Node sitesNode = mock(Node.class); Node rootNode = mock(Node.class); when(file1.getName()).thenReturn("test1.txt"); when(file1.getPath()).thenReturn("/sites/intranet/web contents/site artifacts/announcements/test1.txt"); when(file1.getParent()).thenReturn(intranetNode); when(file1.getUUID()).thenReturn("c036fb997f0001016364ca764f61b4d1"); PowerMockito.mockStatic(NodeLocation.class); PowerMockito.when(NodeLocation.getNodeByLocation(nodeLocationWithoutUUID)).thenReturn(file1); PowerMockito.when(NodeLocation.getNodeByLocation(nodeLocationWithUUID)).thenReturn(file1); FileUIActivity fileUIActivity = Mockito.spy(new FileUIActivity()); DriveData driveData = new DriveData(); driveData.setWorkspace("collboration"); TrashService trashService = Mockito.mock(TrashService.class); Mockito.doReturn(trashService).when(fileUIActivity).getApplicationComponent(Mockito.eq(TrashService.class)); Mockito.doReturn(driveData).when(fileUIActivity).getDocDrive(0); Mockito.when(trashService.isInTrash(file1)).thenReturn(false); Property titleProperty = Mockito.mock(Property.class); Value titleValue = Mockito.mock(Value.class); ActivityFileAttachment fileAttachment= new ActivityFileAttachment(); fileAttachment.setContentName(file1.getName()); fileAttachment.setNodeLocation(nodeLocationWithUUID); Node contentNode = NodeLocation.getNodeByLocation(fileAttachment.getNodeLocation()); fileUIActivity.setUIActivityData(activityParameters); fileUIActivity.setContentNode(contentNode,0); fileUIActivity.setContentName(fileAttachment.getContentName(),0); assertEquals(1,fileUIActivity.getFilesCount()); when(file1.hasProperty("exo:title")).thenReturn(false); assertEquals("test1.txt", fileUIActivity.getContentName(0)); Mockito.when(titleValue.getString()).thenReturn("text"); Mockito.when(titleProperty.getValue()).thenReturn(titleValue); when(file1.hasProperty("exo:title")).thenReturn(true); when(file1.getProperty("exo:title")).thenReturn(titleProperty); when(file1.getProperty("exo:title").getString()).thenReturn("text"); assertEquals("text", fileUIActivity.getContentName(0)); }
public void setUIActivityData(Map<String, String> activityParams) { activityFileAttachments.clear(); this.message = activityParams.get(FileUIActivity.MESSAGE); this.activityStatus = activityParams.get(FileUIActivity.ACTIVITY_STATUS); String[] nodeUUIDs = getParameterValues(activityParams, FileUIActivity.ID); String[] repositories = getParameterValues(activityParams,UIDocActivity.REPOSITORY); String[] workspaces = getParameterValues(activityParams,UIDocActivity.WORKSPACE); if (nodeUUIDs == null || nodeUUIDs.length == 0) { String[] docPaths = getParameterValues(activityParams, UIDocActivity.DOCPATH); if (docPaths != null && docPaths.length > 0) { nodeUUIDs = new String[docPaths.length]; for (int i = 0; i < docPaths.length; i++) { String repository = "repository"; if (repositories != null && repositories.length == docPaths.length && StringUtils.isNotBlank(repositories[i])) { repository = repositories[i]; } String workspace = "collaboration"; if (workspaces != null && workspaces.length == docPaths.length && StringUtils.isNotBlank(workspaces[i])) { workspace = workspaces[i]; } String docPath = docPaths[i]; NodeLocation nodeLocation = new NodeLocation(repository, workspace, docPath); Node node = NodeLocation.getNodeByLocation(nodeLocation); if (node != null) { try { nodeUUIDs[i] = node.getUUID(); } catch (RepositoryException e) { LOG.error("can not get UUID", e); } } } } } this.filesCount = nodeUUIDs == null ? 0 : nodeUUIDs.length; String[] contentLink = getParameterValues(activityParams,FileUIActivity.CONTENT_LINK); String[] state = getParameterValues(activityParams, FileUIActivity.STATE); String[] author = getParameterValues(activityParams, FileUIActivity.AUTHOR); String[] dateCreated = getParameterValues(activityParams, FileUIActivity.DATE_CREATED); String[] lastModified = getParameterValues(activityParams, FileUIActivity.LAST_MODIFIED); String[] mimeType = getParameterValues(activityParams, FileUIActivity.MIME_TYPE); String[] imagePath = getParameterValues(activityParams, FileUIActivity.IMAGE_PATH); String[] docTypeName = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TYPE_LABEL); String[] docTitle = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TITLE); String[] docVersion = getParameterValues(activityParams, FileUIActivity.DOCUMENT_VERSION); String[] docSummary = getParameterValues(activityParams, FileUIActivity.DOCUMENT_SUMMARY); String[] docPath = getParameterValues(activityParams, UIDocActivity.DOCPATH); Boolean[] isSymlink = null; String[] isSymlinkParams = getParameterValues(activityParams, UIDocActivity.IS_SYMLINK); if(isSymlinkParams != null) { isSymlink = new Boolean[isSymlinkParams.length]; for (int i = 0; i < isSymlinkParams.length; i++) { isSymlink[i] = Boolean.parseBoolean(isSymlinkParams[i]); } } for (int i = 0; i < this.filesCount; i++) { ActivityFileAttachment fileAttachment = new ActivityFileAttachment(); String repositoryName = (String) getValueFromArray(i, repositories); String workspaceName = (String) getValueFromArray(i, workspaces); if(StringUtils.isBlank(repositoryName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); repositoryName = repository == null ? null : repository.getConfiguration().getName(); } if(StringUtils.isBlank(workspaceName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); workspaceName = repository == null ? null : repository.getConfiguration().getDefaultWorkspaceName(); } fileAttachment.setNodeUUID(nodeUUIDs[i]) .setRepository(repositoryName) .setWorkspace(workspaceName) .setContentLink((String) getValueFromArray(i, contentLink)) .setState((String) getValueFromArray(i, state)) .setAuthor(getValueFromArray(i, author)) .setDateCreated(getValueFromArray(i, dateCreated)) .setLastModified(getValueFromArray(i, lastModified)) .setMimeType(getValueFromArray(i, mimeType)) .setImagePath(getValueFromArray(i, imagePath)) .setDocTypeName(getValueFromArray(i, docTypeName)) .setDocTitle(getValueFromArray(i, docTitle)) .setDocVersion(getValueFromArray(i, docVersion)) .setDocSummary(getValueFromArray(i, docSummary)) .setSymlink(getValueFromArray(i, isSymlink)) .setDocPath(getValueFromArray(i,docPath)); Node contentNode = NodeLocation.getNodeByLocation(fileAttachment.getNodeLocation()); if (contentNode != null) { try { if (!getTrashService().isInTrash(contentNode)) { fileAttachment.setContentName(getContentName(contentNode, fileAttachment.getContentName())); activityFileAttachments.add(fileAttachment); } } catch (Exception e) { LOG.error("Error while testing if the content is in trash", e); } } } this.filesCount = this.activityFileAttachments.size(); }
FileUIActivity extends BaseUIActivity { public void setUIActivityData(Map<String, String> activityParams) { activityFileAttachments.clear(); this.message = activityParams.get(FileUIActivity.MESSAGE); this.activityStatus = activityParams.get(FileUIActivity.ACTIVITY_STATUS); String[] nodeUUIDs = getParameterValues(activityParams, FileUIActivity.ID); String[] repositories = getParameterValues(activityParams,UIDocActivity.REPOSITORY); String[] workspaces = getParameterValues(activityParams,UIDocActivity.WORKSPACE); if (nodeUUIDs == null || nodeUUIDs.length == 0) { String[] docPaths = getParameterValues(activityParams, UIDocActivity.DOCPATH); if (docPaths != null && docPaths.length > 0) { nodeUUIDs = new String[docPaths.length]; for (int i = 0; i < docPaths.length; i++) { String repository = "repository"; if (repositories != null && repositories.length == docPaths.length && StringUtils.isNotBlank(repositories[i])) { repository = repositories[i]; } String workspace = "collaboration"; if (workspaces != null && workspaces.length == docPaths.length && StringUtils.isNotBlank(workspaces[i])) { workspace = workspaces[i]; } String docPath = docPaths[i]; NodeLocation nodeLocation = new NodeLocation(repository, workspace, docPath); Node node = NodeLocation.getNodeByLocation(nodeLocation); if (node != null) { try { nodeUUIDs[i] = node.getUUID(); } catch (RepositoryException e) { LOG.error("can not get UUID", e); } } } } } this.filesCount = nodeUUIDs == null ? 0 : nodeUUIDs.length; String[] contentLink = getParameterValues(activityParams,FileUIActivity.CONTENT_LINK); String[] state = getParameterValues(activityParams, FileUIActivity.STATE); String[] author = getParameterValues(activityParams, FileUIActivity.AUTHOR); String[] dateCreated = getParameterValues(activityParams, FileUIActivity.DATE_CREATED); String[] lastModified = getParameterValues(activityParams, FileUIActivity.LAST_MODIFIED); String[] mimeType = getParameterValues(activityParams, FileUIActivity.MIME_TYPE); String[] imagePath = getParameterValues(activityParams, FileUIActivity.IMAGE_PATH); String[] docTypeName = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TYPE_LABEL); String[] docTitle = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TITLE); String[] docVersion = getParameterValues(activityParams, FileUIActivity.DOCUMENT_VERSION); String[] docSummary = getParameterValues(activityParams, FileUIActivity.DOCUMENT_SUMMARY); String[] docPath = getParameterValues(activityParams, UIDocActivity.DOCPATH); Boolean[] isSymlink = null; String[] isSymlinkParams = getParameterValues(activityParams, UIDocActivity.IS_SYMLINK); if(isSymlinkParams != null) { isSymlink = new Boolean[isSymlinkParams.length]; for (int i = 0; i < isSymlinkParams.length; i++) { isSymlink[i] = Boolean.parseBoolean(isSymlinkParams[i]); } } for (int i = 0; i < this.filesCount; i++) { ActivityFileAttachment fileAttachment = new ActivityFileAttachment(); String repositoryName = (String) getValueFromArray(i, repositories); String workspaceName = (String) getValueFromArray(i, workspaces); if(StringUtils.isBlank(repositoryName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); repositoryName = repository == null ? null : repository.getConfiguration().getName(); } if(StringUtils.isBlank(workspaceName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); workspaceName = repository == null ? null : repository.getConfiguration().getDefaultWorkspaceName(); } fileAttachment.setNodeUUID(nodeUUIDs[i]) .setRepository(repositoryName) .setWorkspace(workspaceName) .setContentLink((String) getValueFromArray(i, contentLink)) .setState((String) getValueFromArray(i, state)) .setAuthor(getValueFromArray(i, author)) .setDateCreated(getValueFromArray(i, dateCreated)) .setLastModified(getValueFromArray(i, lastModified)) .setMimeType(getValueFromArray(i, mimeType)) .setImagePath(getValueFromArray(i, imagePath)) .setDocTypeName(getValueFromArray(i, docTypeName)) .setDocTitle(getValueFromArray(i, docTitle)) .setDocVersion(getValueFromArray(i, docVersion)) .setDocSummary(getValueFromArray(i, docSummary)) .setSymlink(getValueFromArray(i, isSymlink)) .setDocPath(getValueFromArray(i,docPath)); Node contentNode = NodeLocation.getNodeByLocation(fileAttachment.getNodeLocation()); if (contentNode != null) { try { if (!getTrashService().isInTrash(contentNode)) { fileAttachment.setContentName(getContentName(contentNode, fileAttachment.getContentName())); activityFileAttachments.add(fileAttachment); } } catch (Exception e) { LOG.error("Error while testing if the content is in trash", e); } } } this.filesCount = this.activityFileAttachments.size(); } }
FileUIActivity extends BaseUIActivity { public void setUIActivityData(Map<String, String> activityParams) { activityFileAttachments.clear(); this.message = activityParams.get(FileUIActivity.MESSAGE); this.activityStatus = activityParams.get(FileUIActivity.ACTIVITY_STATUS); String[] nodeUUIDs = getParameterValues(activityParams, FileUIActivity.ID); String[] repositories = getParameterValues(activityParams,UIDocActivity.REPOSITORY); String[] workspaces = getParameterValues(activityParams,UIDocActivity.WORKSPACE); if (nodeUUIDs == null || nodeUUIDs.length == 0) { String[] docPaths = getParameterValues(activityParams, UIDocActivity.DOCPATH); if (docPaths != null && docPaths.length > 0) { nodeUUIDs = new String[docPaths.length]; for (int i = 0; i < docPaths.length; i++) { String repository = "repository"; if (repositories != null && repositories.length == docPaths.length && StringUtils.isNotBlank(repositories[i])) { repository = repositories[i]; } String workspace = "collaboration"; if (workspaces != null && workspaces.length == docPaths.length && StringUtils.isNotBlank(workspaces[i])) { workspace = workspaces[i]; } String docPath = docPaths[i]; NodeLocation nodeLocation = new NodeLocation(repository, workspace, docPath); Node node = NodeLocation.getNodeByLocation(nodeLocation); if (node != null) { try { nodeUUIDs[i] = node.getUUID(); } catch (RepositoryException e) { LOG.error("can not get UUID", e); } } } } } this.filesCount = nodeUUIDs == null ? 0 : nodeUUIDs.length; String[] contentLink = getParameterValues(activityParams,FileUIActivity.CONTENT_LINK); String[] state = getParameterValues(activityParams, FileUIActivity.STATE); String[] author = getParameterValues(activityParams, FileUIActivity.AUTHOR); String[] dateCreated = getParameterValues(activityParams, FileUIActivity.DATE_CREATED); String[] lastModified = getParameterValues(activityParams, FileUIActivity.LAST_MODIFIED); String[] mimeType = getParameterValues(activityParams, FileUIActivity.MIME_TYPE); String[] imagePath = getParameterValues(activityParams, FileUIActivity.IMAGE_PATH); String[] docTypeName = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TYPE_LABEL); String[] docTitle = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TITLE); String[] docVersion = getParameterValues(activityParams, FileUIActivity.DOCUMENT_VERSION); String[] docSummary = getParameterValues(activityParams, FileUIActivity.DOCUMENT_SUMMARY); String[] docPath = getParameterValues(activityParams, UIDocActivity.DOCPATH); Boolean[] isSymlink = null; String[] isSymlinkParams = getParameterValues(activityParams, UIDocActivity.IS_SYMLINK); if(isSymlinkParams != null) { isSymlink = new Boolean[isSymlinkParams.length]; for (int i = 0; i < isSymlinkParams.length; i++) { isSymlink[i] = Boolean.parseBoolean(isSymlinkParams[i]); } } for (int i = 0; i < this.filesCount; i++) { ActivityFileAttachment fileAttachment = new ActivityFileAttachment(); String repositoryName = (String) getValueFromArray(i, repositories); String workspaceName = (String) getValueFromArray(i, workspaces); if(StringUtils.isBlank(repositoryName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); repositoryName = repository == null ? null : repository.getConfiguration().getName(); } if(StringUtils.isBlank(workspaceName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); workspaceName = repository == null ? null : repository.getConfiguration().getDefaultWorkspaceName(); } fileAttachment.setNodeUUID(nodeUUIDs[i]) .setRepository(repositoryName) .setWorkspace(workspaceName) .setContentLink((String) getValueFromArray(i, contentLink)) .setState((String) getValueFromArray(i, state)) .setAuthor(getValueFromArray(i, author)) .setDateCreated(getValueFromArray(i, dateCreated)) .setLastModified(getValueFromArray(i, lastModified)) .setMimeType(getValueFromArray(i, mimeType)) .setImagePath(getValueFromArray(i, imagePath)) .setDocTypeName(getValueFromArray(i, docTypeName)) .setDocTitle(getValueFromArray(i, docTitle)) .setDocVersion(getValueFromArray(i, docVersion)) .setDocSummary(getValueFromArray(i, docSummary)) .setSymlink(getValueFromArray(i, isSymlink)) .setDocPath(getValueFromArray(i,docPath)); Node contentNode = NodeLocation.getNodeByLocation(fileAttachment.getNodeLocation()); if (contentNode != null) { try { if (!getTrashService().isInTrash(contentNode)) { fileAttachment.setContentName(getContentName(contentNode, fileAttachment.getContentName())); activityFileAttachments.add(fileAttachment); } } catch (Exception e) { LOG.error("Error while testing if the content is in trash", e); } } } this.filesCount = this.activityFileAttachments.size(); } FileUIActivity(); }
FileUIActivity extends BaseUIActivity { public void setUIActivityData(Map<String, String> activityParams) { activityFileAttachments.clear(); this.message = activityParams.get(FileUIActivity.MESSAGE); this.activityStatus = activityParams.get(FileUIActivity.ACTIVITY_STATUS); String[] nodeUUIDs = getParameterValues(activityParams, FileUIActivity.ID); String[] repositories = getParameterValues(activityParams,UIDocActivity.REPOSITORY); String[] workspaces = getParameterValues(activityParams,UIDocActivity.WORKSPACE); if (nodeUUIDs == null || nodeUUIDs.length == 0) { String[] docPaths = getParameterValues(activityParams, UIDocActivity.DOCPATH); if (docPaths != null && docPaths.length > 0) { nodeUUIDs = new String[docPaths.length]; for (int i = 0; i < docPaths.length; i++) { String repository = "repository"; if (repositories != null && repositories.length == docPaths.length && StringUtils.isNotBlank(repositories[i])) { repository = repositories[i]; } String workspace = "collaboration"; if (workspaces != null && workspaces.length == docPaths.length && StringUtils.isNotBlank(workspaces[i])) { workspace = workspaces[i]; } String docPath = docPaths[i]; NodeLocation nodeLocation = new NodeLocation(repository, workspace, docPath); Node node = NodeLocation.getNodeByLocation(nodeLocation); if (node != null) { try { nodeUUIDs[i] = node.getUUID(); } catch (RepositoryException e) { LOG.error("can not get UUID", e); } } } } } this.filesCount = nodeUUIDs == null ? 0 : nodeUUIDs.length; String[] contentLink = getParameterValues(activityParams,FileUIActivity.CONTENT_LINK); String[] state = getParameterValues(activityParams, FileUIActivity.STATE); String[] author = getParameterValues(activityParams, FileUIActivity.AUTHOR); String[] dateCreated = getParameterValues(activityParams, FileUIActivity.DATE_CREATED); String[] lastModified = getParameterValues(activityParams, FileUIActivity.LAST_MODIFIED); String[] mimeType = getParameterValues(activityParams, FileUIActivity.MIME_TYPE); String[] imagePath = getParameterValues(activityParams, FileUIActivity.IMAGE_PATH); String[] docTypeName = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TYPE_LABEL); String[] docTitle = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TITLE); String[] docVersion = getParameterValues(activityParams, FileUIActivity.DOCUMENT_VERSION); String[] docSummary = getParameterValues(activityParams, FileUIActivity.DOCUMENT_SUMMARY); String[] docPath = getParameterValues(activityParams, UIDocActivity.DOCPATH); Boolean[] isSymlink = null; String[] isSymlinkParams = getParameterValues(activityParams, UIDocActivity.IS_SYMLINK); if(isSymlinkParams != null) { isSymlink = new Boolean[isSymlinkParams.length]; for (int i = 0; i < isSymlinkParams.length; i++) { isSymlink[i] = Boolean.parseBoolean(isSymlinkParams[i]); } } for (int i = 0; i < this.filesCount; i++) { ActivityFileAttachment fileAttachment = new ActivityFileAttachment(); String repositoryName = (String) getValueFromArray(i, repositories); String workspaceName = (String) getValueFromArray(i, workspaces); if(StringUtils.isBlank(repositoryName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); repositoryName = repository == null ? null : repository.getConfiguration().getName(); } if(StringUtils.isBlank(workspaceName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); workspaceName = repository == null ? null : repository.getConfiguration().getDefaultWorkspaceName(); } fileAttachment.setNodeUUID(nodeUUIDs[i]) .setRepository(repositoryName) .setWorkspace(workspaceName) .setContentLink((String) getValueFromArray(i, contentLink)) .setState((String) getValueFromArray(i, state)) .setAuthor(getValueFromArray(i, author)) .setDateCreated(getValueFromArray(i, dateCreated)) .setLastModified(getValueFromArray(i, lastModified)) .setMimeType(getValueFromArray(i, mimeType)) .setImagePath(getValueFromArray(i, imagePath)) .setDocTypeName(getValueFromArray(i, docTypeName)) .setDocTitle(getValueFromArray(i, docTitle)) .setDocVersion(getValueFromArray(i, docVersion)) .setDocSummary(getValueFromArray(i, docSummary)) .setSymlink(getValueFromArray(i, isSymlink)) .setDocPath(getValueFromArray(i,docPath)); Node contentNode = NodeLocation.getNodeByLocation(fileAttachment.getNodeLocation()); if (contentNode != null) { try { if (!getTrashService().isInTrash(contentNode)) { fileAttachment.setContentName(getContentName(contentNode, fileAttachment.getContentName())); activityFileAttachments.add(fileAttachment); } } catch (Exception e) { LOG.error("Error while testing if the content is in trash", e); } } } this.filesCount = this.activityFileAttachments.size(); } FileUIActivity(); String getActivityTitle(); void setActivityTitle(String activityTitle); String getContentLink(int i); void setContentLink(int i,String contentLink); String getMessage(); void setMessage(String message); String getContentName(int i); String getContentName(Node contentNode, String activityContentName); void setContentName(String contentName, int i); String getImagePath(int i); void setImagePath(String imagePath, int i); String getMimeType(int i); void setMimeType(String mimeType, int i); String getNodeUUID(int i); void setNodeUUID(String nodeUUID, int i); String getState(int i); void setState(String state, int i); String getAuthor(int i); void setAuthor(String author, int i); String getDocTypeName(int i); String getDocTitle(int i); String getDocVersion(int i); String getDocSummary(int i); boolean isSymlink(int i); String getTitle(Node node); String getDateCreated(int i); void setDateCreated(String dateCreated, int i); String getLastModified(int i); void setLastModified(String lastModified, int i); Node getContentNode(int i); void setContentNode(Node contentNode, int i); NodeLocation getNodeLocation(int i); void setNodeLocation(NodeLocation nodeLocation, int i); String getSummary(Node node); String getDocumentSummary(Map<String, String> activityParams); String getUserFullName(String userId); String getUserProfileUri(String userId); String getUserAvatarImageSource(String userId); String getSpaceAvatarImageSource(String spaceIdentityId); String getActivityStatus(); int getFilesCount(); void setUIActivityData(Map<String, String> activityParams); String getWebdavURL(int i); String[] getSystemCommentBundle(Map<String, String> activityParams); String[] getSystemCommentTitle(Map<String, String> activityParams); DriveData getDocDrive(int i); String getDefaultIconClass(int i); String getDocFileBreadCrumb(int i); String getDocFilePath(int i); LinkedHashMap<String, String> getDocFolderRelativePathWithLinks(int i); String getDocFolderRelativePath(int i); String getCurrentDocOpenUri(int i); String getDocOpenUri(String nodePath, int i); String getEditLink(int i); String getActivityEditLink(int i); String getDownloadAllLink(); String getDownloadLink(int i); boolean isFileSupportPreview(Node data); boolean canEditDocument(Node data); @Override void end(); String getLinkDescription(); void setLinkDescription(String linkDescription); String getLinkImage(); void setLinkImage(String linkImage); String getLinkSource(); void setLinkSource(String linkSource); String getLinkTitle(); void setLinkTitle(String linkTitle); String getEmbedHtml(); void setEmbedHtml(String embedHtml); CloudDrive getCloudDrive(Node node); boolean isCloudFile(CloudDrive cloudDrive); CloudFile getCloudFile(Node node); String getCloudFileIcon(CloudDrive cloudDrive); }
FileUIActivity extends BaseUIActivity { public void setUIActivityData(Map<String, String> activityParams) { activityFileAttachments.clear(); this.message = activityParams.get(FileUIActivity.MESSAGE); this.activityStatus = activityParams.get(FileUIActivity.ACTIVITY_STATUS); String[] nodeUUIDs = getParameterValues(activityParams, FileUIActivity.ID); String[] repositories = getParameterValues(activityParams,UIDocActivity.REPOSITORY); String[] workspaces = getParameterValues(activityParams,UIDocActivity.WORKSPACE); if (nodeUUIDs == null || nodeUUIDs.length == 0) { String[] docPaths = getParameterValues(activityParams, UIDocActivity.DOCPATH); if (docPaths != null && docPaths.length > 0) { nodeUUIDs = new String[docPaths.length]; for (int i = 0; i < docPaths.length; i++) { String repository = "repository"; if (repositories != null && repositories.length == docPaths.length && StringUtils.isNotBlank(repositories[i])) { repository = repositories[i]; } String workspace = "collaboration"; if (workspaces != null && workspaces.length == docPaths.length && StringUtils.isNotBlank(workspaces[i])) { workspace = workspaces[i]; } String docPath = docPaths[i]; NodeLocation nodeLocation = new NodeLocation(repository, workspace, docPath); Node node = NodeLocation.getNodeByLocation(nodeLocation); if (node != null) { try { nodeUUIDs[i] = node.getUUID(); } catch (RepositoryException e) { LOG.error("can not get UUID", e); } } } } } this.filesCount = nodeUUIDs == null ? 0 : nodeUUIDs.length; String[] contentLink = getParameterValues(activityParams,FileUIActivity.CONTENT_LINK); String[] state = getParameterValues(activityParams, FileUIActivity.STATE); String[] author = getParameterValues(activityParams, FileUIActivity.AUTHOR); String[] dateCreated = getParameterValues(activityParams, FileUIActivity.DATE_CREATED); String[] lastModified = getParameterValues(activityParams, FileUIActivity.LAST_MODIFIED); String[] mimeType = getParameterValues(activityParams, FileUIActivity.MIME_TYPE); String[] imagePath = getParameterValues(activityParams, FileUIActivity.IMAGE_PATH); String[] docTypeName = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TYPE_LABEL); String[] docTitle = getParameterValues(activityParams, FileUIActivity.DOCUMENT_TITLE); String[] docVersion = getParameterValues(activityParams, FileUIActivity.DOCUMENT_VERSION); String[] docSummary = getParameterValues(activityParams, FileUIActivity.DOCUMENT_SUMMARY); String[] docPath = getParameterValues(activityParams, UIDocActivity.DOCPATH); Boolean[] isSymlink = null; String[] isSymlinkParams = getParameterValues(activityParams, UIDocActivity.IS_SYMLINK); if(isSymlinkParams != null) { isSymlink = new Boolean[isSymlinkParams.length]; for (int i = 0; i < isSymlinkParams.length; i++) { isSymlink[i] = Boolean.parseBoolean(isSymlinkParams[i]); } } for (int i = 0; i < this.filesCount; i++) { ActivityFileAttachment fileAttachment = new ActivityFileAttachment(); String repositoryName = (String) getValueFromArray(i, repositories); String workspaceName = (String) getValueFromArray(i, workspaces); if(StringUtils.isBlank(repositoryName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); repositoryName = repository == null ? null : repository.getConfiguration().getName(); } if(StringUtils.isBlank(workspaceName)) { ManageableRepository repository = WCMCoreUtils.getRepository(); workspaceName = repository == null ? null : repository.getConfiguration().getDefaultWorkspaceName(); } fileAttachment.setNodeUUID(nodeUUIDs[i]) .setRepository(repositoryName) .setWorkspace(workspaceName) .setContentLink((String) getValueFromArray(i, contentLink)) .setState((String) getValueFromArray(i, state)) .setAuthor(getValueFromArray(i, author)) .setDateCreated(getValueFromArray(i, dateCreated)) .setLastModified(getValueFromArray(i, lastModified)) .setMimeType(getValueFromArray(i, mimeType)) .setImagePath(getValueFromArray(i, imagePath)) .setDocTypeName(getValueFromArray(i, docTypeName)) .setDocTitle(getValueFromArray(i, docTitle)) .setDocVersion(getValueFromArray(i, docVersion)) .setDocSummary(getValueFromArray(i, docSummary)) .setSymlink(getValueFromArray(i, isSymlink)) .setDocPath(getValueFromArray(i,docPath)); Node contentNode = NodeLocation.getNodeByLocation(fileAttachment.getNodeLocation()); if (contentNode != null) { try { if (!getTrashService().isInTrash(contentNode)) { fileAttachment.setContentName(getContentName(contentNode, fileAttachment.getContentName())); activityFileAttachments.add(fileAttachment); } } catch (Exception e) { LOG.error("Error while testing if the content is in trash", e); } } } this.filesCount = this.activityFileAttachments.size(); } FileUIActivity(); String getActivityTitle(); void setActivityTitle(String activityTitle); String getContentLink(int i); void setContentLink(int i,String contentLink); String getMessage(); void setMessage(String message); String getContentName(int i); String getContentName(Node contentNode, String activityContentName); void setContentName(String contentName, int i); String getImagePath(int i); void setImagePath(String imagePath, int i); String getMimeType(int i); void setMimeType(String mimeType, int i); String getNodeUUID(int i); void setNodeUUID(String nodeUUID, int i); String getState(int i); void setState(String state, int i); String getAuthor(int i); void setAuthor(String author, int i); String getDocTypeName(int i); String getDocTitle(int i); String getDocVersion(int i); String getDocSummary(int i); boolean isSymlink(int i); String getTitle(Node node); String getDateCreated(int i); void setDateCreated(String dateCreated, int i); String getLastModified(int i); void setLastModified(String lastModified, int i); Node getContentNode(int i); void setContentNode(Node contentNode, int i); NodeLocation getNodeLocation(int i); void setNodeLocation(NodeLocation nodeLocation, int i); String getSummary(Node node); String getDocumentSummary(Map<String, String> activityParams); String getUserFullName(String userId); String getUserProfileUri(String userId); String getUserAvatarImageSource(String userId); String getSpaceAvatarImageSource(String spaceIdentityId); String getActivityStatus(); int getFilesCount(); void setUIActivityData(Map<String, String> activityParams); String getWebdavURL(int i); String[] getSystemCommentBundle(Map<String, String> activityParams); String[] getSystemCommentTitle(Map<String, String> activityParams); DriveData getDocDrive(int i); String getDefaultIconClass(int i); String getDocFileBreadCrumb(int i); String getDocFilePath(int i); LinkedHashMap<String, String> getDocFolderRelativePathWithLinks(int i); String getDocFolderRelativePath(int i); String getCurrentDocOpenUri(int i); String getDocOpenUri(String nodePath, int i); String getEditLink(int i); String getActivityEditLink(int i); String getDownloadAllLink(); String getDownloadLink(int i); boolean isFileSupportPreview(Node data); boolean canEditDocument(Node data); @Override void end(); String getLinkDescription(); void setLinkDescription(String linkDescription); String getLinkImage(); void setLinkImage(String linkImage); String getLinkSource(); void setLinkSource(String linkSource); String getLinkTitle(); void setLinkTitle(String linkTitle); String getEmbedHtml(); void setEmbedHtml(String embedHtml); CloudDrive getCloudDrive(Node node); boolean isCloudFile(CloudDrive cloudDrive); CloudFile getCloudFile(Node node); String getCloudFileIcon(CloudDrive cloudDrive); static final String[] EMPTY_ARRAY; static final String SEPARATOR_REGEX; static final String ID; static final String CONTENT_LINK; static final String MESSAGE; static final String ACTIVITY_STATUS; static final String IMAGE_PATH; static final String MIME_TYPE; static final String STATE; static final String AUTHOR; static final String DATE_CREATED; static final String LAST_MODIFIED; static final String DOCUMENT_TYPE_LABEL; static final String DOCUMENT_TITLE; static final String DOCUMENT_VERSION; static final String DOCUMENT_SUMMARY; static final String IS_SYSTEM_COMMENT; static final String SYSTEM_COMMENT; static final String ONE_DRIVE_PROVIDER_ID; static final String GOOGLE_DRIVE_PROVIDER_ID; static final String ONE_DRIVE_ICON; static final String GOOGLE_DRIVE_ICON; public int filesCount; }