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            */
089            public static com.liferay.portal.model.RoleSoap addRole(
090                    java.lang.String className, long classPK, java.lang.String name,
091                    java.lang.String[] titleMapLanguageIds,
092                    java.lang.String[] titleMapValues,
093                    java.lang.String[] descriptionMapLanguageIds,
094                    java.lang.String[] descriptionMapValues, int type,
095                    java.lang.String subtype,
096                    com.liferay.portal.service.ServiceContext serviceContext)
097                    throws RemoteException {
098                    try {
099                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
100                                            titleMapValues);
101                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
102                                            descriptionMapValues);
103    
104                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.addRole(className,
105                                            classPK, name, titleMap, descriptionMap, type, subtype,
106                                            serviceContext);
107    
108                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
109                    }
110                    catch (Exception e) {
111                            _log.error(e, e);
112    
113                            throw new RemoteException(e.getMessage());
114                    }
115            }
116    
117            /**
118            * Adds the roles to the user. The user is reindexed after the roles are
119            * added.
120            *
121            * @param userId the primary key of the user
122            * @param roleIds the primary keys of the roles
123            */
124            public static void addUserRoles(long userId, long[] roleIds)
125                    throws RemoteException {
126                    try {
127                            RoleServiceUtil.addUserRoles(userId, roleIds);
128                    }
129                    catch (Exception e) {
130                            _log.error(e, e);
131    
132                            throw new RemoteException(e.getMessage());
133                    }
134            }
135    
136            /**
137            * Deletes the role with the primary key and its associated permissions.
138            *
139            * @param roleId the primary key of the role
140            */
141            public static void deleteRole(long roleId) throws RemoteException {
142                    try {
143                            RoleServiceUtil.deleteRole(roleId);
144                    }
145                    catch (Exception e) {
146                            _log.error(e, e);
147    
148                            throw new RemoteException(e.getMessage());
149                    }
150            }
151    
152            public static com.liferay.portal.model.RoleSoap fetchRole(long roleId)
153                    throws RemoteException {
154                    try {
155                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.fetchRole(roleId);
156    
157                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
158                    }
159                    catch (Exception e) {
160                            _log.error(e, e);
161    
162                            throw new RemoteException(e.getMessage());
163                    }
164            }
165    
166            /**
167            * Returns all the roles associated with the group.
168            *
169            * @param groupId the primary key of the group
170            * @return the roles associated with the group
171            */
172            public static com.liferay.portal.model.RoleSoap[] getGroupRoles(
173                    long groupId) throws RemoteException {
174                    try {
175                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId);
176    
177                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
178                    }
179                    catch (Exception e) {
180                            _log.error(e, e);
181    
182                            throw new RemoteException(e.getMessage());
183                    }
184            }
185    
186            /**
187            * Returns the role with the primary key.
188            *
189            * @param roleId the primary key of the role
190            * @return the role with the primary key
191            */
192            public static com.liferay.portal.model.RoleSoap getRole(long roleId)
193                    throws RemoteException {
194                    try {
195                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId);
196    
197                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
198                    }
199                    catch (Exception e) {
200                            _log.error(e, e);
201    
202                            throw new RemoteException(e.getMessage());
203                    }
204            }
205    
206            /**
207            * Returns the role with the name in the company.
208            *
209            * <p>
210            * The method searches the system roles map first for default roles. If a
211            * role with the name is not found, then the method will query the database.
212            * </p>
213            *
214            * @param companyId the primary key of the company
215            * @param name the role's name
216            * @return the role with the name
217            */
218            public static com.liferay.portal.model.RoleSoap getRole(long companyId,
219                    java.lang.String name) throws RemoteException {
220                    try {
221                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId,
222                                            name);
223    
224                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
225                    }
226                    catch (Exception e) {
227                            _log.error(e, e);
228    
229                            throw new RemoteException(e.getMessage());
230                    }
231            }
232    
233            public static com.liferay.portal.model.RoleSoap[] getRoles(int type,
234                    java.lang.String subtype) throws RemoteException {
235                    try {
236                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getRoles(type,
237                                            subtype);
238    
239                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
240                    }
241                    catch (Exception e) {
242                            _log.error(e, e);
243    
244                            throw new RemoteException(e.getMessage());
245                    }
246            }
247    
248            public static com.liferay.portal.model.RoleSoap[] getRoles(long companyId,
249                    int[] types) throws RemoteException {
250                    try {
251                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getRoles(companyId,
252                                            types);
253    
254                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
255                    }
256                    catch (Exception e) {
257                            _log.error(e, e);
258    
259                            throw new RemoteException(e.getMessage());
260                    }
261            }
262    
263            /**
264            * Returns all the user's roles within the user group.
265            *
266            * @param userId the primary key of the user
267            * @param groupId the primary key of the group
268            * @return the user's roles within the user group
269            */
270            public static com.liferay.portal.model.RoleSoap[] getUserGroupGroupRoles(
271                    long userId, long groupId) throws RemoteException {
272                    try {
273                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupGroupRoles(userId,
274                                            groupId);
275    
276                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
277                    }
278                    catch (Exception e) {
279                            _log.error(e, e);
280    
281                            throw new RemoteException(e.getMessage());
282                    }
283            }
284    
285            /**
286            * Returns all the user's roles within the user group.
287            *
288            * @param userId the primary key of the user
289            * @param groupId the primary key of the group
290            * @return the user's roles within the user group
291            */
292            public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles(
293                    long userId, long groupId) throws RemoteException {
294                    try {
295                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId,
296                                            groupId);
297    
298                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
299                    }
300                    catch (Exception e) {
301                            _log.error(e, e);
302    
303                            throw new RemoteException(e.getMessage());
304                    }
305            }
306    
307            /**
308            * Returns the union of all the user's roles within the groups.
309            *
310            * @param userId the primary key of the user
311            * @param groups the groups (optionally <code>null</code>)
312            * @return the union of all the user's roles within the groups
313            */
314            public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles(
315                    long userId, com.liferay.portal.model.GroupSoap[] groups)
316                    throws RemoteException {
317                    try {
318                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId,
319                                            com.liferay.portal.model.impl.GroupModelImpl.toModels(
320                                                    groups));
321    
322                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
323                    }
324                    catch (Exception e) {
325                            _log.error(e, e);
326    
327                            throw new RemoteException(e.getMessage());
328                    }
329            }
330    
331            /**
332            * Returns all the roles associated with the user.
333            *
334            * @param userId the primary key of the user
335            * @return the roles associated with the user
336            */
337            public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId)
338                    throws RemoteException {
339                    try {
340                            java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId);
341    
342                            return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue);
343                    }
344                    catch (Exception e) {
345                            _log.error(e, e);
346    
347                            throw new RemoteException(e.getMessage());
348                    }
349            }
350    
351            /**
352            * Returns <code>true</code> if the user is associated with the named
353            * regular role.
354            *
355            * @param userId the primary key of the user
356            * @param companyId the primary key of the company
357            * @param name the name of the role
358            * @param inherited whether to include the user's inherited roles in the
359            search
360            * @return <code>true</code> if the user is associated with the regular
361            role; <code>false</code> otherwise
362            */
363            public static boolean hasUserRole(long userId, long companyId,
364                    java.lang.String name, boolean inherited) throws RemoteException {
365                    try {
366                            boolean returnValue = RoleServiceUtil.hasUserRole(userId,
367                                            companyId, name, inherited);
368    
369                            return returnValue;
370                    }
371                    catch (Exception e) {
372                            _log.error(e, e);
373    
374                            throw new RemoteException(e.getMessage());
375                    }
376            }
377    
378            /**
379            * Returns <code>true</code> if the user has any one of the named regular
380            * roles.
381            *
382            * @param userId the primary key of the user
383            * @param companyId the primary key of the company
384            * @param names the names of the roles
385            * @param inherited whether to include the user's inherited roles in the
386            search
387            * @return <code>true</code> if the user has any one of the regular roles;
388            <code>false</code> otherwise
389            */
390            public static boolean hasUserRoles(long userId, long companyId,
391                    java.lang.String[] names, boolean inherited) throws RemoteException {
392                    try {
393                            boolean returnValue = RoleServiceUtil.hasUserRoles(userId,
394                                            companyId, names, inherited);
395    
396                            return returnValue;
397                    }
398                    catch (Exception e) {
399                            _log.error(e, e);
400    
401                            throw new RemoteException(e.getMessage());
402                    }
403            }
404    
405            /**
406            * Removes the matching roles associated with the user. The user is
407            * reindexed after the roles are removed.
408            *
409            * @param userId the primary key of the user
410            * @param roleIds the primary keys of the roles
411            */
412            public static void unsetUserRoles(long userId, long[] roleIds)
413                    throws RemoteException {
414                    try {
415                            RoleServiceUtil.unsetUserRoles(userId, roleIds);
416                    }
417                    catch (Exception e) {
418                            _log.error(e, e);
419    
420                            throw new RemoteException(e.getMessage());
421                    }
422            }
423    
424            /**
425            * Updates the role with the primary key.
426            *
427            * @param roleId the primary key of the role
428            * @param name the role's new name
429            * @param titleMap the new localized titles (optionally <code>null</code>)
430            to replace those existing for the role
431            * @param descriptionMap the new localized descriptions (optionally
432            <code>null</code>) to replace those existing for the role
433            * @param subtype the role's new subtype (optionally <code>null</code>)
434            * @param serviceContext the service context to be applied (optionally
435            <code>null</code>). Can set the expando bridge attributes for the
436            role.
437            * @return the role with the primary key
438            */
439            public static com.liferay.portal.model.RoleSoap updateRole(long roleId,
440                    java.lang.String name, java.lang.String[] titleMapLanguageIds,
441                    java.lang.String[] titleMapValues,
442                    java.lang.String[] descriptionMapLanguageIds,
443                    java.lang.String[] descriptionMapValues, java.lang.String subtype,
444                    com.liferay.portal.service.ServiceContext serviceContext)
445                    throws RemoteException {
446                    try {
447                            Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds,
448                                            titleMapValues);
449                            Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds,
450                                            descriptionMapValues);
451    
452                            com.liferay.portal.model.Role returnValue = RoleServiceUtil.updateRole(roleId,
453                                            name, titleMap, descriptionMap, subtype, serviceContext);
454    
455                            return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue);
456                    }
457                    catch (Exception e) {
458                            _log.error(e, e);
459    
460                            throw new RemoteException(e.getMessage());
461                    }
462            }
463    
464            private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class);
465    }