001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.http;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.service.RoleServiceUtil;
020    
021    import java.rmi.RemoteException;
022    
023    /**
024     * <p>
025     * This class provides a SOAP utility for the
026     * {@link com.liferay.portal.service.RoleServiceUtil} service utility. The
027     * static methods of this class calls the same methods of the service utility.
028     * However, the signatures are different because it is difficult for SOAP to
029     * support certain types.
030     * </p>
031     *
032     * <p>
033     * ServiceBuilder follows certain rules in translating the methods. For example,
034     * if the method in the service utility returns a {@link java.util.List}, that
035     * is translated to an array of {@link com.liferay.portal.model.RoleSoap}.
036     * If the method in the service utility returns a
037     * {@link com.liferay.portal.model.Role}, that is translated to a
038     * {@link com.liferay.portal.model.RoleSoap}. Methods that SOAP cannot
039     * safely wire are skipped.
040     * </p>
041     *
042     * <p>
043     * The benefits of using the SOAP utility is that it is cross platform
044     * compatible. SOAP allows different languages like Java, .NET, C++, PHP, and
045     * even Perl, to call the generated services. One drawback of SOAP is that it is
046     * slow because it needs to serialize all calls into a text format (XML).
047     * </p>
048     *
049     * <p>
050     * You can see a list of services at
051     * http://localhost:8080/tunnel-web/secure/axis. Set the property
052     * <b>tunnel.servlet.hosts.allowed</b> in portal.properties to configure
053     * security.
054     * </p>
055     *
056     * <p>
057     * The SOAP utility is only generated for remote services.
058     * </p>
059     *
060     * @author    Brian Wing Shun Chan
061     * @see       RoleServiceHttp
062     * @see       com.liferay.portal.model.RoleSoap
063     * @see       com.liferay.portal.service.RoleServiceUtil
064     * @generated
065     */
066    public class RoleServiceSoap {
067            /**
068            * Adds the roles to the user. The user is reindexed after the roles are
069            * added.
070            *
071            * @param userId the primary key of the user
072            * @param roleIds the primary keys of the roles
073            * @throws PortalException if a user with the primary key could not be
074            found or if the user did not have permission to assign members
075            to one of the roles
076            * @throws SystemException if a system exception occurred
077            */
078            public static void addUserRoles(long userId, long[] roleIds)
079                    throws RemoteException {
080                    try {
081                            RoleServiceUtil.addUserRoles(userId, roleIds);
082                    }
083                    catch (Exception e) {
084                            _log.error(e, e);
085    
086                            throw new RemoteException(e.getMessage());
087                    }
088            }
089    
090            /**
091            * Deletes the role with the primary key and its associated permissions.
092            *
093            * @param roleId the primary key of the role
094            * @throws PortalException if the user did not have permission to delete
095            the role, if a role with the primary key could not be found, if
096            the role is a default system role, or if the role's resource
097            could not be found
098            * @throws SystemException if a system exception occurred
099            */
100            public static void deleteRole(long roleId) throws RemoteException {
101                    try {
102                            RoleServiceUtil.deleteRole(roleId);
103                    }
104                    catch (Exception e) {
105                            _log.error(e, e);
106    
107                            throw new RemoteException(e.getMessage());
108                    }
109            }
110    
111            /**
112            * Returns all the roles associated with the group.
113            *
114            * @param groupId the primary key of the group
115            * @return the roles associated with the group
116            * @throws PortalException if a portal exception occurred
117            * @throws SystemException if a system exception occurred
118            */
119            public static com.liferay.portal.model.RoleSoap[] getGroupRoles(
120                    long groupId) throws RemoteException {
121                    try {
122                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId);
123    
124                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
125                    }
126                    catch (Exception e) {
127                            _log.error(e, e);
128    
129                            throw new RemoteException(e.getMessage());
130                    }
131            }
132    
133            /**
134            * Returns the role with the primary key.
135            *
136            * @param roleId the primary key of the role
137            * @return the role with the primary key
138            * @throws PortalException if a role with the primary key could not be
139            found or if the user did not have permission to view the role
140            * @throws SystemException if a system exception occurred
141            */
142            public static com.liferay.portal.model.RoleSoap getRole(long roleId)
143                    throws RemoteException {
144                    try {
145                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId);
146    
147                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
148                    }
149                    catch (Exception e) {
150                            _log.error(e, e);
151    
152                            throw new RemoteException(e.getMessage());
153                    }
154            }
155    
156            /**
157            * Returns the role with the name in the company.
158            *
159            * <p>
160            * The method searches the system roles map first for default roles. If a
161            * role with the name is not found, then the method will query the
162            * database.
163            * </p>
164            *
165            * @param companyId the primary key of the company
166            * @param name the role's name
167            * @return the role with the name
168            * @throws PortalException if a role with the name could not be found in
169            the company or if the user did not have permission to view the
170            role
171            * @throws SystemException if a system exception occurred
172            */
173            public static com.liferay.portal.model.RoleSoap getRole(long companyId,
174                    java.lang.String name) throws RemoteException {
175                    try {
176                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId,
177                                            name);
178    
179                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
180                    }
181                    catch (Exception e) {
182                            _log.error(e, e);
183    
184                            throw new RemoteException(e.getMessage());
185                    }
186            }
187    
188            /**
189            * Returns all the user's roles within the user group.
190            *
191            * @param userId the primary key of the user
192            * @param groupId the primary key of the group
193            * @return the user's roles within the user group
194            * @throws PortalException if a portal exception occurred
195            * @throws SystemException if a system exception occurred
196            */
197            public static com.liferay.portal.model.RoleSoap[] getUserGroupGroupRoles(
198                    long userId, long groupId) throws RemoteException {
199                    try {
200                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupGroupRoles(userId,
201                                            groupId);
202    
203                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
204                    }
205                    catch (Exception e) {
206                            _log.error(e, e);
207    
208                            throw new RemoteException(e.getMessage());
209                    }
210            }
211    
212            /**
213            * Returns all the user's roles within the user group.
214            *
215            * @param userId the primary key of the user
216            * @param groupId the primary key of the group
217            * @return the user's roles within the user group
218            * @throws PortalException if a portal exception occurred
219            * @throws SystemException if a system exception occurred
220            */
221            public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles(
222                    long userId, long groupId) throws RemoteException {
223                    try {
224                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId,
225                                            groupId);
226    
227                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
228                    }
229                    catch (Exception e) {
230                            _log.error(e, e);
231    
232                            throw new RemoteException(e.getMessage());
233                    }
234            }
235    
236            /**
237            * Returns the union of all the user's roles within the groups.
238            *
239            * @param userId the primary key of the user
240            * @param groups the groups (optionally <code>null</code>)
241            * @return the union of all the user's roles within the groups
242            * @throws PortalException if a portal exception occurred
243            * @throws SystemException if a system exception occurred
244            */
245            public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles(
246                    long userId, com.liferay.portal.model.GroupSoap[] groups)
247                    throws RemoteException {
248                    try {
249                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId,
250                                            com.liferay.portal.model.impl.GroupModelImpl.toModels(
251                                                    groups));
252    
253                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
254                    }
255                    catch (Exception e) {
256                            _log.error(e, e);
257    
258                            throw new RemoteException(e.getMessage());
259                    }
260            }
261    
262            /**
263            * Returns all the roles associated with the user.
264            *
265            * @param userId the primary key of the user
266            * @return the roles associated with the user
267            * @throws PortalException if a portal exception occurred
268            * @throws SystemException if a system exception occurred
269            */
270            public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId)
271                    throws RemoteException {
272                    try {
273                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId);
274    
275                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
276                    }
277                    catch (Exception e) {
278                            _log.error(e, e);
279    
280                            throw new RemoteException(e.getMessage());
281                    }
282            }
283    
284            /**
285            * Returns <code>true</code> if the user is associated with the named
286            * regular role.
287            *
288            * @param userId the primary key of the user
289            * @param companyId the primary key of the company
290            * @param name the name of the role
291            * @param inherited whether to include the user's inherited roles in the
292            search
293            * @return <code>true</code> if the user is associated with the regular
294            role; <code>false</code> otherwise
295            * @throws PortalException if a role with the name could not be found in
296            the company or if a default user for the company could not be
297            found
298            * @throws SystemException if a system exception occurred
299            */
300            public static boolean hasUserRole(long userId, long companyId,
301                    java.lang.String name, boolean inherited) throws RemoteException {
302                    try {
303                            boolean returnValue = RoleServiceUtil.hasUserRole(userId,
304                                            companyId, name, inherited);
305    
306                            return returnValue;
307                    }
308                    catch (Exception e) {
309                            _log.error(e, e);
310    
311                            throw new RemoteException(e.getMessage());
312                    }
313            }
314    
315            /**
316            * Returns <code>true</code> if the user has any one of the named regular
317            * roles.
318            *
319            * @param userId the primary key of the user
320            * @param companyId the primary key of the company
321            * @param names the names of the roles
322            * @param inherited whether to include the user's inherited roles in the
323            search
324            * @return <code>true</code> if the user has any one of the regular roles;
325            <code>false</code> otherwise
326            * @throws PortalException if any one of the roles with the names could not
327            be found in the company or if the default user for the company
328            could not be found
329            * @throws SystemException if a system exception occurred
330            */
331            public static boolean hasUserRoles(long userId, long companyId,
332                    java.lang.String[] names, boolean inherited) throws RemoteException {
333                    try {
334                            boolean returnValue = RoleServiceUtil.hasUserRoles(userId,
335                                            companyId, names, inherited);
336    
337                            return returnValue;
338                    }
339                    catch (Exception e) {
340                            _log.error(e, e);
341    
342                            throw new RemoteException(e.getMessage());
343                    }
344            }
345    
346            /**
347            * Removes the matching roles associated with the user. The user is
348            * reindexed after the roles are removed.
349            *
350            * @param userId the primary key of the user
351            * @param roleIds the primary keys of the roles
352            * @throws PortalException if a user with the primary key could not be
353            found, if the user did not have permission to remove members
354            from a role, or if a role with any one of the primary keys could
355            not be found
356            * @throws SystemException if a system exception occurred
357            */
358            public static void unsetUserRoles(long userId, long[] roleIds)
359                    throws RemoteException {
360                    try {
361                            RoleServiceUtil.unsetUserRoles(userId, roleIds);
362                    }
363                    catch (Exception e) {
364                            _log.error(e, e);
365    
366                            throw new RemoteException(e.getMessage());
367                    }
368            }
369    
370            private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class);
371    }