1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.webdav;
16  
17  import com.liferay.portal.kernel.exception.SystemException;
18  import com.liferay.portal.model.Group;
19  import com.liferay.portal.model.Lock;
20  import com.liferay.portal.service.GroupLocalServiceUtil;
21  import com.liferay.portal.service.LayoutLocalServiceUtil;
22  
23  import javax.servlet.http.HttpServletResponse;
24  
25  /**
26   * <a href="BaseWebDAVStorageImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public abstract class BaseWebDAVStorageImpl implements WebDAVStorage {
31  
32      @SuppressWarnings("unused")
33      public int copyCollectionResource(
34              WebDAVRequest webDavRequest, Resource resource, String destination,
35              boolean overwrite, long depth)
36          throws WebDAVException {
37  
38          return HttpServletResponse.SC_FORBIDDEN;
39      }
40  
41      @SuppressWarnings("unused")
42      public int copySimpleResource(
43              WebDAVRequest webDavRequest, Resource resource, String destination,
44              boolean overwrite)
45          throws WebDAVException {
46  
47          return HttpServletResponse.SC_FORBIDDEN;
48      }
49  
50      @SuppressWarnings("unused")
51      public int deleteResource(WebDAVRequest webDavRequest)
52          throws WebDAVException {
53  
54          return HttpServletResponse.SC_FORBIDDEN;
55      }
56  
57      public String getRootPath() {
58          return _rootPath;
59      }
60  
61      public String getToken() {
62          return _token;
63      }
64  
65      public boolean isAvailable(WebDAVRequest webDavRequest)
66          throws WebDAVException {
67  
68          if (getResource(webDavRequest) == null) {
69              return false;
70          }
71          else {
72              return true;
73          }
74      }
75  
76      public boolean isSupportsClassTwo() {
77          return false;
78      }
79  
80      @SuppressWarnings("unused")
81      public Status lockResource(
82              WebDAVRequest webDavRequest, String owner, long timeout)
83          throws WebDAVException {
84  
85          return null;
86      }
87  
88      @SuppressWarnings("unused")
89      public Status makeCollection(WebDAVRequest webDavRequest)
90          throws WebDAVException {
91  
92          return new Status(HttpServletResponse.SC_FORBIDDEN);
93      }
94  
95      @SuppressWarnings("unused")
96      public int moveCollectionResource(
97              WebDAVRequest webDavRequest, Resource resource, String destination,
98              boolean overwrite)
99          throws WebDAVException {
100 
101         return HttpServletResponse.SC_FORBIDDEN;
102     }
103 
104     @SuppressWarnings("unused")
105     public int moveSimpleResource(
106             WebDAVRequest webDavRequest, Resource resource, String destination,
107             boolean overwrite)
108         throws WebDAVException {
109 
110         return HttpServletResponse.SC_FORBIDDEN;
111     }
112 
113     @SuppressWarnings("unused")
114     public int putResource(WebDAVRequest webDavRequest) throws WebDAVException {
115         return HttpServletResponse.SC_FORBIDDEN;
116     }
117 
118     @SuppressWarnings("unused")
119     public Lock refreshResourceLock(
120             WebDAVRequest webDavRequest, String uuid, long timeout)
121         throws WebDAVException {
122 
123         return null;
124     }
125 
126     public void setRootPath(String rootPath) {
127         _rootPath = rootPath;
128     }
129 
130     public void setToken(String token) {
131         _token = token;
132     }
133 
134     @SuppressWarnings("unused")
135     public boolean unlockResource(WebDAVRequest webDavRequest, String token)
136         throws WebDAVException {
137 
138         return false;
139     }
140 
141     protected long getPlid(long groupId) throws SystemException {
142         return LayoutLocalServiceUtil.getDefaultPlid(groupId);
143     }
144 
145     protected boolean isAddCommunityPermissions(long groupId) throws Exception {
146         Group group = GroupLocalServiceUtil.getGroup(groupId);
147 
148         if (!group.isUser()) {
149             return true;
150         }
151         else {
152             return false;
153         }
154     }
155 
156     private String _rootPath;
157     private String _token;
158 
159 }