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.TagsAssetServiceUtil;
26  
27  /**
28   * <a href="TagsAssetServiceJSON.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.TagsAssetServiceUtil</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.TagsAsset</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.TagsAssetJSONSerializer</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.TagsAssetServiceUtil
70   * @see com.liferay.portlet.tags.service.http.TagsAssetJSONSerializer
71   *
72   */
73  public class TagsAssetServiceJSON {
74      public static void deleteAsset(long assetId)
75          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
76              com.liferay.portal.SystemException {
77          TagsAssetServiceUtil.deleteAsset(assetId);
78      }
79  
80      public static JSONObject getAsset(long assetId)
81          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
82              com.liferay.portal.SystemException {
83          com.liferay.portlet.tags.model.TagsAsset returnValue = TagsAssetServiceUtil.getAsset(assetId);
84  
85          return TagsAssetJSONSerializer.toJSONObject(returnValue);
86      }
87  
88      public static java.lang.String getAssetsRSS(long groupId,
89          long[] classNameIds, long[] entryIds, long[] notEntryIds,
90          boolean andOperator, java.lang.String orderByCol1,
91          java.lang.String orderByCol2, java.lang.String orderByType1,
92          java.lang.String orderByType2, boolean excludeZeroViewCount,
93          java.util.Date publishDate, java.util.Date expirationDate, int max,
94          java.lang.String type, double version, java.lang.String displayStyle,
95          java.lang.String feedURL, java.lang.String entryURL)
96          throws java.rmi.RemoteException, com.liferay.portal.PortalException,
97              com.liferay.portal.SystemException {
98          java.lang.String returnValue = TagsAssetServiceUtil.getAssetsRSS(groupId,
99                  classNameIds, entryIds, notEntryIds, andOperator, orderByCol1,
100                 orderByCol2, orderByType1, orderByType2, excludeZeroViewCount,
101                 publishDate, expirationDate, max, type, version, displayStyle,
102                 feedURL, entryURL);
103 
104         return returnValue;
105     }
106 
107     public static com.liferay.portlet.tags.model.TagsAssetType[] getAssetTypes(
108         java.lang.String languageId) throws java.rmi.RemoteException {
109         com.liferay.portlet.tags.model.TagsAssetType[] returnValue = TagsAssetServiceUtil.getAssetTypes(languageId);
110 
111         return returnValue;
112     }
113 
114     public static com.liferay.portlet.tags.model.TagsAssetDisplay[] getCompanyAssetDisplays(
115         long companyId, int start, int end, java.lang.String languageId)
116         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
117         com.liferay.portlet.tags.model.TagsAssetDisplay[] returnValue = TagsAssetServiceUtil.getCompanyAssetDisplays(companyId,
118                 start, end, languageId);
119 
120         return returnValue;
121     }
122 
123     public static JSONArray getCompanyAssets(long companyId, int start, int end)
124         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
125         java.util.List<com.liferay.portlet.tags.model.TagsAsset> returnValue = TagsAssetServiceUtil.getCompanyAssets(companyId,
126                 start, end);
127 
128         return TagsAssetJSONSerializer.toJSONArray(returnValue);
129     }
130 
131     public static int getCompanyAssetsCount(long companyId)
132         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
133         int returnValue = TagsAssetServiceUtil.getCompanyAssetsCount(companyId);
134 
135         return returnValue;
136     }
137 
138     public static java.lang.String getCompanyAssetsRSS(long companyId, int max,
139         java.lang.String type, double version, java.lang.String displayStyle,
140         java.lang.String feedURL, java.lang.String entryURL)
141         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
142             com.liferay.portal.SystemException {
143         java.lang.String returnValue = TagsAssetServiceUtil.getCompanyAssetsRSS(companyId,
144                 max, type, version, displayStyle, feedURL, entryURL);
145 
146         return returnValue;
147     }
148 
149     public static JSONObject incrementViewCounter(java.lang.String className,
150         long classPK)
151         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
152         com.liferay.portlet.tags.model.TagsAsset returnValue = TagsAssetServiceUtil.incrementViewCounter(className,
153                 classPK);
154 
155         return TagsAssetJSONSerializer.toJSONObject(returnValue);
156     }
157 
158     public static com.liferay.portlet.tags.model.TagsAssetDisplay[] searchAssetDisplays(
159         long companyId, java.lang.String portletId, java.lang.String keywords,
160         java.lang.String languageId, int start, int end)
161         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
162         com.liferay.portlet.tags.model.TagsAssetDisplay[] returnValue = TagsAssetServiceUtil.searchAssetDisplays(companyId,
163                 portletId, keywords, languageId, start, end);
164 
165         return returnValue;
166     }
167 
168     public static int searchAssetDisplaysCount(long companyId,
169         java.lang.String portletId, java.lang.String keywords,
170         java.lang.String languageId)
171         throws java.rmi.RemoteException, com.liferay.portal.SystemException {
172         int returnValue = TagsAssetServiceUtil.searchAssetDisplaysCount(companyId,
173                 portletId, keywords, languageId);
174 
175         return returnValue;
176     }
177 
178     public static JSONObject updateAsset(long groupId,
179         java.lang.String className, long classPK,
180         java.lang.String[] entryNames, java.util.Date startDate,
181         java.util.Date endDate, java.util.Date publishDate,
182         java.util.Date expirationDate, java.lang.String mimeType,
183         java.lang.String title, java.lang.String description,
184         java.lang.String summary, java.lang.String url, int height, int width,
185         java.lang.Integer priority)
186         throws java.rmi.RemoteException, com.liferay.portal.PortalException,
187             com.liferay.portal.SystemException {
188         com.liferay.portlet.tags.model.TagsAsset returnValue = TagsAssetServiceUtil.updateAsset(groupId,
189                 className, classPK, entryNames, startDate, endDate,
190                 publishDate, expirationDate, mimeType, title, description,
191                 summary, url, height, width, priority);
192 
193         return TagsAssetJSONSerializer.toJSONObject(returnValue);
194     }
195 }