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