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 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 public class RoleServiceSoap { 070 /** 071 * Adds a role. The user is reindexed after role is added. 072 * 073 * @param className the name of the class for which the role is created 074 * @param classPK the primary key of the class for which the role is 075 created (optionally <code>0</code>) 076 * @param name the role's name 077 * @param titleMap the role's localized titles (optionally 078 <code>null</code>) 079 * @param descriptionMap the role's localized descriptions (optionally 080 <code>null</code>) 081 * @param type the role's type (optionally <code>0</code>) 082 * @param subType the role's subtype (optionally <code>null</code>) 083 * @param serviceContext the role's service context (optionally 084 <code>null</code>). Can set the expando bridge attributes for the 085 role. 086 * @return the role 087 * @throws PortalException if a user with the primary key could not be 088 found, if the user did not have permission to add roles, if the 089 class name or the role name were invalid, or if the role is a 090 duplicate 091 * @throws SystemException if a system exception occurred 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 * @throws SystemException if a system exception occurred 136 * @deprecated {@link #addRole(String, long, String, Map, Map, int, String, 137 ServiceContext)} 138 */ 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 * @throws SystemException if a system exception occurred 173 */ 174 public static void addUserRoles(long userId, long[] roleIds) 175 throws RemoteException { 176 try { 177 RoleServiceUtil.addUserRoles(userId, roleIds); 178 } 179 catch (Exception e) { 180 _log.error(e, e); 181 182 throw new RemoteException(e.getMessage()); 183 } 184 } 185 186 /** 187 * Deletes the role with the primary key and its associated permissions. 188 * 189 * @param roleId the primary key of the role 190 * @throws PortalException if the user did not have permission to delete the 191 role, if a role with the primary key could not be found, if the 192 role is a default system role, or if the role's resource could 193 not be found 194 * @throws SystemException if a system exception occurred 195 */ 196 public static void deleteRole(long roleId) throws RemoteException { 197 try { 198 RoleServiceUtil.deleteRole(roleId); 199 } 200 catch (Exception e) { 201 _log.error(e, e); 202 203 throw new RemoteException(e.getMessage()); 204 } 205 } 206 207 /** 208 * Returns all the roles associated with the group. 209 * 210 * @param groupId the primary key of the group 211 * @return the roles associated with the group 212 * @throws PortalException if a portal exception occurred 213 * @throws SystemException if a system exception occurred 214 */ 215 public static com.liferay.portal.model.RoleSoap[] getGroupRoles( 216 long groupId) throws RemoteException { 217 try { 218 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId); 219 220 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 221 } 222 catch (Exception e) { 223 _log.error(e, e); 224 225 throw new RemoteException(e.getMessage()); 226 } 227 } 228 229 /** 230 * Returns the role with the primary key. 231 * 232 * @param roleId the primary key of the role 233 * @return the role with the primary key 234 * @throws PortalException if a role with the primary key could not be found 235 or if the user did not have permission to view the role 236 * @throws SystemException if a system exception occurred 237 */ 238 public static com.liferay.portal.model.RoleSoap getRole(long roleId) 239 throws RemoteException { 240 try { 241 com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId); 242 243 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 244 } 245 catch (Exception e) { 246 _log.error(e, e); 247 248 throw new RemoteException(e.getMessage()); 249 } 250 } 251 252 /** 253 * Returns the role with the name in the company. 254 * 255 * <p> 256 * The method searches the system roles map first for default roles. If a 257 * role with the name is not found, then the method will query the database. 258 * </p> 259 * 260 * @param companyId the primary key of the company 261 * @param name the role's name 262 * @return the role with the name 263 * @throws PortalException if a role with the name could not be found in the 264 company or if the user did not have permission to view the role 265 * @throws SystemException if a system exception occurred 266 */ 267 public static com.liferay.portal.model.RoleSoap getRole(long companyId, 268 java.lang.String name) throws RemoteException { 269 try { 270 com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId, 271 name); 272 273 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 274 } 275 catch (Exception e) { 276 _log.error(e, e); 277 278 throw new RemoteException(e.getMessage()); 279 } 280 } 281 282 /** 283 * Returns all the user's roles within the user group. 284 * 285 * @param userId the primary key of the user 286 * @param groupId the primary key of the group 287 * @return the user's roles within the user group 288 * @throws PortalException if a portal exception occurred 289 * @throws SystemException if a system exception occurred 290 */ 291 public static com.liferay.portal.model.RoleSoap[] getUserGroupGroupRoles( 292 long userId, long groupId) throws RemoteException { 293 try { 294 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupGroupRoles(userId, 295 groupId); 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 /** 307 * Returns all the user's roles within the user group. 308 * 309 * @param userId the primary key of the user 310 * @param groupId the primary key of the group 311 * @return the user's roles within the user group 312 * @throws PortalException if a portal exception occurred 313 * @throws SystemException if a system exception occurred 314 */ 315 public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles( 316 long userId, long groupId) throws RemoteException { 317 try { 318 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId, 319 groupId); 320 321 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 322 } 323 catch (Exception e) { 324 _log.error(e, e); 325 326 throw new RemoteException(e.getMessage()); 327 } 328 } 329 330 /** 331 * Returns the union of all the user's roles within the groups. 332 * 333 * @param userId the primary key of the user 334 * @param groups the groups (optionally <code>null</code>) 335 * @return the union of all the user's roles within the groups 336 * @throws PortalException if a portal exception occurred 337 * @throws SystemException if a system exception occurred 338 */ 339 public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles( 340 long userId, com.liferay.portal.model.GroupSoap[] groups) 341 throws RemoteException { 342 try { 343 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId, 344 com.liferay.portal.model.impl.GroupModelImpl.toModels( 345 groups)); 346 347 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 348 } 349 catch (Exception e) { 350 _log.error(e, e); 351 352 throw new RemoteException(e.getMessage()); 353 } 354 } 355 356 /** 357 * Returns all the roles associated with the user. 358 * 359 * @param userId the primary key of the user 360 * @return the roles associated with the user 361 * @throws PortalException if a portal exception occurred 362 * @throws SystemException if a system exception occurred 363 */ 364 public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId) 365 throws RemoteException { 366 try { 367 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId); 368 369 return com.liferay.portal.model.RoleSoap.toSoapModels(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 is associated with the named 380 * regular role. 381 * 382 * @param userId the primary key of the user 383 * @param companyId the primary key of the company 384 * @param name the name of the role 385 * @param inherited whether to include the user's inherited roles in the 386 search 387 * @return <code>true</code> if the user is associated with the regular 388 role; <code>false</code> otherwise 389 * @throws PortalException if a role with the name could not be found in the 390 company or if a default user for the company could not be found 391 * @throws SystemException if a system exception occurred 392 */ 393 public static boolean hasUserRole(long userId, long companyId, 394 java.lang.String name, boolean inherited) throws RemoteException { 395 try { 396 boolean returnValue = RoleServiceUtil.hasUserRole(userId, 397 companyId, name, inherited); 398 399 return returnValue; 400 } 401 catch (Exception e) { 402 _log.error(e, e); 403 404 throw new RemoteException(e.getMessage()); 405 } 406 } 407 408 /** 409 * Returns <code>true</code> if the user has any one of the named regular 410 * roles. 411 * 412 * @param userId the primary key of the user 413 * @param companyId the primary key of the company 414 * @param names the names of the roles 415 * @param inherited whether to include the user's inherited roles in the 416 search 417 * @return <code>true</code> if the user has any one of the regular roles; 418 <code>false</code> otherwise 419 * @throws PortalException if any one of the roles with the names could not 420 be found in the company or if the default user for the company 421 could not be found 422 * @throws SystemException if a system exception occurred 423 */ 424 public static boolean hasUserRoles(long userId, long companyId, 425 java.lang.String[] names, boolean inherited) throws RemoteException { 426 try { 427 boolean returnValue = RoleServiceUtil.hasUserRoles(userId, 428 companyId, names, inherited); 429 430 return returnValue; 431 } 432 catch (Exception e) { 433 _log.error(e, e); 434 435 throw new RemoteException(e.getMessage()); 436 } 437 } 438 439 /** 440 * Removes the matching roles associated with the user. The user is 441 * reindexed after the roles are removed. 442 * 443 * @param userId the primary key of the user 444 * @param roleIds the primary keys of the roles 445 * @throws PortalException if a user with the primary key could not be 446 found, if the user did not have permission to remove members from 447 a role, or if a role with any one of the primary keys could not 448 be found 449 * @throws SystemException if a system exception occurred 450 */ 451 public static void unsetUserRoles(long userId, long[] roleIds) 452 throws RemoteException { 453 try { 454 RoleServiceUtil.unsetUserRoles(userId, roleIds); 455 } 456 catch (Exception e) { 457 _log.error(e, e); 458 459 throw new RemoteException(e.getMessage()); 460 } 461 } 462 463 /** 464 * Updates the role with the primary key. 465 * 466 * @param roleId the primary key of the role 467 * @param name the role's new name 468 * @param titleMap the new localized titles (optionally <code>null</code>) 469 to replace those existing for the role 470 * @param descriptionMap the new localized descriptions (optionally 471 <code>null</code>) to replace those existing for the role 472 * @param subtype the role's new subtype (optionally <code>null</code>) 473 * @param serviceContext the role's service context (optionally 474 <code>null</code>). Can set the expando bridge attributes for the 475 role. 476 * @return the role with the primary key 477 * @throws PortalException if the user did not have permission to update the 478 role, if a role with the primary could not be found, or if the 479 role's name was invalid 480 * @throws SystemException if a system exception occurred 481 */ 482 public static com.liferay.portal.model.RoleSoap updateRole(long roleId, 483 java.lang.String name, java.lang.String[] titleMapLanguageIds, 484 java.lang.String[] titleMapValues, 485 java.lang.String[] descriptionMapLanguageIds, 486 java.lang.String[] descriptionMapValues, java.lang.String subtype, 487 com.liferay.portal.service.ServiceContext serviceContext) 488 throws RemoteException { 489 try { 490 Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds, 491 titleMapValues); 492 Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds, 493 descriptionMapValues); 494 495 com.liferay.portal.model.Role returnValue = RoleServiceUtil.updateRole(roleId, 496 name, titleMap, descriptionMap, subtype, serviceContext); 497 498 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 499 } 500 catch (Exception e) { 501 _log.error(e, e); 502 503 throw new RemoteException(e.getMessage()); 504 } 505 } 506 507 private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class); 508 }