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