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             * @throws PortalException if a default user for the company could not be
408             *         found
409             */
410            public long getGuestOrUserId() throws PortalException {
411                    long userId = getUserId();
412    
413                    if (userId > 0) {
414                            return userId;
415                    }
416    
417                    long companyId = getCompanyId();
418    
419                    if (companyId > 0) {
420                            return UserLocalServiceUtil.getDefaultUserId(getCompanyId());
421                    }
422    
423                    return 0;
424            }
425    
426            /**
427             * Returns the specific guest permissions for a resource if this service
428             * context is being passed as a parameter to a method which manipulates the
429             * resource.
430             *
431             * @return the specific guest permissions
432             */
433            public String[] getGuestPermissions() {
434                    return _modelPermissions.getActionIds(RoleConstants.GUEST);
435            }
436    
437            /**
438             * Returns the the map of request header name/value pairs of this service
439             * context.
440             *
441             * @return the the map of request header name/value pairs
442             * @see    HttpHeaders
443             */
444            @JSON(include = false)
445            public Map<String, String> getHeaders() {
446                    return _headers;
447            }
448    
449            /**
450             * Returns the language ID of the locale of this service context's current
451             * user.
452             *
453             * @return the language ID
454             */
455            public String getLanguageId() {
456                    if (_languageId != null) {
457                            return _languageId;
458                    }
459    
460                    return LocaleUtil.toLanguageId(LocaleUtil.getMostRelevantLocale());
461            }
462    
463            /**
464             * Returns the complete URL of the current page if a page context can be
465             * determined for this service context.
466             *
467             * @return the complete URL of the current page
468             */
469            public String getLayoutFullURL() {
470                    return _layoutFullURL;
471            }
472    
473            /**
474             * Returns the relative URL of the current page if a page context can be
475             * determined for this service context.
476             *
477             * @return the relative URL of the current page
478             */
479            public String getLayoutURL() {
480                    return _layoutURL;
481            }
482    
483            @JSON(include = false)
484            public LiferayPortletRequest getLiferayPortletRequest() {
485                    if (_request == null) {
486                            return null;
487                    }
488    
489                    LiferayPortletRequest liferayPortletRequest =
490                            (LiferayPortletRequest)_request.getAttribute(
491                                    JavaConstants.JAVAX_PORTLET_REQUEST);
492    
493                    return liferayPortletRequest;
494            }
495    
496            @JSON(include = false)
497            public LiferayPortletResponse getLiferayPortletResponse() {
498                    if (_request == null) {
499                            return null;
500                    }
501    
502                    LiferayPortletResponse liferayPortletResponse =
503                            (LiferayPortletResponse)_request.getAttribute(
504                                    JavaConstants.JAVAX_PORTLET_RESPONSE);
505    
506                    return liferayPortletResponse;
507            }
508    
509            public Locale getLocale() {
510                    return LocaleUtil.fromLanguageId(_languageId);
511            }
512    
513            public ModelPermissions getModelPermissions() {
514                    return _modelPermissions;
515            }
516    
517            /**
518             * Returns the date when an entity was modified if this service context is
519             * being passed as a parameter to a method which updates an entity.
520             *
521             * @return the date when an entity was modified if this service context is
522             *         being passed as a parameter to a method which updates an entity
523             */
524            public Date getModifiedDate() {
525                    return _modifiedDate;
526            }
527    
528            /**
529             * Returns the date when an entity was modified if this service context is
530             * being passed as a parameter to a method which modifies an entity.
531             *
532             * @param  defaultModifiedDate an optional default modified date to use if
533             *         this service context does not have a modified date
534             * @return the modified date if available; the default date otherwise
535             */
536            public Date getModifiedDate(Date defaultModifiedDate) {
537                    if (_modifiedDate != null) {
538                            return _modifiedDate;
539                    }
540                    else if (defaultModifiedDate != null) {
541                            return defaultModifiedDate;
542                    }
543                    else {
544                            return new Date();
545                    }
546            }
547    
548            public String getPathFriendlyURLPrivateGroup() {
549                    return _pathFriendlyURLPrivateGroup;
550            }
551    
552            public String getPathFriendlyURLPrivateUser() {
553                    return _pathFriendlyURLPrivateUser;
554            }
555    
556            public String getPathFriendlyURLPublic() {
557                    return _pathFriendlyURLPublic;
558            }
559    
560            /**
561             * Returns the main context path of the portal, concatenated with
562             * <code>/c</code>.
563             *
564             * @return the main context path of the portal
565             */
566            public String getPathMain() {
567                    return _pathMain;
568            }
569    
570            /**
571             * Returns the portal layout ID of the current page of this service context.
572             *
573             * @return the portal layout ID of the current page
574             */
575            public long getPlid() {
576                    return _plid;
577            }
578    
579            /**
580             * Returns the URL of this service context's portal, including the protocol,
581             * domain, and non-default port relative to the company instance and any
582             * virtual host.
583             *
584             * <p>
585             * The URL returned does not include the port if a default port is used.
586             * </p>
587             *
588             * @return the URL of this service context's portal, including the protocol,
589             *         domain, and non-default port relative to company instance and any
590             *         virtual host
591             */
592            public String getPortalURL() {
593                    return _portalURL;
594            }
595    
596            /**
597             * Returns the ID of the current portlet if this service context is being
598             * passed as a parameter to a portlet.
599             *
600             * @return the ID of the current portlet
601             * @see    PortletPreferencesIds
602             */
603            public String getPortletId() {
604                    if (_portletPreferencesIds == null) {
605                            return null;
606                    }
607    
608                    return _portletPreferencesIds.getPortletId();
609            }
610    
611            /**
612             * Returns the portlet preferences IDs of the current portlet if the service
613             * context is being passed as a parameter to a portlet.
614             *
615             * <p>
616             * The {@link PortletPreferencesIds} can be used to look up portlet
617             * preferences of the current portlet.
618             * </p>
619             *
620             * @return the portlet preferences IDs of the current portlet
621             * @see    PortletPreferencesIds
622             */
623            public PortletPreferencesIds getPortletPreferencesIds() {
624                    return _portletPreferencesIds;
625            }
626    
627            /**
628             * Returns the remote address of the user making the request in this service
629             * context.
630             *
631             * @return the remote address of the user making the request
632             */
633            public String getRemoteAddr() {
634                    return _remoteAddr;
635            }
636    
637            /**
638             * Returns the remote host name of the user making the request in this
639             * service context.
640             *
641             * @return the remote host name of the user making the request
642             */
643            public String getRemoteHost() {
644                    return _remoteHost;
645            }
646    
647            @JSON(include = false)
648            public HttpServletRequest getRequest() {
649                    return _request;
650            }
651    
652            @JSON(include = false)
653            public HttpServletResponse getResponse() {
654                    LiferayPortletResponse liferayPortletResponse =
655                            getLiferayPortletResponse();
656    
657                    if (liferayPortletResponse == null) {
658                            return null;
659                    }
660    
661                    return PortalUtil.getHttpServletResponse(liferayPortletResponse);
662            }
663    
664            public String getRootPortletId() {
665                    String portletId = getPortletId();
666    
667                    if (portletId == null) {
668                            return null;
669                    }
670    
671                    return PortletConstants.getRootPortletId(portletId);
672            }
673    
674            public Group getScopeGroup() throws PortalException {
675                    return GroupLocalServiceUtil.getGroup(_scopeGroupId);
676            }
677    
678            /**
679             * Returns the ID of the group corresponding to the current data scope of
680             * this service context.
681             *
682             * @return the ID of the group corresponding to the current data scope
683             * @see    Group
684             */
685            public long getScopeGroupId() {
686                    return _scopeGroupId;
687            }
688    
689            public ThemeDisplay getThemeDisplay() {
690                    if (_request == null) {
691                            return null;
692                    }
693    
694                    return (ThemeDisplay)_request.getAttribute(WebKeys.THEME_DISPLAY);
695            }
696    
697            public TimeZone getTimeZone() {
698                    return _timeZone;
699            }
700    
701            /**
702             * Returns the user-agent request header of this service context.
703             *
704             * @return the user-agent request header
705             * @see    HttpHeaders
706             */
707            public String getUserAgent() {
708                    if (_request == null) {
709                            return null;
710                    }
711    
712                    return _request.getHeader(HttpHeaders.USER_AGENT);
713            }
714    
715            /**
716             * Returns the complete URL of this service context's current user's profile
717             * page.
718             *
719             * @return the complete URL of this service context's current user's profile
720             *         page
721             */
722            public String getUserDisplayURL() {
723                    return _userDisplayURL;
724            }
725    
726            /**
727             * Returns the ID of this service context's current user.
728             *
729             * @return the ID of this service context's current user
730             */
731            public long getUserId() {
732                    return _userId;
733            }
734    
735            /**
736             * Returns the UUID of this service context's current entity.
737             *
738             * <p>
739             * To ensure the same UUID is never used by two entities, the UUID is reset
740             * to <code>null</code> upon invoking this method.
741             * </p>
742             *
743             * @return the UUID of this service context's current entity
744             */
745            public String getUuid() {
746                    String uuid = _uuid;
747    
748                    _uuid = null;
749    
750                    return uuid;
751            }
752    
753            public String getUuidWithoutReset() {
754                    return _uuid;
755            }
756    
757            /**
758             * Returns the workflow action to take if this service context is being
759             * passed as a parameter to a method that processes a workflow action.
760             *
761             * @return the workflow action to take
762             */
763            public int getWorkflowAction() {
764                    return _workflowAction;
765            }
766    
767            /**
768             * Returns <code>true</code> if this service context is being passed as a
769             * parameter to a method which manipulates a resource to which default group
770             * permissions apply.
771             *
772             * @return <code>true</code> if this service context is being passed as a
773             *         parameter to a method which manipulates a resource to which
774             *         default group permissions apply; <code>false</code> otherwise
775             */
776            public boolean isAddGroupPermissions() {
777                    return _addGroupPermissions;
778            }
779    
780            /**
781             * Returns <code>true</code> if this service context is being passed as a
782             * parameter to a method which manipulates a resource to which default guest
783             * permissions apply.
784             *
785             * @return <code>true</code> if this service context is being passed as a
786             *         parameter to a method which manipulates a resource to which
787             *         default guest permissions apply; <code>false</code> otherwise
788             */
789            public boolean isAddGuestPermissions() {
790                    return _addGuestPermissions;
791            }
792    
793            public boolean isAssetEntryVisible() {
794                    return _assetEntryVisible;
795            }
796    
797            /**
798             * Returns <code>true</code> if this service context contains an add command
799             * (i.e. has command value {@link Constants#ADD})
800             *
801             * @return <code>true</code> if this service context contains an add
802             *         command; <code>false</code> otherwise
803             */
804            public boolean isCommandAdd() {
805                    if (Validator.equals(_command, Constants.ADD) ||
806                            Validator.equals(_command, Constants.ADD_DYNAMIC) ||
807                            Validator.equals(_command, Constants.ADD_MULTIPLE) ||
808                            Validator.equals(_command, Constants.ADD_WEBDAV)) {
809    
810                            return true;
811                    }
812                    else {
813                            return false;
814                    }
815            }
816    
817            /**
818             * Returns <code>true</code> if this service context contains an update
819             * command (i.e. has command value {@link Constants#UPDATE})
820             *
821             * @return <code>true</code> if this service context contains an update
822             *         command; <code>false</code> otherwise
823             */
824            public boolean isCommandUpdate() {
825                    if (Validator.equals(_command, Constants.UPDATE) ||
826                            Validator.equals(_command, Constants.UPDATE_AND_CHECKIN) ||
827                            Validator.equals(_command, Constants.UPDATE_WEBDAV)) {
828    
829                            return true;
830                    }
831                    else {
832                            return false;
833                    }
834            }
835    
836            public boolean isDeriveDefaultPermissions() {
837                    return _deriveDefaultPermissions;
838            }
839    
840            /**
841             * Returns <code>true</code> if portal exceptions should be handled as
842             * failures, possibly halting processing, or <code>false</code> if the
843             * exceptions should be handled differently, possibly allowing processing to
844             * continue in some manner. Services may check this flag to execute desired
845             * behavior.
846             *
847             * <p>
848             * Batch invocation of such services (exposed as a JSON web services) can
849             * result in execution of all service invocations, in spite of portal
850             * exceptions.
851             * </p>
852             *
853             * <p>
854             * If this flag is set to <code>false</code>, services can implement logic
855             * that allows processing to continue, while collecting information
856             * regarding the exceptions for returning to the caller. For example, the
857             * {@link
858             * com.liferay.portlet.asset.service.impl.AssetVocabularyServiceImpl#deleteVocabularies(
859             * long[], ServiceContext)} method uses the list it returns to give
860             * information on vocabularies it fails to delete; it returns an empty list
861             * if all deletions are successful.
862             * </p>
863             *
864             * @return <code>true</code> if portal exceptions are to be handled as
865             *         failures; <code>false</code> if portal exceptions can be handled
866             *         differently, possibly allowing processing to continue in some
867             *         manner
868             */
869            public boolean isFailOnPortalException() {
870                    return _failOnPortalException;
871            }
872    
873            /**
874             * Returns whether the primary entity of this service context is to be
875             * indexed/re-indexed.
876             *
877             * @return <code>true</code> the primary entity of this service context is
878             *         to be indexed/re-indexed; <code>false</code> otherwise
879             */
880            public boolean isIndexingEnabled() {
881                    return _indexingEnabled;
882            }
883    
884            /**
885             * Returns <code>true</code> if the sender of this service context's request
886             * is signed in.
887             *
888             * @return <code>true</code> if the sender of this service context's request
889             *         is signed in; <code>false</code> otherwise
890             */
891            public boolean isSignedIn() {
892                    return _signedIn;
893            }
894    
895            /**
896             * Merges all of the specified service context's non-<code>null</code>
897             * attributes, attributes greater than <code>0</code>, and fields (except
898             * the request) with this service context object.
899             *
900             * @param serviceContext the service context object to be merged
901             */
902            public void merge(ServiceContext serviceContext) {
903                    setAddGroupPermissions(serviceContext.isAddGroupPermissions());
904                    setAddGuestPermissions(serviceContext.isAddGuestPermissions());
905    
906                    if (serviceContext.getAssetCategoryIds() != null) {
907                            setAssetCategoryIds(serviceContext.getAssetCategoryIds());
908                    }
909    
910                    setAssetEntryVisible(serviceContext.isAssetEntryVisible());
911    
912                    if (serviceContext.getAssetLinkEntryIds() != null) {
913                            setAssetLinkEntryIds(serviceContext.getAssetLinkEntryIds());
914                    }
915    
916                    if (serviceContext.getAssetPriority() > 0) {
917                            setAssetPriority(serviceContext.getAssetPriority());
918                    }
919    
920                    if (serviceContext.getAssetTagNames() != null) {
921                            setAssetTagNames(serviceContext.getAssetTagNames());
922                    }
923    
924                    if (serviceContext.getAttributes() != null) {
925                            setAttributes(serviceContext.getAttributes());
926                    }
927    
928                    if (Validator.isNotNull(serviceContext.getCommand())) {
929                            setCommand(serviceContext.getCommand());
930                    }
931    
932                    if (serviceContext.getCompanyId() > 0) {
933                            setCompanyId(serviceContext.getCompanyId());
934                    }
935    
936                    if (serviceContext.getCreateDate() != null) {
937                            setCreateDate(serviceContext.getCreateDate());
938                    }
939    
940                    if (Validator.isNotNull(serviceContext.getCurrentURL())) {
941                            setCurrentURL(serviceContext.getCurrentURL());
942                    }
943    
944                    setDeriveDefaultPermissions(
945                            serviceContext.isDeriveDefaultPermissions());
946    
947                    if (serviceContext.getExpandoBridgeAttributes() != null) {
948                            setExpandoBridgeAttributes(
949                                    serviceContext.getExpandoBridgeAttributes());
950                    }
951    
952                    setFailOnPortalException(serviceContext.isFailOnPortalException());
953    
954                    if (serviceContext.getGroupPermissions() != null) {
955                            setGroupPermissions(serviceContext.getGroupPermissions());
956                    }
957    
958                    if (serviceContext.getGuestPermissions() != null) {
959                            setGuestPermissions(serviceContext.getGuestPermissions());
960                    }
961    
962                    if (serviceContext.getHeaders() != null) {
963                            setHeaders(serviceContext.getHeaders());
964                    }
965    
966                    setIndexingEnabled(serviceContext.isIndexingEnabled());
967                    setLanguageId(serviceContext.getLanguageId());
968    
969                    if (Validator.isNotNull(serviceContext.getLayoutFullURL())) {
970                            setLayoutFullURL(serviceContext.getLayoutFullURL());
971                    }
972    
973                    if (Validator.isNotNull(serviceContext.getLayoutURL())) {
974                            setLayoutURL(serviceContext.getLayoutURL());
975                    }
976    
977                    if (serviceContext.getModifiedDate() != null) {
978                            setModifiedDate(serviceContext.getModifiedDate());
979                    }
980    
981                    if (Validator.isNotNull(
982                                    serviceContext.getPathFriendlyURLPrivateGroup())) {
983    
984                            setPathFriendlyURLPrivateGroup(
985                                    serviceContext.getPathFriendlyURLPrivateGroup());
986                    }
987    
988                    if (Validator.isNotNull(
989                                    serviceContext.getPathFriendlyURLPrivateUser())) {
990    
991                            setPathFriendlyURLPrivateUser(
992                                    serviceContext.getPathFriendlyURLPrivateUser());
993                    }
994    
995                    if (Validator.isNotNull(serviceContext.getPathFriendlyURLPublic())) {
996                            setPathFriendlyURLPublic(serviceContext.getPathFriendlyURLPublic());
997                    }
998    
999                    if (Validator.isNotNull(serviceContext.getPathMain())) {
1000                            setPathMain(serviceContext.getPathMain());
1001                    }
1002    
1003                    if (serviceContext.getPlid() > 0) {
1004                            setPlid(serviceContext.getPlid());
1005                    }
1006    
1007                    if (Validator.isNotNull(serviceContext.getPortalURL())) {
1008                            setPortalURL(serviceContext.getPortalURL());
1009                    }
1010    
1011                    if (serviceContext.getPortletPreferencesIds() != null) {
1012                            setPortletPreferencesIds(serviceContext.getPortletPreferencesIds());
1013                    }
1014    
1015                    if (Validator.isNotNull(serviceContext.getRemoteAddr())) {
1016                            setRemoteAddr(serviceContext.getRemoteAddr());
1017                    }
1018    
1019                    if (Validator.isNotNull(serviceContext.getRemoteHost())) {
1020                            setRemoteHost(serviceContext.getRemoteHost());
1021                    }
1022    
1023                    if (serviceContext.getScopeGroupId() > 0) {
1024                            setScopeGroupId(serviceContext.getScopeGroupId());
1025                    }
1026    
1027                    setSignedIn(serviceContext.isSignedIn());
1028    
1029                    if (serviceContext.getTimeZone() != null) {
1030                            setTimeZone(serviceContext.getTimeZone());
1031                    }
1032    
1033                    if (Validator.isNotNull(serviceContext.getUserDisplayURL())) {
1034                            setUserDisplayURL(serviceContext.getUserDisplayURL());
1035                    }
1036    
1037                    if (serviceContext.getUserId() > 0) {
1038                            setUserId(serviceContext.getUserId());
1039                    }
1040    
1041                    // Refrence serviceContext#_uuid directly because calling
1042                    // serviceContext#getUuid() would set it to null
1043    
1044                    if (Validator.isNotNull(serviceContext._uuid)) {
1045                            setUuid(serviceContext._uuid);
1046                    }
1047    
1048                    if (serviceContext.getWorkflowAction() > 0) {
1049                            setWorkflowAction(serviceContext.getWorkflowAction());
1050                    }
1051            }
1052    
1053            /**
1054             * Removes the mapping of the serializable object to the name of the
1055             * standard parameter of this service context.
1056             *
1057             * @param  name the name of the standard parameter
1058             * @return the serializable object associated to the name
1059             */
1060            public Serializable removeAttribute(String name) {
1061                    return _attributes.remove(name);
1062            }
1063    
1064            /**
1065             * Sets whether or not default community permissions should apply to a
1066             * resource being manipulated by a method to which this service context is
1067             * passed as a parameter.
1068             *
1069             * @param      addCommunityPermissions indicates whether or not to apply
1070             *             default community permissions
1071             * @deprecated As of 6.1.0, renamed to {@link
1072             *             #setAddGroupPermissions(boolean)}
1073             */
1074            @Deprecated
1075            public void setAddCommunityPermissions(boolean addCommunityPermissions) {
1076                    setAddGroupPermissions(addCommunityPermissions);
1077            }
1078    
1079            /**
1080             * Sets whether or not default group permissions should apply to a resource
1081             * being manipulated by a method to which this service context is passed as
1082             * a parameter.
1083             *
1084             * @param addGroupPermissions indicates whether or not to apply default
1085             *        group permissions
1086             */
1087            public void setAddGroupPermissions(boolean addGroupPermissions) {
1088                    _addGroupPermissions = addGroupPermissions;
1089            }
1090    
1091            /**
1092             * Sets whether or not default guest permissions should apply to a resource
1093             * being manipulated by a method to which this service context is passed as
1094             * a parameter.
1095             *
1096             * @param addGuestPermissions indicates whether or not to apply default
1097             *        guest permissions
1098             */
1099            public void setAddGuestPermissions(boolean addGuestPermissions) {
1100                    _addGuestPermissions = addGuestPermissions;
1101            }
1102    
1103            /**
1104             * Sets an array of asset category IDs to be applied to an asset entry if
1105             * this service context is being passed as a parameter to a method which
1106             * manipulates the asset entry.
1107             *
1108             * @param assetCategoryIds the primary keys of the asset categories
1109             */
1110            public void setAssetCategoryIds(long[] assetCategoryIds) {
1111                    _assetCategoryIds = assetCategoryIds;
1112            }
1113    
1114            public void setAssetEntryVisible(boolean assetEntryVisible) {
1115                    _assetEntryVisible = assetEntryVisible;
1116            }
1117    
1118            /**
1119             * Sets an array of the primary keys of asset entries to be linked to an
1120             * asset entry if this service context is being passed as a parameter to a
1121             * method which manipulates the asset entry.
1122             *
1123             * @param assetLinkEntryIds the primary keys of the asset entries to be
1124             *        linked to an asset entry
1125             */
1126            public void setAssetLinkEntryIds(long[] assetLinkEntryIds) {
1127                    _assetLinkEntryIds = assetLinkEntryIds;
1128            }
1129    
1130            /**
1131             * Sets the priority of an asset entry if this service context is being
1132             * passed as a parameter to a method which manipulates the asset entry.
1133             *
1134             * @param assetPriority the priority of an asset entry
1135             */
1136            public void setAssetPriority(double assetPriority) {
1137                    _assetPriority = assetPriority;
1138            }
1139    
1140            /**
1141             * Sets an array of asset tag names to be applied to an asset entry if this
1142             * service context is being passed as a parameter to a method which
1143             * manipulates the asset entry.
1144             *
1145             * @param assetTagNames the tag names to be applied to an asset entry
1146             */
1147            public void setAssetTagNames(String[] assetTagNames) {
1148                    _assetTagNames = assetTagNames;
1149            }
1150    
1151            /**
1152             * Sets a mapping of a standard parameter's name to its serializable object.
1153             *
1154             * @param name the standard parameter name to associate with the value
1155             * @param value the serializable object to be associated with the name
1156             */
1157            public void setAttribute(String name, Serializable value) {
1158                    _attributes.put(name, value);
1159            }
1160    
1161            /**
1162             * Sets the map of the name/value pairs that are the standard parameters of
1163             * this service context. Each value must be serializable.
1164             *
1165             * @param attributes the map of the name/value pairs that are the standard
1166             *        parameters of this service context
1167             */
1168            public void setAttributes(Map<String, Serializable> attributes) {
1169                    _attributes = attributes;
1170            }
1171    
1172            /**
1173             * Sets the value of the {@link Constants#CMD} parameter used in most
1174             * Liferay forms for internal portlets.
1175             *
1176             * @param command the value of the {@link Constants#CMD} parameter
1177             */
1178            public void setCommand(String command) {
1179                    _command = command;
1180            }
1181    
1182            /**
1183             * Sets an array containing specific community permissions for a resource if
1184             * this service context is being passed as a parameter to a method which
1185             * manipulates the resource.
1186             *
1187             * @param      communityPermissions the community permissions (optionally
1188             *             <code>null</code>)
1189             * @deprecated As of 6.1.0, renamed to {@link
1190             *             #setGroupPermissions(String[])}
1191             */
1192            @Deprecated
1193            public void setCommunityPermissions(String[] communityPermissions) {
1194                    setGroupPermissions(communityPermissions);
1195            }
1196    
1197            /**
1198             * Sets the company ID of this service context's current portal instance.
1199             *
1200             * @param companyId the primary key of this service context's current portal
1201             *        instance
1202             */
1203            public void setCompanyId(long companyId) {
1204                    _companyId = companyId;
1205            }
1206    
1207            /**
1208             * Sets the date when an entity was created if this service context is being
1209             * passed as a parameter to a method which creates an entity.
1210             *
1211             * @param createDate the date the entity was created
1212             */
1213            public void setCreateDate(Date createDate) {
1214                    _createDate = createDate;
1215            }
1216    
1217            /**
1218             * Sets the current URL of this service context
1219             *
1220             * @param currentURL the current URL of this service context
1221             */
1222            public void setCurrentURL(String currentURL) {
1223                    _currentURL = currentURL;
1224            }
1225    
1226            public void setDeriveDefaultPermissions(boolean deriveDefaultPermissions) {
1227                    _deriveDefaultPermissions = deriveDefaultPermissions;
1228            }
1229    
1230            /**
1231             * Sets an arbitrary number of attributes of an entity to be persisted.
1232             *
1233             * <p>
1234             * These attributes should only include fields that {@link
1235             * com.liferay.portal.service.ServiceContext} does not possess by default.
1236             * </p>
1237             *
1238             * @param expandoBridgeAttributes the expando bridge attributes (optionally
1239             *        <code>null</code>)
1240             */
1241            public void setExpandoBridgeAttributes(
1242                    Map<String, Serializable> expandoBridgeAttributes) {
1243    
1244                    _expandoBridgeAttributes = expandoBridgeAttributes;
1245            }
1246    
1247            /**
1248             * Sets whether portal exceptions should be handled as failures, possibly
1249             * halting processing, or if exceptions should be handled differently,
1250             * possibly allowing processing to continue in some manner.
1251             *
1252             * @param failOnPortalException whether portal exceptions should be handled
1253             *        as failures, or if portal exceptions should be handled
1254             *        differently, possibly allowing processing to continue in some
1255             *        manner
1256             * @see   #isFailOnPortalException()
1257             */
1258            public void setFailOnPortalException(boolean failOnPortalException) {
1259                    _failOnPortalException = failOnPortalException;
1260            }
1261    
1262            /**
1263             * Sets the date when an <code>aui:form</code> was generated in this service
1264             * context. The form date can be used in detecting situations in which an
1265             * entity has been modified while another client was editing that entity.
1266             *
1267             * <p>
1268             * Example:
1269             * </p>
1270             *
1271             * <p>
1272             * Person1 and person2 start editing the same version of a Web Content
1273             * article. Person1 publishes changes to the article first. When person2
1274             * attempts to publish changes to that article, the service implementation
1275             * finds that a modification to that article has already been published some
1276             * time after person2 started editing the article. Since the article
1277             * modification date was found to be later than the form date for person2,
1278             * person2 could be alerted to the modification and make a backup copy of
1279             * his edits before synchronizing with the published changes by person1.
1280             * </p>
1281             *
1282             * @param formDate the date that an <code>aui:form</code> was generated for
1283             *        this service context (optionally <code>null</code>)
1284             */
1285            public void setFormDate(Date formDate) {
1286                    _formDate = formDate;
1287            }
1288    
1289            /**
1290             * Sets an array containing specific group permissions for a resource if
1291             * this service context is being passed as a parameter to a method which
1292             * manipulates the resource.
1293             *
1294             * @param groupPermissions the permissions (optionally <code>null</code>)
1295             */
1296            public void setGroupPermissions(String[] groupPermissions) {
1297                    _modelPermissions.addRolePermissions(
1298                            RoleConstants.PLACEHOLDER_DEFAULT_GROUP_ROLE, groupPermissions);
1299            }
1300    
1301            /**
1302             * Sets an array containing specific guest permissions for a resource if
1303             * this service context is being passed as a parameter to a method which
1304             * manipulates the resource.
1305             *
1306             * @param guestPermissions the guest permissions (optionally
1307             *        <code>null</code>)
1308             */
1309            public void setGuestPermissions(String[] guestPermissions) {
1310                    _modelPermissions.addRolePermissions(
1311                            RoleConstants.GUEST, guestPermissions);
1312            }
1313    
1314            /**
1315             * Sets the map of request header name/value pairs of this service context.
1316             *
1317             * @param headers map of request header name/value pairs of this service
1318             *        context
1319             * @see   HttpHeaders
1320             */
1321            public void setHeaders(Map<String, String> headers) {
1322                    _headers = headers;
1323            }
1324    
1325            /**
1326             * Sets whether the primary entity of this service context is to be
1327             * indexed/re-indexed.
1328             *
1329             * <p>
1330             * The entity is only indexed/re-indexed if the method receiving this
1331             * service context as a parameter does indexing.
1332             * </p>
1333             *
1334             * @param indexingEnabled whether the primary entity of this service context
1335             *        is to be indexed/re-indexed (default is <code>true</code>)
1336             */
1337            public void setIndexingEnabled(boolean indexingEnabled) {
1338                    _indexingEnabled = indexingEnabled;
1339            }
1340    
1341            /**
1342             * Sets the language ID of the locale of this service context.
1343             *
1344             * @param languageId the language ID of the locale of this service context's
1345             *        current user
1346             */
1347            public void setLanguageId(String languageId) {
1348                    _languageId = languageId;
1349            }
1350    
1351            /**
1352             * Sets the complete URL of the current page for this service context.
1353             *
1354             * @param layoutFullURL the complete URL of the current page if a page
1355             *        context can be determined for this service context
1356             */
1357            public void setLayoutFullURL(String layoutFullURL) {
1358                    _layoutFullURL = layoutFullURL;
1359            }
1360    
1361            /**
1362             * Sets the relative URL of the current page for this service context.
1363             *
1364             * @param layoutURL the relative URL of the current page if a page context
1365             *        can be determined for this service context
1366             */
1367            public void setLayoutURL(String layoutURL) {
1368                    _layoutURL = layoutURL;
1369            }
1370    
1371            public void setModelPermissions(ModelPermissions modelPermissions) {
1372                    _modelPermissions = modelPermissions;
1373            }
1374    
1375            /**
1376             * Sets the date when an entity was modified in this service context.
1377             *
1378             * @param modifiedDate the date when an entity was modified in this service
1379             *        context
1380             */
1381            public void setModifiedDate(Date modifiedDate) {
1382                    _modifiedDate = modifiedDate;
1383            }
1384    
1385            public void setPathFriendlyURLPrivateGroup(
1386                    String pathFriendlyURLPrivateGroup) {
1387    
1388                    _pathFriendlyURLPrivateGroup = pathFriendlyURLPrivateGroup;
1389            }
1390    
1391            public void setPathFriendlyURLPrivateUser(
1392                    String pathFriendlyURLPrivateUser) {
1393    
1394                    _pathFriendlyURLPrivateUser = pathFriendlyURLPrivateUser;
1395            }
1396    
1397            public void setPathFriendlyURLPublic(String pathFriendlyURLPublic) {
1398                    _pathFriendlyURLPublic = pathFriendlyURLPublic;
1399            }
1400    
1401            /**
1402             * Sets the main context path of the portal, concatenated with
1403             * <code>/c</code>.
1404             *
1405             * @param pathMain the main context path of the portal
1406             */
1407            public void setPathMain(String pathMain) {
1408                    _pathMain = pathMain;
1409            }
1410    
1411            /**
1412             * Sets the portal layout ID of the current page in this service context.
1413             *
1414             * @param plid the portal layout ID of the current page
1415             */
1416            public void setPlid(long plid) {
1417                    _plid = plid;
1418            }
1419    
1420            /**
1421             * Sets the URL of this service context's portal, including the protocol,
1422             * domain, and non-default port relative to the company instance and any
1423             * virtual host.
1424             *
1425             * <p>
1426             * The URL should not include the port if a default port is used.
1427             * </p>
1428             *
1429             * @param portalURL the portal URL
1430             */
1431            public void setPortalURL(String portalURL) {
1432                    _portalURL = portalURL;
1433            }
1434    
1435            /**
1436             * Sets the portlet preferences IDs of the current portlet if this service
1437             * context is being passed as a parameter to a portlet.
1438             *
1439             * <p>
1440             * The {@link PortletPreferencesIds} can be used to look up portlet
1441             * preferences of the current portlet.
1442             * </p>
1443             *
1444             * @param portletPreferencesIds the portlet preferences
1445             * @see   PortletPreferencesIds
1446             */
1447            public void setPortletPreferencesIds(
1448                    PortletPreferencesIds portletPreferencesIds) {
1449    
1450                    _portletPreferencesIds = portletPreferencesIds;
1451            }
1452    
1453            /**
1454             * Sets the remote address of the user making the request in this service
1455             * context.
1456             *
1457             * @param remoteAddr the remote address of the user making the request in
1458             *        this service context
1459             */
1460            public void setRemoteAddr(String remoteAddr) {
1461                    _remoteAddr = remoteAddr;
1462            }
1463    
1464            /**
1465             * Sets the remote host name of the user making the request in this service
1466             * context.
1467             *
1468             * @param remoteHost the remote host name of the user making the request in
1469             *        this service context
1470             */
1471            public void setRemoteHost(String remoteHost) {
1472                    _remoteHost = remoteHost;
1473            }
1474    
1475            /**
1476             * Sets the optional request used when instantiating this service context.
1477             * The field is volatile and so will be discarded on serialization.
1478             *
1479             * @param request the request
1480             */
1481            public void setRequest(HttpServletRequest request) {
1482                    _request = request;
1483            }
1484    
1485            /**
1486             * Sets the ID of the group corresponding to the current data scope of this
1487             * service context.
1488             *
1489             * @param scopeGroupId the ID of the group corresponding to the current data
1490             *        scope of this service context
1491             * @see   Group
1492             */
1493            public void setScopeGroupId(long scopeGroupId) {
1494                    _scopeGroupId = scopeGroupId;
1495            }
1496    
1497            /**
1498             * Sets whether the sender of this service context's request is signed in.
1499             *
1500             * @param signedIn whether the sender of this service context's request is
1501             *        signed in
1502             */
1503            public void setSignedIn(boolean signedIn) {
1504                    _signedIn = signedIn;
1505            }
1506    
1507            public void setTimeZone(TimeZone timeZone) {
1508                    _timeZone = timeZone;
1509            }
1510    
1511            /**
1512             * Sets the complete URL of this service context's current user's profile
1513             * page.
1514             *
1515             * @param userDisplayURL the complete URL of the current user's profile page
1516             */
1517            public void setUserDisplayURL(String userDisplayURL) {
1518                    _userDisplayURL = userDisplayURL;
1519            }
1520    
1521            /**
1522             * Sets the ID of this service context's current user.
1523             *
1524             * @param userId the ID of the current user
1525             */
1526            public void setUserId(long userId) {
1527                    _userId = userId;
1528            }
1529    
1530            /**
1531             * Sets the UUID of this service context's current entity.
1532             *
1533             * @param uuid the UUID of the current entity
1534             */
1535            public void setUuid(String uuid) {
1536                    _uuid = uuid;
1537            }
1538    
1539            /**
1540             * Sets the workflow action to take if this service context is being passed
1541             * as parameter to a method that processes a workflow action.
1542             *
1543             * @param workflowAction workflow action to take (default is {@link
1544             *        WorkflowConstants#ACTION_PUBLISH})
1545             */
1546            public void setWorkflowAction(int workflowAction) {
1547                    _workflowAction = workflowAction;
1548            }
1549    
1550            public String translate(String pattern, Object... arguments) {
1551                    Locale locale = getLocale();
1552    
1553                    return LanguageUtil.format(locale, pattern, arguments);
1554            }
1555    
1556            public void validateModifiedDate(
1557                            AuditedModel auditedModel, Class<? extends PortalException> clazz)
1558                    throws PortalException {
1559    
1560                    int value = DateUtil.compareTo(
1561                            auditedModel.getModifiedDate(), _formDate);
1562    
1563                    if (value > 0) {
1564                            try {
1565                                    throw clazz.newInstance();
1566                            }
1567                            catch (IllegalAccessException iae) {
1568                                    throw new RuntimeException(iae);
1569                            }
1570                            catch (InstantiationException ie) {
1571                                    throw new RuntimeException(ie);
1572                            }
1573                    }
1574            }
1575    
1576            private boolean _addGroupPermissions;
1577            private boolean _addGuestPermissions;
1578            private long[] _assetCategoryIds;
1579            private boolean _assetEntryVisible = true;
1580            private long[] _assetLinkEntryIds;
1581            private double _assetPriority;
1582            private String[] _assetTagNames;
1583            private Map<String, Serializable> _attributes;
1584            private String _command;
1585            private long _companyId;
1586            private Date _createDate;
1587            private String _currentURL;
1588            private boolean _deriveDefaultPermissions;
1589            private Map<String, Serializable> _expandoBridgeAttributes;
1590            private boolean _failOnPortalException = true;
1591            private Date _formDate;
1592            private transient Map<String, String> _headers;
1593            private boolean _indexingEnabled = true;
1594            private String _languageId;
1595            private String _layoutFullURL;
1596            private String _layoutURL;
1597            private ModelPermissions _modelPermissions = new ModelPermissions();
1598            private Date _modifiedDate;
1599            private String _pathFriendlyURLPrivateGroup;
1600            private String _pathFriendlyURLPrivateUser;
1601            private String _pathFriendlyURLPublic;
1602            private String _pathMain;
1603            private long _plid;
1604            private String _portalURL;
1605            private PortletPreferencesIds _portletPreferencesIds;
1606            private String _remoteAddr;
1607            private String _remoteHost;
1608            private transient HttpServletRequest _request;
1609            private long _scopeGroupId;
1610            private boolean _signedIn;
1611            private TimeZone _timeZone;
1612            private String _userDisplayURL;
1613            private long _userId;
1614            private String _uuid;
1615            private int _workflowAction = WorkflowConstants.ACTION_PUBLISH;
1616    
1617    }