1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.ratings.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.DoubleWrapper;
20  import com.liferay.portal.kernel.util.LongWrapper;
21  import com.liferay.portal.kernel.util.MethodWrapper;
22  import com.liferay.portal.kernel.util.NullWrapper;
23  import com.liferay.portal.security.auth.HttpPrincipal;
24  import com.liferay.portal.service.http.TunnelUtil;
25  
26  import com.liferay.portlet.ratings.service.RatingsEntryServiceUtil;
27  
28  /**
29   * <a href="RatingsEntryServiceHttp.java.html"><b><i>View Source</i></b></a>
30   *
31   * <p>
32   * ServiceBuilder generated this class. Modifications in this class will be
33   * overwritten the next time is generated.
34   * </p>
35   *
36   * <p>
37   * This class provides a HTTP utility for the
38   * {@link com.liferay.portlet.ratings.service.RatingsEntryServiceUtil} service utility. The
39   * static methods of this class calls the same methods of the service utility.
40   * However, the signatures are different because it requires an additional
41   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
42   * </p>
43   *
44   * <p>
45   * The benefits of using the HTTP utility is that it is fast and allows for
46   * tunneling without the cost of serializing to text. The drawback is that it
47   * only works with Java.
48   * </p>
49   *
50   * <p>
51   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
52   * configure security.
53   * </p>
54   *
55   * <p>
56   * The HTTP utility is only generated for remote services.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       RatingsEntryServiceSoap
61   * @see       com.liferay.portal.security.auth.HttpPrincipal
62   * @see       com.liferay.portlet.ratings.service.RatingsEntryServiceUtil
63   * @generated
64   */
65  public class RatingsEntryServiceHttp {
66      public static void deleteEntry(HttpPrincipal httpPrincipal,
67          java.lang.String className, long classPK)
68          throws com.liferay.portal.kernel.exception.PortalException,
69              com.liferay.portal.kernel.exception.SystemException {
70          try {
71              Object paramObj0 = className;
72  
73              if (className == null) {
74                  paramObj0 = new NullWrapper("java.lang.String");
75              }
76  
77              Object paramObj1 = new LongWrapper(classPK);
78  
79              MethodWrapper methodWrapper = new MethodWrapper(RatingsEntryServiceUtil.class.getName(),
80                      "deleteEntry", new Object[] { paramObj0, paramObj1 });
81  
82              try {
83                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
84              }
85              catch (Exception e) {
86                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
87                      throw (com.liferay.portal.kernel.exception.PortalException)e;
88                  }
89  
90                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
91                      throw (com.liferay.portal.kernel.exception.SystemException)e;
92                  }
93  
94                  throw new com.liferay.portal.kernel.exception.SystemException(e);
95              }
96          }
97          catch (com.liferay.portal.kernel.exception.SystemException se) {
98              _log.error(se, se);
99  
100             throw se;
101         }
102     }
103 
104     public static com.liferay.portlet.ratings.model.RatingsEntry updateEntry(
105         HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
106         double score)
107         throws com.liferay.portal.kernel.exception.PortalException,
108             com.liferay.portal.kernel.exception.SystemException {
109         try {
110             Object paramObj0 = className;
111 
112             if (className == null) {
113                 paramObj0 = new NullWrapper("java.lang.String");
114             }
115 
116             Object paramObj1 = new LongWrapper(classPK);
117 
118             Object paramObj2 = new DoubleWrapper(score);
119 
120             MethodWrapper methodWrapper = new MethodWrapper(RatingsEntryServiceUtil.class.getName(),
121                     "updateEntry",
122                     new Object[] { paramObj0, paramObj1, paramObj2 });
123 
124             Object returnObj = null;
125 
126             try {
127                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
128             }
129             catch (Exception e) {
130                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
131                     throw (com.liferay.portal.kernel.exception.PortalException)e;
132                 }
133 
134                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
135                     throw (com.liferay.portal.kernel.exception.SystemException)e;
136                 }
137 
138                 throw new com.liferay.portal.kernel.exception.SystemException(e);
139             }
140 
141             return (com.liferay.portlet.ratings.model.RatingsEntry)returnObj;
142         }
143         catch (com.liferay.portal.kernel.exception.SystemException se) {
144             _log.error(se, se);
145 
146             throw se;
147         }
148     }
149 
150     private static Log _log = LogFactoryUtil.getLog(RatingsEntryServiceHttp.class);
151 }