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 com.liferay.portal.service.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 com.liferay.portal.service.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 /** 206 * Returns all the roles associated with the group. 207 * 208 * @param groupId the primary key of the group 209 * @return the roles associated with the group 210 * @throws PortalException if a portal exception occurred 211 */ 212 public static com.liferay.portal.model.RoleSoap[] getGroupRoles( 213 long groupId) throws RemoteException { 214 try { 215 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId); 216 217 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 218 } 219 catch (Exception e) { 220 _log.error(e, e); 221 222 throw new RemoteException(e.getMessage()); 223 } 224 } 225 226 /** 227 * Returns the role with the primary key. 228 * 229 * @param roleId the primary key of the role 230 * @return the role with the primary key 231 * @throws PortalException if a role with the primary key could not be found 232 or if the user did not have permission to view the role 233 */ 234 public static com.liferay.portal.model.RoleSoap getRole(long roleId) 235 throws RemoteException { 236 try { 237 com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId); 238 239 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 240 } 241 catch (Exception e) { 242 _log.error(e, e); 243 244 throw new RemoteException(e.getMessage()); 245 } 246 } 247 248 /** 249 * Returns the role with the name in the company. 250 * 251 * <p> 252 * The method searches the system roles map first for default roles. If a 253 * role with the name is not found, then the method will query the database. 254 * </p> 255 * 256 * @param companyId the primary key of the company 257 * @param name the role's name 258 * @return the role with the name 259 * @throws PortalException if a role with the name could not be found in the 260 company or if the user did not have permission to view the role 261 */ 262 public static com.liferay.portal.model.RoleSoap getRole(long companyId, 263 java.lang.String name) throws RemoteException { 264 try { 265 com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId, 266 name); 267 268 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 269 } 270 catch (Exception e) { 271 _log.error(e, e); 272 273 throw new RemoteException(e.getMessage()); 274 } 275 } 276 277 /** 278 * Returns all the user's roles within the user group. 279 * 280 * @param userId the primary key of the user 281 * @param groupId the primary key of the group 282 * @return the user's roles within the user group 283 * @throws PortalException if a portal exception occurred 284 */ 285 public static com.liferay.portal.model.RoleSoap[] getUserGroupGroupRoles( 286 long userId, long groupId) throws RemoteException { 287 try { 288 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupGroupRoles(userId, 289 groupId); 290 291 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 292 } 293 catch (Exception e) { 294 _log.error(e, e); 295 296 throw new RemoteException(e.getMessage()); 297 } 298 } 299 300 /** 301 * Returns all the user's roles within the user group. 302 * 303 * @param userId the primary key of the user 304 * @param groupId the primary key of the group 305 * @return the user's roles within the user group 306 * @throws PortalException if a portal exception occurred 307 */ 308 public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles( 309 long userId, long groupId) throws RemoteException { 310 try { 311 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId, 312 groupId); 313 314 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 315 } 316 catch (Exception e) { 317 _log.error(e, e); 318 319 throw new RemoteException(e.getMessage()); 320 } 321 } 322 323 /** 324 * Returns the union of all the user's roles within the groups. 325 * 326 * @param userId the primary key of the user 327 * @param groups the groups (optionally <code>null</code>) 328 * @return the union of all the user's roles within the groups 329 * @throws PortalException if a portal exception occurred 330 */ 331 public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles( 332 long userId, com.liferay.portal.model.GroupSoap[] groups) 333 throws RemoteException { 334 try { 335 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId, 336 com.liferay.portal.model.impl.GroupModelImpl.toModels( 337 groups)); 338 339 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 340 } 341 catch (Exception e) { 342 _log.error(e, e); 343 344 throw new RemoteException(e.getMessage()); 345 } 346 } 347 348 /** 349 * Returns all the roles associated with the user. 350 * 351 * @param userId the primary key of the user 352 * @return the roles associated with the user 353 * @throws PortalException if a portal exception occurred 354 */ 355 public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId) 356 throws RemoteException { 357 try { 358 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId); 359 360 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 361 } 362 catch (Exception e) { 363 _log.error(e, e); 364 365 throw new RemoteException(e.getMessage()); 366 } 367 } 368 369 /** 370 * Returns <code>true</code> if the user is associated with the named 371 * regular role. 372 * 373 * @param userId the primary key of the user 374 * @param companyId the primary key of the company 375 * @param name the name of the role 376 * @param inherited whether to include the user's inherited roles in the 377 search 378 * @return <code>true</code> if the user is associated with the regular 379 role; <code>false</code> otherwise 380 * @throws PortalException if a role with the name could not be found in the 381 company or if a default user for the company could not be found 382 */ 383 public static boolean hasUserRole(long userId, long companyId, 384 java.lang.String name, boolean inherited) throws RemoteException { 385 try { 386 boolean returnValue = RoleServiceUtil.hasUserRole(userId, 387 companyId, name, inherited); 388 389 return returnValue; 390 } 391 catch (Exception e) { 392 _log.error(e, e); 393 394 throw new RemoteException(e.getMessage()); 395 } 396 } 397 398 /** 399 * Returns <code>true</code> if the user has any one of the named regular 400 * roles. 401 * 402 * @param userId the primary key of the user 403 * @param companyId the primary key of the company 404 * @param names the names of the roles 405 * @param inherited whether to include the user's inherited roles in the 406 search 407 * @return <code>true</code> if the user has any one of the regular roles; 408 <code>false</code> otherwise 409 * @throws PortalException if any one of the roles with the names could not 410 be found in the company or if the default user for the company 411 could not be found 412 */ 413 public static boolean hasUserRoles(long userId, long companyId, 414 java.lang.String[] names, boolean inherited) throws RemoteException { 415 try { 416 boolean returnValue = RoleServiceUtil.hasUserRoles(userId, 417 companyId, names, inherited); 418 419 return returnValue; 420 } 421 catch (Exception e) { 422 _log.error(e, e); 423 424 throw new RemoteException(e.getMessage()); 425 } 426 } 427 428 /** 429 * Removes the matching roles associated with the user. The user is 430 * reindexed after the roles are removed. 431 * 432 * @param userId the primary key of the user 433 * @param roleIds the primary keys of the roles 434 * @throws PortalException if a user with the primary key could not be 435 found, if the user did not have permission to remove members from 436 a role, or if a role with any one of the primary keys could not 437 be found 438 */ 439 public static void unsetUserRoles(long userId, long[] roleIds) 440 throws RemoteException { 441 try { 442 RoleServiceUtil.unsetUserRoles(userId, roleIds); 443 } 444 catch (Exception e) { 445 _log.error(e, e); 446 447 throw new RemoteException(e.getMessage()); 448 } 449 } 450 451 /** 452 * Updates the role with the primary key. 453 * 454 * @param roleId the primary key of the role 455 * @param name the role's new name 456 * @param titleMap the new localized titles (optionally <code>null</code>) 457 to replace those existing for the role 458 * @param descriptionMap the new localized descriptions (optionally 459 <code>null</code>) to replace those existing for the role 460 * @param subtype the role's new subtype (optionally <code>null</code>) 461 * @param serviceContext the service context to be applied (optionally 462 <code>null</code>). Can set the expando bridge attributes for the 463 role. 464 * @return the role with the primary key 465 * @throws PortalException if the user did not have permission to update the 466 role, if a role with the primary could not be found, or if the 467 role's name was invalid 468 */ 469 public static com.liferay.portal.model.RoleSoap updateRole(long roleId, 470 java.lang.String name, java.lang.String[] titleMapLanguageIds, 471 java.lang.String[] titleMapValues, 472 java.lang.String[] descriptionMapLanguageIds, 473 java.lang.String[] descriptionMapValues, java.lang.String subtype, 474 com.liferay.portal.service.ServiceContext serviceContext) 475 throws RemoteException { 476 try { 477 Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds, 478 titleMapValues); 479 Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds, 480 descriptionMapValues); 481 482 com.liferay.portal.model.Role returnValue = RoleServiceUtil.updateRole(roleId, 483 name, titleMap, descriptionMap, subtype, serviceContext); 484 485 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 486 } 487 catch (Exception e) { 488 _log.error(e, e); 489 490 throw new RemoteException(e.getMessage()); 491 } 492 } 493 494 private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class); 495 }