001    /**
002     * Copyright (c) 2000-present 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.json.JSON;
019    import com.liferay.portal.kernel.language.LanguageUtil;
020    import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
021    import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
022    import com.liferay.portal.kernel.servlet.HttpHeaders;
023    import com.liferay.portal.kernel.util.Constants;
024    import com.liferay.portal.kernel.util.DateUtil;
025    import com.liferay.portal.kernel.util.JavaConstants;
026    import com.liferay.portal.kernel.util.LocaleUtil;
027    import com.liferay.portal.kernel.util.Validator;
028    import com.liferay.portal.kernel.util.WebKeys;
029    import com.liferay.portal.kernel.workflow.WorkflowConstants;
030    import com.liferay.portal.model.AuditedModel;
031    import com.liferay.portal.model.Group;
032    import com.liferay.portal.model.PortletConstants;
033    import com.liferay.portal.model.PortletPreferencesIds;
034    import com.liferay.portal.model.Role;
035    import com.liferay.portal.model.RoleConstants;
036    import com.liferay.portal.security.permission.ResourceActionsUtil;
037    import com.liferay.portal.service.permission.ModelPermissions;
038    import com.liferay.portal.theme.ThemeDisplay;
039    import com.liferay.portal.util.PortalUtil;
040    
041    import java.io.Serializable;
042    
043    import java.util.ArrayList;
044    import java.util.Date;
045    import java.util.LinkedHashMap;
046    import java.util.List;
047    import java.util.Locale;
048    import java.util.Map;
049    import java.util.TimeZone;
050    
051    import javax.servlet.http.HttpServletRequest;
052    import javax.servlet.http.HttpServletResponse;
053    
054    /**
055     * Contains context information about a given API call.
056     *
057     * <p>
058     * The <code>ServiceContext</code> object simplifies method signatures and
059     * provides a way to consolidate many different methods with different sets of
060     * optional parameters into a single, easier to use method. It also aggregates
061     * information necessary for transversal features such as permissioning,
062     * tagging, categorization, etc.
063     * </p>
064     *
065     * @author Raymond Aug??
066     * @author Brian Wing Shun Chan
067     * @author Jorge Ferrer
068     */
069    @JSON
070    public class ServiceContext implements Cloneable, Serializable {
071    
072            /**
073             * Creates a new service context object with an attributes map and an
074             * expando bridge attributes map. The attributes map contains standard
075             * service context parameters and the expando bridge attributes map contains
076             * optional service context parameters.
077             */
078            public ServiceContext() {
079                    _attributes = new LinkedHashMap<>();
080                    _expandoBridgeAttributes = new LinkedHashMap<>();
081            }
082    
083            /**
084             * Returns a new service context object identical to this service context
085             * object.
086             *
087             * @return a new service context object
088             */
089            @Override
090            public Object clone() {
091                    ServiceContext serviceContext = new ServiceContext();
092    
093                    serviceContext.setAddGroupPermissions(isAddGroupPermissions());
094                    serviceContext.setAddGuestPermissions(isAddGuestPermissions());
095                    serviceContext.setAssetCategoryIds(getAssetCategoryIds());
096                    serviceContext.setAssetEntryVisible(isAssetEntryVisible());
097                    serviceContext.setAssetLinkEntryIds(getAssetLinkEntryIds());
098                    serviceContext.setAssetPriority(getAssetPriority());
099                    serviceContext.setAssetTagNames(getAssetTagNames());
100                    serviceContext.setAttributes(getAttributes());
101                    serviceContext.setCommand(getCommand());
102                    serviceContext.setCompanyId(getCompanyId());
103                    serviceContext.setCreateDate(getCreateDate());
104                    serviceContext.setCurrentURL(getCurrentURL());
105                    serviceContext.setExpandoBridgeAttributes(getExpandoBridgeAttributes());
106                    serviceContext.setFailOnPortalException(isFailOnPortalException());
107                    serviceContext.setGroupPermissions(getGroupPermissions());
108                    serviceContext.setGuestPermissions(getGuestPermissions());
109                    serviceContext.setHeaders(getHeaders());
110                    serviceContext.setIndexingEnabled(isIndexingEnabled());
111                    serviceContext.setLanguageId(getLanguageId());
112                    serviceContext.setLayoutFullURL(getLayoutFullURL());
113                    serviceContext.setLayoutURL(getLayoutURL());
114                    serviceContext.setModelPermissions(
115                            (ModelPermissions)_modelPermissions.clone());
116                    serviceContext.setModifiedDate(getModifiedDate());
117                    serviceContext.setPathFriendlyURLPrivateGroup(
118                            getPathFriendlyURLPrivateGroup());
119                    serviceContext.setPathFriendlyURLPrivateUser(
120                            getPathFriendlyURLPrivateUser());
121                    serviceContext.setPathFriendlyURLPublic(getPathFriendlyURLPublic());
122                    serviceContext.setPathMain(getPathMain());
123                    serviceContext.setPlid(getPlid());
124                    serviceContext.setPortalURL(getPortalURL());
125                    serviceContext.setPortletPreferencesIds(getPortletPreferencesIds());
126                    serviceContext.setRemoteAddr(getRemoteAddr());
127                    serviceContext.setRemoteHost(getRemoteHost());
128                    serviceContext.setRequest(getRequest());
129                    serviceContext.setScopeGroupId(getScopeGroupId());
130                    serviceContext.setSignedIn(isSignedIn());
131                    serviceContext.setUserDisplayURL(getUserDisplayURL());
132                    serviceContext.setUserId(getUserId());
133                    serviceContext.setUuid(getUuid());
134                    serviceContext.setWorkflowAction(getWorkflowAction());
135    
136                    return serviceContext;
137            }
138    
139            /**
140             * Derive default permissions based on the logic found in
141             * portal-web/docroot/html/taglib/ui/input_permissions/page.jsp. Do not
142             * update this logic updating the logic in the JSP.
143             */
144            public void deriveDefaultPermissions(long repositoryId, String modelName)
145                    throws PortalException {
146    
147                    long siteGroupId = PortalUtil.getSiteGroupId(repositoryId);
148    
149                    Group siteGroup = GroupLocalServiceUtil.getGroup(siteGroupId);
150    
151                    Role defaultGroupRole = RoleLocalServiceUtil.getDefaultGroupRole(
152                            siteGroupId);
153    
154                    List<String> groupPermissionsList = new ArrayList<>();
155                    List<String> guestPermissionsList = new ArrayList<>();
156    
157                    String[] roleNames = {RoleConstants.GUEST, defaultGroupRole.getName()};
158    
159                    List<String> supportedActions =
160                            ResourceActionsUtil.getModelResourceActions(modelName);
161                    List<String> groupDefaultActions =
162                            ResourceActionsUtil.getModelResourceGroupDefaultActions(modelName);
163                    List<String> guestDefaultActions =
164                            ResourceActionsUtil.getModelResourceGuestDefaultActions(modelName);
165                    List<String> guestUnsupportedActions =
166                            ResourceActionsUtil.getModelResourceGuestUnsupportedActions(
167                                    modelName);
168    
169                    for (String roleName : roleNames) {
170                            for (String action : supportedActions) {
171                                    if (roleName.equals(RoleConstants.GUEST) &&
172                                            !guestUnsupportedActions.contains(action) &&
173                                            guestDefaultActions.contains(action) &&
174                                            siteGroup.hasPublicLayouts()) {
175    
176                                            guestPermissionsList.add(action);
177                                    }
178                                    else if (roleName.equals(defaultGroupRole.getName()) &&
179                                                     groupDefaultActions.contains(action)) {
180    
181                                            groupPermissionsList.add(action);
182                                    }
183                            }
184                    }
185    
186                    String[] groupPermissions = groupPermissionsList.toArray(
187                            new String[groupPermissionsList.size()]);
188    
189                    setGroupPermissions(groupPermissions);
190    
191                    String[] guestPermissions = guestPermissionsList.toArray(
192                            new String[guestPermissionsList.size()]);
193    
194                    setGuestPermissions(guestPermissions);
195            }
196    
197            /**
198             * Returns <code>true</code> if this service context is being passed as a
199             * parameter to a method which manipulates a resource to which default group
200             * permissions apply.
201             *
202             * @return     <code>true</code> if this service context is being passed as
203             *             a parameter to a method which manipulates a resource to which
204             *             default community permissions apply; <code>false</code>
205             *             otherwise
206             * @deprecated As of 6.1.0, renamed to {@link #isAddGroupPermissions()}
207             */
208            @Deprecated
209            public boolean getAddCommunityPermissions() {
210                    return isAddGroupPermissions();
211            }
212    
213            /**
214             * Returns the asset category IDs to be applied to an asset entry if the
215             * service context is being passed as a parameter to a method which
216             * manipulates the asset entry.
217             *
218             * @return the asset category IDs
219             */
220            public long[] getAssetCategoryIds() {
221                    return _assetCategoryIds;
222            }
223    
224            /**
225             * Returns the primary keys of the asset entries linked to an asset entry if
226             * the service context is being passed as a parameter to a method which
227             * manipulates the asset entry.
228             *
229             * @return the primary keys of the asset entries
230             */
231            public long[] getAssetLinkEntryIds() {
232                    return _assetLinkEntryIds;
233            }
234    
235            /**
236             * Returns the priority of an asset entry if this service context is being
237             * passed as a parameter to a method which manipulates the asset entry.
238             *
239             * @return the asset entry's priority
240             */
241            public double getAssetPriority() {
242                    return _assetPriority;
243            }
244    
245            /**
246             * Returns the asset tag names to be applied to an asset entry if the
247             * service context is being passed as a parameter to a method which
248             * manipulates the asset entry.
249             *
250             * @return the asset tag names
251             */
252            public String[] getAssetTagNames() {
253                    return _assetTagNames;
254            }
255    
256            /**
257             * Returns the serializable object associated with the name of the standard
258             * parameter of this service context.
259             *
260             * @param  name the name of the standard parameter
261             * @return the serializable object associated with the name
262             */
263            public Serializable getAttribute(String name) {
264                    return _attributes.get(name);
265            }
266    
267            /**
268             * Returns the map of name/value pairs that are the standard parameters of
269             * this service context. Each value is serializable.
270             *
271             * @return the map of name/value pairs
272             */
273            public Map<String, Serializable> getAttributes() {
274                    return _attributes;
275            }
276    
277            /**
278             * Returns the value of the {@link Constants#CMD} parameter used in most
279             * Liferay forms for internal portlets.
280             *
281             * @return the value of the command parameter
282             */
283            public String getCommand() {
284                    return _command;
285            }
286    
287            /**
288             * Returns the specific community permissions for a resource if the service
289             * context is being passed as a parameter to a method which manipulates the
290             * resource.
291             *
292             * @return     the community permissions
293             * @deprecated As of 6.1.0, renamed to {@link #getGroupPermissions()}
294             */
295            @Deprecated
296            public String[] getCommunityPermissions() {
297                    return getGroupPermissions();
298            }
299    
300            /**
301             * Returns the company ID of this service context's current portal instance.
302             *
303             * @return the company ID
304             */
305            public long getCompanyId() {
306                    return _companyId;
307            }
308    
309            /**
310             * Returns the date when an entity was created if this service context is
311             * being passed as a parameter to a method which creates an entity.
312             *
313             * @return the creation date
314             */
315            public Date getCreateDate() {
316                    return _createDate;
317            }
318    
319            /**
320             * Returns the date when an entity was created (or a default date) if this
321             * service context is being passed as a parameter to a method which creates
322             * an entity.
323             *
324             * @param  defaultCreateDate an optional default create date to use if the
325             *         service context does not have a create date
326             * @return the creation date if available; the default date otherwise
327             */
328            public Date getCreateDate(Date defaultCreateDate) {
329                    if (_createDate != null) {
330                            return _createDate;
331                    }
332                    else if (defaultCreateDate != null) {
333                            return defaultCreateDate;
334                    }
335                    else {
336                            return new Date();
337                    }
338            }
339    
340            /**
341             * Returns the current URL of this service context
342             *
343             * @return the current URL
344             */
345            public String getCurrentURL() {
346                    return _currentURL;
347            }
348    
349            /**
350             * Returns an arbitrary number of attributes of an entity to be persisted.
351             *
352             * <p>
353             * These attributes only include fields that this service context does not
354             * possess by default.
355             * </p>
356             *
357             * @return the expando bridge attributes
358             */
359            public Map<String, Serializable> getExpandoBridgeAttributes() {
360                    return _expandoBridgeAttributes;
361            }
362    
363            /**
364             * Returns the date when an <code>aui:form</code> was generated in this
365             * service context. The form date can be used in detecting situations in
366             * which an entity has been modified while another client was editing that
367             * entity. </p>
368             *
369             * <p>
370             * Example:
371             * </p>
372             *
373             * <p>
374             * Person1 and person2 start editing the same version of a Web Content
375             * article. Person1 publishes changes to the article first. When person2
376             * attempts to publish changes to that article, the service implementation
377             * finds that a modification to that article has already been published some
378             * time after person2 started editing the article. Since the the article
379             * modification date was found to be later than the form date for person2,
380             * person2 could be alerted to the modification and make a backup copy of
381             * his edits before synchronizing with the published changes by person1.
382             * </p>
383             */
384            public Date getFormDate() {
385                    return _formDate;
386            }
387    
388            /**
389             * Returns the specific group permissions for a resource if this service
390             * context is being passed as a parameter to a method which manipulates the
391             * resource.
392             *
393             * @return the specific group permissions
394             */
395            public String[] getGroupPermissions() {
396                    return _modelPermissions.getActionIds(
397                            RoleConstants.PLACEHOLDER_DEFAULT_GROUP_ROLE);
398            }
399    
400            /**
401             * Returns this service context's user ID or guest ID if no user ID is
402             * available.
403             *
404             * @return the user ID, or guest ID if there is no user in this service
405             *         context, or <code>0</code> if there is no company in this service
406             *         context
407             */
408            public long getGuestOrUserId() throws PortalException {
409                    long userId = getUserId();
410    
411                    if (userId > 0) {
412                            return userId;
413                    }
414    
415                    long companyId = getCompanyId();
416    
417                    if (companyId > 0) {
418                            return UserLocalServiceUtil.getDefaultUserId(getCompanyId());
419                    }
420    
421                    return 0;
422            }
423    
424            /**
425             * Returns the specific guest permissions for a resource if this service
426             * context is being passed as a parameter to a method which manipulates the
427             * resource.
428             *
429             * @return the specific guest permissions
430             */
431            public String[] getGuestPermissions() {
432                    return _modelPermissions.getActionIds(RoleConstants.GUEST);
433            }
434    
435            /**
436             * Returns the the map of request header name/value pairs of this service
437             * context.
438             *
439             * @return the the map of request header name/value pairs
440             * @see    HttpHeaders
441             */
442            @JSON(include = false)
443            public Map<String, String> getHeaders() {
444                    return _headers;
445            }
446    
447            /**
448             * Returns the language ID of the locale of this service context's current
449             * user.
450             *
451             * @return the language ID
452             */
453            public String getLanguageId() {
454                    if (_languageId != null) {
455                            return _languageId;
456                    }
457    
458                    return LocaleUtil.toLanguageId(LocaleUtil.getMostRelevantLocale());
459            }
460    
461            /**
462             * Returns the complete URL of the current page if a page context can be
463             * determined for this service context.
464             *
465             * @return the complete URL of the current page
466             */
467            public String getLayoutFullURL() {
468                    return _layoutFullURL;
469            }
470    
471            /**
472             * Returns the relative URL of the current page if a page context can be
473             * determined for this service context.
474             *
475             * @return the relative URL of the current page
476             */
477            public String getLayoutURL() {
478                    return _layoutURL;
479            }
480    
481            @JSON(include = false)
482            public LiferayPortletRequest getLiferayPortletRequest() {
483                    if (_request == null) {
484                            return null;
485                    }
486    
487                    LiferayPortletRequest liferayPortletRequest =
488                            (LiferayPortletRequest)_request.getAttribute(
489                                    JavaConstants.JAVAX_PORTLET_REQUEST);
490    
491                    return liferayPortletRequest;
492            }
493    
494            @JSON(include = false)
495            public LiferayPortletResponse getLiferayPortletResponse() {
496                    if (_request == null) {
497                            return null;
498                    }
499    
500                    LiferayPortletResponse liferayPortletResponse =
501                            (LiferayPortletResponse)_request.getAttribute(
502                                    JavaConstants.JAVAX_PORTLET_RESPONSE);
503    
504                    return liferayPortletResponse;
505            }
506    
507            public Locale getLocale() {
508                    return LocaleUtil.fromLanguageId(_languageId);
509            }
510    
511            public ModelPermissions getModelPermissions() {
512                    return _modelPermissions;
513            }
514    
515            /**
516             * Returns the date when an entity was modified if this service context is
517             * being passed as a parameter to a method which updates an entity.
518             *
519             * @return the date when an entity was modified if this service context is
520             *         being passed as a parameter to a method which updates an entity
521             */
522            public Date getModifiedDate() {
523                    return _modifiedDate;
524            }
525    
526            /**
527             * Returns the date when an entity was modified if this service context is
528             * being passed as a parameter to a method which modifies an entity.
529             *
530             * @param  defaultModifiedDate an optional default modified date to use if
531             *         this service context does not have a modified date
532             * @return the modified date if available; the default date otherwise
533             */
534            public Date getModifiedDate(Date defaultModifiedDate) {
535                    if (_modifiedDate != null) {
536                            return _modifiedDate;
537                    }
538                    else if (defaultModifiedDate != null) {
539                            return defaultModifiedDate;
540                    }
541                    else {
542                            return new Date();
543                    }
544            }
545    
546            public String getPathFriendlyURLPrivateGroup() {
547                    return _pathFriendlyURLPrivateGroup;
548            }
549    
550            public String getPathFriendlyURLPrivateUser() {
551                    return _pathFriendlyURLPrivateUser;
552            }
553    
554            public String getPathFriendlyURLPublic() {
555                    return _pathFriendlyURLPublic;
556            }
557    
558            /**
559             * Returns the main context path of the portal, concatenated with
560             * <code>/c</code>.
561             *
562             * @return the main context path of the portal
563             */
564            public String getPathMain() {
565                    return _pathMain;
566            }
567    
568            /**
569             * Returns the portal layout ID of the current page of this service context.
570             *
571             * @return the portal layout ID of the current page
572             */
573            public long getPlid() {
574                    return _plid;
575            }
576    
577            /**
578             * Returns the URL of this service context's portal, including the protocol,
579             * domain, and non-default port relative to the company instance and any
580             * virtual host.
581             *
582             * <p>
583             * The URL returned does not include the port if a default port is used.
584             * </p>
585             *
586             * @return the URL of this service context's portal, including the protocol,
587             *         domain, and non-default port relative to company instance and any
588             *         virtual host
589             */
590            public String getPortalURL() {
591                    return _portalURL;
592            }
593    
594            /**
595             * Returns the ID of the current portlet if this service context is being
596             * passed as a parameter to a portlet.
597             *
598             * @return the ID of the current portlet
599             * @see    PortletPreferencesIds
600             */
601            public String getPortletId() {
602                    if (_portletPreferencesIds == null) {
603                            return null;
604                    }
605    
606                    return _portletPreferencesIds.getPortletId();
607            }
608    
609            /**
610             * Returns the portlet preferences IDs of the current portlet if the service
611             * context is being passed as a parameter to a portlet.
612             *
613             * <p>
614             * The {@link PortletPreferencesIds} can be used to look up portlet
615             * preferences of the current portlet.
616             * </p>
617             *
618             * @return the portlet preferences IDs of the current portlet
619             * @see    PortletPreferencesIds
620             */
621            public PortletPreferencesIds getPortletPreferencesIds() {
622                    return _portletPreferencesIds;
623            }
624    
625            /**
626             * Returns the remote address of the user making the request in this service
627             * context.
628             *
629             * @return the remote address of the user making the request
630             */
631            public String getRemoteAddr() {
632                    return _remoteAddr;
633            }
634    
635            /**
636             * Returns the remote host name of the user making the request in this
637             * service context.
638             *
639             * @return the remote host name of the user making the request
640             */
641            public String getRemoteHost() {
642                    return _remoteHost;
643            }
644    
645            @JSON(include = false)
646            public HttpServletRequest getRequest() {
647                    return _request;
648            }
649    
650            @JSON(include = false)
651            public HttpServletResponse getResponse() {
652                    LiferayPortletResponse liferayPortletResponse =
653                            getLiferayPortletResponse();
654    
655                    if (liferayPortletResponse == null) {
656                            return null;
657                    }
658    
659                    return PortalUtil.getHttpServletResponse(liferayPortletResponse);
660            }
661    
662            public String getRootPortletId() {
663                    String portletId = getPortletId();
664    
665                    if (portletId == null) {
666                            return null;
667                    }
668    
669                    return PortletConstants.getRootPortletId(portletId);
670            }
671    
672            public Group getScopeGroup() throws PortalException {
673                    return GroupLocalServiceUtil.getGroup(_scopeGroupId);
674            }
675    
676            /**
677             * Returns the ID of the group corresponding to the current data scope of
678             * this service context.
679             *
680             * @return the ID of the group corresponding to the current data scope
681             * @see    Group
682             */
683            public long getScopeGroupId() {
684                    return _scopeGroupId;
685            }
686    
687            public ThemeDisplay getThemeDisplay() {
688                    if (_request == null) {
689                            return null;
690                    }
691    
692                    return (ThemeDisplay)_request.getAttribute(WebKeys.THEME_DISPLAY);
693            }
694    
695            public TimeZone getTimeZone() {
696                    return _timeZone;
697            }
698    
699            /**
700             * Returns the user-agent request header of this service context.
701             *
702             * @return the user-agent request header
703             * @see    HttpHeaders
704             */
705            public String getUserAgent() {
706                    if (_request == null) {
707                            return null;
708                    }
709    
710                    return _request.getHeader(HttpHeaders.USER_AGENT);
711            }
712    
713            /**
714             * Returns the complete URL of this service context's current user's profile
715             * page.
716             *
717             * @return the complete URL of this service context's current user's profile
718             *         page
719             */
720            public String getUserDisplayURL() {
721                    return _userDisplayURL;
722            }
723    
724            /**
725             * Returns the ID of this service context's current user.
726             *
727             * @return the ID of this service context's current user
728             */
729            public long getUserId() {
730                    return _userId;
731            }
732    
733            /**
734             * Returns the UUID of this service context's current entity.
735             *
736             * <p>
737             * To ensure the same UUID is never used by two entities, the UUID is reset
738             * to <code>null</code> upon invoking this method.
739             * </p>
740             *
741             * @return the UUID of this service context's current entity
742             */
743            public String getUuid() {
744                    String uuid = _uuid;
745    
746                    _uuid = null;
747    
748                    return uuid;
749            }
750    
751            public String getUuidWithoutReset() {
752                    return _uuid;
753            }
754    
755            /**
756             * Returns the workflow action to take if this service context is being
757             * passed as a parameter to a method that processes a workflow action.
758             *
759             * @return the workflow action to take
760             */
761            public int getWorkflowAction() {
762                    return _workflowAction;
763            }
764    
765            /**
766             * Returns <code>true</code> if this service context is being passed as a
767             * parameter to a method which manipulates a resource to which default group
768             * permissions apply.
769             *
770             * @return <code>true</code> if this service context is being passed as a
771             *         parameter to a method which manipulates a resource to which
772             *         default group permissions apply; <code>false</code> otherwise
773             */
774            public boolean isAddGroupPermissions() {
775                    return _addGroupPermissions;
776            }
777    
778            /**
779             * Returns <code>true</code> if this service context is being passed as a
780             * parameter to a method which manipulates a resource to which default guest
781             * permissions apply.
782             *
783             * @return <code>true</code> if this service context is being passed as a
784             *         parameter to a method which manipulates a resource to which
785             *         default guest permissions apply; <code>false</code> otherwise
786             */
787            public boolean isAddGuestPermissions() {
788                    return _addGuestPermissions;
789            }
790    
791            public boolean isAssetEntryVisible() {
792                    return _assetEntryVisible;
793            }
794    
795            /**
796             * Returns <code>true</code> if this service context contains an add command
797             * (i.e. has command value {@link Constants#ADD})
798             *
799             * @return <code>true</code> if this service context contains an add
800             *         command; <code>false</code> otherwise
801             */
802            public boolean isCommandAdd() {
803                    if (Validator.equals(_command, Constants.ADD) ||
804                            Validator.equals(_command, Constants.ADD_DYNAMIC) ||
805                            Validator.equals(_command, Constants.ADD_MULTIPLE) ||
806                            Validator.equals(_command, Constants.ADD_WEBDAV)) {
807    
808                            return true;
809                    }
810                    else {
811                            return false;
812                    }
813            }
814    
815            /**
816             * Returns <code>true</code> if this service context contains an update
817             * command (i.e. has command value {@link Constants#UPDATE})
818             *
819             * @return <code>true</code> if this service context contains an update
820             *         command; <code>false</code> otherwise
821             */
822            public boolean isCommandUpdate() {
823                    if (Validator.equals(_command, Constants.UPDATE) ||
824                            Validator.equals(_command, Constants.UPDATE_AND_CHECKIN) ||
825                            Validator.equals(_command, Constants.UPDATE_WEBDAV)) {
826    
827                            return true;
828                    }
829                    else {
830                            return false;
831                    }
832            }
833    
834            public boolean isDeriveDefaultPermissions() {
835                    return _deriveDefaultPermissions;
836            }
837    
838            /**
839             * Returns <code>true</code> if portal exceptions should be handled as
840             * failures, possibly halting processing, or <code>false</code> if the
841             * exceptions should be handled differently, possibly allowing processing to
842             * continue in some manner. Services may check this flag to execute desired
843             * behavior.
844             *
845             * <p>
846             * Batch invocation of such services (exposed as a JSON web services) can
847             * result in execution of all service invocations, in spite of portal
848             * exceptions.
849             * </p>
850             *
851             * <p>
852             * If this flag is set to <code>false</code>, services can implement logic
853             * that allows processing to continue, while collecting information
854             * regarding the exceptions for returning to the caller. For example, the
855             * {@link
856             * com.liferay.portlet.asset.service.impl.AssetVocabularyServiceImpl#deleteVocabularies(
857             * long[], ServiceContext)} method uses the list it returns to give
858             * information on vocabularies it fails to delete; it returns an empty list
859             * if all deletions are successful.
860             * </p>
861             *
862             * @return <code>true</code> if portal exceptions are to be handled as
863             *         failures; <code>false</code> if portal exceptions can be handled
864             *         differently, possibly allowing processing to continue in some
865             *         manner
866             */
867            public boolean isFailOnPortalException() {
868                    return _failOnPortalException;
869            }
870    
871            /**
872             * Returns whether the primary entity of this service context is to be
873             * indexed/re-indexed.
874             *
875             * @return <code>true</code> the primary entity of this service context is
876             *         to be indexed/re-indexed; <code>false</code> otherwise
877             */
878            public boolean isIndexingEnabled() {
879                    return _indexingEnabled;
880            }
881    
882            /**
883             * Returns <code>true</code> if the sender of this service context's request
884             * is signed in.
885             *
886             * @return <code>true</code> if the sender of this service context's request
887             *         is signed in; <code>false</code> otherwise
888             */
889            public boolean isSignedIn() {
890                    return _signedIn;
891            }
892    
893            /**
894             * Merges all of the specified service context's non-<code>null</code>
895             * attributes, attributes greater than <code>0</code>, and fields (except
896             * the request) with this service context object.
897             *
898             * @param serviceContext the service context object to be merged
899             */
900            public void merge(ServiceContext serviceContext) {
901                    setAddGroupPermissions(serviceContext.isAddGroupPermissions());
902                    setAddGuestPermissions(serviceContext.isAddGuestPermissions());
903    
904                    if (serviceContext.getAssetCategoryIds() != null) {
905                            setAssetCategoryIds(serviceContext.getAssetCategoryIds());
906                    }
907    
908                    setAssetEntryVisible(serviceContext.isAssetEntryVisible());
909    
910                    if (serviceContext.getAssetLinkEntryIds() != null) {
911                            setAssetLinkEntryIds(serviceContext.getAssetLinkEntryIds());
912                    }
913    
914                    if (serviceContext.getAssetPriority() > 0) {
915                            setAssetPriority(serviceContext.getAssetPriority());
916                    }
917    
918                    if (serviceContext.getAssetTagNames() != null) {
919                            setAssetTagNames(serviceContext.getAssetTagNames());
920                    }
921    
922                    if (serviceContext.getAttributes() != null) {
923                            setAttributes(serviceContext.getAttributes());
924                    }
925    
926                    if (Validator.isNotNull(serviceContext.getCommand())) {
927                            setCommand(serviceContext.getCommand());
928                    }
929    
930                    if (serviceContext.getCompanyId() > 0) {
931                            setCompanyId(serviceContext.getCompanyId());
932                    }
933    
934                    if (serviceContext.getCreateDate() != null) {
935                            setCreateDate(serviceContext.getCreateDate());
936                    }
937    
938                    if (Validator.isNotNull(serviceContext.getCurrentURL())) {
939                            setCurrentURL(serviceContext.getCurrentURL());
940                    }
941    
942                    setDeriveDefaultPermissions(
943                            serviceContext.isDeriveDefaultPermissions());
944    
945                    if (serviceContext.getExpandoBridgeAttributes() != null) {
946                            setExpandoBridgeAttributes(
947                                    serviceContext.getExpandoBridgeAttributes());
948                    }
949    
950                    setFailOnPortalException(serviceContext.isFailOnPortalException());
951    
952                    if (serviceContext.getGroupPermissions() != null) {
953                            setGroupPermissions(serviceContext.getGroupPermissions());
954                    }
955    
956                    if (serviceContext.getGuestPermissions() != null) {
957                            setGuestPermissions(serviceContext.getGuestPermissions());
958                    }
959    
960                    if (serviceContext.getHeaders() != null) {
961                            setHeaders(serviceContext.getHeaders());
962                    }
963    
964                    setIndexingEnabled(serviceContext.isIndexingEnabled());
965                    setLanguageId(serviceContext.getLanguageId());
966    
967                    if (Validator.isNotNull(serviceContext.getLayoutFullURL())) {
968                            setLayoutFullURL(serviceContext.getLayoutFullURL());
969                    }
970    
971                    if (Validator.isNotNull(serviceContext.getLayoutURL())) {
972                            setLayoutURL(serviceContext.getLayoutURL());
973                    }
974    
975                    if (serviceContext.getModifiedDate() != null) {
976                            setModifiedDate(serviceContext.getModifiedDate());
977                    }
978    
979                    if (Validator.isNotNull(
980                                    serviceContext.getPathFriendlyURLPrivateGroup())) {
981    
982                            setPathFriendlyURLPrivateGroup(
983                                    serviceContext.getPathFriendlyURLPrivateGroup());
984                    }
985    
986                    if (Validator.isNotNull(
987                                    serviceContext.getPathFriendlyURLPrivateUser())) {
988    
989                            setPathFriendlyURLPrivateUser(
990                                    serviceContext.getPathFriendlyURLPrivateUser());
991                    }
992    
993                    if (Validator.isNotNull(serviceContext.getPathFriendlyURLPublic())) {
994                            setPathFriendlyURLPublic(serviceContext.getPathFriendlyURLPublic());
995                    }
996    
997                    if (Validator.isNotNull(serviceContext.getPathMain())) {
998                            setPathMain(serviceContext.getPathMain());
999                    }
1000    
1001                    if (serviceContext.getPlid() > 0) {
1002                            setPlid(serviceContext.getPlid());
1003                    }
1004    
1005                    if (Validator.isNotNull(serviceContext.getPortalURL())) {
1006                            setPortalURL(serviceContext.getPortalURL());
1007                    }
1008    
1009                    if (serviceContext.getPortletPreferencesIds() != null) {
1010                            setPortletPreferencesIds(serviceContext.getPortletPreferencesIds());
1011                    }
1012    
1013                    if (Validator.isNotNull(serviceContext.getRemoteAddr())) {
1014                            setRemoteAddr(serviceContext.getRemoteAddr());
1015                    }
1016    
1017                    if (Validator.isNotNull(serviceContext.getRemoteHost())) {
1018                            setRemoteHost(serviceContext.getRemoteHost());
1019                    }
1020    
1021                    if (serviceContext.getScopeGroupId() > 0) {
1022                            setScopeGroupId(serviceContext.getScopeGroupId());
1023                    }
1024    
1025                    setSignedIn(serviceContext.isSignedIn());
1026    
1027                    if (serviceContext.getTimeZone() != null) {
1028                            setTimeZone(serviceContext.getTimeZone());
1029                    }
1030    
1031                    if (Validator.isNotNull(serviceContext.getUserDisplayURL())) {
1032                            setUserDisplayURL(serviceContext.getUserDisplayURL());
1033                    }
1034    
1035                    if (serviceContext.getUserId() > 0) {
1036                            setUserId(serviceContext.getUserId());
1037                    }
1038    
1039                    // Refrence serviceContext#_uuid directly because calling
1040                    // serviceContext#getUuid() would set it to null
1041    
1042                    if (Validator.isNotNull(serviceContext._uuid)) {
1043                            setUuid(serviceContext._uuid);
1044                    }
1045    
1046                    if (serviceContext.getWorkflowAction() > 0) {
1047                            setWorkflowAction(serviceContext.getWorkflowAction());
1048                    }
1049            }
1050    
1051            /**
1052             * Removes the mapping of the serializable object to the name of the
1053             * standard parameter of this service context.
1054             *
1055             * @param  name the name of the standard parameter
1056             * @return the serializable object associated to the name
1057             */
1058            public Serializable removeAttribute(String name) {
1059                    return _attributes.remove(name);
1060            }
1061    
1062            /**
1063             * Sets whether or not default community permissions should apply to a
1064             * resource being manipulated by a method to which this service context is
1065             * passed as a parameter.
1066             *
1067             * @param      addCommunityPermissions indicates whether or not to apply
1068             *             default community permissions
1069             * @deprecated As of 6.1.0, renamed to {@link
1070             *             #setAddGroupPermissions(boolean)}
1071             */
1072            @Deprecated
1073            public void setAddCommunityPermissions(boolean addCommunityPermissions) {
1074                    setAddGroupPermissions(addCommunityPermissions);
1075            }
1076    
1077            /**
1078             * Sets whether or not default group permissions should apply to a resource
1079             * being manipulated by a method to which this service context is passed as
1080             * a parameter.
1081             *
1082             * @param addGroupPermissions indicates whether or not to apply default
1083             *        group permissions
1084             */
1085            public void setAddGroupPermissions(boolean addGroupPermissions) {
1086                    _addGroupPermissions = addGroupPermissions;
1087            }
1088    
1089            /**
1090             * Sets whether or not default guest permissions should apply to a resource
1091             * being manipulated by a method to which this service context is passed as
1092             * a parameter.
1093             *
1094             * @param addGuestPermissions indicates whether or not to apply default
1095             *        guest permissions
1096             */
1097            public void setAddGuestPermissions(boolean addGuestPermissions) {
1098                    _addGuestPermissions = addGuestPermissions;
1099            }
1100    
1101            /**
1102             * Sets an array of asset category IDs to be applied to an asset entry if
1103             * this service context is being passed as a parameter to a method which
1104             * manipulates the asset entry.
1105             *
1106             * @param assetCategoryIds the primary keys of the asset categories
1107             */
1108            public void setAssetCategoryIds(long[] assetCategoryIds) {
1109                    _assetCategoryIds = assetCategoryIds;
1110            }
1111    
1112            public void setAssetEntryVisible(boolean assetEntryVisible) {
1113                    _assetEntryVisible = assetEntryVisible;
1114            }
1115    
1116            /**
1117             * Sets an array of the primary keys of asset entries to be linked to an
1118             * asset entry if this service context is being passed as a parameter to a
1119             * method which manipulates the asset entry.
1120             *
1121             * @param assetLinkEntryIds the primary keys of the asset entries to be
1122             *        linked to an asset entry
1123             */
1124            public void setAssetLinkEntryIds(long[] assetLinkEntryIds) {
1125                    _assetLinkEntryIds = assetLinkEntryIds;
1126            }
1127    
1128            /**
1129             * Sets the priority of an asset entry if this service context is being
1130             * passed as a parameter to a method which manipulates the asset entry.
1131             *
1132             * @param assetPriority the priority of an asset entry
1133             */
1134            public void setAssetPriority(double assetPriority) {
1135                    _assetPriority = assetPriority;
1136            }
1137    
1138            /**
1139             * Sets an array of asset tag names to be applied to an asset entry if this
1140             * service context is being passed as a parameter to a method which
1141             * manipulates the asset entry.
1142             *
1143             * @param assetTagNames the tag names to be applied to an asset entry
1144             */
1145            public void setAssetTagNames(String[] assetTagNames) {
1146                    _assetTagNames = assetTagNames;
1147            }
1148    
1149            /**
1150             * Sets a mapping of a standard parameter's name to its serializable object.
1151             *
1152             * @param name the standard parameter name to associate with the value
1153             * @param value the serializable object to be associated with the name
1154             */
1155            public void setAttribute(String name, Serializable value) {
1156                    _attributes.put(name, value);
1157            }
1158    
1159            /**
1160             * Sets the map of the name/value pairs that are the standard parameters of
1161             * this service context. Each value must be serializable.
1162             *
1163             * @param attributes the map of the name/value pairs that are the standard
1164             *        parameters of this service context
1165             */
1166            public void setAttributes(Map<String, Serializable> attributes) {
1167                    _attributes = attributes;
1168            }
1169    
1170            /**
1171             * Sets the value of the {@link Constants#CMD} parameter used in most
1172             * Liferay forms for internal portlets.
1173             *
1174             * @param command the value of the {@link Constants#CMD} parameter
1175             */
1176            public void setCommand(String command) {
1177                    _command = command;
1178            }
1179    
1180            /**
1181             * Sets an array containing specific community permissions for a resource if
1182             * this service context is being passed as a parameter to a method which
1183             * manipulates the resource.
1184             *
1185             * @param      communityPermissions the community permissions (optionally
1186             *             <code>null</code>)
1187             * @deprecated As of 6.1.0, renamed to {@link
1188             *             #setGroupPermissions(String[])}
1189             */
1190            @Deprecated
1191            public void setCommunityPermissions(String[] communityPermissions) {
1192                    setGroupPermissions(communityPermissions);
1193            }
1194    
1195            /**
1196             * Sets the company ID of this service context's current portal instance.
1197             *
1198             * @param companyId the primary key of this service context's current portal
1199             *        instance
1200             */
1201            public void setCompanyId(long companyId) {
1202                    _companyId = companyId;
1203            }
1204    
1205            /**
1206             * Sets the date when an entity was created if this service context is being
1207             * passed as a parameter to a method which creates an entity.
1208             *
1209             * @param createDate the date the entity was created
1210             */
1211            public void setCreateDate(Date createDate) {
1212                    _createDate = createDate;
1213            }
1214    
1215            /**
1216             * Sets the current URL of this service context
1217             *
1218             * @param currentURL the current URL of this service context
1219             */
1220            public void setCurrentURL(String currentURL) {
1221                    _currentURL = currentURL;
1222            }
1223    
1224            public void setDeriveDefaultPermissions(boolean deriveDefaultPermissions) {
1225                    _deriveDefaultPermissions = deriveDefaultPermissions;
1226            }
1227    
1228            /**
1229             * Sets an arbitrary number of attributes of an entity to be persisted.
1230             *
1231             * <p>
1232             * These attributes should only include fields that {@link
1233             * com.liferay.portal.service.ServiceContext} does not possess by default.
1234             * </p>
1235             *
1236             * @param expandoBridgeAttributes the expando bridge attributes (optionally
1237             *        <code>null</code>)
1238             */
1239            public void setExpandoBridgeAttributes(
1240                    Map<String, Serializable> expandoBridgeAttributes) {
1241    
1242                    _expandoBridgeAttributes = expandoBridgeAttributes;
1243            }
1244    
1245            /**
1246             * Sets whether portal exceptions should be handled as failures, possibly
1247             * halting processing, or if exceptions should be handled differently,
1248             * possibly allowing processing to continue in some manner.
1249             *
1250             * @param failOnPortalException whether portal exceptions should be handled
1251             *        as failures, or if portal exceptions should be handled
1252             *        differently, possibly allowing processing to continue in some
1253             *        manner
1254             * @see   #isFailOnPortalException()
1255             */
1256            public void setFailOnPortalException(boolean failOnPortalException) {
1257                    _failOnPortalException = failOnPortalException;
1258            }
1259    
1260            /**
1261             * Sets the date when an <code>aui:form</code> was generated in this service
1262             * context. The form date can be used in detecting situations in which an
1263             * entity has been modified while another client was editing that entity.
1264             *
1265             * <p>
1266             * Example:
1267             * </p>
1268             *
1269             * <p>
1270             * Person1 and person2 start editing the same version of a Web Content
1271             * article. Person1 publishes changes to the article first. When person2
1272             * attempts to publish changes to that article, the service implementation
1273             * finds that a modification to that article has already been published some
1274             * time after person2 started editing the article. Since the article
1275             * modification date was found to be later than the form date for person2,
1276             * person2 could be alerted to the modification and make a backup copy of
1277             * his edits before synchronizing with the published changes by person1.
1278             * </p>
1279             *
1280             * @param formDate the date that an <code>aui:form</code> was generated for
1281             *        this service context (optionally <code>null</code>)
1282             */
1283            public void setFormDate(Date formDate) {
1284                    _formDate = formDate;
1285            }
1286    
1287            /**
1288             * Sets an array containing specific group permissions for a resource if
1289             * this service context is being passed as a parameter to a method which
1290             * manipulates the resource.
1291             *
1292             * @param groupPermissions the permissions (optionally <code>null</code>)
1293             */
1294            public void setGroupPermissions(String[] groupPermissions) {
1295                    _modelPermissions.addRolePermissions(
1296                            RoleConstants.PLACEHOLDER_DEFAULT_GROUP_ROLE, groupPermissions);
1297            }
1298    
1299            /**
1300             * Sets an array containing specific guest permissions for a resource if
1301             * this service context is being passed as a parameter to a method which
1302             * manipulates the resource.
1303             *
1304             * @param guestPermissions the guest permissions (optionally
1305             *        <code>null</code>)
1306             */
1307            public void setGuestPermissions(String[] guestPermissions) {
1308                    _modelPermissions.addRolePermissions(
1309                            RoleConstants.GUEST, guestPermissions);
1310            }
1311    
1312            /**
1313             * Sets the map of request header name/value pairs of this service context.
1314             *
1315             * @param headers map of request header name/value pairs of this service
1316             *        context
1317             * @see   HttpHeaders
1318             */
1319            public void setHeaders(Map<String, String> headers) {
1320                    _headers = headers;
1321            }
1322    
1323            /**
1324             * Sets whether the primary entity of this service context is to be
1325             * indexed/re-indexed.
1326             *
1327             * <p>
1328             * The entity is only indexed/re-indexed if the method receiving this
1329             * service context as a parameter does indexing.
1330             * </p>
1331             *
1332             * @param indexingEnabled whether the primary entity of this service context
1333             *        is to be indexed/re-indexed (default is <code>true</code>)
1334             */
1335            public void setIndexingEnabled(boolean indexingEnabled) {
1336                    _indexingEnabled = indexingEnabled;
1337            }
1338    
1339            /**
1340             * Sets the language ID of the locale of this service context.
1341             *
1342             * @param languageId the language ID of the locale of this service context's
1343             *        current user
1344             */
1345            public void setLanguageId(String languageId) {
1346                    _languageId = languageId;
1347            }
1348    
1349            /**
1350             * Sets the complete URL of the current page for this service context.
1351             *
1352             * @param layoutFullURL the complete URL of the current page if a page
1353             *        context can be determined for this service context
1354             */
1355            public void setLayoutFullURL(String layoutFullURL) {
1356                    _layoutFullURL = layoutFullURL;
1357            }
1358    
1359            /**
1360             * Sets the relative URL of the current page for this service context.
1361             *
1362             * @param layoutURL the relative URL of the current page if a page context
1363             *        can be determined for this service context
1364             */
1365            public void setLayoutURL(String layoutURL) {
1366                    _layoutURL = layoutURL;
1367            }
1368    
1369            public void setModelPermissions(ModelPermissions modelPermissions) {
1370                    _modelPermissions = modelPermissions;
1371            }
1372    
1373            /**
1374             * Sets the date when an entity was modified in this service context.
1375             *
1376             * @param modifiedDate the date when an entity was modified in this service
1377             *        context
1378             */
1379            public void setModifiedDate(Date modifiedDate) {
1380                    _modifiedDate = modifiedDate;
1381            }
1382    
1383            public void setPathFriendlyURLPrivateGroup(
1384                    String pathFriendlyURLPrivateGroup) {
1385    
1386                    _pathFriendlyURLPrivateGroup = pathFriendlyURLPrivateGroup;
1387            }
1388    
1389            public void setPathFriendlyURLPrivateUser(
1390                    String pathFriendlyURLPrivateUser) {
1391    
1392                    _pathFriendlyURLPrivateUser = pathFriendlyURLPrivateUser;
1393            }
1394    
1395            public void setPathFriendlyURLPublic(String pathFriendlyURLPublic) {
1396                    _pathFriendlyURLPublic = pathFriendlyURLPublic;
1397            }
1398    
1399            /**
1400             * Sets the main context path of the portal, concatenated with
1401             * <code>/c</code>.
1402             *
1403             * @param pathMain the main context path of the portal
1404             */
1405            public void setPathMain(String pathMain) {
1406                    _pathMain = pathMain;
1407            }
1408    
1409            /**
1410             * Sets the portal layout ID of the current page in this service context.
1411             *
1412             * @param plid the portal layout ID of the current page
1413             */
1414            public void setPlid(long plid) {
1415                    _plid = plid;
1416            }
1417    
1418            /**
1419             * Sets the URL of this service context's portal, including the protocol,
1420             * domain, and non-default port relative to the company instance and any
1421             * virtual host.
1422             *
1423             * <p>
1424             * The URL should not include the port if a default port is used.
1425             * </p>
1426             *
1427             * @param portalURL the portal URL
1428             */
1429            public void setPortalURL(String portalURL) {
1430                    _portalURL = portalURL;
1431            }
1432    
1433            /**
1434             * Sets the portlet preferences IDs of the current portlet if this service
1435             * context is being passed as a parameter to a portlet.
1436             *
1437             * <p>
1438             * The {@link PortletPreferencesIds} can be used to look up portlet
1439             * preferences of the current portlet.
1440             * </p>
1441             *
1442             * @param portletPreferencesIds the portlet preferences
1443             * @see   PortletPreferencesIds
1444             */
1445            public void setPortletPreferencesIds(
1446                    PortletPreferencesIds portletPreferencesIds) {
1447    
1448                    _portletPreferencesIds = portletPreferencesIds;
1449            }
1450    
1451            /**
1452             * Sets the remote address of the user making the request in this service
1453             * context.
1454             *
1455             * @param remoteAddr the remote address of the user making the request in
1456             *        this service context
1457             */
1458            public void setRemoteAddr(String remoteAddr) {
1459                    _remoteAddr = remoteAddr;
1460            }
1461    
1462            /**
1463             * Sets the remote host name of the user making the request in this service
1464             * context.
1465             *
1466             * @param remoteHost the remote host name of the user making the request in
1467             *        this service context
1468             */
1469            public void setRemoteHost(String remoteHost) {
1470                    _remoteHost = remoteHost;
1471            }
1472    
1473            /**
1474             * Sets the optional request used when instantiating this service context.
1475             * The field is volatile and so will be discarded on serialization.
1476             *
1477             * @param request the request
1478             */
1479            public void setRequest(HttpServletRequest request) {
1480                    _request = request;
1481            }
1482    
1483            /**
1484             * Sets the ID of the group corresponding to the current data scope of this
1485             * service context.
1486             *
1487             * @param scopeGroupId the ID of the group corresponding to the current data
1488             *        scope of this service context
1489             * @see   Group
1490             */
1491            public void setScopeGroupId(long scopeGroupId) {
1492                    _scopeGroupId = scopeGroupId;
1493            }
1494    
1495            /**
1496             * Sets whether the sender of this service context's request is signed in.
1497             *
1498             * @param signedIn whether the sender of this service context's request is
1499             *        signed in
1500             */
1501            public void setSignedIn(boolean signedIn) {
1502                    _signedIn = signedIn;
1503            }
1504    
1505            public void setTimeZone(TimeZone timeZone) {
1506                    _timeZone = timeZone;
1507            }
1508    
1509            /**
1510             * Sets the complete URL of this service context's current user's profile
1511             * page.
1512             *
1513             * @param userDisplayURL the complete URL of the current user's profile page
1514             */
1515            public void setUserDisplayURL(String userDisplayURL) {
1516                    _userDisplayURL = userDisplayURL;
1517            }
1518    
1519            /**
1520             * Sets the ID of this service context's current user.
1521             *
1522             * @param userId the ID of the current user
1523             */
1524            public void setUserId(long userId) {
1525                    _userId = userId;
1526            }
1527    
1528            /**
1529             * Sets the UUID of this service context's current entity.
1530             *
1531             * @param uuid the UUID of the current entity
1532             */
1533            public void setUuid(String uuid) {
1534                    _uuid = uuid;
1535            }
1536    
1537            /**
1538             * Sets the workflow action to take if this service context is being passed
1539             * as parameter to a method that processes a workflow action.
1540             *
1541             * @param workflowAction workflow action to take (default is {@link
1542             *        WorkflowConstants#ACTION_PUBLISH})
1543             */
1544            public void setWorkflowAction(int workflowAction) {
1545                    _workflowAction = workflowAction;
1546            }
1547    
1548            public String translate(String pattern, Object... arguments) {
1549                    Locale locale = getLocale();
1550    
1551                    return LanguageUtil.format(locale, pattern, arguments);
1552            }
1553    
1554            public void validateModifiedDate(
1555                            AuditedModel auditedModel, Class<? extends PortalException> clazz)
1556                    throws PortalException {
1557    
1558                    int value = DateUtil.compareTo(
1559                            auditedModel.getModifiedDate(), _formDate);
1560    
1561                    if (value > 0) {
1562                            try {
1563                                    throw clazz.newInstance();
1564                            }
1565                            catch (IllegalAccessException iae) {
1566                                    throw new RuntimeException(iae);
1567                            }
1568                            catch (InstantiationException ie) {
1569                                    throw new RuntimeException(ie);
1570                            }
1571                    }
1572            }
1573    
1574            private boolean _addGroupPermissions;
1575            private boolean _addGuestPermissions;
1576            private long[] _assetCategoryIds;
1577            private boolean _assetEntryVisible = true;
1578            private long[] _assetLinkEntryIds;
1579            private double _assetPriority;
1580            private String[] _assetTagNames;
1581            private Map<String, Serializable> _attributes;
1582            private String _command;
1583            private long _companyId;
1584            private Date _createDate;
1585            private String _currentURL;
1586            private boolean _deriveDefaultPermissions;
1587            private Map<String, Serializable> _expandoBridgeAttributes;
1588            private boolean _failOnPortalException = true;
1589            private Date _formDate;
1590            private transient Map<String, String> _headers;
1591            private boolean _indexingEnabled = true;
1592            private String _languageId;
1593            private String _layoutFullURL;
1594            private String _layoutURL;
1595            private ModelPermissions _modelPermissions = new ModelPermissions();
1596            private Date _modifiedDate;
1597            private String _pathFriendlyURLPrivateGroup;
1598            private String _pathFriendlyURLPrivateUser;
1599            private String _pathFriendlyURLPublic;
1600            private String _pathMain;
1601            private long _plid;
1602            private String _portalURL;
1603            private PortletPreferencesIds _portletPreferencesIds;
1604            private String _remoteAddr;
1605            private String _remoteHost;
1606            private transient HttpServletRequest _request;
1607            private long _scopeGroupId;
1608            private boolean _signedIn;
1609            private TimeZone _timeZone;
1610            private String _userDisplayURL;
1611            private long _userId;
1612            private String _uuid;
1613            private int _workflowAction = WorkflowConstants.ACTION_PUBLISH;
1614    
1615    }