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.portal.service.http;
022:
023: import com.liferay.portal.service.OrganizationServiceUtil;
024:
025: import org.json.JSONArray;
026: import org.json.JSONObject;
027:
028: /**
029: * <a href="OrganizationServiceJSON.java.html"><b><i>View Source</i></b></a>
030: *
031: * <p>
032: * ServiceBuilder generated this class. Modifications in this class will be
033: * overwritten the next time is generated.
034: * </p>
035: *
036: * <p>
037: * This class provides a JSON utility for the
038: * <code>com.liferay.portal.service.OrganizationServiceUtil</code>
039: * service utility. The static methods of this class calls the same methods of
040: * the service utility. However, the signatures are different because it is
041: * difficult for JSON to support certain types.
042: * </p>
043: *
044: * <p>
045: * ServiceBuilder follows certain rules in translating the methods. For example,
046: * if the method in the service utility returns a <code>java.util.List</code>,
047: * that is translated to a <code>org.json.JSONArray</code>. If the method in the
048: * service utility returns a <code>com.liferay.portal.model.Organization</code>,
049: * that is translated to a <code>org.json.JSONObject</code>. Methods that JSON
050: * cannot safely use are skipped. The logic for the translation is encapsulated
051: * in <code>com.liferay.portal.service.http.OrganizationJSONSerializer</code>.
052: * </p>
053: *
054: * <p>
055: * This allows you to call the the backend services directly from JavaScript.
056: * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
057: * reference of how that portlet uses the generated JavaScript in
058: * <code>portal-web/docroot/html/js/service.js</code> to call the backend
059: * services directly from JavaScript.
060: * </p>
061: *
062: * <p>
063: * The JSON utility is only generated for remote services.
064: * </p>
065: *
066: * @author Brian Wing Shun Chan
067: *
068: * @see com.liferay.portal.service.OrganizationServiceUtil
069: * @see com.liferay.portal.service.http.OrganizationJSONSerializer
070: *
071: */
072: public class OrganizationServiceJSON {
073: public static void addGroupOrganizations(long groupId,
074: long[] organizationIds) throws java.rmi.RemoteException,
075: com.liferay.portal.SystemException,
076: com.liferay.portal.PortalException {
077: OrganizationServiceUtil.addGroupOrganizations(groupId,
078: organizationIds);
079: }
080:
081: public static void addPasswordPolicyOrganizations(
082: long passwordPolicyId, long[] organizationIds)
083: throws java.rmi.RemoteException,
084: com.liferay.portal.SystemException,
085: com.liferay.portal.PortalException {
086: OrganizationServiceUtil.addPasswordPolicyOrganizations(
087: passwordPolicyId, organizationIds);
088: }
089:
090: public static JSONObject addOrganization(long parentOrganizationId,
091: java.lang.String name, int type, boolean recursable,
092: long regionId, long countryId, int statusId,
093: java.lang.String comments) throws java.rmi.RemoteException,
094: com.liferay.portal.SystemException,
095: com.liferay.portal.PortalException {
096: com.liferay.portal.model.Organization returnValue = OrganizationServiceUtil
097: .addOrganization(parentOrganizationId, name, type,
098: recursable, regionId, countryId, statusId,
099: comments);
100:
101: return OrganizationJSONSerializer.toJSONObject(returnValue);
102: }
103:
104: public static void deleteOrganization(long organizationId)
105: throws java.rmi.RemoteException,
106: com.liferay.portal.SystemException,
107: com.liferay.portal.PortalException {
108: OrganizationServiceUtil.deleteOrganization(organizationId);
109: }
110:
111: public static JSONObject getOrganization(long organizationId)
112: throws java.rmi.RemoteException,
113: com.liferay.portal.SystemException,
114: com.liferay.portal.PortalException {
115: com.liferay.portal.model.Organization returnValue = OrganizationServiceUtil
116: .getOrganization(organizationId);
117:
118: return OrganizationJSONSerializer.toJSONObject(returnValue);
119: }
120:
121: public static long getOrganizationId(long companyId,
122: java.lang.String name) throws java.rmi.RemoteException,
123: com.liferay.portal.SystemException,
124: com.liferay.portal.PortalException {
125: long returnValue = OrganizationServiceUtil.getOrganizationId(
126: companyId, name);
127:
128: return returnValue;
129: }
130:
131: public static JSONArray getUserOrganizations(long userId)
132: throws java.rmi.RemoteException,
133: com.liferay.portal.SystemException,
134: com.liferay.portal.PortalException {
135: java.util.List returnValue = OrganizationServiceUtil
136: .getUserOrganizations(userId);
137:
138: return OrganizationJSONSerializer.toJSONArray(returnValue);
139: }
140:
141: public static void setGroupOrganizations(long groupId,
142: long[] organizationIds) throws java.rmi.RemoteException,
143: com.liferay.portal.SystemException,
144: com.liferay.portal.PortalException {
145: OrganizationServiceUtil.setGroupOrganizations(groupId,
146: organizationIds);
147: }
148:
149: public static void unsetGroupOrganizations(long groupId,
150: long[] organizationIds) throws java.rmi.RemoteException,
151: com.liferay.portal.SystemException,
152: com.liferay.portal.PortalException {
153: OrganizationServiceUtil.unsetGroupOrganizations(groupId,
154: organizationIds);
155: }
156:
157: public static void unsetPasswordPolicyOrganizations(
158: long passwordPolicyId, long[] organizationIds)
159: throws java.rmi.RemoteException,
160: com.liferay.portal.SystemException,
161: com.liferay.portal.PortalException {
162: OrganizationServiceUtil.unsetPasswordPolicyOrganizations(
163: passwordPolicyId, organizationIds);
164: }
165:
166: public static JSONObject updateOrganization(long organizationId,
167: long parentOrganizationId, java.lang.String name, int type,
168: boolean recursable, long regionId, long countryId,
169: int statusId, java.lang.String comments)
170: throws java.rmi.RemoteException,
171: com.liferay.portal.SystemException,
172: com.liferay.portal.PortalException {
173: com.liferay.portal.model.Organization returnValue = OrganizationServiceUtil
174: .updateOrganization(organizationId,
175: parentOrganizationId, name, type, recursable,
176: regionId, countryId, statusId, comments);
177:
178: return OrganizationJSONSerializer.toJSONObject(returnValue);
179: }
180: }
|