List of usage examples for com.liferay.portal.kernel.util Constants ADD_WEBDAV
String ADD_WEBDAV
To view the source code for com.liferay.portal.kernel.util Constants ADD_WEBDAV.
Click Source Link
From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public int putResource(WebDAVRequest webDAVRequest) throws WebDAVException { File file = null;//from w ww. j a v a 2 s. c o m try { HttpServletRequest request = webDAVRequest.getHttpServletRequest(); String[] pathArray = webDAVRequest.getPathArray(); long companyId = webDAVRequest.getCompanyId(); long groupId = webDAVRequest.getGroupId(); long parentFolderId = getParentFolderId(companyId, pathArray); String title = getTitle(pathArray); String description = StringPool.BLANK; String changeLog = StringPool.BLANK; ServiceContext serviceContext = ServiceContextFactory.getInstance(request); serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId)); serviceContext.setAddGuestPermissions(true); String extension = FileUtil.getExtension(title); file = FileUtil.createTempFile(extension); FileUtil.write(file, request.getInputStream()); String contentType = getContentType(request, file, title, extension); try { FileEntry fileEntry = _dlAppService.getFileEntry(groupId, parentFolderId, title); if (!hasLock(fileEntry, webDAVRequest.getLockUuid()) && (fileEntry.getLock() != null)) { return WebDAVUtil.SC_LOCKED; } long fileEntryId = fileEntry.getFileEntryId(); description = fileEntry.getDescription(); populateServiceContext(serviceContext, fileEntry); serviceContext.setCommand(Constants.UPDATE_WEBDAV); _dlAppService.updateFileEntry(fileEntryId, title, contentType, title, description, changeLog, false, file, serviceContext); } catch (NoSuchFileEntryException nsfee) { if (_log.isDebugEnabled()) { _log.debug(nsfee, nsfee); } serviceContext.setCommand(Constants.ADD_WEBDAV); _dlAppService.addFileEntry(groupId, parentFolderId, title, contentType, title, description, changeLog, file, serviceContext); } if (_log.isInfoEnabled()) { _log.info("Added " + StringUtil.merge(pathArray, StringPool.SLASH)); } return HttpServletResponse.SC_CREATED; } catch (FileSizeException fse) { if (_log.isDebugEnabled()) { _log.debug(fse, fse); } return HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE; } catch (NoSuchFolderException nsfe) { if (_log.isDebugEnabled()) { _log.debug(nsfe, nsfe); } return HttpServletResponse.SC_CONFLICT; } catch (PrincipalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return HttpServletResponse.SC_FORBIDDEN; } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn(pe, pe); } return HttpServletResponse.SC_CONFLICT; } catch (Exception e) { throw new WebDAVException(e); } finally { FileUtil.delete(file); } }
From source file:com.liferay.portlet.documentlibrary.util.DLImpl.java
License:Open Source License
protected String getEntryURL(DLFileVersion dlFileVersion, ServiceContext serviceContext) throws PortalException { if (Validator.equals(serviceContext.getCommand(), Constants.ADD_WEBDAV) || Validator.equals(serviceContext.getCommand(), Constants.UPDATE_WEBDAV)) { return serviceContext.getPortalURL() + serviceContext.getCurrentURL(); }/*w w w. jav a2 s . c o m*/ String entryURL = GetterUtil.getString(serviceContext.getAttribute("entryURL")); if (Validator.isNotNull(entryURL)) { return entryURL; } HttpServletRequest request = serviceContext.getRequest(); if ((request == null) || (serviceContext.getThemeDisplay() == null)) { return StringPool.BLANK; } long plid = serviceContext.getPlid(); long controlPanelPlid = PortalUtil.getControlPanelPlid(serviceContext.getCompanyId()); if (plid == controlPanelPlid) { plid = PortalUtil.getPlidFromPortletId(dlFileVersion.getGroupId(), PortletKeys.DOCUMENT_LIBRARY); } if (plid == LayoutConstants.DEFAULT_PLID) { plid = controlPanelPlid; } PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.DOCUMENT_LIBRARY, plid, PortletRequest.RENDER_PHASE); portletURL.setParameter("struts_action", "/document_library/view_file_entry"); portletURL.setParameter("fileEntryId", String.valueOf(dlFileVersion.getFileEntryId())); return portletURL.toString(); }