Example usage for com.liferay.portal.kernel.webdav Status Status

List of usage examples for com.liferay.portal.kernel.webdav Status Status

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.webdav Status Status.

Prototype

public Status(int code) 

Source Link

Usage

From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java

License:Open Source License

@Override
public Status makeCollection(WebDAVRequest webDAVRequest) throws WebDAVException {

    try {//from  w  w w  .j  av  a  2  s  .  c o  m
        HttpServletRequest request = webDAVRequest.getHttpServletRequest();

        if (request.getContentLength() > 0) {
            return new Status(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
        }

        String[] pathArray = webDAVRequest.getPathArray();

        long companyId = webDAVRequest.getCompanyId();
        long groupId = webDAVRequest.getGroupId();
        long parentFolderId = getParentFolderId(companyId, pathArray);
        String name = WebDAVUtil.getResourceName(pathArray);
        String description = StringPool.BLANK;

        ServiceContext serviceContext = new ServiceContext();

        serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId));
        serviceContext.setAddGuestPermissions(true);

        _dlAppService.addFolder(groupId, parentFolderId, name, description, serviceContext);

        String location = StringUtil.merge(pathArray, StringPool.SLASH);

        return new Status(location, HttpServletResponse.SC_CREATED);
    } catch (DuplicateFolderNameException dfne) {
        if (_log.isDebugEnabled()) {
            _log.debug(dfne, dfne);
        }

        return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    } catch (DuplicateFileEntryException dfee) {
        if (_log.isDebugEnabled()) {
            _log.debug(dfee, dfee);
        }

        return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    } catch (NoSuchFolderException nsfe) {
        if (_log.isDebugEnabled()) {
            _log.debug(nsfe, nsfe);
        }

        return new Status(HttpServletResponse.SC_CONFLICT);
    } catch (PrincipalException pe) {
        if (_log.isDebugEnabled()) {
            _log.debug(pe, pe);
        }

        return new Status(HttpServletResponse.SC_FORBIDDEN);
    } catch (Exception e) {
        throw new WebDAVException(e);
    }
}

From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java

License:Open Source License

@Override
public Status makeCollection(WebDAVRequest webDavRequest) throws WebDAVException {

    try {//from w  w  w  . j  a  v a  2  s .  c o m
        HttpServletRequest request = webDavRequest.getHttpServletRequest();

        if (request.getContentLength() > 0) {
            return new Status(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
        }

        String[] pathArray = webDavRequest.getPathArray();

        long companyId = webDavRequest.getCompanyId();
        long groupId = webDavRequest.getGroupId();
        long parentFolderId = getParentFolderId(companyId, pathArray);
        String name = WebDAVUtil.getResourceName(pathArray);
        String description = StringPool.BLANK;

        ServiceContext serviceContext = new ServiceContext();

        serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId));
        serviceContext.setAddGuestPermissions(true);

        DLAppServiceUtil.addFolder(groupId, parentFolderId, name, description, serviceContext);

        String location = StringUtil.merge(pathArray, StringPool.SLASH);

        return new Status(location, HttpServletResponse.SC_CREATED);
    } catch (DuplicateFolderNameException dfne) {
        return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    } catch (DuplicateFileException dfe) {
        return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    } catch (NoSuchFolderException nsfe) {
        return new Status(HttpServletResponse.SC_CONFLICT);
    } catch (PrincipalException pe) {
        return new Status(HttpServletResponse.SC_FORBIDDEN);
    } catch (Exception e) {
        throw new WebDAVException(e);
    }
}