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.DLFolderServiceUtil;
024:
025: import org.json.JSONObject;
026:
027: /**
028: * <a href="DLFolderServiceJSON.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.DLFolderServiceUtil</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.DLFolder</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.DLFolderJSONSerializer</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.DLFolderServiceUtil
068: * @see com.liferay.portlet.documentlibrary.service.http.DLFolderJSONSerializer
069: *
070: */
071: public class DLFolderServiceJSON {
072: public static JSONObject addFolder(long plid, long parentFolderId,
073: java.lang.String name, java.lang.String description,
074: boolean addCommunityPermissions, boolean addGuestPermissions)
075: throws java.rmi.RemoteException,
076: com.liferay.portal.SystemException,
077: com.liferay.portal.PortalException {
078: com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil
079: .addFolder(plid, parentFolderId, name, description,
080: addCommunityPermissions, addGuestPermissions);
081:
082: return DLFolderJSONSerializer.toJSONObject(returnValue);
083: }
084:
085: public static JSONObject addFolder(long plid, long parentFolderId,
086: java.lang.String name, java.lang.String description,
087: java.lang.String[] communityPermissions,
088: java.lang.String[] guestPermissions)
089: throws java.rmi.RemoteException,
090: com.liferay.portal.SystemException,
091: com.liferay.portal.PortalException {
092: com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil
093: .addFolder(plid, parentFolderId, name, description,
094: communityPermissions, guestPermissions);
095:
096: return DLFolderJSONSerializer.toJSONObject(returnValue);
097: }
098:
099: public static JSONObject copyFolder(long plid, long sourceFolderId,
100: long parentFolderId, java.lang.String name,
101: java.lang.String description,
102: boolean addCommunityPermissions, boolean addGuestPermissions)
103: throws java.rmi.RemoteException,
104: com.liferay.portal.SystemException,
105: com.liferay.portal.PortalException {
106: com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil
107: .copyFolder(plid, sourceFolderId, parentFolderId, name,
108: description, addCommunityPermissions,
109: addGuestPermissions);
110:
111: return DLFolderJSONSerializer.toJSONObject(returnValue);
112: }
113:
114: public static void deleteFolder(long folderId)
115: throws java.rmi.RemoteException,
116: com.liferay.portal.SystemException,
117: com.liferay.portal.PortalException {
118: DLFolderServiceUtil.deleteFolder(folderId);
119: }
120:
121: public static void deleteFolder(long groupId, long parentFolderId,
122: java.lang.String name) throws java.rmi.RemoteException,
123: com.liferay.portal.SystemException,
124: com.liferay.portal.PortalException {
125: DLFolderServiceUtil.deleteFolder(groupId, parentFolderId, name);
126: }
127:
128: public static JSONObject getFolder(long folderId)
129: throws java.rmi.RemoteException,
130: com.liferay.portal.SystemException,
131: com.liferay.portal.PortalException {
132: com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil
133: .getFolder(folderId);
134:
135: return DLFolderJSONSerializer.toJSONObject(returnValue);
136: }
137:
138: public static JSONObject getFolder(long groupId,
139: long parentFolderId, java.lang.String name)
140: throws java.rmi.RemoteException,
141: com.liferay.portal.SystemException,
142: com.liferay.portal.PortalException {
143: com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil
144: .getFolder(groupId, parentFolderId, name);
145:
146: return DLFolderJSONSerializer.toJSONObject(returnValue);
147: }
148:
149: public static long getFolderId(long groupId, long parentFolderId,
150: java.lang.String name) throws java.rmi.RemoteException,
151: com.liferay.portal.SystemException,
152: com.liferay.portal.PortalException {
153: long returnValue = DLFolderServiceUtil.getFolderId(groupId,
154: parentFolderId, name);
155:
156: return returnValue;
157: }
158:
159: public static void reIndexSearch(long companyId)
160: throws java.rmi.RemoteException,
161: com.liferay.portal.SystemException,
162: com.liferay.portal.PortalException {
163: DLFolderServiceUtil.reIndexSearch(companyId);
164: }
165:
166: public static JSONObject updateFolder(long folderId,
167: long parentFolderId, java.lang.String name,
168: java.lang.String description)
169: throws java.rmi.RemoteException,
170: com.liferay.portal.SystemException,
171: com.liferay.portal.PortalException {
172: com.liferay.portlet.documentlibrary.model.DLFolder returnValue = DLFolderServiceUtil
173: .updateFolder(folderId, parentFolderId, name,
174: description);
175:
176: return DLFolderJSONSerializer.toJSONObject(returnValue);
177: }
178: }
|