1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service;
16  
17  import com.liferay.portal.kernel.util.Constants;
18  import com.liferay.portal.kernel.util.Validator;
19  import com.liferay.portal.kernel.workflow.WorkflowConstants;
20  import com.liferay.portal.model.PortletPreferencesIds;
21  
22  import java.io.Serializable;
23  
24  import java.util.Date;
25  import java.util.LinkedHashMap;
26  import java.util.Map;
27  
28  /**
29   * <a href="ServiceContext.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Raymond Augé
32   * @author Brian Wing Shun Chan
33   * @author Jorge Ferrer
34   */
35  public class ServiceContext implements Serializable {
36  
37      public ServiceContext() {
38          _attributes = new LinkedHashMap<String, Serializable>();
39          _expandoBridgeAttributes = new LinkedHashMap<String, Serializable>();
40      }
41  
42      public boolean getAddCommunityPermissions() {
43          return _addCommunityPermissions;
44      }
45  
46      public boolean getAddGuestPermissions() {
47          return _addGuestPermissions;
48      }
49  
50      public long[] getAssetCategoryIds() {
51          return _assetCategoryIds;
52      }
53  
54      public String[] getAssetTagNames() {
55          return _assetTagNames;
56      }
57  
58      public Serializable getAttribute(String name) {
59          return _attributes.get(name);
60      }
61  
62      public Map<String, Serializable> getAttributes() {
63          return _attributes;
64      }
65  
66      public String getCommand() {
67          return _command;
68      }
69  
70      public String[] getCommunityPermissions() {
71          return _communityPermissions;
72      }
73  
74      public long getCompanyId() {
75          return _companyId;
76      }
77  
78      public Date getCreateDate() {
79          return _createDate;
80      }
81  
82      public Date getCreateDate(Date defaultCreateDate) {
83          if (_createDate != null) {
84              return _createDate;
85          }
86          else if (defaultCreateDate != null) {
87              return defaultCreateDate;
88          }
89          else {
90              return new Date();
91          }
92      }
93  
94      public Map<String, Serializable> getExpandoBridgeAttributes() {
95          return _expandoBridgeAttributes;
96      }
97  
98      public String[] getGuestPermissions() {
99          return _guestPermissions;
100     }
101 
102     public String getLanguageId() {
103         return _languageId;
104     }
105 
106     public String getLayoutFullURL() {
107         return _layoutFullURL;
108     }
109 
110     public String getLayoutURL() {
111         return _layoutURL;
112     }
113 
114     public Date getModifiedDate() {
115         return _modifiedDate;
116     }
117 
118     public Date getModifiedDate(Date defaultModifiedDate) {
119         if (_modifiedDate != null) {
120             return _modifiedDate;
121         }
122         else if (defaultModifiedDate != null) {
123             return defaultModifiedDate;
124         }
125         else {
126             return new Date();
127         }
128     }
129 
130     public String getPathMain() {
131         return _pathMain;
132     }
133 
134     public long getPlid() {
135         return _plid;
136     }
137 
138     public String getPortalURL() {
139         return _portalURL;
140     }
141 
142     public PortletPreferencesIds getPortletPreferencesIds() {
143         return _portletPreferencesIds;
144     }
145 
146     public long getScopeGroupId() {
147         return _scopeGroupId;
148     }
149 
150     public String getUserDisplayURL() {
151         return _userDisplayURL;
152     }
153 
154     public long getUserId() {
155         return _userId;
156     }
157 
158     public int getWorkflowAction() {
159         return _workflowAction;
160     }
161 
162     public boolean isCommandAdd() {
163         if (Validator.equals(_command, Constants.ADD)) {
164             return true;
165         }
166         else {
167             return false;
168         }
169     }
170 
171     public boolean isCommandUpdate() {
172         if (Validator.equals(_command, Constants.UPDATE)) {
173             return true;
174         }
175         else {
176             return false;
177         }
178     }
179 
180     public void setAddCommunityPermissions(boolean addCommunityPermissions) {
181         _addCommunityPermissions = addCommunityPermissions;
182     }
183 
184     public void setAddGuestPermissions(boolean addGuestPermissions) {
185         _addGuestPermissions = addGuestPermissions;
186     }
187 
188     public void setAssetCategoryIds(long[] assetCategoryIds) {
189         _assetCategoryIds = assetCategoryIds;
190     }
191 
192     public void setAssetTagNames(String[] assetTagNames) {
193         _assetTagNames = assetTagNames;
194     }
195 
196     public void setAttribute(String name, Serializable value) {
197         _attributes.put(name, value);
198     }
199 
200     public void setAttributes(Map<String, Serializable> attributes) {
201         _attributes = attributes;
202     }
203 
204     public void setCommand(String command) {
205         _command = command;
206     }
207 
208     public void setCommunityPermissions(String[] communityPermissions) {
209         _communityPermissions = communityPermissions;
210     }
211 
212     public void setCompanyId(long companyId) {
213         _companyId = companyId;
214     }
215 
216     public void setCreateDate(Date createDate) {
217         _createDate = createDate;
218     }
219 
220     public void setExpandoBridgeAttributes(
221         Map<String, Serializable> expandoBridgeAttributes) {
222 
223         _expandoBridgeAttributes = expandoBridgeAttributes;
224     }
225 
226     public void setGuestPermissions(String[] guestPermissions) {
227         _guestPermissions = guestPermissions;
228     }
229 
230     public void setLanguageId(String languageId) {
231         _languageId = languageId;
232     }
233 
234     public void setLayoutFullURL(String layoutFullURL) {
235         _layoutFullURL = layoutFullURL;
236     }
237 
238     public void setLayoutURL(String layoutURL) {
239         _layoutURL = layoutURL;
240     }
241 
242     public void setModifiedDate(Date modifiedDate) {
243         _modifiedDate = modifiedDate;
244     }
245 
246     public void setPathMain(String pathMain) {
247         _pathMain = pathMain;
248     }
249 
250     public void setPlid(long plid) {
251         _plid = plid;
252     }
253 
254     public void setPortalURL(String portalURL) {
255         _portalURL = portalURL;
256     }
257 
258     public void setPortletPreferencesIds(
259         PortletPreferencesIds portletPreferencesIds) {
260 
261         _portletPreferencesIds = portletPreferencesIds;
262     }
263 
264     public void setScopeGroupId(long scopeGroupId) {
265         _scopeGroupId = scopeGroupId;
266     }
267 
268     public void setUserDisplayURL(String userDisplayURL) {
269         _userDisplayURL = userDisplayURL;
270     }
271 
272     public void setUserId(long userId) {
273         _userId = userId;
274     }
275 
276     public void setWorkflowAction(int workflowAction) {
277         _workflowAction = workflowAction;
278     }
279 
280     private boolean _addCommunityPermissions;
281     private boolean _addGuestPermissions;
282     private long[] _assetCategoryIds;
283     private String[] _assetTagNames;
284     private Map<String, Serializable> _attributes;
285     private String _command;
286     private String[] _communityPermissions;
287     private long _companyId;
288     private Date _createDate;
289     private Map<String, Serializable> _expandoBridgeAttributes;
290     private String[] _guestPermissions;
291     private String _languageId;
292     private String _layoutFullURL;
293     private String _layoutURL;
294     private Date _modifiedDate;
295     private String _pathMain;
296     private String _portalURL;
297     private PortletPreferencesIds _portletPreferencesIds;
298     private long _scopeGroupId;
299     private String _userDisplayURL;
300     private long _plid;
301     private int _workflowAction = WorkflowConstants.ACTION_PUBLISH;
302     private long _userId;
303 
304 }