1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.webdav;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.model.Group;
27  import com.liferay.portal.model.Lock;
28  import com.liferay.portal.service.GroupLocalServiceUtil;
29  import com.liferay.portal.service.LayoutLocalServiceUtil;
30  
31  import javax.servlet.http.HttpServletResponse;
32  
33  /**
34   * <a href="BaseWebDAVStorageImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   */
38  public abstract class BaseWebDAVStorageImpl implements WebDAVStorage {
39  
40      @SuppressWarnings("unused")
41      public int copyCollectionResource(
42              WebDAVRequest webDavRequest, Resource resource, String destination,
43              boolean overwrite, long depth)
44          throws WebDAVException {
45  
46          return HttpServletResponse.SC_FORBIDDEN;
47      }
48  
49      @SuppressWarnings("unused")
50      public int copySimpleResource(
51              WebDAVRequest webDavRequest, Resource resource, String destination,
52              boolean overwrite)
53          throws WebDAVException {
54  
55          return HttpServletResponse.SC_FORBIDDEN;
56      }
57  
58      @SuppressWarnings("unused")
59      public int deleteResource(WebDAVRequest webDavRequest)
60          throws WebDAVException {
61  
62          return HttpServletResponse.SC_FORBIDDEN;
63      }
64  
65      public String getRootPath() {
66          return _rootPath;
67      }
68  
69      public String getToken() {
70          return _token;
71      }
72  
73      public boolean isAvailable(WebDAVRequest webDavRequest)
74          throws WebDAVException {
75  
76          if (getResource(webDavRequest) == null) {
77              return false;
78          }
79          else {
80              return true;
81          }
82      }
83  
84      public boolean isSupportsClassTwo() {
85          return false;
86      }
87  
88      @SuppressWarnings("unused")
89      public Status lockResource(
90              WebDAVRequest webDavRequest, String owner, long timeout)
91          throws WebDAVException {
92  
93          return null;
94      }
95  
96      @SuppressWarnings("unused")
97      public Status makeCollection(WebDAVRequest webDavRequest)
98          throws WebDAVException {
99  
100         return new Status(HttpServletResponse.SC_FORBIDDEN);
101     }
102 
103     @SuppressWarnings("unused")
104     public int moveCollectionResource(
105             WebDAVRequest webDavRequest, Resource resource, String destination,
106             boolean overwrite)
107         throws WebDAVException {
108 
109         return HttpServletResponse.SC_FORBIDDEN;
110     }
111 
112     @SuppressWarnings("unused")
113     public int moveSimpleResource(
114             WebDAVRequest webDavRequest, Resource resource, String destination,
115             boolean overwrite)
116         throws WebDAVException {
117 
118         return HttpServletResponse.SC_FORBIDDEN;
119     }
120 
121     @SuppressWarnings("unused")
122     public int putResource(WebDAVRequest webDavRequest) throws WebDAVException {
123         return HttpServletResponse.SC_FORBIDDEN;
124     }
125 
126     @SuppressWarnings("unused")
127     public Lock refreshResourceLock(
128             WebDAVRequest webDavRequest, String uuid, long timeout)
129         throws WebDAVException {
130 
131         return null;
132     }
133 
134     public void setRootPath(String rootPath) {
135         _rootPath = rootPath;
136     }
137 
138     public void setToken(String token) {
139         _token = token;
140     }
141 
142     @SuppressWarnings("unused")
143     public boolean unlockResource(WebDAVRequest webDavRequest, String token)
144         throws WebDAVException {
145 
146         return false;
147     }
148 
149     protected long getPlid(long groupId) throws SystemException {
150         return LayoutLocalServiceUtil.getDefaultPlid(groupId);
151     }
152 
153     protected boolean isAddCommunityPermissions(long groupId) throws Exception {
154         Group group = GroupLocalServiceUtil.getGroup(groupId);
155 
156         if (!group.isUser()) {
157             return true;
158         }
159         else {
160             return false;
161         }
162     }
163 
164     private String _rootPath;
165     private String _token;
166 
167 }