001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service;
016    
017    import com.liferay.portal.kernel.util.Constants;
018    import com.liferay.portal.kernel.util.Validator;
019    import com.liferay.portal.kernel.workflow.WorkflowConstants;
020    import com.liferay.portal.model.PortletPreferencesIds;
021    
022    import java.io.Serializable;
023    
024    import java.util.Date;
025    import java.util.LinkedHashMap;
026    import java.util.Map;
027    
028    /**
029     * @author Raymond Augé
030     * @author Brian Wing Shun Chan
031     * @author Jorge Ferrer
032     */
033    public class ServiceContext implements Serializable {
034    
035            public ServiceContext() {
036                    _attributes = new LinkedHashMap<String, Serializable>();
037                    _expandoBridgeAttributes = new LinkedHashMap<String, Serializable>();
038            }
039    
040            public boolean getAddCommunityPermissions() {
041                    return _addCommunityPermissions;
042            }
043    
044            public boolean getAddGuestPermissions() {
045                    return _addGuestPermissions;
046            }
047    
048            public long[] getAssetCategoryIds() {
049                    return _assetCategoryIds;
050            }
051    
052            public String[] getAssetTagNames() {
053                    return _assetTagNames;
054            }
055    
056            public Serializable getAttribute(String name) {
057                    return _attributes.get(name);
058            }
059    
060            public Map<String, Serializable> getAttributes() {
061                    return _attributes;
062            }
063    
064            public String getCommand() {
065                    return _command;
066            }
067    
068            public String[] getCommunityPermissions() {
069                    return _communityPermissions;
070            }
071    
072            public long getCompanyId() {
073                    return _companyId;
074            }
075    
076            public Date getCreateDate() {
077                    return _createDate;
078            }
079    
080            public Date getCreateDate(Date defaultCreateDate) {
081                    if (_createDate != null) {
082                            return _createDate;
083                    }
084                    else if (defaultCreateDate != null) {
085                            return defaultCreateDate;
086                    }
087                    else {
088                            return new Date();
089                    }
090            }
091    
092            public Map<String, Serializable> getExpandoBridgeAttributes() {
093                    return _expandoBridgeAttributes;
094            }
095    
096            public String[] getGuestPermissions() {
097                    return _guestPermissions;
098            }
099    
100            public String getLanguageId() {
101                    return _languageId;
102            }
103    
104            public String getLayoutFullURL() {
105                    return _layoutFullURL;
106            }
107    
108            public String getLayoutURL() {
109                    return _layoutURL;
110            }
111    
112            public Date getModifiedDate() {
113                    return _modifiedDate;
114            }
115    
116            public Date getModifiedDate(Date defaultModifiedDate) {
117                    if (_modifiedDate != null) {
118                            return _modifiedDate;
119                    }
120                    else if (defaultModifiedDate != null) {
121                            return defaultModifiedDate;
122                    }
123                    else {
124                            return new Date();
125                    }
126            }
127    
128            public String getPathMain() {
129                    return _pathMain;
130            }
131    
132            public long getPlid() {
133                    return _plid;
134            }
135    
136            public String getPortalURL() {
137                    return _portalURL;
138            }
139    
140            public PortletPreferencesIds getPortletPreferencesIds() {
141                    return _portletPreferencesIds;
142            }
143    
144            public long getScopeGroupId() {
145                    return _scopeGroupId;
146            }
147    
148            public String getUserDisplayURL() {
149                    return _userDisplayURL;
150            }
151    
152            public long getUserId() {
153                    return _userId;
154            }
155    
156            public String getUuid() {
157                    String uuid = _uuid;
158    
159                    _uuid = null;
160    
161                    return uuid;
162            }
163    
164            public int getWorkflowAction() {
165                    return _workflowAction;
166            }
167    
168            public boolean isCommandAdd() {
169                    if (Validator.equals(_command, Constants.ADD)) {
170                            return true;
171                    }
172                    else {
173                            return false;
174                    }
175            }
176    
177            public boolean isCommandUpdate() {
178                    if (Validator.equals(_command, Constants.UPDATE)) {
179                            return true;
180                    }
181                    else {
182                            return false;
183                    }
184            }
185    
186            public void setAddCommunityPermissions(boolean addCommunityPermissions) {
187                    _addCommunityPermissions = addCommunityPermissions;
188            }
189    
190            public void setAddGuestPermissions(boolean addGuestPermissions) {
191                    _addGuestPermissions = addGuestPermissions;
192            }
193    
194            public void setAssetCategoryIds(long[] assetCategoryIds) {
195                    _assetCategoryIds = assetCategoryIds;
196            }
197    
198            public void setAssetTagNames(String[] assetTagNames) {
199                    _assetTagNames = assetTagNames;
200            }
201    
202            public void setAttribute(String name, Serializable value) {
203                    _attributes.put(name, value);
204            }
205    
206            public void setAttributes(Map<String, Serializable> attributes) {
207                    _attributes = attributes;
208            }
209    
210            public void setCommand(String command) {
211                    _command = command;
212            }
213    
214            public void setCommunityPermissions(String[] communityPermissions) {
215                    _communityPermissions = communityPermissions;
216            }
217    
218            public void setCompanyId(long companyId) {
219                    _companyId = companyId;
220            }
221    
222            public void setCreateDate(Date createDate) {
223                    _createDate = createDate;
224            }
225    
226            public void setExpandoBridgeAttributes(
227                    Map<String, Serializable> expandoBridgeAttributes) {
228    
229                    _expandoBridgeAttributes = expandoBridgeAttributes;
230            }
231    
232            public void setGuestPermissions(String[] guestPermissions) {
233                    _guestPermissions = guestPermissions;
234            }
235    
236            public void setLanguageId(String languageId) {
237                    _languageId = languageId;
238            }
239    
240            public void setLayoutFullURL(String layoutFullURL) {
241                    _layoutFullURL = layoutFullURL;
242            }
243    
244            public void setLayoutURL(String layoutURL) {
245                    _layoutURL = layoutURL;
246            }
247    
248            public void setModifiedDate(Date modifiedDate) {
249                    _modifiedDate = modifiedDate;
250            }
251    
252            public void setPathMain(String pathMain) {
253                    _pathMain = pathMain;
254            }
255    
256            public void setPlid(long plid) {
257                    _plid = plid;
258            }
259    
260            public void setPortalURL(String portalURL) {
261                    _portalURL = portalURL;
262            }
263    
264            public void setPortletPreferencesIds(
265                    PortletPreferencesIds portletPreferencesIds) {
266    
267                    _portletPreferencesIds = portletPreferencesIds;
268            }
269    
270            public void setScopeGroupId(long scopeGroupId) {
271                    _scopeGroupId = scopeGroupId;
272            }
273    
274            public void setUserDisplayURL(String userDisplayURL) {
275                    _userDisplayURL = userDisplayURL;
276            }
277    
278            public void setUserId(long userId) {
279                    _userId = userId;
280            }
281    
282            public void setUuid(String uuid) {
283                    _uuid = uuid;
284            }
285    
286            public void setWorkflowAction(int workflowAction) {
287                    _workflowAction = workflowAction;
288            }
289    
290            private boolean _addCommunityPermissions;
291            private boolean _addGuestPermissions;
292            private long[] _assetCategoryIds;
293            private String[] _assetTagNames;
294            private Map<String, Serializable> _attributes;
295            private String _command;
296            private String[] _communityPermissions;
297            private long _companyId;
298            private Date _createDate;
299            private Map<String, Serializable> _expandoBridgeAttributes;
300            private String[] _guestPermissions;
301            private String _languageId;
302            private String _layoutFullURL;
303            private String _layoutURL;
304            private Date _modifiedDate;
305            private String _pathMain;
306            private String _portalURL;
307            private PortletPreferencesIds _portletPreferencesIds;
308            private long _scopeGroupId;
309            private String _userDisplayURL;
310            private long _plid;
311            private int _workflowAction = WorkflowConstants.ACTION_PUBLISH;
312            private long _userId;
313            private String _uuid;
314    
315    }