List of usage examples for com.liferay.portal.kernel.util Constants ADD_DYNAMIC
String ADD_DYNAMIC
To view the source code for com.liferay.portal.kernel.util Constants ADD_DYNAMIC.
Click Source Link
From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); FileEntry fileEntry = null;/* www . j a va2 s . c om*/ PortletConfig portletConfig = getPortletConfig(actionRequest); try { UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { Throwable cause = uploadException.getCause(); if (cmd.equals(Constants.ADD_TEMP)) { if (cause instanceof FileUploadBase.IOFileUploadException) { if (_log.isInfoEnabled()) { _log.info("Temporary upload was cancelled"); } } } else { if (uploadException.isExceededFileSizeLimit()) { throw new FileSizeException(cause); } if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(cause); } if (uploadException.isExceededUploadRequestSizeLimit()) { throw new UploadRequestSizeException(cause); } throw new PortalException(cause); } } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC) || cmd.equals(Constants.UPDATE) || cmd.equals(Constants.UPDATE_AND_CHECKIN)) { fileEntry = updateFileEntry(portletConfig, actionRequest, actionResponse); } else if (cmd.equals(Constants.ADD_MULTIPLE)) { addMultipleFileEntries(portletConfig, actionRequest, actionResponse); hideDefaultSuccessMessage(actionRequest); } else if (cmd.equals(Constants.ADD_TEMP)) { addTempFileEntry(actionRequest, actionResponse); } else if (cmd.equals(Constants.DELETE)) { deleteFileEntry(actionRequest, false); } else if (cmd.equals(Constants.DELETE_TEMP)) { deleteTempFileEntry(actionRequest, actionResponse); } else if (cmd.equals(Constants.CANCEL_CHECKOUT)) { cancelFileEntriesCheckOut(actionRequest); } else if (cmd.equals(Constants.CHECKIN)) { checkInFileEntries(actionRequest); } else if (cmd.equals(Constants.CHECKOUT)) { checkOutFileEntries(actionRequest); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deleteFileEntry(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restoreTrashEntries(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertFileEntry(actionRequest); } WindowState windowState = actionRequest.getWindowState(); if (cmd.equals(Constants.ADD_TEMP) || cmd.equals(Constants.DELETE_TEMP)) { actionResponse.setRenderParameter("mvcPath", "/null.jsp"); } else if (cmd.equals(Constants.PREVIEW)) { SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_FORCE_SEND_REDIRECT); hideDefaultSuccessMessage(actionRequest); actionResponse.setRenderParameter("mvcRenderCommandName", "/document_library/edit_file_entry"); } else if (!windowState.equals(LiferayWindowState.POP_UP)) { } else { String redirect = ParamUtil.getString(actionRequest, "redirect"); int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_SAVE_DRAFT); if ((fileEntry != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) { redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, fileEntry, redirect); sendRedirect(actionRequest, actionResponse, redirect); } else { if (windowState.equals(LiferayWindowState.POP_UP)) { redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { if (cmd.equals(Constants.ADD) && (fileEntry != null)) { String portletId = HttpUtil.getParameter(redirect, "p_p_id", false); String namespace = _portal.getPortletNamespace(portletId); redirect = HttpUtil.addParameter(redirect, namespace + "className", DLFileEntry.class.getName()); redirect = HttpUtil.addParameter(redirect, namespace + "classPK", fileEntry.getFileEntryId()); } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); } } } } } catch (Exception e) { handleUploadException(portletConfig, actionRequest, actionResponse, cmd, e); } }
From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java
License:Open Source License
protected void handleUploadException(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse, String cmd, Exception e) throws Exception { if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); } else if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException || e instanceof DuplicateFolderNameException || e instanceof FileExtensionException || e instanceof FileMimeTypeException || e instanceof FileNameException || e instanceof FileSizeException || e instanceof LiferayFileItemException || e instanceof NoSuchFolderException || e instanceof SourceFileNameException || e instanceof StorageFieldRequiredException || e instanceof UploadRequestSizeException) { if (!cmd.equals(Constants.ADD_DYNAMIC) && !cmd.equals(Constants.ADD_MULTIPLE) && !cmd.equals(Constants.ADD_TEMP)) { if (e instanceof AntivirusScannerException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { SessionErrors.add(actionRequest, e.getClass()); }//from ww w .ja v a 2s . c om return; } else if (cmd.equals(Constants.ADD_TEMP)) { hideDefaultErrorMessage(actionRequest); } if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException || e instanceof FileExtensionException || e instanceof FileNameException || e instanceof FileSizeException || e instanceof UploadRequestSizeException) { HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); response.setContentType(ContentTypes.TEXT_HTML); response.setStatus(HttpServletResponse.SC_OK); String errorMessage = StringPool.BLANK; int errorType = 0; ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (e instanceof AntivirusScannerException) { AntivirusScannerException ase = (AntivirusScannerException) e; errorMessage = themeDisplay.translate(ase.getMessageKey()); errorType = ServletResponseConstants.SC_FILE_ANTIVIRUS_EXCEPTION; } if (e instanceof DuplicateFileEntryException) { errorMessage = themeDisplay.translate("please-enter-a-unique-document-name"); errorType = ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION; } else if (e instanceof FileExtensionException) { errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-extension-x", StringUtil .merge(getAllowedFileExtensions(portletConfig, actionRequest, actionResponse))); errorType = ServletResponseConstants.SC_FILE_EXTENSION_EXCEPTION; } else if (e instanceof FileNameException) { errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-file-name"); errorType = ServletResponseConstants.SC_FILE_NAME_EXCEPTION; } else if (e instanceof FileSizeException) { long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE); if (fileMaxSize == 0) { fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE); } errorMessage = themeDisplay.translate( "please-enter-a-file-with-a-valid-file-size-no-" + "larger-than-x", TextFormatter.formatStorageSize(fileMaxSize, themeDisplay.getLocale())); errorType = ServletResponseConstants.SC_FILE_SIZE_EXCEPTION; } JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("message", errorMessage); jsonObject.put("status", errorType); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } if (e instanceof AntivirusScannerException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { SessionErrors.add(actionRequest, e.getClass()); } } else if (e instanceof DuplicateLockException || e instanceof FileEntryLockException.MustOwnLock || e instanceof InvalidFileVersionException || e instanceof NoSuchFileEntryException || e instanceof PrincipalException) { if (e instanceof DuplicateLockException) { DuplicateLockException dle = (DuplicateLockException) e; SessionErrors.add(actionRequest, dle.getClass(), dle.getLock()); } else { SessionErrors.add(actionRequest, e.getClass()); } actionResponse.setRenderParameter("mvcPath", "/document_library/error.jsp"); } else { Throwable cause = e.getCause(); if (cause instanceof DuplicateFileEntryException) { SessionErrors.add(actionRequest, DuplicateFileEntryException.class); } else { throw e; } } }
From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java
License:Open Source License
protected FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(uploadPortletRequest, Constants.CMD); long fileEntryId = ParamUtil.getLong(uploadPortletRequest, "fileEntryId"); long repositoryId = ParamUtil.getLong(uploadPortletRequest, "repositoryId"); long folderId = ParamUtil.getLong(uploadPortletRequest, "folderId"); String sourceFileName = uploadPortletRequest.getFileName("file"); String title = ParamUtil.getString(uploadPortletRequest, "title"); String description = ParamUtil.getString(uploadPortletRequest, "description"); String changeLog = ParamUtil.getString(uploadPortletRequest, "changeLog"); boolean majorVersion = ParamUtil.getBoolean(uploadPortletRequest, "majorVersion"); if (folderId > 0) { Folder folder = _dlAppService.getFolder(folderId); if (folder.getGroupId() != themeDisplay.getScopeGroupId()) { throw new NoSuchFolderException("{folderId=" + folderId + "}"); }/* ww w . j a va 2s . c om*/ } InputStream inputStream = null; if (cmd.equals(Constants.ADD_DYNAMIC)) { title = uploadPortletRequest.getFileName("file"); } try { String contentType = uploadPortletRequest.getContentType("file"); long size = uploadPortletRequest.getSize("file"); if ((cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC)) && (size == 0)) { contentType = MimeTypesUtil.getContentType(title); } if (cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC) || (size > 0)) { String portletName = portletConfig.getPortletName(); if (portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY)) { PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); DLPortletInstanceSettings dlPortletInstanceSettings = DLPortletInstanceSettings .getInstance(themeDisplay.getLayout(), portletDisplay.getId()); String[] mimeTypes = dlPortletInstanceSettings.getMimeTypes(); if (Arrays.binarySearch(mimeTypes, contentType) < 0) { throw new FileMimeTypeException(contentType); } } } inputStream = uploadPortletRequest.getFileAsStream("file"); ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), uploadPortletRequest); FileEntry fileEntry = null; if (cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC)) { // Add file entry fileEntry = _dlAppService.addFileEntry(repositoryId, folderId, sourceFileName, contentType, title, description, changeLog, inputStream, size, serviceContext); if (cmd.equals(Constants.ADD_DYNAMIC)) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("fileEntryId", fileEntry.getFileEntryId()); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } } else if (cmd.equals(Constants.UPDATE_AND_CHECKIN)) { // Update file entry and checkin fileEntry = _dlAppService.updateFileEntryAndCheckIn(fileEntryId, sourceFileName, contentType, title, description, changeLog, majorVersion, inputStream, size, serviceContext); } else { // Update file entry fileEntry = _dlAppService.updateFileEntry(fileEntryId, sourceFileName, contentType, title, description, changeLog, majorVersion, inputStream, size, serviceContext); } return fileEntry; } finally { StreamUtil.cleanUp(inputStream); } }
From source file:com.liferay.wiki.web.internal.portlet.action.EditPageAttachmentsMVCActionCommand.java
License:Open Source License
/** * TODO: Remove. This should extend from EditFileEntryAction once it is * modularized.//from ww w . j ava2s . c om */ protected void handleUploadException(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse, String cmd, Exception e) throws Exception { if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); } else if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException || e instanceof DuplicateFolderNameException || e instanceof FileExtensionException || e instanceof FileMimeTypeException || e instanceof FileNameException || e instanceof FileSizeException || e instanceof LiferayFileItemException || e instanceof NoSuchFolderException || e instanceof SourceFileNameException || e instanceof StorageFieldRequiredException || e instanceof UploadRequestSizeException) { if (!cmd.equals(Constants.ADD_DYNAMIC) && !cmd.equals(Constants.ADD_MULTIPLE) && !cmd.equals(Constants.ADD_TEMP)) { if (e instanceof AntivirusScannerException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { SessionErrors.add(actionRequest, e.getClass()); } return; } else if (cmd.equals(Constants.ADD_TEMP)) { hideDefaultErrorMessage(actionRequest); } if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException || e instanceof FileExtensionException || e instanceof FileNameException || e instanceof FileSizeException || e instanceof UploadRequestSizeException) { HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); response.setContentType(ContentTypes.TEXT_HTML); response.setStatus(HttpServletResponse.SC_OK); String errorMessage = StringPool.BLANK; int errorType = 0; ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (e instanceof AntivirusScannerException) { AntivirusScannerException ase = (AntivirusScannerException) e; errorMessage = themeDisplay.translate(ase.getMessageKey()); errorType = ServletResponseConstants.SC_FILE_ANTIVIRUS_EXCEPTION; } if (e instanceof DuplicateFileEntryException) { errorMessage = themeDisplay.translate("please-enter-a-unique-document-name"); errorType = ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION; } else if (e instanceof FileExtensionException) { errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-extension-x", StringUtil .merge(getAllowedFileExtensions(portletConfig, actionRequest, actionResponse))); errorType = ServletResponseConstants.SC_FILE_EXTENSION_EXCEPTION; } else if (e instanceof FileNameException) { errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-file-name"); errorType = ServletResponseConstants.SC_FILE_NAME_EXCEPTION; } else if (e instanceof FileSizeException) { long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE); if (fileMaxSize == 0) { fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE); } errorMessage = themeDisplay.translate( "please-enter-a-file-with-a-valid-file-size-no-larger" + "-than-x", TextFormatter.formatStorageSize(fileMaxSize, themeDisplay.getLocale())); errorType = ServletResponseConstants.SC_FILE_SIZE_EXCEPTION; } JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("message", errorMessage); jsonObject.put("status", errorType); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } if (e instanceof AntivirusScannerException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { SessionErrors.add(actionRequest, e.getClass()); } } else if (e instanceof DuplicateLockException || e instanceof InvalidFileVersionException || e instanceof NoSuchFileEntryException || e instanceof PrincipalException) { if (e instanceof DuplicateLockException) { DuplicateLockException dle = (DuplicateLockException) e; SessionErrors.add(actionRequest, dle.getClass(), dle.getLock()); } else { SessionErrors.add(actionRequest, e.getClass()); } actionResponse.setRenderParameter("mvcPath", "/html/porltet/document_library/error.jsp"); } else { Throwable cause = e.getCause(); if (cause instanceof DuplicateFileEntryException) { SessionErrors.add(actionRequest, DuplicateFileEntryException.class); } else { throw e; } } }
From source file:org.lsug.quota.web.internal.portlet.action.documentlibrary.QuotaEditFileEntryMVCActionCommand.java
License:Open Source License
protected void handleUploadException(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse, String cmd, Exception e) throws Exception { Throwable errorThrowable = null; if (e instanceof QuotaExceededException) { errorThrowable = e;//from w w w. jav a 2 s . com } else if (e.getCause() instanceof QuotaExceededException) { errorThrowable = e.getCause(); } if (errorThrowable != null) { if (!cmd.equals(Constants.ADD_DYNAMIC)) { SessionErrors.add(actionRequest, errorThrowable.getClass()); return; } HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); response.setContentType(ContentTypes.TEXT_HTML); response.setStatus(HttpServletResponse.SC_OK); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", themeDisplay.getLocale(), getClass()); String errorMessage = ResourceBundleUtil.getString(resourceBundle, "quota-exceeded-error"); int errorType = PortletKeys.SC_QUOTA_EXCEEDED_ERROR_TYPE; JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("message", errorMessage); jsonObject.put("status", errorType); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); SessionErrors.add(actionRequest, errorThrowable.getClass()); } else { throw e; } }
From source file:org.opencps.paymentmgt.portlet.PaymentMgtFrontOfficePortlet.java
License:Open Source License
/** * Upload file// www . ja va2 s .c o m * * @param actionRequest * @param actionResponse * @return * @throws Exception */ protected FileEntry updateFileEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(uploadPortletRequest, Constants.CMD); long repositoryId = themeDisplay.getScopeGroupId(); long folderId = 0; Folder folderFile = initFolderService(actionRequest, themeDisplay); if (Validator.isNotNull(folderFile)) { folderId = folderFile.getFolderId(); } Date now = new Date(); String sourceFileName = now.getTime() + "_" + uploadPortletRequest.getFileName("uploadedFile"); String title = ParamUtil.getString(uploadPortletRequest, "fileName"); String description = ParamUtil.getString(uploadPortletRequest, "description"); String changeLog = ParamUtil.getString(uploadPortletRequest, "changeLog"); System.out.println("----FILE NAME----" + sourceFileName); if (folderId > 0) { Folder folder = DLAppServiceUtil.getFolder(folderId); if (folder.getGroupId() != themeDisplay.getScopeGroupId()) { throw new NoSuchFolderException("{folderId=" + folderId + "}"); } } InputStream inputStream = null; try { String contentType = uploadPortletRequest.getContentType("uploadedFile"); long size = uploadPortletRequest.getSize("uploadedFile"); if ((cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC)) && (size == 0)) { contentType = MimeTypesUtil.getContentType(title); } inputStream = uploadPortletRequest.getFileAsStream("uploadedFile"); ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), uploadPortletRequest); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); FileEntry fileEntry = null; // Add file entry fileEntry = DLAppServiceUtil.addFileEntry(repositoryId, folderId, sourceFileName, contentType, sourceFileName, description, changeLog, inputStream, size, serviceContext); System.out.println("----FILE ENTRY ID----" + fileEntry.getFileEntryId()); AssetPublisherUtil.addAndStoreSelection(actionRequest, DLFileEntry.class.getName(), fileEntry.getFileEntryId(), -1); AssetPublisherUtil.addRecentFolderId(actionRequest, DLFileEntry.class.getName(), folderId); return fileEntry; } catch (Exception e) { e.printStackTrace(); UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(); } else if (uploadException.isExceededSizeLimit()) { throw new FileSizeException(uploadException.getCause()); } } throw e; } finally { StreamUtil.cleanUp(inputStream); } }
From source file:org.opencps.servicemgt.service.impl.TemplateFileLocalServiceImpl.java
License:Open Source License
protected FileEntry updateFileEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(uploadPortletRequest, Constants.CMD); long repositoryId = themeDisplay.getScopeGroupId(); long folderId = 0; Folder folderFile = initFolderService(actionRequest, themeDisplay); if (Validator.isNotNull(folderFile)) { folderId = folderFile.getFolderId(); }/*from w ww . j a va 2s .c o m*/ String sourceFileName = uploadPortletRequest.getFileName("uploadedFile"); String title = ParamUtil.getString(uploadPortletRequest, "fileName"); String description = ParamUtil.getString(uploadPortletRequest, "description"); String changeLog = ParamUtil.getString(uploadPortletRequest, "changeLog"); if (folderId > 0) { Folder folder = DLAppServiceUtil.getFolder(folderId); if (folder.getGroupId() != themeDisplay.getScopeGroupId()) { throw new NoSuchFolderException("{folderId=" + folderId + "}"); } } InputStream inputStream = null; try { String contentType = uploadPortletRequest.getContentType("uploadedFile"); long size = uploadPortletRequest.getSize("uploadedFile"); if ((cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC)) && (size == 0)) { contentType = MimeTypesUtil.getContentType(title); } inputStream = uploadPortletRequest.getFileAsStream("uploadedFile"); ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), uploadPortletRequest); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); FileEntry fileEntry = null; // Add file entry fileEntry = DLAppServiceUtil.addFileEntry(repositoryId, folderId, sourceFileName, contentType, sourceFileName, description, changeLog, inputStream, size, serviceContext); AssetPublisherUtil.addAndStoreSelection(actionRequest, DLFileEntry.class.getName(), fileEntry.getFileEntryId(), -1); AssetPublisherUtil.addRecentFolderId(actionRequest, DLFileEntry.class.getName(), folderId); return fileEntry; } catch (Exception e) { UploadException uploadException = (UploadException) actionRequest .getAttribute(WebKeys.UPLOAD_EXCEPTION); if (uploadException != null) { if (uploadException.isExceededLiferayFileItemSizeLimit()) { throw new LiferayFileItemException(); } else if (uploadException.isExceededSizeLimit()) { throw new FileSizeException(uploadException.getCause()); } } throw e; } finally { StreamUtil.cleanUp(inputStream); } }