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.tags.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.tags.service.TagsEntryServiceUtil;
26  
27  /**
28   * <a href="TagsEntryServiceJSON.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.tags.service.TagsEntryServiceUtil</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.tags.model.TagsEntry</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.tags.service.http.TagsEntryJSONSerializer</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.tags.service.TagsEntryServiceUtil
70   * @see com.liferay.portlet.tags.service.http.TagsEntryJSONSerializer
71   *
72   */
73  public class TagsEntryServiceJSON {
74      public static JSONObject addEntry(java.lang.String name)
75          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
76              com.liferay.portal.SystemException {
77          com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil.addEntry(name);
78  
79          return TagsEntryJSONSerializer.toJSONObject(returnValue);
80      }
81  
82      public static JSONObject addEntry(java.lang.String name,
83          java.lang.String[] properties)
84          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
85              com.liferay.portal.SystemException {
86          com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil.addEntry(name,
87                  properties);
88  
89          return TagsEntryJSONSerializer.toJSONObject(returnValue);
90      }
91  
92      public static void deleteEntry(long entryId)
93          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
94              com.liferay.portal.SystemException {
95          TagsEntryServiceUtil.deleteEntry(entryId);
96      }
97  
98      public static JSONArray getEntries(java.lang.String className, long classPK)
99          throws java.rmi.RemoteException, com.liferay.portal.SystemException {
100         java.util.List<com.liferay.portlet.tags.model.TagsEntry> returnValue = TagsEntryServiceUtil.getEntries(className,
101                 classPK);
102 
103         return TagsEntryJSONSerializer.toJSONArray(returnValue);
104     }
105 
106     public static JSONArray getEntries(long groupId, long companyId,
107         long classNameId, java.lang.String name)
108         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
109         java.util.List<com.liferay.portlet.tags.model.TagsEntry> returnValue = TagsEntryServiceUtil.getEntries(groupId,
110                 companyId, classNameId, name);
111 
112         return TagsEntryJSONSerializer.toJSONArray(returnValue);
113     }
114 
115     public static void mergeEntries(long fromEntryId, long toEntryId)
116         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
117             com.liferay.portal.SystemException {
118         TagsEntryServiceUtil.mergeEntries(fromEntryId, toEntryId);
119     }
120 
121     public static JSONArray search(long companyId, java.lang.String name,
122         java.lang.String[] properties)
123         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
124         java.util.List<com.liferay.portlet.tags.model.TagsEntry> returnValue = TagsEntryServiceUtil.search(companyId,
125                 name, properties);
126 
127         return TagsEntryJSONSerializer.toJSONArray(returnValue);
128     }
129 
130     public static JSONArray search(long companyId, java.lang.String name,
131         java.lang.String[] properties, int start, int end)
132         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
133         java.util.List<com.liferay.portlet.tags.model.TagsEntry> returnValue = TagsEntryServiceUtil.search(companyId,
134                 name, properties, start, end);
135 
136         return TagsEntryJSONSerializer.toJSONArray(returnValue);
137     }
138 
139     public static com.liferay.portal.kernel.json.JSONArray searchAutocomplete(
140         long companyId, java.lang.String name, java.lang.String[] properties,
141         int start, int end)
142         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
143         com.liferay.portal.kernel.json.JSONArray returnValue = TagsEntryServiceUtil.searchAutocomplete(companyId,
144                 name, properties, start, end);
145 
146         return returnValue;
147     }
148 
149     public static int searchCount(long companyId, java.lang.String name,
150         java.lang.String[] properties)
151         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
152         int returnValue = TagsEntryServiceUtil.searchCount(companyId, name,
153                 properties);
154 
155         return returnValue;
156     }
157 
158     public static JSONObject updateEntry(long entryId, java.lang.String name)
159         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
160             com.liferay.portal.SystemException {
161         com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil.updateEntry(entryId,
162                 name);
163 
164         return TagsEntryJSONSerializer.toJSONObject(returnValue);
165     }
166 
167     public static JSONObject updateEntry(long entryId, java.lang.String name,
168         java.lang.String[] properties)
169         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
170             com.liferay.portal.SystemException {
171         com.liferay.portlet.tags.model.TagsEntry returnValue = TagsEntryServiceUtil.updateEntry(entryId,
172                 name, properties);
173 
174         return TagsEntryJSONSerializer.toJSONObject(returnValue);
175     }
176 }