1   /**
2    * Copyright (c) 2000-2007 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.documentlibrary.service.http;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.BooleanWrapper;
28  import com.liferay.portal.kernel.util.LongWrapper;
29  import com.liferay.portal.kernel.util.MethodWrapper;
30  import com.liferay.portal.kernel.util.NullWrapper;
31  import com.liferay.portal.security.auth.HttpPrincipal;
32  import com.liferay.portal.service.http.TunnelUtil;
33  
34  import com.liferay.portlet.documentlibrary.service.DLFileShortcutServiceUtil;
35  
36  /**
37   * <a href="DLFileShortcutServiceHttp.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be overwritten
41   * the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the <code>com.liferay.portlet.documentlibrary.service.DLFileShortcutServiceUtil</code>
46   * service utility. The static methods of this class calls the same methods of the
47   * service utility. However, the signatures are different because it requires an
48   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code> parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
53   * without the cost of serializing to text. The drawback is that it only works with
54   * Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
59   * to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portlet.documentlibrary.service.DLFileShortcutServiceUtil
70   * @see com.liferay.portlet.documentlibrary.service.http.DLFileShortcutServiceSoap
71   *
72   */
73  public class DLFileShortcutServiceHttp {
74      public static com.liferay.portlet.documentlibrary.model.DLFileShortcut addFileShortcut(
75          HttpPrincipal httpPrincipal, long folderId, long toFolderId,
76          java.lang.String toName, boolean addCommunityPermissions,
77          boolean addGuestPermissions)
78          throws com.liferay.portal.SystemException, 
79              com.liferay.portal.PortalException {
80          try {
81              Object paramObj0 = new LongWrapper(folderId);
82              Object paramObj1 = new LongWrapper(toFolderId);
83              Object paramObj2 = toName;
84  
85              if (toName == null) {
86                  paramObj2 = new NullWrapper("java.lang.String");
87              }
88  
89              Object paramObj3 = new BooleanWrapper(addCommunityPermissions);
90              Object paramObj4 = new BooleanWrapper(addGuestPermissions);
91              MethodWrapper methodWrapper = new MethodWrapper(DLFileShortcutServiceUtil.class.getName(),
92                      "addFileShortcut",
93                      new Object[] {
94                          paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
95                      });
96              Object returnObj = null;
97  
98              try {
99                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
100             }
101             catch (Exception e) {
102                 if (e instanceof com.liferay.portal.SystemException) {
103                     throw (com.liferay.portal.SystemException)e;
104                 }
105 
106                 if (e instanceof com.liferay.portal.PortalException) {
107                     throw (com.liferay.portal.PortalException)e;
108                 }
109 
110                 throw new com.liferay.portal.SystemException(e);
111             }
112 
113             return (com.liferay.portlet.documentlibrary.model.DLFileShortcut)returnObj;
114         }
115         catch (com.liferay.portal.SystemException se) {
116             _log.error(se, se);
117             throw se;
118         }
119     }
120 
121     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut addFileShortcut(
122         HttpPrincipal httpPrincipal, long folderId, long toFolderId,
123         java.lang.String toName, java.lang.String[] communityPermissions,
124         java.lang.String[] guestPermissions)
125         throws com.liferay.portal.SystemException, 
126             com.liferay.portal.PortalException {
127         try {
128             Object paramObj0 = new LongWrapper(folderId);
129             Object paramObj1 = new LongWrapper(toFolderId);
130             Object paramObj2 = toName;
131 
132             if (toName == null) {
133                 paramObj2 = new NullWrapper("java.lang.String");
134             }
135 
136             Object paramObj3 = communityPermissions;
137 
138             if (communityPermissions == null) {
139                 paramObj3 = new NullWrapper("[Ljava.lang.String;");
140             }
141 
142             Object paramObj4 = guestPermissions;
143 
144             if (guestPermissions == null) {
145                 paramObj4 = new NullWrapper("[Ljava.lang.String;");
146             }
147 
148             MethodWrapper methodWrapper = new MethodWrapper(DLFileShortcutServiceUtil.class.getName(),
149                     "addFileShortcut",
150                     new Object[] {
151                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
152                     });
153             Object returnObj = null;
154 
155             try {
156                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
157             }
158             catch (Exception e) {
159                 if (e instanceof com.liferay.portal.SystemException) {
160                     throw (com.liferay.portal.SystemException)e;
161                 }
162 
163                 if (e instanceof com.liferay.portal.PortalException) {
164                     throw (com.liferay.portal.PortalException)e;
165                 }
166 
167                 throw new com.liferay.portal.SystemException(e);
168             }
169 
170             return (com.liferay.portlet.documentlibrary.model.DLFileShortcut)returnObj;
171         }
172         catch (com.liferay.portal.SystemException se) {
173             _log.error(se, se);
174             throw se;
175         }
176     }
177 
178     public static void deleteFileShortcut(HttpPrincipal httpPrincipal,
179         long fileShortcutId)
180         throws com.liferay.portal.SystemException, 
181             com.liferay.portal.PortalException {
182         try {
183             Object paramObj0 = new LongWrapper(fileShortcutId);
184             MethodWrapper methodWrapper = new MethodWrapper(DLFileShortcutServiceUtil.class.getName(),
185                     "deleteFileShortcut", new Object[] { paramObj0 });
186 
187             try {
188                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
189             }
190             catch (Exception e) {
191                 if (e instanceof com.liferay.portal.SystemException) {
192                     throw (com.liferay.portal.SystemException)e;
193                 }
194 
195                 if (e instanceof com.liferay.portal.PortalException) {
196                     throw (com.liferay.portal.PortalException)e;
197                 }
198 
199                 throw new com.liferay.portal.SystemException(e);
200             }
201         }
202         catch (com.liferay.portal.SystemException se) {
203             _log.error(se, se);
204             throw se;
205         }
206     }
207 
208     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut getFileShortcut(
209         HttpPrincipal httpPrincipal, long fileShortcutId)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portal.PortalException {
212         try {
213             Object paramObj0 = new LongWrapper(fileShortcutId);
214             MethodWrapper methodWrapper = new MethodWrapper(DLFileShortcutServiceUtil.class.getName(),
215                     "getFileShortcut", new Object[] { paramObj0 });
216             Object returnObj = null;
217 
218             try {
219                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
220             }
221             catch (Exception e) {
222                 if (e instanceof com.liferay.portal.SystemException) {
223                     throw (com.liferay.portal.SystemException)e;
224                 }
225 
226                 if (e instanceof com.liferay.portal.PortalException) {
227                     throw (com.liferay.portal.PortalException)e;
228                 }
229 
230                 throw new com.liferay.portal.SystemException(e);
231             }
232 
233             return (com.liferay.portlet.documentlibrary.model.DLFileShortcut)returnObj;
234         }
235         catch (com.liferay.portal.SystemException se) {
236             _log.error(se, se);
237             throw se;
238         }
239     }
240 
241     public static com.liferay.portlet.documentlibrary.model.DLFileShortcut updateFileShortcut(
242         HttpPrincipal httpPrincipal, long fileShortcutId, long folderId,
243         long toFolderId, java.lang.String toName)
244         throws com.liferay.portal.SystemException, 
245             com.liferay.portal.PortalException {
246         try {
247             Object paramObj0 = new LongWrapper(fileShortcutId);
248             Object paramObj1 = new LongWrapper(folderId);
249             Object paramObj2 = new LongWrapper(toFolderId);
250             Object paramObj3 = toName;
251 
252             if (toName == null) {
253                 paramObj3 = new NullWrapper("java.lang.String");
254             }
255 
256             MethodWrapper methodWrapper = new MethodWrapper(DLFileShortcutServiceUtil.class.getName(),
257                     "updateFileShortcut",
258                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
259             Object returnObj = null;
260 
261             try {
262                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
263             }
264             catch (Exception e) {
265                 if (e instanceof com.liferay.portal.SystemException) {
266                     throw (com.liferay.portal.SystemException)e;
267                 }
268 
269                 if (e instanceof com.liferay.portal.PortalException) {
270                     throw (com.liferay.portal.PortalException)e;
271                 }
272 
273                 throw new com.liferay.portal.SystemException(e);
274             }
275 
276             return (com.liferay.portlet.documentlibrary.model.DLFileShortcut)returnObj;
277         }
278         catch (com.liferay.portal.SystemException se) {
279             _log.error(se, se);
280             throw se;
281         }
282     }
283 
284     private static Log _log = LogFactoryUtil.getLog(DLFileShortcutServiceHttp.class);
285 }