001    /**
002     * Copyright (c) 2000-2010 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.model.Group;
019    import com.liferay.portal.model.Lock;
020    import com.liferay.portal.service.GroupLocalServiceUtil;
021    import com.liferay.portal.service.LayoutLocalServiceUtil;
022    
023    import javax.servlet.http.HttpServletResponse;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public abstract class BaseWebDAVStorageImpl implements WebDAVStorage {
029    
030            /**
031             * @throws WebDAVException
032             */
033            public int copyCollectionResource(
034                            WebDAVRequest webDavRequest, Resource resource, String destination,
035                            boolean overwrite, long depth)
036                    throws WebDAVException {
037    
038                    return HttpServletResponse.SC_FORBIDDEN;
039            }
040    
041            /**
042             * @throws WebDAVException
043             */
044            public int copySimpleResource(
045                            WebDAVRequest webDavRequest, Resource resource, String destination,
046                            boolean overwrite)
047                    throws WebDAVException {
048    
049                    return HttpServletResponse.SC_FORBIDDEN;
050            }
051    
052            /**
053             * @throws WebDAVException
054             */
055            public int deleteResource(WebDAVRequest webDavRequest)
056                    throws WebDAVException {
057    
058                    return HttpServletResponse.SC_FORBIDDEN;
059            }
060    
061            public String getRootPath() {
062                    return _rootPath;
063            }
064    
065            public String getToken() {
066                    return _token;
067            }
068    
069            public boolean isAvailable(WebDAVRequest webDavRequest)
070                    throws WebDAVException {
071    
072                    if (getResource(webDavRequest) == null) {
073                            return false;
074                    }
075                    else {
076                            return true;
077                    }
078            }
079    
080            public boolean isSupportsClassTwo() {
081                    return false;
082            }
083    
084            /**
085             * @throws WebDAVException
086             */
087            public Status lockResource(
088                            WebDAVRequest webDavRequest, String owner, long timeout)
089                    throws WebDAVException {
090    
091                    return null;
092            }
093    
094            /**
095             * @throws WebDAVException
096             */
097            public Status makeCollection(WebDAVRequest webDavRequest)
098                    throws WebDAVException {
099    
100                    return new Status(HttpServletResponse.SC_FORBIDDEN);
101            }
102    
103            /**
104             * @throws WebDAVException
105             */
106            public int moveCollectionResource(
107                            WebDAVRequest webDavRequest, Resource resource, String destination,
108                            boolean overwrite)
109                    throws WebDAVException {
110    
111                    return HttpServletResponse.SC_FORBIDDEN;
112            }
113    
114            /**
115             * @throws WebDAVException
116             */
117            public int moveSimpleResource(
118                            WebDAVRequest webDavRequest, Resource resource, String destination,
119                            boolean overwrite)
120                    throws WebDAVException {
121    
122                    return HttpServletResponse.SC_FORBIDDEN;
123            }
124    
125            /**
126             * @throws WebDAVException
127             */
128            public int putResource(WebDAVRequest webDavRequest) throws WebDAVException {
129                    return HttpServletResponse.SC_FORBIDDEN;
130            }
131    
132            /**
133             * @throws WebDAVException
134             */
135            public Lock refreshResourceLock(
136                            WebDAVRequest webDavRequest, String uuid, long timeout)
137                    throws WebDAVException {
138    
139                    return null;
140            }
141    
142            public void setRootPath(String rootPath) {
143                    _rootPath = rootPath;
144            }
145    
146            public void setToken(String token) {
147                    _token = token;
148            }
149    
150            /**
151             * @throws WebDAVException
152             */
153            public boolean unlockResource(WebDAVRequest webDavRequest, String token)
154                    throws WebDAVException {
155    
156                    return false;
157            }
158    
159            protected long getPlid(long groupId) throws SystemException {
160                    return LayoutLocalServiceUtil.getDefaultPlid(groupId);
161            }
162    
163            protected boolean isAddCommunityPermissions(long groupId) throws Exception {
164                    Group group = GroupLocalServiceUtil.getGroup(groupId);
165    
166                    if (!group.isUser()) {
167                            return true;
168                    }
169                    else {
170                            return false;
171                    }
172            }
173    
174            private String _rootPath;
175            private String _token;
176    
177    }