1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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.model.PortletPreferencesIds;
20  
21  import java.io.Serializable;
22  
23  import java.util.Date;
24  import java.util.LinkedHashMap;
25  import java.util.Map;
26  
27  /**
28   * <a href="ServiceContext.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Raymond Augé
31   * @author Brian Wing Shun Chan
32   * @author Jorge Ferrer
33   */
34  public class ServiceContext implements Serializable {
35  
36      public ServiceContext() {
37          _attributes = new LinkedHashMap<String, Serializable>();
38          _expandoBridgeAttributes = new LinkedHashMap<String, Serializable>();
39      }
40  
41      public boolean getAddCommunityPermissions() {
42          return _addCommunityPermissions;
43      }
44  
45      public boolean getAddGuestPermissions() {
46          return _addGuestPermissions;
47      }
48  
49      public Serializable getAttribute(String name) {
50          return _attributes.get(name);
51      }
52  
53      public Map<String, Serializable> getAttributes() {
54          return _attributes;
55      }
56  
57      public String getCommand() {
58          return _command;
59      }
60  
61      public String[] getCommunityPermissions() {
62          return _communityPermissions;
63      }
64  
65      public long getCompanyId() {
66          return _companyId;
67      }
68  
69      public Date getCreateDate() {
70          return _createDate;
71      }
72  
73      public Date getCreateDate(Date defaultCreateDate) {
74          if (_createDate != null) {
75              return _createDate;
76          }
77          else if (defaultCreateDate != null) {
78              return defaultCreateDate;
79          }
80          else {
81              return new Date();
82          }
83      }
84  
85      public Map<String, Serializable> getExpandoBridgeAttributes() {
86          return _expandoBridgeAttributes;
87      }
88  
89      public String[] getGuestPermissions() {
90          return _guestPermissions;
91      }
92  
93      public String getLanguageId() {
94          return _languageId;
95      }
96  
97      public String getLayoutFullURL() {
98          return _layoutFullURL;
99      }
100 
101     public String getLayoutURL() {
102         return _layoutURL;
103     }
104 
105     public Date getModifiedDate() {
106         return _modifiedDate;
107     }
108 
109     public Date getModifiedDate(Date defaultModifiedDate) {
110         if (_modifiedDate != null) {
111             return _modifiedDate;
112         }
113         else if (defaultModifiedDate != null) {
114             return defaultModifiedDate;
115         }
116         else {
117             return new Date();
118         }
119     }
120 
121     public String getPathMain() {
122         return _pathMain;
123     }
124 
125     public long getPlid() {
126         return _plid;
127     }
128 
129     public String getPortalURL() {
130         return _portalURL;
131     }
132 
133     public PortletPreferencesIds getPortletPreferencesIds() {
134         return _portletPreferencesIds;
135     }
136 
137     public long getScopeGroupId() {
138         return _scopeGroupId;
139     }
140 
141     public String[] getTagsCategories() {
142         return _tagsCategories;
143     }
144 
145     public String[] getTagsEntries() {
146         return _tagsEntries;
147     }
148 
149     public String getUserDisplayURL() {
150         return _userDisplayURL;
151     }
152 
153     public long getUserId() {
154         return _userId;
155     }
156 
157     public boolean isCommandAdd() {
158         if (Validator.equals(_command, Constants.ADD)) {
159             return true;
160         }
161         else {
162             return false;
163         }
164     }
165 
166     public boolean isCommandUpdate() {
167         if (Validator.equals(_command, Constants.UPDATE)) {
168             return true;
169         }
170         else {
171             return false;
172         }
173     }
174 
175     public void setAddCommunityPermissions(boolean addCommunityPermissions) {
176         _addCommunityPermissions = addCommunityPermissions;
177     }
178 
179     public void setAddGuestPermissions(boolean addGuestPermissions) {
180         _addGuestPermissions = addGuestPermissions;
181     }
182 
183     public void setAttribute(String name, Serializable value) {
184         _attributes.put(name, value);
185     }
186 
187     public void setAttributes(Map<String, Serializable> attributes) {
188         _attributes = attributes;
189     }
190 
191     public void setCommand(String command) {
192         _command = command;
193     }
194 
195     public void setCommunityPermissions(String[] communityPermissions) {
196         _communityPermissions = communityPermissions;
197     }
198 
199     public void setCompanyId(long companyId) {
200         _companyId = companyId;
201     }
202 
203     public void setCreateDate(Date createDate) {
204         _createDate = createDate;
205     }
206 
207     public void setExpandoBridgeAttributes(
208         Map<String, Serializable> expandoBridgeAttributes) {
209 
210         _expandoBridgeAttributes = expandoBridgeAttributes;
211     }
212 
213     public void setGuestPermissions(String[] guestPermissions) {
214         _guestPermissions = guestPermissions;
215     }
216 
217     public void setLanguageId(String languageId) {
218         _languageId = languageId;
219     }
220 
221     public void setLayoutFullURL(String layoutFullURL) {
222         _layoutFullURL = layoutFullURL;
223     }
224 
225     public void setLayoutURL(String layoutURL) {
226         _layoutURL = layoutURL;
227     }
228 
229     public void setModifiedDate(Date modifiedDate) {
230         _modifiedDate = modifiedDate;
231     }
232 
233     public void setPathMain(String pathMain) {
234         _pathMain = pathMain;
235     }
236 
237     public void setPlid(long plid) {
238         _plid = plid;
239     }
240 
241     public void setPortalURL(String portalURL) {
242         _portalURL = portalURL;
243     }
244 
245     public void setPortletPreferencesIds(
246         PortletPreferencesIds portletPreferencesIds) {
247 
248         _portletPreferencesIds = portletPreferencesIds;
249     }
250 
251     public void setScopeGroupId(long scopeGroupId) {
252         _scopeGroupId = scopeGroupId;
253     }
254 
255     public void setTagsCategories(String[] tagsCategories) {
256         _tagsCategories = tagsCategories;
257     }
258 
259     public void setTagsEntries(String[] tagsEntries) {
260         _tagsEntries = tagsEntries;
261     }
262 
263     public void setUserDisplayURL(String userDisplayURL) {
264         _userDisplayURL = userDisplayURL;
265     }
266 
267     public void setUserId(long userId) {
268         _userId = userId;
269     }
270 
271     private boolean _addCommunityPermissions;
272     private boolean _addGuestPermissions;
273     private Map<String, Serializable> _attributes;
274     private String _command;
275     private String[] _communityPermissions;
276     private long _companyId;
277     private Date _createDate;
278     private Map<String, Serializable> _expandoBridgeAttributes;
279     private String[] _guestPermissions;
280     private String _languageId;
281     private String _layoutFullURL;
282     private String _layoutURL;
283     private Date _modifiedDate;
284     private String _pathMain;
285     private String _portalURL;
286     private PortletPreferencesIds _portletPreferencesIds;
287     private long _scopeGroupId;
288     private String[] _tagsCategories;
289     private String[] _tagsEntries;
290     private String _userDisplayURL;
291     private long _plid;
292     private long _userId;
293 
294 }