protected String fileUpload( CommandArgument commandArgument, String fileName, File file, String extension) { try { Group group = commandArgument.getCurrentGroup(); Folder folder = _getFolder(group.getGroupId(), commandArgument.getCurrentFolder()); long folderId = folder.getFolderId(); String title = fileName; String description = StringPool.BLANK; String changeLog = StringPool.BLANK; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddCommunityPermissions(true); serviceContext.setAddGuestPermissions(true); DLAppServiceUtil.addFileEntry( group.getGroupId(), folderId, title, description, changeLog, file, serviceContext); } catch (Exception e) { throw new FCKException(e); } return "0"; }
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(); Folder folder = _getFolder(group.getGroupId(), commandArgument.getCurrentFolder()); List<Folder> folders = DLAppServiceUtil.getFolders(group.getGroupId(), folder.getFolderId()); for (Folder curFolder : folders) { Element folderElement = document.createElement("Folder"); foldersElement.appendChild(folderElement); folderElement.setAttribute("name", curFolder.getName()); } } }
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()); } }
protected String createFolder(CommandArgument commandArgument) { try { Group group = commandArgument.getCurrentGroup(); Folder folder = _getFolder(group.getGroupId(), StringPool.SLASH + commandArgument.getCurrentFolder()); long parentFolderId = folder.getFolderId(); String name = commandArgument.getNewFolder(); String description = StringPool.BLANK; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddCommunityPermissions(true); serviceContext.setAddGuestPermissions(true); DLAppServiceUtil.addFolder( group.getGroupId(), parentFolderId, name, description, serviceContext); } catch (Exception e) { throw new FCKException(e); } return "0"; }
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)); } } }