1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.tags.service.http;
24  
25  import com.liferay.portal.kernel.json.JSONArray;
26  import com.liferay.portal.kernel.json.JSONObject;
27  
28  import com.liferay.portlet.tags.service.TagsAssetServiceUtil;
29  
30  /**
31   * <a href="TagsAssetServiceJSON.java.html"><b><i>View Source</i></b></a>
32   *
33   * <p>
34   * ServiceBuilder generated this class. Modifications in this class will be
35   * overwritten the next time is generated.
36   * </p>
37   *
38   * <p>
39   * This class provides a JSON utility for the
40   * <code>com.liferay.portlet.tags.service.TagsAssetServiceUtil</code>
41   * service utility. The static methods of this class calls the same methods of
42   * the service utility. However, the signatures are different because it is
43   * difficult for JSON to support certain types.
44   * </p>
45   *
46   * <p>
47   * ServiceBuilder follows certain rules in translating the methods. For example,
48   * if the method in the service utility returns a <code>java.util.List</code>,
49   * that is translated to a
50   * <code>com.liferay.portal.kernel.json.JSONArray</code>. If the method in the
51   * service utility returns a <code>com.liferay.portlet.tags.model.TagsAsset</code>,
52   * that is translated to a
53   * <code>com.liferay.portal.kernel.json.JSONObject</code>. Methods that JSON
54   * cannot safely use are skipped. The logic for the translation is encapsulated
55   * in <code>com.liferay.portlet.tags.service.http.TagsAssetJSONSerializer</code>.
56   * </p>
57   *
58   * <p>
59   * This allows you to call the the backend services directly from JavaScript.
60   * See <code>portal-web/docroot/html/portlet/tags_admin/unpacked.js</code> for a
61   * reference of how that portlet uses the generated JavaScript in
62   * <code>portal-web/docroot/html/js/service.js</code> to call the backend
63   * services directly from JavaScript.
64   * </p>
65   *
66   * <p>
67   * The JSON utility is only generated for remote services.
68   * </p>
69   *
70   * @author Brian Wing Shun Chan
71   *
72   * @see com.liferay.portlet.tags.service.TagsAssetServiceUtil
73   * @see com.liferay.portlet.tags.service.http.TagsAssetJSONSerializer
74   *
75   */
76  public class TagsAssetServiceJSON {
77      public static void deleteAsset(long assetId)
78          throws com.liferay.portal.PortalException,
79              com.liferay.portal.SystemException {
80          TagsAssetServiceUtil.deleteAsset(assetId);
81      }
82  
83      public static JSONObject getAsset(long assetId)
84          throws com.liferay.portal.PortalException,
85              com.liferay.portal.SystemException {
86          com.liferay.portlet.tags.model.TagsAsset returnValue = TagsAssetServiceUtil.getAsset(assetId);
87  
88          return TagsAssetJSONSerializer.toJSONObject(returnValue);
89      }
90  
91      public static JSONArray getAssets(long groupId, long[] classNameIds,
92          long[] entryIds, long[] notEntryIds, boolean andOperator,
93          java.lang.String orderByCol1, java.lang.String orderByCol2,
94          java.lang.String orderByType1, java.lang.String orderByType2,
95          boolean excludeZeroViewCount, java.util.Date publishDate,
96          java.util.Date expirationDate, int start, int end)
97          throws com.liferay.portal.PortalException,
98              com.liferay.portal.SystemException {
99          java.util.List<com.liferay.portlet.tags.model.TagsAsset> returnValue = TagsAssetServiceUtil.getAssets(groupId,
100                 classNameIds, entryIds, notEntryIds, andOperator, orderByCol1,
101                 orderByCol2, orderByType1, orderByType2, excludeZeroViewCount,
102                 publishDate, expirationDate, start, end);
103 
104         return TagsAssetJSONSerializer.toJSONArray(returnValue);
105     }
106 
107     public static int getAssetsCount(long groupId, long[] classNameIds,
108         long[] entryIds, long[] notEntryIds, boolean andOperator,
109         boolean excludeZeroViewCount, java.util.Date publishDate,
110         java.util.Date expirationDate)
111         throws com.liferay.portal.PortalException,
112             com.liferay.portal.SystemException {
113         int returnValue = TagsAssetServiceUtil.getAssetsCount(groupId,
114                 classNameIds, entryIds, notEntryIds, andOperator,
115                 excludeZeroViewCount, publishDate, expirationDate);
116 
117         return returnValue;
118     }
119 
120     public static java.lang.String getAssetsRSS(long groupId,
121         long[] classNameIds, long[] entryIds, long[] notEntryIds,
122         boolean andOperator, java.lang.String orderByCol1,
123         java.lang.String orderByCol2, java.lang.String orderByType1,
124         java.lang.String orderByType2, boolean excludeZeroViewCount,
125         java.util.Date publishDate, java.util.Date expirationDate, int max,
126         java.lang.String type, double version, java.lang.String displayStyle,
127         java.lang.String feedURL, java.lang.String entryURL)
128         throws com.liferay.portal.PortalException,
129             com.liferay.portal.SystemException {
130         java.lang.String returnValue = TagsAssetServiceUtil.getAssetsRSS(groupId,
131                 classNameIds, entryIds, notEntryIds, andOperator, orderByCol1,
132                 orderByCol2, orderByType1, orderByType2, excludeZeroViewCount,
133                 publishDate, expirationDate, max, type, version, displayStyle,
134                 feedURL, entryURL);
135 
136         return returnValue;
137     }
138 
139     public static com.liferay.portlet.tags.model.TagsAssetType[] getAssetTypes(
140         java.lang.String languageId) {
141         com.liferay.portlet.tags.model.TagsAssetType[] returnValue = TagsAssetServiceUtil.getAssetTypes(languageId);
142 
143         return returnValue;
144     }
145 
146     public static com.liferay.portlet.tags.model.TagsAssetDisplay[] getCompanyAssetDisplays(
147         long companyId, int start, int end, java.lang.String languageId)
148         throws com.liferay.portal.SystemException {
149         com.liferay.portlet.tags.model.TagsAssetDisplay[] returnValue = TagsAssetServiceUtil.getCompanyAssetDisplays(companyId,
150                 start, end, languageId);
151 
152         return returnValue;
153     }
154 
155     public static JSONArray getCompanyAssets(long companyId, int start, int end)
156         throws com.liferay.portal.SystemException {
157         java.util.List<com.liferay.portlet.tags.model.TagsAsset> returnValue = TagsAssetServiceUtil.getCompanyAssets(companyId,
158                 start, end);
159 
160         return TagsAssetJSONSerializer.toJSONArray(returnValue);
161     }
162 
163     public static int getCompanyAssetsCount(long companyId)
164         throws com.liferay.portal.SystemException {
165         int returnValue = TagsAssetServiceUtil.getCompanyAssetsCount(companyId);
166 
167         return returnValue;
168     }
169 
170     public static java.lang.String getCompanyAssetsRSS(long companyId, int max,
171         java.lang.String type, double version, java.lang.String displayStyle,
172         java.lang.String feedURL, java.lang.String entryURL)
173         throws com.liferay.portal.PortalException,
174             com.liferay.portal.SystemException {
175         java.lang.String returnValue = TagsAssetServiceUtil.getCompanyAssetsRSS(companyId,
176                 max, type, version, displayStyle, feedURL, entryURL);
177 
178         return returnValue;
179     }
180 
181     public static JSONObject incrementViewCounter(java.lang.String className,
182         long classPK) throws com.liferay.portal.SystemException {
183         com.liferay.portlet.tags.model.TagsAsset returnValue = TagsAssetServiceUtil.incrementViewCounter(className,
184                 classPK);
185 
186         return TagsAssetJSONSerializer.toJSONObject(returnValue);
187     }
188 
189     public static com.liferay.portlet.tags.model.TagsAssetDisplay[] searchAssetDisplays(
190         long companyId, java.lang.String portletId, java.lang.String keywords,
191         java.lang.String languageId, int start, int end)
192         throws com.liferay.portal.SystemException {
193         com.liferay.portlet.tags.model.TagsAssetDisplay[] returnValue = TagsAssetServiceUtil.searchAssetDisplays(companyId,
194                 portletId, keywords, languageId, start, end);
195 
196         return returnValue;
197     }
198 
199     public static int searchAssetDisplaysCount(long companyId,
200         java.lang.String portletId, java.lang.String keywords,
201         java.lang.String languageId) throws com.liferay.portal.SystemException {
202         int returnValue = TagsAssetServiceUtil.searchAssetDisplaysCount(companyId,
203                 portletId, keywords, languageId);
204 
205         return returnValue;
206     }
207 
208     public static JSONObject updateAsset(long groupId,
209         java.lang.String className, long classPK,
210         java.lang.String[] categoryNames, java.lang.String[] entryNames,
211         boolean visible, java.util.Date startDate, java.util.Date endDate,
212         java.util.Date publishDate, java.util.Date expirationDate,
213         java.lang.String mimeType, java.lang.String title,
214         java.lang.String description, java.lang.String summary,
215         java.lang.String url, int height, int width, java.lang.Integer priority)
216         throws com.liferay.portal.PortalException,
217             com.liferay.portal.SystemException {
218         com.liferay.portlet.tags.model.TagsAsset returnValue = TagsAssetServiceUtil.updateAsset(groupId,
219                 className, classPK, categoryNames, entryNames, visible,
220                 startDate, endDate, publishDate, expirationDate, mimeType,
221                 title, description, summary, url, height, width, priority);
222 
223         return TagsAssetJSONSerializer.toJSONObject(returnValue);
224     }
225 }