List of usage examples for com.liferay.portal.sharepoint SharepointRequest getHttpServletRequest
public HttpServletRequest getHttpServletRequest()
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 ww .j a v a 2 s . c o 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); } }