001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.documentlibrary.service.http;
022:
023: import com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil;
024:
025: import org.json.JSONObject;
026:
027: /**
028: * <a href="DLFileEntryServiceJSON.java.html"><b><i>View Source</i></b></a>
029: *
030: * <p>
031: * ServiceBuilder generated this class. Modifications in this class will be
032: * overwritten the next time is generated.
033: * </p>
034: *
035: * <p>
036: * This class provides a JSON utility for the
037: * <code>com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil</code>
038: * service utility. The static methods of this class calls the same methods of
039: * the service utility. However, the signatures are different because it is
040: * difficult for JSON to support certain types.
041: * </p>
042: *
043: * <p>
044: * ServiceBuilder follows certain rules in translating the methods. For example,
045: * if the method in the service utility returns a <code>java.util.List</code>,
046: * that is translated to a <code>org.json.JSONArray</code>. If the method in the
047: * service utility returns a <code>com.liferay.portlet.documentlibrary.model.DLFileEntry</code>,
048: * that is translated to a <code>org.json.JSONObject</code>. Methods that JSON
049: * cannot safely use are skipped. The logic for the translation is encapsulated
050: * in <code>com.liferay.portlet.documentlibrary.service.http.DLFileEntryJSONSerializer</code>.
051: * </p>
052: *
053: * <p>
054: * This allows you to call the the backend services directly from JavaScript.
055: * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
056: * reference of how that portlet uses the generated JavaScript in
057: * <code>portal-web/docroot/html/js/service.js</code> to call the backend
058: * services directly from JavaScript.
059: * </p>
060: *
061: * <p>
062: * The JSON utility is only generated for remote services.
063: * </p>
064: *
065: * @author Brian Wing Shun Chan
066: *
067: * @see com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil
068: * @see com.liferay.portlet.documentlibrary.service.http.DLFileEntryJSONSerializer
069: *
070: */
071: public class DLFileEntryServiceJSON {
072: public static JSONObject addFileEntry(long folderId,
073: java.lang.String name, java.lang.String title,
074: java.lang.String description,
075: java.lang.String[] tagsEntries,
076: java.lang.String extraSettings, byte[] byteArray,
077: boolean addCommunityPermissions, boolean addGuestPermissions)
078: throws java.rmi.RemoteException,
079: com.liferay.portal.SystemException,
080: com.liferay.portal.PortalException {
081: com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil
082: .addFileEntry(folderId, name, title, description,
083: tagsEntries, extraSettings, byteArray,
084: addCommunityPermissions, addGuestPermissions);
085:
086: return DLFileEntryJSONSerializer.toJSONObject(returnValue);
087: }
088:
089: public static JSONObject addFileEntry(long folderId,
090: java.lang.String name, java.lang.String title,
091: java.lang.String description,
092: java.lang.String[] tagsEntries,
093: java.lang.String extraSettings, byte[] byteArray,
094: java.lang.String[] communityPermissions,
095: java.lang.String[] guestPermissions)
096: throws java.rmi.RemoteException,
097: com.liferay.portal.SystemException,
098: com.liferay.portal.PortalException {
099: com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil
100: .addFileEntry(folderId, name, title, description,
101: tagsEntries, extraSettings, byteArray,
102: communityPermissions, guestPermissions);
103:
104: return DLFileEntryJSONSerializer.toJSONObject(returnValue);
105: }
106:
107: public static void deleteFileEntry(long folderId,
108: java.lang.String name)
109: throws com.liferay.portal.SystemException,
110: com.liferay.portal.PortalException,
111: java.rmi.RemoteException {
112: DLFileEntryServiceUtil.deleteFileEntry(folderId, name);
113: }
114:
115: public static void deleteFileEntry(long folderId,
116: java.lang.String name, double version)
117: throws com.liferay.portal.SystemException,
118: com.liferay.portal.PortalException,
119: java.rmi.RemoteException {
120: DLFileEntryServiceUtil.deleteFileEntry(folderId, name, version);
121: }
122:
123: public static void deleteFileEntryByTitle(long folderId,
124: java.lang.String titleWithExtension)
125: throws com.liferay.portal.SystemException,
126: com.liferay.portal.PortalException,
127: java.rmi.RemoteException {
128: DLFileEntryServiceUtil.deleteFileEntryByTitle(folderId,
129: titleWithExtension);
130: }
131:
132: public static JSONObject getFileEntry(long folderId,
133: java.lang.String name) throws java.rmi.RemoteException,
134: com.liferay.portal.SystemException,
135: com.liferay.portal.PortalException {
136: com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil
137: .getFileEntry(folderId, name);
138:
139: return DLFileEntryJSONSerializer.toJSONObject(returnValue);
140: }
141:
142: public static JSONObject getFileEntryByTitle(long folderId,
143: java.lang.String titleWithExtension)
144: throws java.rmi.RemoteException,
145: com.liferay.portal.SystemException,
146: com.liferay.portal.PortalException {
147: com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil
148: .getFileEntryByTitle(folderId, titleWithExtension);
149:
150: return DLFileEntryJSONSerializer.toJSONObject(returnValue);
151: }
152:
153: public static void lockFileEntry(long folderId,
154: java.lang.String name)
155: throws com.liferay.portal.SystemException,
156: com.liferay.portal.PortalException,
157: java.rmi.RemoteException {
158: DLFileEntryServiceUtil.lockFileEntry(folderId, name);
159: }
160:
161: public static void unlockFileEntry(long folderId,
162: java.lang.String name)
163: throws com.liferay.portal.SystemException,
164: com.liferay.portal.PortalException,
165: java.rmi.RemoteException {
166: DLFileEntryServiceUtil.unlockFileEntry(folderId, name);
167: }
168:
169: public static JSONObject updateFileEntry(long folderId,
170: long newFolderId, java.lang.String name,
171: java.lang.String sourceFileName, java.lang.String title,
172: java.lang.String description,
173: java.lang.String[] tagsEntries,
174: java.lang.String extraSettings, byte[] byteArray)
175: throws com.liferay.portal.SystemException,
176: com.liferay.portal.PortalException,
177: java.rmi.RemoteException {
178: com.liferay.portlet.documentlibrary.model.DLFileEntry returnValue = DLFileEntryServiceUtil
179: .updateFileEntry(folderId, newFolderId, name,
180: sourceFileName, title, description,
181: tagsEntries, extraSettings, byteArray);
182:
183: return DLFileEntryJSONSerializer.toJSONObject(returnValue);
184: }
185: }
|