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.tags.service.http;
022:
023: import com.liferay.portlet.tags.service.TagsEntryServiceUtil;
024:
025: import org.json.JSONArray;
026: import org.json.JSONObject;
027:
028: /**
029: * <a href="TagsEntryServiceJSON.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.portlet.tags.service.TagsEntryServiceUtil</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.portlet.tags.model.TagsEntry</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.portlet.tags.service.http.TagsEntryJSONSerializer</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.portlet.tags.service.TagsEntryServiceUtil
069: * @see com.liferay.portlet.tags.service.http.TagsEntryJSONSerializer
070: *
071: */
072: public class TagsEntryServiceJSON {
073: public static JSONObject addEntry(java.lang.String name)
074: throws java.rmi.RemoteException,
075: com.liferay.portal.SystemException,
076: com.liferay.portal.PortalException {
077: com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil
078: .addEntry(name);
079:
080: return TagsEntryJSONSerializer.toJSONObject(returnValue);
081: }
082:
083: public static JSONObject addEntry(java.lang.String name,
084: java.lang.String[] properties)
085: throws java.rmi.RemoteException,
086: com.liferay.portal.SystemException,
087: com.liferay.portal.PortalException {
088: com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil
089: .addEntry(name, properties);
090:
091: return TagsEntryJSONSerializer.toJSONObject(returnValue);
092: }
093:
094: public static void deleteEntry(long entryId)
095: throws java.rmi.RemoteException,
096: com.liferay.portal.SystemException,
097: com.liferay.portal.PortalException {
098: TagsEntryServiceUtil.deleteEntry(entryId);
099: }
100:
101: public static JSONArray getEntries(java.lang.String className,
102: long classPK) throws java.rmi.RemoteException,
103: com.liferay.portal.SystemException,
104: com.liferay.portal.PortalException {
105: java.util.List returnValue = TagsEntryServiceUtil.getEntries(
106: className, classPK);
107:
108: return TagsEntryJSONSerializer.toJSONArray(returnValue);
109: }
110:
111: public static JSONArray search(long companyId,
112: java.lang.String name, java.lang.String[] properties)
113: throws java.rmi.RemoteException,
114: com.liferay.portal.SystemException {
115: java.util.List returnValue = TagsEntryServiceUtil.search(
116: companyId, name, properties);
117:
118: return TagsEntryJSONSerializer.toJSONArray(returnValue);
119: }
120:
121: public static JSONArray search(long companyId,
122: java.lang.String name, java.lang.String[] properties,
123: int begin, int end) throws java.rmi.RemoteException,
124: com.liferay.portal.SystemException {
125: java.util.List returnValue = TagsEntryServiceUtil.search(
126: companyId, name, properties, begin, end);
127:
128: return TagsEntryJSONSerializer.toJSONArray(returnValue);
129: }
130:
131: public static JSONArray searchAutocomplete(long companyId,
132: java.lang.String name, java.lang.String[] properties,
133: int begin, int end) throws java.rmi.RemoteException,
134: com.liferay.portal.SystemException {
135: com.liferay.portal.kernel.json.JSONArrayWrapper returnValue = TagsEntryServiceUtil
136: .searchAutocomplete(companyId, name, properties, begin,
137: end);
138:
139: return (JSONArray) returnValue.getValue();
140: }
141:
142: public static int searchCount(long companyId,
143: java.lang.String name, java.lang.String[] properties)
144: throws java.rmi.RemoteException,
145: com.liferay.portal.SystemException {
146: int returnValue = TagsEntryServiceUtil.searchCount(companyId,
147: name, properties);
148:
149: return returnValue;
150: }
151:
152: public static JSONObject updateEntry(long entryId,
153: java.lang.String name) throws java.rmi.RemoteException,
154: com.liferay.portal.SystemException,
155: com.liferay.portal.PortalException {
156: com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil
157: .updateEntry(entryId, name);
158:
159: return TagsEntryJSONSerializer.toJSONObject(returnValue);
160: }
161:
162: public static JSONObject updateEntry(long entryId,
163: java.lang.String name, java.lang.String[] properties)
164: throws java.rmi.RemoteException,
165: com.liferay.portal.SystemException,
166: com.liferay.portal.PortalException {
167: com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil
168: .updateEntry(entryId, name, properties);
169:
170: return TagsEntryJSONSerializer.toJSONObject(returnValue);
171: }
172: }
|