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 * <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 055 * http://localhost:8080/api/secure/axis. Set the property 056 * <b>axis.servlet.hosts.allowed</b> in portal.properties to configure 057 * security. 058 * </p> 059 * 060 * <p> 061 * The SOAP utility is only generated for remote services. 062 * </p> 063 * 064 * @author Brian Wing Shun Chan 065 * @see RoleServiceHttp 066 * @see com.liferay.portal.model.RoleSoap 067 * @see com.liferay.portal.service.RoleServiceUtil 068 * @generated 069 */ 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 * @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) 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 107 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 108 } 109 catch (Exception e) { 110 _log.error(e, e); 111 112 throw new RemoteException(e.getMessage()); 113 } 114 } 115 116 /** 117 * Adds a role. The user is reindexed after role is added. 118 * 119 * @param name the role's name 120 * @param titleMap the role's localized titles (optionally 121 <code>null</code>) 122 * @param descriptionMap the role's localized descriptions (optionally 123 <code>null</code>) 124 * @param type the role's type (optionally <code>0</code>) 125 * @return the role 126 * @throws PortalException if a user with the primary key could not be 127 found, if the user did not have permission to add roles, if 128 the class name or the role name were invalid, or if the role 129 is a duplicate 130 * @throws SystemException if a system exception occurred 131 * @deprecated {@link #addRole(String, long, String, Map, Map, int, String)} 132 */ 133 public static com.liferay.portal.model.RoleSoap addRole( 134 java.lang.String name, java.lang.String[] titleMapLanguageIds, 135 java.lang.String[] titleMapValues, 136 java.lang.String[] descriptionMapLanguageIds, 137 java.lang.String[] descriptionMapValues, int type) 138 throws RemoteException { 139 try { 140 Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds, 141 titleMapValues); 142 Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds, 143 descriptionMapValues); 144 145 com.liferay.portal.model.Role returnValue = RoleServiceUtil.addRole(name, 146 titleMap, descriptionMap, type); 147 148 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 149 } 150 catch (Exception e) { 151 _log.error(e, e); 152 153 throw new RemoteException(e.getMessage()); 154 } 155 } 156 157 /** 158 * Adds the roles to the user. The user is reindexed after the roles are 159 * added. 160 * 161 * @param userId the primary key of the user 162 * @param roleIds the primary keys of the roles 163 * @throws PortalException if a user with the primary key could not be found 164 or if the user did not have permission to assign members to one 165 of the roles 166 * @throws SystemException if a system exception occurred 167 */ 168 public static void addUserRoles(long userId, long[] roleIds) 169 throws RemoteException { 170 try { 171 RoleServiceUtil.addUserRoles(userId, roleIds); 172 } 173 catch (Exception e) { 174 _log.error(e, e); 175 176 throw new RemoteException(e.getMessage()); 177 } 178 } 179 180 /** 181 * Deletes the role with the primary key and its associated permissions. 182 * 183 * @param roleId the primary key of the role 184 * @throws PortalException if the user did not have permission to delete the 185 role, if a role with the primary key could not be found, if the 186 role is a default system role, or if the role's resource could 187 not be found 188 * @throws SystemException if a system exception occurred 189 */ 190 public static void deleteRole(long roleId) throws RemoteException { 191 try { 192 RoleServiceUtil.deleteRole(roleId); 193 } 194 catch (Exception e) { 195 _log.error(e, e); 196 197 throw new RemoteException(e.getMessage()); 198 } 199 } 200 201 /** 202 * Returns all the roles associated with the group. 203 * 204 * @param groupId the primary key of the group 205 * @return the roles associated with the group 206 * @throws PortalException if a portal exception occurred 207 * @throws SystemException if a system exception occurred 208 */ 209 public static com.liferay.portal.model.RoleSoap[] getGroupRoles( 210 long groupId) throws RemoteException { 211 try { 212 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getGroupRoles(groupId); 213 214 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 215 } 216 catch (Exception e) { 217 _log.error(e, e); 218 219 throw new RemoteException(e.getMessage()); 220 } 221 } 222 223 /** 224 * Returns the role with the primary key. 225 * 226 * @param roleId the primary key of the role 227 * @return the role with the primary key 228 * @throws PortalException if a role with the primary key could not be found 229 or if the user did not have permission to view the role 230 * @throws SystemException if a system exception occurred 231 */ 232 public static com.liferay.portal.model.RoleSoap getRole(long roleId) 233 throws RemoteException { 234 try { 235 com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(roleId); 236 237 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 238 } 239 catch (Exception e) { 240 _log.error(e, e); 241 242 throw new RemoteException(e.getMessage()); 243 } 244 } 245 246 /** 247 * Returns the role with the name in the company. 248 * 249 * <p> 250 * The method searches the system roles map first for default roles. If a 251 * role with the name is not found, then the method will query the database. 252 * </p> 253 * 254 * @param companyId the primary key of the company 255 * @param name the role's name 256 * @return the role with the name 257 * @throws PortalException if a role with the name could not be found in the 258 company or if the user did not have permission to view the role 259 * @throws SystemException if a system exception occurred 260 */ 261 public static com.liferay.portal.model.RoleSoap getRole(long companyId, 262 java.lang.String name) throws RemoteException { 263 try { 264 com.liferay.portal.model.Role returnValue = RoleServiceUtil.getRole(companyId, 265 name); 266 267 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 268 } 269 catch (Exception e) { 270 _log.error(e, e); 271 272 throw new RemoteException(e.getMessage()); 273 } 274 } 275 276 /** 277 * Returns all the user's roles within the user group. 278 * 279 * @param userId the primary key of the user 280 * @param groupId the primary key of the group 281 * @return the user's roles within the user group 282 * @throws PortalException if a portal exception occurred 283 * @throws SystemException if a system 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 * @throws SystemException if a system exception occurred 308 */ 309 public static com.liferay.portal.model.RoleSoap[] getUserGroupRoles( 310 long userId, long groupId) throws RemoteException { 311 try { 312 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserGroupRoles(userId, 313 groupId); 314 315 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 316 } 317 catch (Exception e) { 318 _log.error(e, e); 319 320 throw new RemoteException(e.getMessage()); 321 } 322 } 323 324 /** 325 * Returns the union of all the user's roles within the groups. 326 * 327 * @param userId the primary key of the user 328 * @param groups the groups (optionally <code>null</code>) 329 * @return the union of all the user's roles within the groups 330 * @throws PortalException if a portal exception occurred 331 * @throws SystemException if a system exception occurred 332 */ 333 public static com.liferay.portal.model.RoleSoap[] getUserRelatedRoles( 334 long userId, com.liferay.portal.model.GroupSoap[] groups) 335 throws RemoteException { 336 try { 337 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRelatedRoles(userId, 338 com.liferay.portal.model.impl.GroupModelImpl.toModels( 339 groups)); 340 341 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 342 } 343 catch (Exception e) { 344 _log.error(e, e); 345 346 throw new RemoteException(e.getMessage()); 347 } 348 } 349 350 /** 351 * Returns all the roles associated with the user. 352 * 353 * @param userId the primary key of the user 354 * @return the roles associated with the user 355 * @throws PortalException if a portal exception occurred 356 * @throws SystemException if a system exception occurred 357 */ 358 public static com.liferay.portal.model.RoleSoap[] getUserRoles(long userId) 359 throws RemoteException { 360 try { 361 java.util.List<com.liferay.portal.model.Role> returnValue = RoleServiceUtil.getUserRoles(userId); 362 363 return com.liferay.portal.model.RoleSoap.toSoapModels(returnValue); 364 } 365 catch (Exception e) { 366 _log.error(e, e); 367 368 throw new RemoteException(e.getMessage()); 369 } 370 } 371 372 /** 373 * Returns <code>true</code> if the user is associated with the named 374 * regular role. 375 * 376 * @param userId the primary key of the user 377 * @param companyId the primary key of the company 378 * @param name the name of the role 379 * @param inherited whether to include the user's inherited roles in the 380 search 381 * @return <code>true</code> if the user is associated with the regular 382 role; <code>false</code> otherwise 383 * @throws PortalException if a role with the name could not be found in the 384 company or if a default user for the company could not be found 385 * @throws SystemException if a system exception occurred 386 */ 387 public static boolean hasUserRole(long userId, long companyId, 388 java.lang.String name, boolean inherited) throws RemoteException { 389 try { 390 boolean returnValue = RoleServiceUtil.hasUserRole(userId, 391 companyId, name, inherited); 392 393 return returnValue; 394 } 395 catch (Exception e) { 396 _log.error(e, e); 397 398 throw new RemoteException(e.getMessage()); 399 } 400 } 401 402 /** 403 * Returns <code>true</code> if the user has any one of the named regular 404 * roles. 405 * 406 * @param userId the primary key of the user 407 * @param companyId the primary key of the company 408 * @param names the names of the roles 409 * @param inherited whether to include the user's inherited roles in the 410 search 411 * @return <code>true</code> if the user has any one of the regular roles; 412 <code>false</code> otherwise 413 * @throws PortalException if any one of the roles with the names could not 414 be found in the company or if the default user for the company 415 could not be found 416 * @throws SystemException if a system exception occurred 417 */ 418 public static boolean hasUserRoles(long userId, long companyId, 419 java.lang.String[] names, boolean inherited) throws RemoteException { 420 try { 421 boolean returnValue = RoleServiceUtil.hasUserRoles(userId, 422 companyId, names, inherited); 423 424 return returnValue; 425 } 426 catch (Exception e) { 427 _log.error(e, e); 428 429 throw new RemoteException(e.getMessage()); 430 } 431 } 432 433 /** 434 * Removes the matching roles associated with the user. The user is 435 * reindexed after the roles are removed. 436 * 437 * @param userId the primary key of the user 438 * @param roleIds the primary keys of the roles 439 * @throws PortalException if a user with the primary key could not be 440 found, if the user did not have permission to remove members from 441 a role, or if a role with any one of the primary keys could not 442 be found 443 * @throws SystemException if a system exception occurred 444 */ 445 public static void unsetUserRoles(long userId, long[] roleIds) 446 throws RemoteException { 447 try { 448 RoleServiceUtil.unsetUserRoles(userId, roleIds); 449 } 450 catch (Exception e) { 451 _log.error(e, e); 452 453 throw new RemoteException(e.getMessage()); 454 } 455 } 456 457 /** 458 * Updates the role with the primary key. 459 * 460 * @param roleId the primary key of the role 461 * @param name the role's new name 462 * @param titleMap the new localized titles (optionally <code>null</code>) 463 to replace those existing for the role 464 * @param descriptionMap the new localized descriptions (optionally 465 <code>null</code>) to replace those existing for the role 466 * @param subtype the role's new subtype (optionally <code>null</code>) 467 * @return the role with the primary key 468 * @throws PortalException if the user did not have permission to update the 469 role, if a role with the primary could not be found, or if the 470 role's name was invalid 471 * @throws SystemException if a system exception occurred 472 */ 473 public static com.liferay.portal.model.RoleSoap updateRole(long roleId, 474 java.lang.String name, java.lang.String[] titleMapLanguageIds, 475 java.lang.String[] titleMapValues, 476 java.lang.String[] descriptionMapLanguageIds, 477 java.lang.String[] descriptionMapValues, java.lang.String subtype) 478 throws RemoteException { 479 try { 480 Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(titleMapLanguageIds, 481 titleMapValues); 482 Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(descriptionMapLanguageIds, 483 descriptionMapValues); 484 485 com.liferay.portal.model.Role returnValue = RoleServiceUtil.updateRole(roleId, 486 name, titleMap, descriptionMap, subtype); 487 488 return com.liferay.portal.model.RoleSoap.toSoapModel(returnValue); 489 } 490 catch (Exception e) { 491 _log.error(e, e); 492 493 throw new RemoteException(e.getMessage()); 494 } 495 } 496 497 private static Log _log = LogFactoryUtil.getLog(RoleServiceSoap.class); 498 }