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