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