001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    import com.liferay.portal.kernel.util.LocalizationUtil;
022    import com.liferay.portal.service.RoleServiceUtil;
023    
024    import java.rmi.RemoteException;
025    
026    import java.util.Locale;
027    import java.util.Map;
028    
029    /**
030     * Provides the SOAP utility for the
031     * {@link RoleServiceUtil} service utility. The
032     * static methods of this class calls the same methods of the service utility.
033     * However, the signatures are different because it is difficult for SOAP to
034     * support certain types.
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 http://localhost:8080/api/axis. Set the
055     * property <b>axis.servlet.hosts.allowed</b> in portal.properties to configure
056     * security.
057     * </p>
058     *
059     * <p>
060     * The SOAP utility is only generated for remote services.
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see RoleServiceHttp
065     * @see com.liferay.portal.model.RoleSoap
066     * @see RoleServiceUtil
067     * @generated
068     */
069    @ProviderType
070    public class RoleServiceSoap {
071            /**
072            * Adds a role. The user is reindexed after role is added.
073            *
074            * @param className the name of the class for which the role is created
075            * @param classPK the primary key of the class for which the role is
076            created (optionally <code>0</code>)
077            * @param name the role's name
078            * @param titleMap the role's localized titles (optionally
079            <code>null</code>)
080            * @param descriptionMap the role's localized descriptions (optionally
081            <code>null</code>)
082            * @param type the role's type (optionally <code>0</code>)
083            * @param subtype the role's subtype (optionally <code>null</code>)
084            * @param serviceContext the service context to be applied (optionally
085            <code>null</code>). Can set the expando bridge attributes for the
086            role.
087            * @return the role
088            * @throws PortalException if a user with the primary key could not be
089            found, if the user did not have permission to add roles, if the
090            class name or the role name were invalid, or if the role is a
091            duplicate
092            */
093            public static com.liferay.portal.model.RoleSoap addRole(
094                    java.lang.String className, long classPK, java.lang.String name,
095                    java.lang.String[] titleMapLanguageIds,
096                    java.lang.String[] titleMapValues,
097                    java.lang.String[] descriptionMapLanguageIds,
098                    java.lang.String[] descriptionMapValues, int type,
099                    java.lang.String subtype,
100                    com.liferay.portal.service.ServiceContext serviceContext)
101                    throws RemoteException {
102                    try {
103                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
104                                            titleMapValues);
105                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
106                                            descriptionMapValues);
107    
108                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.addRole(className,
109                                            classPK, name, titleMap, descriptionMap, type, subtype,
110                                            serviceContext);
111    
112                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
113                    }
114                    catch (Exception e) {
115                            _log.error(e, e);
116    
117                            throw new RemoteException(e.getMessage());
118                    }
119            }
120    
121            /**
122            * Adds a role. The user is reindexed after role is added.
123            *
124            * @param name the role's name
125            * @param titleMap the role's localized titles (optionally
126            <code>null</code>)
127            * @param descriptionMap the role's localized descriptions (optionally
128            <code>null</code>)
129            * @param type the role's type (optionally <code>0</code>)
130            * @return the role
131            * @throws PortalException if a user with the primary key could not be
132            found, if the user did not have permission to add roles, if
133            the class name or the role name were invalid, or if the role
134            is a duplicate
135            * @deprecated As of 6.2.0, replaced by {@link #addRole(String, long,
136            String, Map, Map, int, String, ServiceContext)}
137            */
138            @Deprecated
139            public static com.liferay.portal.model.RoleSoap addRole(
140                    java.lang.String name, java.lang.String[] titleMapLanguageIds,
141                    java.lang.String[] titleMapValues,
142                    java.lang.String[] descriptionMapLanguageIds,
143                    java.lang.String[] descriptionMapValues, int type)
144                    throws RemoteException {
145                    try {
146                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
147                                            titleMapValues);
148                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
149                                            descriptionMapValues);
150    
151                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.addRole(name,
152                                            titleMap, descriptionMap, type);
153    
154                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
155                    }
156                    catch (Exception e) {
157                            _log.error(e, e);
158    
159                            throw new RemoteException(e.getMessage());
160                    }
161            }
162    
163            /**
164            * Adds the roles to the user. The user is reindexed after the roles are
165            * added.
166            *
167            * @param userId the primary key of the user
168            * @param roleIds the primary keys of the roles
169            * @throws PortalException if a user with the primary key could not be found
170            or if the user did not have permission to assign members to one
171            of the roles
172            */
173            public static void addUserRoles(long userId, long[] roleIds)
174                    throws RemoteException {
175                    try {
176                            RoleServiceUtil.addUserRoles(userId, roleIds);
177                    }
178                    catch (Exception e) {
179                            _log.error(e, e);
180    
181                            throw new RemoteException(e.getMessage());
182                    }
183            }
184    
185            /**
186            * Deletes the role with the primary key and its associated permissions.
187            *
188            * @param roleId the primary key of the role
189            * @throws PortalException if the user did not have permission to delete the
190            role, if a role with the primary key could not be found, if the
191            role is a default system role, or if the role's resource could
192            not be found
193            */
194            public static void deleteRole(long roleId) throws RemoteException {
195                    try {
196                            RoleServiceUtil.deleteRole(roleId);
197                    }
198                    catch (Exception e) {
199                            _log.error(e, e);
200    
201                            throw new RemoteException(e.getMessage());
202                    }
203            }
204    
205            public static com.liferay.portal.model.RoleSoap fetchRole(long roleId)
206                    throws RemoteException {
207                    try {
208                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.fetchRole(roleId);
209    
210                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
211                    }
212                    catch (Exception e) {
213                            _log.error(e, e);
214    
215                            throw new RemoteException(e.getMessage());
216                    }
217            }
218    
219            /**
220            * Returns all the roles associated with the group.
221            *
222            * @param groupId the primary key of the group
223            * @return the roles associated with the group
224            * @throws PortalException if a portal exception occurred
225            */
226            public static com.liferay.portal.model.RoleSoap[] getGroupRoles(
227                    long groupId) throws RemoteException {
228                    try {
229                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId);
230    
231                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
232                    }
233                    catch (Exception e) {
234                            _log.error(e, e);
235    
236                            throw new RemoteException(e.getMessage());
237                    }
238            }
239    
240            /**
241            * Returns the role with the primary key.
242            *
243            * @param roleId the primary key of the role
244            * @return the role with the primary key
245            * @throws PortalException if a role with the primary key could not be found
246            or if the user did not have permission to view the role
247            */
248            public static com.liferay.portal.model.RoleSoap getRole(long roleId)
249                    throws RemoteException {
250                    try {
251                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId);
252    
253                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
254                    }
255                    catch (Exception e) {
256                            _log.error(e, e);
257    
258                            throw new RemoteException(e.getMessage());
259                    }
260            }
261    
262            /**
263            * Returns the role with the name in the company.
264            *
265            * <p>
266            * The method searches the system roles map first for default roles. If a
267            * role with the name is not found, then the method will query the database.
268            * </p>
269            *
270            * @param companyId the primary key of the company
271            * @param name the role's name
272            * @return the role with the name
273            * @throws PortalException if a role with the name could not be found in the
274            company or if the user did not have permission to view the role
275            */
276            public static com.liferay.portal.model.RoleSoap getRole(long companyId,
277                    java.lang.String name) throws RemoteException {
278                    try {
279                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId,
280                                            name);
281    
282                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
283                    }
284                    catch (Exception e) {
285                            _log.error(e, e);
286    
287                            throw new RemoteException(e.getMessage());
288                    }
289            }
290    
291            public static com.liferay.portal.model.RoleSoap[] getRoles(int type,
292                    java.lang.String subtype) throws RemoteException {
293                    try {
294                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getRoles(type,
295                                            subtype);
296    
297                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
298                    }
299                    catch (Exception e) {
300                            _log.error(e, e);
301    
302                            throw new RemoteException(e.getMessage());
303                    }
304            }
305    
306            public static com.liferay.portal.model.RoleSoap[] getRoles(long companyId,
307                    int[] types) throws RemoteException {
308                    try {
309                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getRoles(companyId,
310                                            types);
311    
312                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
313                    }
314                    catch (Exception e) {
315                            _log.error(e, e);
316    
317                            throw new RemoteException(e.getMessage());
318                    }
319            }
320    
321            /**
322            * Returns all the user's roles within the user group.
323            *
324            * @param userId the primary key of the user
325            * @param groupId the primary key of the group
326            * @return the user's roles within the user group
327            * @throws PortalException if a portal exception occurred
328            */
329            public static com.liferay.portal.model.RoleSoap[] getUserGroupGroupRoles(
330                    long userId, long groupId) throws RemoteException {
331                    try {
332                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupGroupRoles(userId,
333                                            groupId);
334    
335                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
336                    }
337                    catch (Exception e) {
338                            _log.error(e, e);
339    
340                            throw new RemoteException(e.getMessage());
341                    }
342            }
343    
344            /**
345            * Returns all the user's roles within the user group.
346            *
347            * @param userId the primary key of the user
348            * @param groupId the primary key of the group
349            * @return the user's roles within the user group
350            * @throws PortalException if a portal exception occurred
351            */
352            public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles(
353                    long userId, long groupId) throws RemoteException {
354                    try {
355                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId,
356                                            groupId);
357    
358                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
359                    }
360                    catch (Exception e) {
361                            _log.error(e, e);
362    
363                            throw new RemoteException(e.getMessage());
364                    }
365            }
366    
367            /**
368            * Returns the union of all the user's roles within the groups.
369            *
370            * @param userId the primary key of the user
371            * @param groups the groups (optionally <code>null</code>)
372            * @return the union of all the user's roles within the groups
373            * @throws PortalException if a portal exception occurred
374            */
375            public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles(
376                    long userId, com.liferay.portal.model.GroupSoap[] groups)
377                    throws RemoteException {
378                    try {
379                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId,
380                                            com.liferay.portal.model.impl.GroupModelImpl.toModels(
381                                                    groups));
382    
383                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
384                    }
385                    catch (Exception e) {
386                            _log.error(e, e);
387    
388                            throw new RemoteException(e.getMessage());
389                    }
390            }
391    
392            /**
393            * Returns all the roles associated with the user.
394            *
395            * @param userId the primary key of the user
396            * @return the roles associated with the user
397            * @throws PortalException if a portal exception occurred
398            */
399            public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId)
400                    throws RemoteException {
401                    try {
402                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId);
403    
404                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
405                    }
406                    catch (Exception e) {
407                            _log.error(e, e);
408    
409                            throw new RemoteException(e.getMessage());
410                    }
411            }
412    
413            /**
414            * Returns <code>true</code> if the user is associated with the named
415            * regular role.
416            *
417            * @param userId the primary key of the user
418            * @param companyId the primary key of the company
419            * @param name the name of the role
420            * @param inherited whether to include the user's inherited roles in the
421            search
422            * @return <code>true</code> if the user is associated with the regular
423            role; <code>false</code> otherwise
424            * @throws PortalException if a role with the name could not be found in the
425            company or if a default user for the company could not be found
426            */
427            public static boolean hasUserRole(long userId, long companyId,
428                    java.lang.String name, boolean inherited) throws RemoteException {
429                    try {
430                            boolean returnValue = RoleServiceUtil.hasUserRole(userId,
431                                            companyId, name, inherited);
432    
433                            return returnValue;
434                    }
435                    catch (Exception e) {
436                            _log.error(e, e);
437    
438                            throw new RemoteException(e.getMessage());
439                    }
440            }
441    
442            /**
443            * Returns <code>true</code> if the user has any one of the named regular
444            * roles.
445            *
446            * @param userId the primary key of the user
447            * @param companyId the primary key of the company
448            * @param names the names of the roles
449            * @param inherited whether to include the user's inherited roles in the
450            search
451            * @return <code>true</code> if the user has any one of the regular roles;
452            <code>false</code> otherwise
453            * @throws PortalException if any one of the roles with the names could not
454            be found in the company or if the default user for the company
455            could not be found
456            */
457            public static boolean hasUserRoles(long userId, long companyId,
458                    java.lang.String[] names, boolean inherited) throws RemoteException {
459                    try {
460                            boolean returnValue = RoleServiceUtil.hasUserRoles(userId,
461                                            companyId, names, inherited);
462    
463                            return returnValue;
464                    }
465                    catch (Exception e) {
466                            _log.error(e, e);
467    
468                            throw new RemoteException(e.getMessage());
469                    }
470            }
471    
472            /**
473            * Removes the matching roles associated with the user. The user is
474            * reindexed after the roles are removed.
475            *
476            * @param userId the primary key of the user
477            * @param roleIds the primary keys of the roles
478            * @throws PortalException if a user with the primary key could not be
479            found, if the user did not have permission to remove members from
480            a role, or if a role with any one of the primary keys could not
481            be found
482            */
483            public static void unsetUserRoles(long userId, long[] roleIds)
484                    throws RemoteException {
485                    try {
486                            RoleServiceUtil.unsetUserRoles(userId, roleIds);
487                    }
488                    catch (Exception e) {
489                            _log.error(e, e);
490    
491                            throw new RemoteException(e.getMessage());
492                    }
493            }
494    
495            /**
496            * Updates the role with the primary key.
497            *
498            * @param roleId the primary key of the role
499            * @param name the role's new name
500            * @param titleMap the new localized titles (optionally <code>null</code>)
501            to replace those existing for the role
502            * @param descriptionMap the new localized descriptions (optionally
503            <code>null</code>) to replace those existing for the role
504            * @param subtype the role's new subtype (optionally <code>null</code>)
505            * @param serviceContext the service context to be applied (optionally
506            <code>null</code>). Can set the expando bridge attributes for the
507            role.
508            * @return the role with the primary key
509            * @throws PortalException if the user did not have permission to update the
510            role, if a role with the primary could not be found, or if the
511            role's name was invalid
512            */
513            public static com.liferay.portal.model.RoleSoap updateRole(long roleId,
514                    java.lang.String name, java.lang.String[] titleMapLanguageIds,
515                    java.lang.String[] titleMapValues,
516                    java.lang.String[] descriptionMapLanguageIds,
517                    java.lang.String[] descriptionMapValues, java.lang.String subtype,
518                    com.liferay.portal.service.ServiceContext serviceContext)
519                    throws RemoteException {
520                    try {
521                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
522                                            titleMapValues);
523                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
524                                            descriptionMapValues);
525    
526                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.updateRole(roleId,
527                                            name, titleMap, descriptionMap, subtype, serviceContext);
528    
529                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
530                    }
531                    catch (Exception e) {
532                            _log.error(e, e);
533    
534                            throw new RemoteException(e.getMessage());
535                    }
536            }
537    
538            private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class);
539    }