List of usage examples for com.liferay.portal.sharepoint SharepointRequest getRootPath
public String getRootPath()
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public void addDocumentElements(SharepointRequest sharepointRequest, Element element) throws Exception { String parentFolderPath = sharepointRequest.getRootPath(); long groupId = SharepointUtil.getGroupId(parentFolderPath); long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); if (parentFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return;//from w w w . j a v a 2s. c om } List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(groupId, parentFolderId); for (FileEntry fileEntry : fileEntries) { String documentPath = parentFolderPath.concat(StringPool.SLASH).concat(fileEntry.getTitle()); addDocumentElement(element, documentPath, fileEntry.getCreateDate(), fileEntry.getModifiedDate(), fileEntry.getUserName()); } }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public void createFolder(SharepointRequest sharepointRequest) throws Exception { String folderPath = sharepointRequest.getRootPath(); String parentFolderPath = getParentFolderPath(folderPath); long groupId = SharepointUtil.getGroupId(parentFolderPath); long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); String folderName = getResourceName(folderPath); String description = StringPool.BLANK; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); DLAppServiceUtil.addFolder(groupId, parentFolderId, folderName, description, serviceContext); }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public Tree getDocumentTree(SharepointRequest sharepointRequest) throws Exception { String documentPath = sharepointRequest.getRootPath(); String parentFolderPath = getParentFolderPath(documentPath); FileEntry fileEntry = getFileEntry(sharepointRequest); return getFileEntryTree(fileEntry, parentFolderPath); }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public Tree getDocumentsTree(SharepointRequest sharepointRequest) throws Exception { Tree documentsTree = new Tree(); String parentFolderPath = sharepointRequest.getRootPath(); long groupId = SharepointUtil.getGroupId(parentFolderPath); long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); if (parentFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(groupId, parentFolderId); for (FileEntry fileEntry : fileEntries) { documentsTree.addChild(getFileEntryTree(fileEntry, parentFolderPath)); }//from w ww . j a v a 2s.c o m } return documentsTree; }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public Tree getFolderTree(SharepointRequest sharepointRequest) throws Exception { String folderPath = sharepointRequest.getRootPath(); String parentFolderPath = getParentFolderPath(folderPath); long groupId = SharepointUtil.getGroupId(folderPath); long folderId = getLastFolderId(groupId, folderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); Folder folder = DLAppServiceUtil.getFolder(folderId); return getFolderTree(folder, parentFolderPath); }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public Tree getFoldersTree(SharepointRequest sharepointRequest) throws Exception { Tree foldersTree = new Tree(); String parentFolderPath = sharepointRequest.getRootPath(); long groupId = SharepointUtil.getGroupId(parentFolderPath); long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); List<Folder> folders = DLAppServiceUtil.getFolders(groupId, parentFolderId, false); for (Folder folder : folders) { foldersTree.addChild(getFolderTree(folder, parentFolderPath)); }//ww w. j a v a 2s . c om foldersTree.addChild(getFolderTree(parentFolderPath)); return foldersTree; }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public Tree[] moveDocument(SharepointRequest sharepointRequest) throws Exception { String parentFolderPath = sharepointRequest.getRootPath(); long groupId = SharepointUtil.getGroupId(parentFolderPath); Folder folder = null;//from w w w.j av a 2 s .co m FileEntry fileEntry = null; try { long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); folder = DLAppServiceUtil.getFolder(parentFolderId); } catch (Exception e1) { if (e1 instanceof NoSuchFolderException) { try { fileEntry = getFileEntry(sharepointRequest); } catch (Exception e2) { } } } Tree movedDocsTree = new Tree(); Tree movedDirsTree = new Tree(); String newPath = sharepointRequest.getParameterValue("newUrl"); String newParentFolderPath = getParentFolderPath(newPath); long newGroupId = SharepointUtil.getGroupId(newParentFolderPath); long newParentFolderId = getLastFolderId(newGroupId, newParentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); String newName = getResourceName(newPath); ServiceContext serviceContext = new ServiceContext(); if (fileEntry != null) { File file = null; try { long fileEntryId = fileEntry.getFileEntryId(); long folderId = fileEntry.getFolderId(); String mimeType = fileEntry.getMimeType(); String description = fileEntry.getDescription(); String changeLog = StringPool.BLANK; InputStream is = fileEntry.getContentStream(); file = FileUtil.createTempFile(is); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(FileEntry.class.getName(), fileEntry.getFileEntryId()); serviceContext.setAssetTagNames(assetTagNames); fileEntry = DLAppServiceUtil.updateFileEntry(fileEntryId, newName, mimeType, newName, description, changeLog, false, file, serviceContext); if (folderId != newParentFolderId) { fileEntry = DLAppServiceUtil.moveFileEntry(fileEntryId, newParentFolderId, serviceContext); } Tree documentTree = getFileEntryTree(fileEntry, newParentFolderPath); movedDocsTree.addChild(documentTree); } finally { FileUtil.delete(file); } } else if (folder != null) { long folderId = folder.getFolderId(); folder = DLAppServiceUtil.moveFolder(folderId, newParentFolderId, serviceContext); Tree folderTree = getFolderTree(folder, newParentFolderPath); movedDirsTree.addChild(folderTree); } return new Tree[] { movedDocsTree, movedDirsTree }; }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public void putDocument(SharepointRequest sharepointRequest) throws Exception { HttpServletRequest request = sharepointRequest.getHttpServletRequest(); String documentPath = sharepointRequest.getRootPath(); String parentFolderPath = getParentFolderPath(documentPath); long groupId = SharepointUtil.getGroupId(parentFolderPath); long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); String title = getResourceName(documentPath); String description = StringPool.BLANK; String changeLog = StringPool.BLANK; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE), ContentTypes.APPLICATION_OCTET_STREAM); String extension = FileUtil.getExtension(title); File file = null;//from w w w. ja v a 2s . co m try { file = FileUtil.createTempFile(extension); FileUtil.write(file, request.getInputStream()); if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) { contentType = MimeTypesUtil.getContentType(file, title); } try { FileEntry fileEntry = getFileEntry(sharepointRequest); long fileEntryId = fileEntry.getFileEntryId(); description = fileEntry.getDescription(); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(FileEntry.class.getName(), fileEntry.getFileEntryId()); serviceContext.setAssetTagNames(assetTagNames); DLAppServiceUtil.updateFileEntry(fileEntryId, title, contentType, title, description, changeLog, false, file, serviceContext); } catch (NoSuchFileEntryException nsfee) { DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType, title, description, changeLog, file, serviceContext); } } finally { FileUtil.delete(file); } }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
@Override public Tree[] removeDocument(SharepointRequest sharepointRequest) { String parentFolderPath = sharepointRequest.getRootPath(); long groupId = SharepointUtil.getGroupId(parentFolderPath); Folder folder = null;/*w w w .j a v a 2 s. c o m*/ FileEntry fileEntry = null; try { long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); folder = DLAppServiceUtil.getFolder(parentFolderId); } catch (Exception e1) { if (e1 instanceof NoSuchFolderException) { try { fileEntry = getFileEntry(sharepointRequest); } catch (Exception e2) { } } } Tree documentTree = new Tree(); Tree removedDocsTree = new Tree(); Tree failedDocsTree = new Tree(); Tree folderTree = new Tree(); Tree removedDirsTree = new Tree(); Tree failedDirsTree = new Tree(); if (fileEntry != null) { try { documentTree = getFileEntryTree(fileEntry, parentFolderPath); DLAppServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); removedDocsTree.addChild(documentTree); } catch (Exception e1) { try { failedDocsTree.addChild(documentTree); } catch (Exception e2) { } } } else if (folder != null) { try { folderTree = getFolderTree(folder, parentFolderPath); DLAppServiceUtil.deleteFolder(folder.getFolderId()); removedDirsTree.addChild(folderTree); } catch (Exception e1) { try { failedDirsTree.addChild(folderTree); } catch (Exception e2) { } } } return new Tree[] { removedDocsTree, removedDirsTree, failedDocsTree, failedDirsTree }; }
From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java
License:Open Source License
protected FileEntry getFileEntry(SharepointRequest sharepointRequest) throws Exception { String documentPath = sharepointRequest.getRootPath(); String parentFolderPath = getParentFolderPath(documentPath); long groupId = SharepointUtil.getGroupId(parentFolderPath); long parentFolderId = getLastFolderId(groupId, parentFolderPath, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); String title = getResourceName(documentPath); return DLAppServiceUtil.getFileEntry(groupId, parentFolderId, title); }