001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.webdav;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portal.kernel.webdav.methods.MethodFactory;
019    import com.liferay.portal.kernel.webdav.methods.MethodFactoryRegistryUtil;
020    import com.liferay.portal.model.Group;
021    import com.liferay.portal.model.Lock;
022    import com.liferay.portal.service.GroupLocalServiceUtil;
023    import com.liferay.portal.service.LayoutLocalServiceUtil;
024    
025    import javax.servlet.http.HttpServletResponse;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     * @author Fabio Pezzutto
030     */
031    public abstract class BaseWebDAVStorageImpl implements WebDAVStorage {
032    
033            @Override
034            @SuppressWarnings("unused")
035            public int copyCollectionResource(
036                            WebDAVRequest webDAVRequest, Resource resource, String destination,
037                            boolean overwrite, long depth)
038                    throws WebDAVException {
039    
040                    return HttpServletResponse.SC_FORBIDDEN;
041            }
042    
043            @Override
044            @SuppressWarnings("unused")
045            public int copySimpleResource(
046                            WebDAVRequest webDAVRequest, Resource resource, String destination,
047                            boolean overwrite)
048                    throws WebDAVException {
049    
050                    return HttpServletResponse.SC_FORBIDDEN;
051            }
052    
053            @Override
054            @SuppressWarnings("unused")
055            public int deleteResource(WebDAVRequest webDAVRequest)
056                    throws WebDAVException {
057    
058                    return HttpServletResponse.SC_FORBIDDEN;
059            }
060    
061            @Override
062            public MethodFactory getMethodFactory() {
063                    return MethodFactoryRegistryUtil.getDefaultMethodFactory();
064            }
065    
066            @Override
067            public String getRootPath() {
068                    return _rootPath;
069            }
070    
071            @Override
072            public String getToken() {
073                    return _token;
074            }
075    
076            @Override
077            public boolean isAvailable(WebDAVRequest webDAVRequest)
078                    throws WebDAVException {
079    
080                    if (getResource(webDAVRequest) == null) {
081                            return false;
082                    }
083                    else {
084                            return true;
085                    }
086            }
087    
088            @Override
089            public boolean isSupportsClassTwo() {
090                    return false;
091            }
092    
093            @Override
094            @SuppressWarnings("unused")
095            public Status lockResource(
096                            WebDAVRequest webDAVRequest, String owner, long timeout)
097                    throws WebDAVException {
098    
099                    return null;
100            }
101    
102            @Override
103            @SuppressWarnings("unused")
104            public Status makeCollection(WebDAVRequest webDAVRequest)
105                    throws WebDAVException {
106    
107                    return new Status(HttpServletResponse.SC_FORBIDDEN);
108            }
109    
110            @Override
111            @SuppressWarnings("unused")
112            public int moveCollectionResource(
113                            WebDAVRequest webDAVRequest, Resource resource, String destination,
114                            boolean overwrite)
115                    throws WebDAVException {
116    
117                    return HttpServletResponse.SC_FORBIDDEN;
118            }
119    
120            @Override
121            @SuppressWarnings("unused")
122            public int moveSimpleResource(
123                            WebDAVRequest webDAVRequest, Resource resource, String destination,
124                            boolean overwrite)
125                    throws WebDAVException {
126    
127                    return HttpServletResponse.SC_FORBIDDEN;
128            }
129    
130            @Override
131            @SuppressWarnings("unused")
132            public int putResource(WebDAVRequest webDAVRequest) throws WebDAVException {
133                    return HttpServletResponse.SC_FORBIDDEN;
134            }
135    
136            @Override
137            @SuppressWarnings("unused")
138            public Lock refreshResourceLock(
139                            WebDAVRequest webDAVRequest, String uuid, long timeout)
140                    throws WebDAVException {
141    
142                    return null;
143            }
144    
145            @Override
146            public void setRootPath(String rootPath) {
147                    _rootPath = rootPath;
148            }
149    
150            @Override
151            public void setToken(String token) {
152                    _token = token;
153            }
154    
155            @Override
156            @SuppressWarnings("unused")
157            public boolean unlockResource(WebDAVRequest webDAVRequest, String token)
158                    throws WebDAVException {
159    
160                    return false;
161            }
162    
163            protected long getPlid(long groupId) throws SystemException {
164                    return LayoutLocalServiceUtil.getDefaultPlid(groupId);
165            }
166    
167            protected boolean isAddGroupPermissions(long groupId) throws Exception {
168                    Group group = GroupLocalServiceUtil.getGroup(groupId);
169    
170                    if (!group.isUser()) {
171                            return true;
172                    }
173                    else {
174                            return false;
175                    }
176            }
177    
178            private String _rootPath;
179            private String _token;
180    
181    }