001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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.kernel.util.LocalizationUtil;
020    import com.liferay.portal.service.RoleServiceUtil;
021    
022    import java.rmi.RemoteException;
023    
024    import java.util.Locale;
025    import java.util.Map;
026    
027    /**
028     * <p>
029     * This class provides a SOAP utility for the
030     * {@link com.liferay.portal.service.RoleServiceUtil} service utility. The
031     * static methods of this class calls the same methods of the service utility.
032     * However, the signatures are different because it is difficult for SOAP to
033     * support certain types.
034     * </p>
035     *
036     * <p>
037     * ServiceBuilder follows certain rules in translating the methods. For example,
038     * if the method in the service utility returns a {@link java.util.List}, that
039     * is translated to an array of {@link com.liferay.portal.model.RoleSoap}.
040     * If the method in the service utility returns a
041     * {@link com.liferay.portal.model.Role}, that is translated to a
042     * {@link com.liferay.portal.model.RoleSoap}. Methods that SOAP cannot
043     * safely wire are skipped.
044     * </p>
045     *
046     * <p>
047     * The benefits of using the SOAP utility is that it is cross platform
048     * compatible. SOAP allows different languages like Java, .NET, C++, PHP, and
049     * even Perl, to call the generated services. One drawback of SOAP is that it is
050     * slow because it needs to serialize all calls into a text format (XML).
051     * </p>
052     *
053     * <p>
054     * You can see a list of services at
055     * http://localhost:8080/api/secure/axis. Set the property
056     * <b>axis.servlet.hosts.allowed</b> in portal.properties to configure
057     * security.
058     * </p>
059     *
060     * <p>
061     * The SOAP utility is only generated for remote services.
062     * </p>
063     *
064     * @author    Brian Wing Shun Chan
065     * @see       RoleServiceHttp
066     * @see       com.liferay.portal.model.RoleSoap
067     * @see       com.liferay.portal.service.RoleServiceUtil
068     * @generated
069     */
070    public class RoleServiceSoap {
071            /**
072            * Adds a role. The user is reindexed after role is added.
073            *
074            * @param name the role's name
075            * @param titleMap the role's localized titles (optionally
076            <code>null</code>)
077            * @param descriptionMap the role's localized descriptions (optionally
078            <code>null</code>)
079            * @param type the role's type (optionally <code>0</code>)
080            * @return the role
081            * @throws PortalException if a user with the primary key could not be
082            found, if the user did not have permission to add roles, if the
083            class name or the role name were invalid, or if the role is a
084            duplicate
085            * @throws SystemException if a system exception occurred
086            */
087            public static com.liferay.portal.model.RoleSoap addRole(
088                    java.lang.String name, java.lang.String[] titleMapLanguageIds,
089                    java.lang.String[] titleMapValues,
090                    java.lang.String[] descriptionMapLanguageIds,
091                    java.lang.String[] descriptionMapValues, int type)
092                    throws RemoteException {
093                    try {
094                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
095                                            titleMapValues);
096                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
097                                            descriptionMapValues);
098    
099                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.addRole(name,
100                                            titleMap, descriptionMap, type);
101    
102                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
103                    }
104                    catch (Exception e) {
105                            _log.error(e, e);
106    
107                            throw new RemoteException(e.getMessage());
108                    }
109            }
110    
111            /**
112            * Adds the roles to the user. The user is reindexed after the roles are
113            * added.
114            *
115            * @param userId the primary key of the user
116            * @param roleIds the primary keys of the roles
117            * @throws PortalException if a user with the primary key could not be found
118            or if the user did not have permission to assign members to one
119            of the roles
120            * @throws SystemException if a system exception occurred
121            */
122            public static void addUserRoles(long userId, long[] roleIds)
123                    throws RemoteException {
124                    try {
125                            RoleServiceUtil.addUserRoles(userId, roleIds);
126                    }
127                    catch (Exception e) {
128                            _log.error(e, e);
129    
130                            throw new RemoteException(e.getMessage());
131                    }
132            }
133    
134            /**
135            * Deletes the role with the primary key and its associated permissions.
136            *
137            * @param roleId the primary key of the role
138            * @throws PortalException if the user did not have permission to delete the
139            role, if a role with the primary key could not be found, if the
140            role is a default system role, or if the role's resource could
141            not be found
142            * @throws SystemException if a system exception occurred
143            */
144            public static void deleteRole(long roleId) throws RemoteException {
145                    try {
146                            RoleServiceUtil.deleteRole(roleId);
147                    }
148                    catch (Exception e) {
149                            _log.error(e, e);
150    
151                            throw new RemoteException(e.getMessage());
152                    }
153            }
154    
155            /**
156            * Returns all the roles associated with the group.
157            *
158            * @param groupId the primary key of the group
159            * @return the roles associated with the group
160            * @throws PortalException if a portal exception occurred
161            * @throws SystemException if a system exception occurred
162            */
163            public static com.liferay.portal.model.RoleSoap[] getGroupRoles(
164                    long groupId) throws RemoteException {
165                    try {
166                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId);
167    
168                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
169                    }
170                    catch (Exception e) {
171                            _log.error(e, e);
172    
173                            throw new RemoteException(e.getMessage());
174                    }
175            }
176    
177            /**
178            * Returns the role with the primary key.
179            *
180            * @param roleId the primary key of the role
181            * @return the role with the primary key
182            * @throws PortalException if a role with the primary key could not be found
183            or if the user did not have permission to view the role
184            * @throws SystemException if a system exception occurred
185            */
186            public static com.liferay.portal.model.RoleSoap getRole(long roleId)
187                    throws RemoteException {
188                    try {
189                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId);
190    
191                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
192                    }
193                    catch (Exception e) {
194                            _log.error(e, e);
195    
196                            throw new RemoteException(e.getMessage());
197                    }
198            }
199    
200            /**
201            * Returns the role with the name in the company.
202            *
203            * <p>
204            * The method searches the system roles map first for default roles. If a
205            * role with the name is not found, then the method will query the database.
206            * </p>
207            *
208            * @param companyId the primary key of the company
209            * @param name the role's name
210            * @return the role with the name
211            * @throws PortalException if a role with the name could not be found in the
212            company or if the user did not have permission to view the role
213            * @throws SystemException if a system exception occurred
214            */
215            public static com.liferay.portal.model.RoleSoap getRole(long companyId,
216                    java.lang.String name) throws RemoteException {
217                    try {
218                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId,
219                                            name);
220    
221                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
222                    }
223                    catch (Exception e) {
224                            _log.error(e, e);
225    
226                            throw new RemoteException(e.getMessage());
227                    }
228            }
229    
230            /**
231            * Returns all the user's roles within the user group.
232            *
233            * @param userId the primary key of the user
234            * @param groupId the primary key of the group
235            * @return the user's roles within the user group
236            * @throws PortalException if a portal exception occurred
237            * @throws SystemException if a system exception occurred
238            */
239            public static com.liferay.portal.model.RoleSoap[] getUserGroupGroupRoles(
240                    long userId, long groupId) throws RemoteException {
241                    try {
242                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupGroupRoles(userId,
243                                            groupId);
244    
245                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
246                    }
247                    catch (Exception e) {
248                            _log.error(e, e);
249    
250                            throw new RemoteException(e.getMessage());
251                    }
252            }
253    
254            /**
255            * Returns all the user's roles within the user group.
256            *
257            * @param userId the primary key of the user
258            * @param groupId the primary key of the group
259            * @return the user's roles within the user group
260            * @throws PortalException if a portal exception occurred
261            * @throws SystemException if a system exception occurred
262            */
263            public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles(
264                    long userId, long groupId) throws RemoteException {
265                    try {
266                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId,
267                                            groupId);
268    
269                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
270                    }
271                    catch (Exception e) {
272                            _log.error(e, e);
273    
274                            throw new RemoteException(e.getMessage());
275                    }
276            }
277    
278            /**
279            * Returns the union of all the user's roles within the groups.
280            *
281            * @param userId the primary key of the user
282            * @param groups the groups (optionally <code>null</code>)
283            * @return the union of all the user's roles within the groups
284            * @throws PortalException if a portal exception occurred
285            * @throws SystemException if a system exception occurred
286            */
287            public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles(
288                    long userId, com.liferay.portal.model.GroupSoap[] groups)
289                    throws RemoteException {
290                    try {
291                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId,
292                                            com.liferay.portal.model.impl.GroupModelImpl.toModels(
293                                                    groups));
294    
295                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
296                    }
297                    catch (Exception e) {
298                            _log.error(e, e);
299    
300                            throw new RemoteException(e.getMessage());
301                    }
302            }
303    
304            /**
305            * Returns all the roles associated with the user.
306            *
307            * @param userId the primary key of the user
308            * @return the roles associated with the user
309            * @throws PortalException if a portal exception occurred
310            * @throws SystemException if a system exception occurred
311            */
312            public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId)
313                    throws RemoteException {
314                    try {
315                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId);
316    
317                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
318                    }
319                    catch (Exception e) {
320                            _log.error(e, e);
321    
322                            throw new RemoteException(e.getMessage());
323                    }
324            }
325    
326            /**
327            * Returns <code>true</code> if the user is associated with the named
328            * regular role.
329            *
330            * @param userId the primary key of the user
331            * @param companyId the primary key of the company
332            * @param name the name of the role
333            * @param inherited whether to include the user's inherited roles in the
334            search
335            * @return <code>true</code> if the user is associated with the regular
336            role; <code>false</code> otherwise
337            * @throws PortalException if a role with the name could not be found in the
338            company or if a default user for the company could not be found
339            * @throws SystemException if a system exception occurred
340            */
341            public static boolean hasUserRole(long userId, long companyId,
342                    java.lang.String name, boolean inherited) throws RemoteException {
343                    try {
344                            boolean returnValue = RoleServiceUtil.hasUserRole(userId,
345                                            companyId, name, inherited);
346    
347                            return returnValue;
348                    }
349                    catch (Exception e) {
350                            _log.error(e, e);
351    
352                            throw new RemoteException(e.getMessage());
353                    }
354            }
355    
356            /**
357            * Returns <code>true</code> if the user has any one of the named regular
358            * roles.
359            *
360            * @param userId the primary key of the user
361            * @param companyId the primary key of the company
362            * @param names the names of the roles
363            * @param inherited whether to include the user's inherited roles in the
364            search
365            * @return <code>true</code> if the user has any one of the regular roles;
366            <code>false</code> otherwise
367            * @throws PortalException if any one of the roles with the names could not
368            be found in the company or if the default user for the company
369            could not be found
370            * @throws SystemException if a system exception occurred
371            */
372            public static boolean hasUserRoles(long userId, long companyId,
373                    java.lang.String[] names, boolean inherited) throws RemoteException {
374                    try {
375                            boolean returnValue = RoleServiceUtil.hasUserRoles(userId,
376                                            companyId, names, inherited);
377    
378                            return returnValue;
379                    }
380                    catch (Exception e) {
381                            _log.error(e, e);
382    
383                            throw new RemoteException(e.getMessage());
384                    }
385            }
386    
387            /**
388            * Removes the matching roles associated with the user. The user is
389            * reindexed after the roles are removed.
390            *
391            * @param userId the primary key of the user
392            * @param roleIds the primary keys of the roles
393            * @throws PortalException if a user with the primary key could not be
394            found, if the user did not have permission to remove members from
395            a role, or if a role with any one of the primary keys could not
396            be found
397            * @throws SystemException if a system exception occurred
398            */
399            public static void unsetUserRoles(long userId, long[] roleIds)
400                    throws RemoteException {
401                    try {
402                            RoleServiceUtil.unsetUserRoles(userId, roleIds);
403                    }
404                    catch (Exception e) {
405                            _log.error(e, e);
406    
407                            throw new RemoteException(e.getMessage());
408                    }
409            }
410    
411            /**
412            * Updates the role with the primary key.
413            *
414            * @param roleId the primary key of the role
415            * @param name the role's new name
416            * @param titleMap the new localized titles (optionally <code>null</code>)
417            to replace those existing for the role
418            * @param descriptionMap the new localized descriptions (optionally
419            <code>null</code>) to replace those existing for the role
420            * @param subtype the role's new subtype (optionally <code>null</code>)
421            * @return the role with the primary key
422            * @throws PortalException if the user did not have permission to update the
423            role, if a role with the primary could not be found, or if the
424            role's name was invalid
425            * @throws SystemException if a system exception occurred
426            */
427            public static com.liferay.portal.model.RoleSoap updateRole(long roleId,
428                    java.lang.String name, java.lang.String[] titleMapLanguageIds,
429                    java.lang.String[] titleMapValues,
430                    java.lang.String[] descriptionMapLanguageIds,
431                    java.lang.String[] descriptionMapValues, java.lang.String subtype)
432                    throws RemoteException {
433                    try {
434                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
435                                            titleMapValues);
436                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
437                                            descriptionMapValues);
438    
439                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.updateRole(roleId,
440                                            name, titleMap, descriptionMap, subtype);
441    
442                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
443                    }
444                    catch (Exception e) {
445                            _log.error(e, e);
446    
447                            throw new RemoteException(e.getMessage());
448                    }
449            }
450    
451            private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class);
452    }