1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.documentlibrary.service.http;
21  
22  import com.liferay.portal.kernel.json.JSONArray;
23  import com.liferay.portal.kernel.json.JSONObject;
24  
25  import com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil;
26  
27  /**
28   * <a href="DLFileEntryServiceJSON.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class provides a JSON utility for the
37   * <code>com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil</code>
38   * service utility. The static methods of this class calls the same methods of
39   * the service utility. However, the signatures are different because it is
40   * difficult for JSON to support certain types.
41   * </p>
42   *
43   * <p>
44   * ServiceBuilder follows certain rules in translating the methods. For example,
45   * if the method in the service utility returns a <code>java.util.List</code>,
46   * that is translated to a
47   * <code>com.liferay.portal.kernel.json.JSONArray</code>. If the method in the
48   * service utility returns a <code>com.liferay.portlet.documentlibrary.model.DLFileEntry</code>,
49   * that is translated to a
50   * <code>com.liferay.portal.kernel.json.JSONObject</code>. Methods that JSON
51   * cannot safely use are skipped. The logic for the translation is encapsulated
52   * in <code>com.liferay.portlet.documentlibrary.service.http.DLFileEntryJSONSerializer</code>.
53   * </p>
54   *
55   * <p>
56   * This allows you to call the the backend services directly from JavaScript.
57   * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
58   * reference of how that portlet uses the generated JavaScript in
59   * <code>portal-web/docroot/html/js/service.js</code> to call the backend
60   * services directly from JavaScript.
61   * </p>
62   *
63   * <p>
64   * The JSON utility is only generated for remote services.
65   * </p>
66   *
67   * @author Brian Wing Shun Chan
68   *
69   * @see com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil
70   * @see com.liferay.portlet.documentlibrary.service.http.DLFileEntryJSONSerializer
71   *
72   */
73  public class DLFileEntryServiceJSON {
74      public static JSONObject addFileEntry(long folderId, java.lang.String name,
75          java.lang.String title, java.lang.String description,
76          java.lang.String[] tagsEntries, java.lang.String extraSettings,
77          byte[] bytes, boolean addCommunityPermissions,
78          boolean addGuestPermissions)
79          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
80              com.liferay.portal.SystemException {
81          com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil.addFileEntry(folderId,
82                  name, title, description, tagsEntries, extraSettings, bytes,
83                  addCommunityPermissions, addGuestPermissions);
84  
85          return DLFileEntryJSONSerializer.toJSONObject(returnValue);
86      }
87  
88      public static JSONObject addFileEntry(long folderId, java.lang.String name,
89          java.lang.String title, java.lang.String description,
90          java.lang.String[] tagsEntries, java.lang.String extraSettings,
91          byte[] bytes, java.lang.String[] communityPermissions,
92          java.lang.String[] guestPermissions)
93          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
94              com.liferay.portal.SystemException {
95          com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil.addFileEntry(folderId,
96                  name, title, description, tagsEntries, extraSettings, bytes,
97                  communityPermissions, guestPermissions);
98  
99          return DLFileEntryJSONSerializer.toJSONObject(returnValue);
100     }
101 
102     public static void deleteFileEntry(long folderId, java.lang.String name)
103         throws com.liferay.portal.PortalException,
104             com.liferay.portal.SystemException, java.rmi.RemoteException {
105         DLFileEntryServiceUtil.deleteFileEntry(folderId, name);
106     }
107 
108     public static void deleteFileEntry(long folderId, java.lang.String name,
109         double version)
110         throws com.liferay.portal.PortalException,
111             com.liferay.portal.SystemException, java.rmi.RemoteException {
112         DLFileEntryServiceUtil.deleteFileEntry(folderId, name, version);
113     }
114 
115     public static void deleteFileEntryByTitle(long folderId,
116         java.lang.String titleWithExtension)
117         throws com.liferay.portal.PortalException,
118             com.liferay.portal.SystemException, java.rmi.RemoteException {
119         DLFileEntryServiceUtil.deleteFileEntryByTitle(folderId,
120             titleWithExtension);
121     }
122 
123     public static JSONArray getFileEntries(long folderId)
124         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
125             com.liferay.portal.SystemException {
126         java.util.List<com.liferay.portlet.documentlibrary.model.DLFileEntry> returnValue =
127             DLFileEntryServiceUtil.getFileEntries(folderId);
128 
129         return DLFileEntryJSONSerializer.toJSONArray(returnValue);
130     }
131 
132     public static JSONObject getFileEntry(long folderId, java.lang.String name)
133         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
134             com.liferay.portal.SystemException {
135         com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil.getFileEntry(folderId,
136                 name);
137 
138         return DLFileEntryJSONSerializer.toJSONObject(returnValue);
139     }
140 
141     public static JSONObject getFileEntryByTitle(long folderId,
142         java.lang.String titleWithExtension)
143         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
144             com.liferay.portal.SystemException {
145         com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil.getFileEntryByTitle(folderId,
146                 titleWithExtension);
147 
148         return DLFileEntryJSONSerializer.toJSONObject(returnValue);
149     }
150 
151     public static com.liferay.lock.model.Lock getFileEntryLock(long folderId,
152         java.lang.String name)
153         throws com.liferay.portal.PortalException, java.rmi.RemoteException {
154         com.liferay.lock.model.Lock returnValue = DLFileEntryServiceUtil.getFileEntryLock(folderId,
155                 name);
156 
157         return returnValue;
158     }
159 
160     public static com.liferay.lock.model.Lock lockFileEntry(long folderId,
161         java.lang.String name)
162         throws com.liferay.portal.PortalException,
163             com.liferay.portal.SystemException, java.rmi.RemoteException {
164         com.liferay.lock.model.Lock returnValue = DLFileEntryServiceUtil.lockFileEntry(folderId,
165                 name);
166 
167         return returnValue;
168     }
169 
170     public static com.liferay.lock.model.Lock lockFileEntry(long folderId,
171         java.lang.String name, java.lang.String owner, long expirationTime)
172         throws com.liferay.portal.PortalException,
173             com.liferay.portal.SystemException, java.rmi.RemoteException {
174         com.liferay.lock.model.Lock returnValue = DLFileEntryServiceUtil.lockFileEntry(folderId,
175                 name, owner, expirationTime);
176 
177         return returnValue;
178     }
179 
180     public static com.liferay.lock.model.Lock refreshFileEntryLock(
181         java.lang.String lockUuid, long expirationTime)
182         throws com.liferay.portal.PortalException, java.rmi.RemoteException {
183         com.liferay.lock.model.Lock returnValue = DLFileEntryServiceUtil.refreshFileEntryLock(lockUuid,
184                 expirationTime);
185 
186         return returnValue;
187     }
188 
189     public static void unlockFileEntry(long folderId, java.lang.String name)
190         throws java.rmi.RemoteException {
191         DLFileEntryServiceUtil.unlockFileEntry(folderId, name);
192     }
193 
194     public static void unlockFileEntry(long folderId, java.lang.String name,
195         java.lang.String lockUuid)
196         throws com.liferay.portal.PortalException, java.rmi.RemoteException {
197         DLFileEntryServiceUtil.unlockFileEntry(folderId, name, lockUuid);
198     }
199 
200     public static JSONObject updateFileEntry(long folderId, long newFolderId,
201         java.lang.String name, java.lang.String sourceFileName,
202         java.lang.String title, java.lang.String description,
203         java.lang.String[] tagsEntries, java.lang.String extraSettings,
204         byte[] bytes)
205         throws com.liferay.portal.PortalException,
206             com.liferay.portal.SystemException, java.rmi.RemoteException {
207         com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil.updateFileEntry(folderId,
208                 newFolderId, name, sourceFileName, title, description,
209                 tagsEntries, extraSettings, bytes);
210 
211         return DLFileEntryJSONSerializer.toJSONObject(returnValue);
212     }
213 }