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; 016 017 import com.liferay.portal.kernel.exception.PortalException; 018 import com.liferay.portal.kernel.exception.SystemException; 019 import com.liferay.portal.kernel.language.LanguageUtil; 020 import com.liferay.portal.kernel.servlet.HttpHeaders; 021 import com.liferay.portal.kernel.util.Constants; 022 import com.liferay.portal.kernel.util.LocaleUtil; 023 import com.liferay.portal.kernel.util.Validator; 024 import com.liferay.portal.kernel.workflow.WorkflowConstants; 025 import com.liferay.portal.model.Group; 026 import com.liferay.portal.model.PortletPreferencesIds; 027 import com.liferay.portal.model.Role; 028 import com.liferay.portal.model.RoleConstants; 029 import com.liferay.portal.security.permission.ResourceActionsUtil; 030 import com.liferay.portal.util.PortalUtil; 031 032 import java.io.Serializable; 033 034 import java.util.ArrayList; 035 import java.util.Date; 036 import java.util.LinkedHashMap; 037 import java.util.List; 038 import java.util.Locale; 039 import java.util.Map; 040 041 /** 042 * Contains context information about a given API call. 043 * 044 * <p> 045 * The <code>ServiceContext</code> object simplifies method signatures and 046 * provides a way to consolidate many different methods with different sets of 047 * optional parameters into a single, easier to use method. It also aggregates 048 * information necessary for transversal features such as permissioning, 049 * tagging, categorization, etc. 050 * </p> 051 * 052 * @author Raymond Augé 053 * @author Brian Wing Shun Chan 054 * @author Jorge Ferrer 055 */ 056 public class ServiceContext implements Cloneable, Serializable { 057 058 /** 059 * Creates a new service context object with an attributes map and an 060 * expando bridge attributes map. The attributes map contains standard 061 * service context parameters and the expando bridge attributes map contains 062 * optional service context parameters. 063 */ 064 public ServiceContext() { 065 _attributes = new LinkedHashMap<String, Serializable>(); 066 _expandoBridgeAttributes = new LinkedHashMap<String, Serializable>(); 067 } 068 069 /** 070 * Returns a new service context object identical to this service context 071 * object. 072 * 073 * @return a new service context object 074 */ 075 @Override 076 public Object clone() { 077 ServiceContext serviceContext = new ServiceContext(); 078 079 serviceContext.setAddGroupPermissions(isAddGroupPermissions()); 080 serviceContext.setAddGuestPermissions(isAddGuestPermissions()); 081 serviceContext.setAssetCategoryIds(getAssetCategoryIds()); 082 serviceContext.setAssetEntryVisible(isAssetEntryVisible()); 083 serviceContext.setAssetLinkEntryIds(getAssetLinkEntryIds()); 084 serviceContext.setAssetTagNames(getAssetTagNames()); 085 serviceContext.setAttributes(getAttributes()); 086 serviceContext.setCommand(getCommand()); 087 serviceContext.setCompanyId(getCompanyId()); 088 serviceContext.setCreateDate(getCreateDate()); 089 serviceContext.setCurrentURL(getCurrentURL()); 090 serviceContext.setExpandoBridgeAttributes(getExpandoBridgeAttributes()); 091 serviceContext.setGroupPermissions(getGroupPermissions()); 092 serviceContext.setGuestPermissions(getGuestPermissions()); 093 serviceContext.setHeaders(getHeaders()); 094 serviceContext.setIndexingEnabled(isIndexingEnabled()); 095 serviceContext.setLanguageId(getLanguageId()); 096 serviceContext.setLayoutFullURL(getLayoutFullURL()); 097 serviceContext.setLayoutURL(getLayoutURL()); 098 serviceContext.setModifiedDate(getModifiedDate()); 099 serviceContext.setPathMain(getPathMain()); 100 serviceContext.setPlid(getPlid()); 101 serviceContext.setPortalURL(getPortalURL()); 102 serviceContext.setPortletPreferencesIds(getPortletPreferencesIds()); 103 serviceContext.setRemoteAddr(getRemoteAddr()); 104 serviceContext.setRemoteHost(getRemoteHost()); 105 serviceContext.setScopeGroupId(getScopeGroupId()); 106 serviceContext.setSignedIn(isSignedIn()); 107 serviceContext.setUserDisplayURL(getUserDisplayURL()); 108 serviceContext.setUserId(getUserId()); 109 serviceContext.setUuid(getUuid()); 110 serviceContext.setWorkflowAction(getWorkflowAction()); 111 112 return serviceContext; 113 } 114 115 /** 116 * Derive default permissions based on the logic found in 117 * portal-web/docroot/html/taglib/ui/input_permissions/page.jsp. Do not 118 * update this logic updating the logic in the JSP. 119 */ 120 public void deriveDefaultPermissions(long repositoryId, String modelName) 121 throws PortalException, SystemException { 122 123 long parentGroupId = PortalUtil.getParentGroupId(repositoryId); 124 125 Group parentGroup = GroupLocalServiceUtil.getGroup(parentGroupId); 126 127 Role defaultGroupRole = RoleLocalServiceUtil.getDefaultGroupRole( 128 parentGroupId); 129 130 List<String> groupPermissions = new ArrayList<String>(); 131 List<String> guestPermissions = new ArrayList<String>(); 132 133 String[] roleNames = {RoleConstants.GUEST, defaultGroupRole.getName()}; 134 135 List<String> supportedActions = 136 ResourceActionsUtil.getModelResourceActions(modelName); 137 List<String> groupDefaultActions = 138 ResourceActionsUtil.getModelResourceGroupDefaultActions(modelName); 139 List<String> guestDefaultActions = 140 ResourceActionsUtil.getModelResourceGuestDefaultActions(modelName); 141 List<String> guestUnsupportedActions = 142 ResourceActionsUtil.getModelResourceGuestUnsupportedActions( 143 modelName); 144 145 for (String roleName : roleNames) { 146 for (String action: supportedActions) { 147 if (roleName.equals(RoleConstants.GUEST) && 148 !guestUnsupportedActions.contains(action) && 149 guestDefaultActions.contains(action) && 150 parentGroup.hasPublicLayouts()) { 151 152 guestPermissions.add(action); 153 } 154 else if (roleName.equals(defaultGroupRole.getName()) && 155 groupDefaultActions.contains(action)) { 156 157 groupPermissions.add(action); 158 } 159 } 160 } 161 162 setGroupPermissions( 163 groupPermissions.toArray(new String[groupPermissions.size()])); 164 setGuestPermissions( 165 guestPermissions.toArray(new String[guestPermissions.size()])); 166 } 167 168 /** 169 * Returns <code>true</code> if this service context is being passed as a 170 * parameter to a method which manipulates a resource to which default group 171 * permissions apply. 172 * 173 * @return <code>true</code> if this service context is being passed as 174 * a parameter to a method which manipulates a resource to which 175 * default community permissions apply; <code>false</code> 176 * otherwise 177 * @deprecated As of 6.1, renamed to {@link #isAddGroupPermissions()} 178 */ 179 public boolean getAddCommunityPermissions() { 180 return isAddGroupPermissions(); 181 } 182 183 /** 184 * Returns the asset category IDs to be applied to an asset entry if the 185 * service context is being passed as a parameter to a method which 186 * manipulates the asset entry. 187 * 188 * @return the asset category IDs 189 */ 190 public long[] getAssetCategoryIds() { 191 return _assetCategoryIds; 192 } 193 194 /** 195 * Returns the primary keys of the asset entries linked to an asset entry if 196 * the service context is being passed as a parameter to a method which 197 * manipulates the asset entry. 198 * 199 * @return the primary keys of the asset entries 200 */ 201 public long[] getAssetLinkEntryIds() { 202 return _assetLinkEntryIds; 203 } 204 205 /** 206 * Returns the asset tag names to be applied to an asset entry if the 207 * service context is being passed as a parameter to a method which 208 * manipulates the asset entry. 209 * 210 * @return the asset tag names 211 */ 212 public String[] getAssetTagNames() { 213 return _assetTagNames; 214 } 215 216 /** 217 * Returns the serializable object associated with the name of the standard 218 * parameter of this service context. 219 * 220 * @param name the name of the standard parameter 221 * @return the serializable object associated with the name 222 */ 223 public Serializable getAttribute(String name) { 224 return _attributes.get(name); 225 } 226 227 /** 228 * Returns the map of name/value pairs that are the standard parameters of 229 * this service context. Each value is serializable. 230 * 231 * @return the map of name/value pairs 232 */ 233 public Map<String, Serializable> getAttributes() { 234 return _attributes; 235 } 236 237 /** 238 * Returns the value of the {@link 239 * com.liferay.portal.kernel.util.Constants#CMD} parameter used in most 240 * Liferay forms for internal portlets. 241 * 242 * @return the value of the command parameter 243 */ 244 public String getCommand() { 245 return _command; 246 } 247 248 /** 249 * Returns the specific community permissions for a resource if the service 250 * context is being passed as a parameter to a method which manipulates the 251 * resource. 252 * 253 * @return the community permissions 254 * @deprecated As of 6.1, renamed to {@link #getGroupPermissions()} 255 */ 256 public String[] getCommunityPermissions() { 257 return getGroupPermissions(); 258 } 259 260 /** 261 * Returns the company ID of this service context's current portal instance. 262 * 263 * @return the company ID 264 */ 265 public long getCompanyId() { 266 return _companyId; 267 } 268 269 /** 270 * Returns the date when an entity was created if this service context is 271 * being passed as a parameter to a method which creates an entity. 272 * 273 * @return the creation date 274 */ 275 public Date getCreateDate() { 276 return _createDate; 277 } 278 279 /** 280 * Returns the date when an entity was created (or a default date) if this 281 * service context is being passed as a parameter to a method which creates 282 * an entity. 283 * 284 * @param defaultCreateDate an optional default create date to use if the 285 * service context does not have a create date 286 * @return the creation date if available; the default date otherwise 287 */ 288 public Date getCreateDate(Date defaultCreateDate) { 289 if (_createDate != null) { 290 return _createDate; 291 } 292 else if (defaultCreateDate != null) { 293 return defaultCreateDate; 294 } 295 else { 296 return new Date(); 297 } 298 } 299 300 /** 301 * Returns the current URL of this service context 302 * 303 * @return the current URL 304 */ 305 public String getCurrentURL() { 306 return _currentURL; 307 } 308 309 /** 310 * Returns an arbitrary number of attributes of an entity to be persisted. 311 * 312 * <p> 313 * These attributes only include fields that this service context does not 314 * possess by default. 315 * </p> 316 * 317 * @return the expando bridge attributes 318 */ 319 public Map<String, Serializable> getExpandoBridgeAttributes() { 320 return _expandoBridgeAttributes; 321 } 322 323 /** 324 * Returns the specific group permissions for a resource if this service 325 * context is being passed as a parameter to a method which manipulates the 326 * resource. 327 * 328 * @return the specific group permissions 329 */ 330 public String[] getGroupPermissions() { 331 return _groupPermissions; 332 } 333 334 /** 335 * Returns this service context's user ID or guest ID if no user ID is 336 * available. 337 * 338 * @return the user ID, or guest ID if there is no user in this service 339 * context, or <code>0</code> if there is no company in this service 340 * context 341 * @throws PortalException if a default user for the company could not be 342 * found 343 * @throws SystemException if a system exception occurred 344 */ 345 public long getGuestOrUserId() throws PortalException, SystemException { 346 long userId = getUserId(); 347 348 if (userId > 0) { 349 return userId; 350 } 351 352 long companyId = getCompanyId(); 353 354 if (companyId > 0) { 355 return UserLocalServiceUtil.getDefaultUserId(getCompanyId()); 356 } 357 358 return 0; 359 } 360 361 /** 362 * Returns the specific guest permissions for a resource if this service 363 * context is being passed as a parameter to a method which manipulates the 364 * resource. 365 * 366 * @return the specific guest permissions 367 */ 368 public String[] getGuestPermissions() { 369 return _guestPermissions; 370 } 371 372 /** 373 * Returns the the map of request header name/value pairs of this service 374 * context. 375 * 376 * @return the the map of request header name/value pairs 377 * @see com.liferay.portal.kernel.servlet.HttpHeaders 378 */ 379 public Map<String, String> getHeaders() { 380 return _headers; 381 } 382 383 /** 384 * Returns the language ID of the locale of this service context's current 385 * user. 386 * 387 * @return the language ID 388 */ 389 public String getLanguageId() { 390 return _languageId; 391 } 392 393 /** 394 * Returns the complete URL of the current page if a page context can be 395 * determined for this service context. 396 * 397 * @return the complete URL of the current page 398 */ 399 public String getLayoutFullURL() { 400 return _layoutFullURL; 401 } 402 403 /** 404 * Returns the relative URL of the current page if a page context can be 405 * determined for this service context. 406 * 407 * @return the relative URL of the current page 408 */ 409 public String getLayoutURL() { 410 return _layoutURL; 411 } 412 413 public Locale getLocale() { 414 return LocaleUtil.fromLanguageId(_languageId); 415 } 416 417 /** 418 * Returns the date when an entity was modified if this service context is 419 * being passed as a parameter to a method which updates an entity. 420 * 421 * @return the date when an entity was modified if this service context is 422 * being passed as a parameter to a method which updates an entity 423 */ 424 public Date getModifiedDate() { 425 return _modifiedDate; 426 } 427 428 /** 429 * Returns the date when an entity was modified if this service context is 430 * being passed as a parameter to a method which modifies an entity. 431 * 432 * @param defaultModifiedDate an optional default modified date to use if 433 * this service context does not have a modified date 434 * @return the modified date if available; the default date otherwise 435 */ 436 public Date getModifiedDate(Date defaultModifiedDate) { 437 if (_modifiedDate != null) { 438 return _modifiedDate; 439 } 440 else if (defaultModifiedDate != null) { 441 return defaultModifiedDate; 442 } 443 else { 444 return new Date(); 445 } 446 } 447 448 /** 449 * Returns the main context path of the portal, concatenated with 450 * <code>/c</code>. 451 * 452 * @return the main context path of the portal 453 */ 454 public String getPathMain() { 455 return _pathMain; 456 } 457 458 /** 459 * Returns the portal layout ID of the current page of this service context. 460 * 461 * @return the portal layout ID of the current page 462 */ 463 public long getPlid() { 464 return _plid; 465 } 466 467 /** 468 * Returns the URL of this service context's portal, including the protocol, 469 * domain, and non-default port relative to the company instance and any 470 * virtual host. 471 * 472 * <p> 473 * The URL returned does not include the port if a default port is used. 474 * </p> 475 * 476 * @return the URL of this service context's portal, including the protocol, 477 * domain, and non-default port relative to company instance and any 478 * virtual host 479 */ 480 public String getPortalURL() { 481 return _portalURL; 482 } 483 484 /** 485 * Returns the ID of the current portlet if this service context is being 486 * passed as a parameter to a portlet. 487 * 488 * @return the ID of the current portlet 489 * @see com.liferay.portal.model.PortletPreferencesIds 490 */ 491 public String getPortletId() { 492 if (_portletPreferencesIds != null) { 493 return _portletPreferencesIds.getPortletId(); 494 } 495 else { 496 return null; 497 } 498 } 499 500 /** 501 * Returns the portlet preferences IDs of the current portlet if the service 502 * context is being passed as a parameter to a portlet. 503 * 504 * <p> 505 * The {@link com.liferay.portal.model.PortletPreferencesIds} can be used to 506 * look up portlet preferences of the current portlet. 507 * </p> 508 * 509 * @return the portlet preferences IDs of the current portlet 510 * @see com.liferay.portal.model.PortletPreferencesIds 511 */ 512 public PortletPreferencesIds getPortletPreferencesIds() { 513 return _portletPreferencesIds; 514 } 515 516 /** 517 * Returns the remote address of the user making the request in this service 518 * context. 519 * 520 * @return the remote address of the user making the request 521 */ 522 public String getRemoteAddr() { 523 return _remoteAddr; 524 } 525 526 /** 527 * Returns the remote host name of the user making the request in this 528 * service context. 529 * 530 * @return the remote host name of the user making the request 531 */ 532 public String getRemoteHost() { 533 return _remoteHost; 534 } 535 536 /** 537 * Returns the ID of the group corresponding to the current data scope of 538 * this service context. 539 * 540 * @return the ID of the group corresponding to the current data scope 541 * @see com.liferay.portal.model.Group 542 */ 543 public long getScopeGroupId() { 544 return _scopeGroupId; 545 } 546 547 /** 548 * Returns the user-agent request header of this service context. 549 * 550 * @return the user-agent request header 551 * @see com.liferay.portal.kernel.servlet.HttpHeaders 552 */ 553 public String getUserAgent() { 554 if (_headers == null) { 555 return null; 556 } 557 558 return _headers.get(HttpHeaders.USER_AGENT); 559 } 560 561 /** 562 * Returns the complete URL of this service context's current user's profile 563 * page. 564 * 565 * @return the complete URL of this service context's current user's profile 566 * page 567 */ 568 public String getUserDisplayURL() { 569 return _userDisplayURL; 570 } 571 572 /** 573 * Returns the ID of this service context's current user. 574 * 575 * @return the ID of this service context's current user 576 */ 577 public long getUserId() { 578 return _userId; 579 } 580 581 /** 582 * Returns the UUID (universally unique identifier) of this service 583 * context's current entity. 584 * 585 * @return the UUID (universally unique identifier) of this service 586 * context's current entity 587 */ 588 public String getUuid() { 589 String uuid = _uuid; 590 591 _uuid = null; 592 593 return uuid; 594 } 595 596 /** 597 * Returns the workflow action to take if this service context is being 598 * passed as a parameter to a method that processes a workflow action. 599 * 600 * @return the workflow action to take 601 */ 602 public int getWorkflowAction() { 603 return _workflowAction; 604 } 605 606 /** 607 * Returns <code>true</code> if this service context is being passed as a 608 * parameter to a method which manipulates a resource to which default guest 609 * permissions apply. 610 * 611 * @return <code>true</code> if this service context is being passed as a 612 * parameter to a method which manipulates a resource to which 613 * default guest permissions apply; <code>false</code> otherwise 614 */ 615 public boolean isAddGuestPermissions() { 616 return _addGuestPermissions; 617 } 618 619 /** 620 * Returns <code>true</code> if this service context is being passed as a 621 * parameter to a method which manipulates a resource to which default group 622 * permissions apply. 623 * 624 * @return <code>true</code> if this service context is being passed as a 625 * parameter to a method which manipulates a resource to which 626 * default group permissions apply; <code>false</code> otherwise 627 */ 628 public boolean isAddGroupPermissions() { 629 return _addGroupPermissions; 630 } 631 632 public boolean isAssetEntryVisible() { 633 return _assetEntryVisible; 634 } 635 636 /** 637 * Returns <code>true</code> if this service context contains an add command 638 * (i.e. has command value {@link 639 * com.liferay.portal.kernel.util.Constants#ADD}) 640 * 641 * @return <code>true</code> if this service context contains an add 642 * command; <code>false</code> otherwise 643 */ 644 public boolean isCommandAdd() { 645 if (Validator.equals(_command, Constants.ADD)) { 646 return true; 647 } 648 else { 649 return false; 650 } 651 } 652 653 /** 654 * Returns <code>true</code> if this service context contains an update 655 * command (i.e. has command value {@link 656 * com.liferay.portal.kernel.util.Constants#UPDATE}) 657 * 658 * @return <code>true</code> if this service context contains an update 659 * command; <code>false</code> otherwise 660 */ 661 public boolean isCommandUpdate() { 662 if (Validator.equals(_command, Constants.UPDATE)) { 663 return true; 664 } 665 else { 666 return false; 667 } 668 } 669 670 public boolean isDeriveDefaultPermissions() { 671 return _deriveDefaultPermissions; 672 } 673 674 /** 675 * Returns whether the primary entity of this service context is to be 676 * indexed/re-indexed. 677 * 678 * @return <code>true</code> the primary entity of this service context is 679 * to be indexed/re-indexed; <code>false</code> otherwise 680 */ 681 public boolean isIndexingEnabled() { 682 return _indexingEnabled; 683 } 684 685 /** 686 * Returns <code>true</code> if the sender of this service context's request 687 * is signed in. 688 * 689 * @return <code>true</code> if the sender of this service context's request 690 * is signed in; <code>false</code> otherwise 691 */ 692 public boolean isSignedIn() { 693 return _signedIn; 694 } 695 696 /** 697 * Removes the mapping of the serializable object to the name of the 698 * standard parameter of this service context. 699 * 700 * @param name the name of the standard parameter 701 * @return the serializable object associated to the name 702 */ 703 public Serializable removeAttribute(String name) { 704 return _attributes.remove(name); 705 } 706 707 /** 708 * Sets whether or not default community permissions should apply to a 709 * resource being manipulated by a method to which this service context is 710 * passed as a parameter. 711 * 712 * @param addCommunityPermissions indicates whether or not to apply 713 * default community permissions 714 * @deprecated As of 6.1, renamed to {@link 715 * #setAddGroupPermissions(boolean)} 716 */ 717 public void setAddCommunityPermissions(boolean addCommunityPermissions) { 718 setAddGroupPermissions(addCommunityPermissions); 719 } 720 721 /** 722 * Sets whether or not default group permissions should apply to a resource 723 * being manipulated by a method to which this service context is passed as 724 * a parameter. 725 * 726 * @param addGroupPermissions indicates whether or not to apply default 727 * group permissions 728 */ 729 public void setAddGroupPermissions(boolean addGroupPermissions) { 730 _addGroupPermissions = addGroupPermissions; 731 } 732 733 /** 734 * Sets whether or not default guest permissions should apply to a resource 735 * being manipulated by a method to which this service context is passed as 736 * a parameter. 737 * 738 * @param addGuestPermissions indicates whether or not to apply default 739 * guest permissions 740 */ 741 public void setAddGuestPermissions(boolean addGuestPermissions) { 742 _addGuestPermissions = addGuestPermissions; 743 } 744 745 /** 746 * Sets an array of asset category IDs to be applied to an asset entry if 747 * this service context is being passed as a parameter to a method which 748 * manipulates the asset entry. 749 * 750 * @param assetCategoryIds the primary keys of the asset categories 751 */ 752 public void setAssetCategoryIds(long[] assetCategoryIds) { 753 _assetCategoryIds = assetCategoryIds; 754 } 755 756 public void setAssetEntryVisible(boolean assetEntryVisible) { 757 _assetEntryVisible = assetEntryVisible; 758 } 759 760 /** 761 * Sets an array of the primary keys of asset entries to be linked to an 762 * asset entry if this service context is being passed as a parameter to a 763 * method which manipulates the asset entry. 764 * 765 * @param assetLinkEntryIds the primary keys of the asset entries to be 766 * linked to an asset entry 767 */ 768 public void setAssetLinkEntryIds(long[] assetLinkEntryIds) { 769 _assetLinkEntryIds = assetLinkEntryIds; 770 } 771 772 /** 773 * Sets an array of asset tag names to be applied to an asset entry if this 774 * service context is being passed as a parameter to a method which 775 * manipulates the asset entry. 776 * 777 * @param assetTagNames the tag names to be applied to an asset entry 778 */ 779 public void setAssetTagNames(String[] assetTagNames) { 780 _assetTagNames = assetTagNames; 781 } 782 783 /** 784 * Sets a mapping of a standard parameter's name to its serializable object. 785 * 786 * @param name the standard parameter name to associate with the value 787 * @param value the serializable object to be associated with the name 788 */ 789 public void setAttribute(String name, Serializable value) { 790 _attributes.put(name, value); 791 } 792 793 /** 794 * Sets the map of the name/value pairs that are the standard parameters of 795 * this service context. Each value must be serializable. 796 * 797 * @param attributes the map of the name/value pairs that are the standard 798 * parameters of this service context 799 */ 800 public void setAttributes(Map<String, Serializable> attributes) { 801 _attributes = attributes; 802 } 803 804 /** 805 * Sets the value of the {@link 806 * com.liferay.portal.kernel.util.Constants#CMD} parameter used in most 807 * Liferay forms for internal portlets. 808 * 809 * @param command the value of the {@link 810 * com.liferay.portal.kernel.util.Constants#CMD} parameter 811 */ 812 public void setCommand(String command) { 813 _command = command; 814 } 815 816 /** 817 * Sets an array containing specific community permissions for a resource if 818 * this service context is being passed as a parameter to a method which 819 * manipulates the resource. 820 * 821 * @param communityPermissions the community permissions (optionally 822 * <code>null</code>) 823 * @deprecated As of 6.1, renamed to {@link #setGroupPermissions(String[])} 824 */ 825 public void setCommunityPermissions(String[] communityPermissions) { 826 setGroupPermissions(communityPermissions); 827 } 828 829 /** 830 * Sets the company ID of this service context's current portal instance. 831 * 832 * @param companyId the primary key of this service context's current portal 833 * instance 834 */ 835 public void setCompanyId(long companyId) { 836 _companyId = companyId; 837 } 838 839 /** 840 * Sets the date when an entity was created if this service context is being 841 * passed as a parameter to a method which creates an entity. 842 * 843 * @param createDate the date the entity was created 844 */ 845 public void setCreateDate(Date createDate) { 846 _createDate = createDate; 847 } 848 849 /** 850 * Sets the current URL of this service context 851 * 852 * @param currentURL the current URL of this service context 853 */ 854 public void setCurrentURL(String currentURL) { 855 _currentURL = currentURL; 856 } 857 858 public void setDeriveDefaultPermissions(boolean deriveDefaultPermissions) { 859 _deriveDefaultPermissions = deriveDefaultPermissions; 860 } 861 862 /** 863 * Sets an arbitrary number of attributes of an entity to be persisted. 864 * 865 * <p> 866 * These attributes should only include fields that {@link 867 * com.liferay.portal.service.ServiceContext} does not possess by default. 868 * </p> 869 * 870 * @param expandoBridgeAttributes the expando bridge attributes (optionally 871 * <code>null</code>) 872 */ 873 public void setExpandoBridgeAttributes( 874 Map<String, Serializable> expandoBridgeAttributes) { 875 876 _expandoBridgeAttributes = expandoBridgeAttributes; 877 } 878 879 /** 880 * Sets an array containing specific group permissions for a resource if 881 * this service context is being passed as a parameter to a method which 882 * manipulates the resource. 883 * 884 * @param groupPermissions the permissions (optionally <code>null</code>) 885 */ 886 public void setGroupPermissions(String[] groupPermissions) { 887 _groupPermissions = groupPermissions; 888 } 889 890 /** 891 * Sets an array containing specific guest permissions for a resource if 892 * this service context is being passed as a parameter to a method which 893 * manipulates the resource. 894 * 895 * @param guestPermissions the guest permissions (optionally 896 * <code>null</code>) 897 */ 898 public void setGuestPermissions(String[] guestPermissions) { 899 _guestPermissions = guestPermissions; 900 } 901 902 /** 903 * Sets the map of request header name/value pairs of this service context. 904 * 905 * @param headers map of request header name/value pairs of this service 906 * context 907 * @see com.liferay.portal.kernel.servlet.HttpHeaders 908 */ 909 public void setHeaders(Map<String, String> headers) { 910 _headers = headers; 911 } 912 913 /** 914 * Sets whether the primary entity of this service context is to be 915 * indexed/re-indexed. 916 * 917 * <p> 918 * The entity is only indexed/re-indexed if the method receiving this 919 * service context as a parameter does indexing. 920 * </p> 921 * 922 * @param indexingEnabled whether the primary entity of this service context 923 * is to be indexed/re-indexed (default is <code>true</code>) 924 */ 925 public void setIndexingEnabled(boolean indexingEnabled) { 926 _indexingEnabled = indexingEnabled; 927 } 928 929 /** 930 * Sets the language ID of the locale of this service context. 931 * 932 * @param languageId the language ID of the locale of this service context's 933 * current user 934 */ 935 public void setLanguageId(String languageId) { 936 _languageId = languageId; 937 } 938 939 /** 940 * Sets the complete URL of the current page for this service context. 941 * 942 * @param layoutFullURL the complete URL of the current page if a page 943 * context can be determined for this service context 944 */ 945 public void setLayoutFullURL(String layoutFullURL) { 946 _layoutFullURL = layoutFullURL; 947 } 948 949 /** 950 * Sets the relative URL of the current page for this service context. 951 * 952 * @param layoutURL the relative URL of the current page if a page context 953 * can be determined for this service context 954 */ 955 public void setLayoutURL(String layoutURL) { 956 _layoutURL = layoutURL; 957 } 958 959 /** 960 * Sets the date when an entity was modified in this service context. 961 * 962 * @param modifiedDate the date when an entity was modified in this service 963 * context 964 */ 965 public void setModifiedDate(Date modifiedDate) { 966 _modifiedDate = modifiedDate; 967 } 968 969 /** 970 * Sets the main context path of the portal, concatenated with 971 * <code>/c</code>. 972 * 973 * @param pathMain the main context path of the portal 974 */ 975 public void setPathMain(String pathMain) { 976 _pathMain = pathMain; 977 } 978 979 /** 980 * Sets the portal layout ID of the current page in this service context. 981 * 982 * @param plid the portal layout ID of the current page 983 */ 984 public void setPlid(long plid) { 985 _plid = plid; 986 } 987 988 /** 989 * Sets the URL of this service context's portal, including the protocol, 990 * domain, and non-default port relative to the company instance and any 991 * virtual host. 992 * 993 * <p> 994 * The URL should not include the port if a default port is used. 995 * </p> 996 * 997 * @param portalURL the portal URL 998 */ 999 public void setPortalURL(String portalURL) { 1000 _portalURL = portalURL; 1001 } 1002 1003 /** 1004 * Sets the portlet preferences IDs of the current portlet if this service 1005 * context is being passed as a parameter to a portlet. 1006 * 1007 * <p> 1008 * The {@link com.liferay.portal.model.PortletPreferencesIds} can be used to 1009 * look up portlet preferences of the current portlet. 1010 * </p> 1011 * 1012 * @param portletPreferencesIds the portlet preferences 1013 * @see com.liferay.portal.model.PortletPreferencesIds 1014 */ 1015 public void setPortletPreferencesIds( 1016 PortletPreferencesIds portletPreferencesIds) { 1017 1018 _portletPreferencesIds = portletPreferencesIds; 1019 } 1020 1021 /** 1022 * Sets the remote address of the user making the request in this service 1023 * context. 1024 * 1025 * @param remoteAddr the remote address of the user making the request in 1026 * this service context 1027 */ 1028 public void setRemoteAddr(String remoteAddr) { 1029 _remoteAddr = remoteAddr; 1030 } 1031 1032 /** 1033 * Sets the remote host name of the user making the request in this service 1034 * context. 1035 * 1036 * @param remoteHost the remote host name of the user making the request in 1037 * this service context 1038 */ 1039 public void setRemoteHost(String remoteHost) { 1040 _remoteHost = remoteHost; 1041 } 1042 1043 /** 1044 * Sets the ID of the group corresponding to the current data scope of this 1045 * service context. 1046 * 1047 * @param scopeGroupId the ID of the group corresponding to the current data 1048 * scope of this service context 1049 * @see com.liferay.portal.model.Group 1050 */ 1051 public void setScopeGroupId(long scopeGroupId) { 1052 _scopeGroupId = scopeGroupId; 1053 } 1054 1055 /** 1056 * Sets whether the sender of this service context's request is signed in. 1057 * 1058 * @param signedIn whether the sender of this service context's request is 1059 * signed in 1060 */ 1061 public void setSignedIn(boolean signedIn) { 1062 _signedIn = signedIn; 1063 } 1064 1065 /** 1066 * Sets the complete URL of this service context's current user's profile 1067 * page. 1068 * 1069 * @param userDisplayURL the complete URL of the current user's profile page 1070 */ 1071 public void setUserDisplayURL(String userDisplayURL) { 1072 _userDisplayURL = userDisplayURL; 1073 } 1074 1075 /** 1076 * Sets the ID of this service context's current user. 1077 * 1078 * @param userId the ID of the current user 1079 */ 1080 public void setUserId(long userId) { 1081 _userId = userId; 1082 } 1083 1084 /** 1085 * Sets the UUID (universally unique identifier) of this service context's 1086 * current entity. 1087 * 1088 * @param uuid the UUID (universally unique identifier) of the current 1089 * entity 1090 */ 1091 public void setUuid(String uuid) { 1092 _uuid = uuid; 1093 } 1094 1095 /** 1096 * Sets the workflow action to take if this service context is being passed 1097 * as parameter to a method that processes a workflow action. 1098 * 1099 * @param workflowAction workflow action to take (default is {@link 1100 * com.liferay.portal.kernel.workflow.WorkflowConstants.ACTION_PUBLISH}) 1101 */ 1102 public void setWorkflowAction(int workflowAction) { 1103 _workflowAction = workflowAction; 1104 } 1105 1106 public String translate(String pattern, Object... arguments) { 1107 Locale locale = getLocale(); 1108 1109 return LanguageUtil.format(locale, pattern, arguments); 1110 } 1111 1112 private boolean _addGroupPermissions; 1113 private boolean _addGuestPermissions; 1114 private long[] _assetCategoryIds; 1115 private boolean _assetEntryVisible = true; 1116 private long[] _assetLinkEntryIds; 1117 private String[] _assetTagNames; 1118 private Map<String, Serializable> _attributes; 1119 private String _command; 1120 private long _companyId; 1121 private Date _createDate; 1122 private String _currentURL; 1123 private boolean _deriveDefaultPermissions; 1124 private Map<String, Serializable> _expandoBridgeAttributes; 1125 private String[] _groupPermissions; 1126 private String[] _guestPermissions; 1127 private Map<String, String> _headers; 1128 private boolean _indexingEnabled = true; 1129 private String _languageId; 1130 private String _layoutFullURL; 1131 private String _layoutURL; 1132 private Date _modifiedDate; 1133 private String _pathMain; 1134 private String _portalURL; 1135 private PortletPreferencesIds _portletPreferencesIds; 1136 private String _remoteAddr; 1137 private String _remoteHost; 1138 private long _scopeGroupId; 1139 private boolean _signedIn; 1140 private String _userDisplayURL; 1141 private long _plid; 1142 private int _workflowAction = WorkflowConstants.ACTION_PUBLISH; 1143 private long _userId; 1144 private String _uuid; 1145 1146 }