private void _getFolders(CommandArgument commandArgument, Document document, Node rootNode) throws Exception { Element foldersElement = document.createElement("Folders"); rootNode.appendChild(foldersElement); if (commandArgument.getCurrentFolder().equals(StringPool.SLASH)) { getRootFolders(commandArgument, document, foldersElement); } else { Group group = commandArgument.getCurrentGroup(); List<Layout> layouts = LayoutLocalServiceUtil.getLayouts( group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); if (("/" + commandArgument.getCurrentGroupName() + "/") .equals(commandArgument.getCurrentFolder())) { for (Layout layout : layouts) { Element folderElement = document.createElement("Folder"); foldersElement.appendChild(folderElement); folderElement.setAttribute("name", "~" + _getLayoutName(layout).replace('/', '>')); } } else { String layoutName = _getLayoutName(commandArgument.getCurrentFolder()); Layout layout = null; for (int i = 0; i < layouts.size(); i++) { layout = _getLayout(layoutName, layouts.get(i)); if (layout != null) { break; } } if (layout != null) { List<Layout> layoutChildren = layout.getChildren(); for (int i = 0; i < layoutChildren.size(); i++) { layout = layoutChildren.get(i); Element folderElement = document.createElement("Folder"); foldersElement.appendChild(folderElement); folderElement.setAttribute("name", "~" + _getLayoutName(layout).replace('/', '>')); } } } } }
private void _getFiles(CommandArgument commandArgument, Document document, Node rootNode) throws Exception { Element filesElement = document.createElement("Files"); rootNode.appendChild(filesElement); if (Validator.isNull(commandArgument.getCurrentGroupName())) { return; } Group group = commandArgument.getCurrentGroup(); Folder folder = _getFolder(group.getGroupId(), commandArgument.getCurrentFolder()); List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(group.getGroupId(), folder.getFolderId()); for (FileEntry fileEntry : fileEntries) { Element fileElement = document.createElement("File"); filesElement.appendChild(fileElement); fileElement.setAttribute("name", fileEntry.getTitle()); fileElement.setAttribute("desc", fileEntry.getTitle()); fileElement.setAttribute("size", getSize(fileEntry.getSize())); StringBundler url = new StringBundler(5); ThemeDisplay themeDisplay = commandArgument.getThemeDisplay(); url.append(themeDisplay.getPathMain()); url.append("/document_library/get_file?uuid="); url.append(fileEntry.getUuid()); url.append("&groupId="); url.append(group.getGroupId()); fileElement.setAttribute("url", url.toString()); } }
private void _getFiles(CommandArgument commandArgument, Document document, Node rootNode) throws Exception { if (commandArgument.getCurrentFolder().equals(StringPool.SLASH)) { return; } Element filesElement = document.createElement("Files"); rootNode.appendChild(filesElement); Group group = commandArgument.getCurrentGroup(); List<Layout> layouts = LayoutLocalServiceUtil.getLayouts( group.getGroupId(), false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); if (("/" + commandArgument.getCurrentGroupName() + "/") .equals(commandArgument.getCurrentFolder())) { for (Layout layout : layouts) { Element fileElement = document.createElement("File"); filesElement.appendChild(fileElement); fileElement.setAttribute("name", _getLayoutName(layout)); fileElement.setAttribute("desc", _getLayoutName(layout)); fileElement.setAttribute("size", StringPool.BLANK); fileElement.setAttribute( "url", PortalUtil.getLayoutURL(layout, commandArgument.getThemeDisplay(), false)); } } else { String layoutName = _getLayoutName(commandArgument.getCurrentFolder()); Layout layout = null; for (int i = 0; i < layouts.size(); i++) { layout = _getLayout(layoutName, layouts.get(i)); if (layout != null) { break; } } if (layout == null) { return; } List<Layout> layoutChildren = layout.getChildren(); for (int i = 0; i < layoutChildren.size(); i++) { layout = layoutChildren.get(i); Element fileElement = document.createElement("File"); filesElement.appendChild(fileElement); fileElement.setAttribute("name", _getLayoutName(layout)); fileElement.setAttribute("desc", _getLayoutName(layout)); fileElement.setAttribute("size", getSize()); fileElement.setAttribute( "url", PortalUtil.getLayoutURL(layout, commandArgument.getThemeDisplay(), false)); } } }