001: /**
002: * $Id: PortletProvisionEvent.java,v 1.7 2007/01/26 03:48:54 portalbld Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.portlet.service.provision;
014:
015: import com.iplanet.sso.SSOToken;
016:
017: import java.util.Map;
018: import javax.servlet.http.HttpServletRequest;
019:
020: /**
021: * Event delivered to a portlet listener. Mainly these events are sent
022: * because a community that is using portlet is created, deleted, undeleted,
023: * disabled, enabled or purged. They can also be sent if a particular service is
024: * individually being created, deleted, disabled, enabled.
025: */
026: public class PortletProvisionEvent {
027:
028: /**
029: * Creation or initialization event. It is called whenever a service is asked
030: * to initialize itself. This happens when a new community is created or
031: * an existing community includes this portlet.
032: */
033: public static final String EVENT_TYPE_CREATED = "CREATED";
034: /**
035: * Deletion event. This event is generally sent whenever the
036: * community that is using this portlet is marked
037: * for deletion. The service data must not be
038: * physically removed when a community is marked for
039: * deletion.
040: */
041: public static final String EVENT_TYPE_DELETED = "DELETED";
042: /**
043: * Disable event. This event is generally sent whenever the
044: * community that is using this portlet is disabled and it asks
045: * its services to disable their functionality if applicable.
046: */
047: public static final String EVENT_TYPE_DISABLED = "DISABLED";
048: /**
049: * Enable event. This event is generally sent whenever the
050: * community that is using this portlet is enabled and it asks its services
051: * to be enable if applicable.
052: */
053: public static final String EVENT_TYPE_ENABLED = "ENABLED";
054: /**
055: * Undo the deletion. This event is generally sent when a community
056: * that is using this portlet is previously marked for deletion is reset
057: * and it asks its services to reset if applicable.
058: */
059: public static final String EVENT_TYPE_UNDELETED = "UNDELETED";
060: /**
061: * Remove event. This event is sent whenever the
062: * community that is using this portlet is permantely removed
063: * and it asks the services it to remove their data too, if applicable.
064: */
065: public static final String EVENT_TYPE_DESTROYED = "DESTROYED";
066:
067: /**
068: * Key to get/set the portlet preferences for a user in OWNER role.
069: */
070: public static final String PREFERENCES_OWNER = "owner";
071: /**
072: * Key to get/set the portlet preferences for a user in MEMBER role.
073: */
074: public static final String PREFERENCES_MEMBER = "member";
075: /**
076: * Key to get/set the portlet preferences for a user in VISITOR role.
077: */
078: public static final String PREFERENCES_VISITOR = "visitor";
079: /**
080: * Key to get/set the portlet preferences for a user in INVITED role.
081: */
082: public static final String PREFERENCES_INVITED = "invited";
083: /**
084: * Key to get/set the portlet preferences for a user in REJECTED role.
085: */
086: public static final String PREFERENCES_REJECTED = "rejected";
087: /**
088: * Key to get/set the portlet preferences for a user in PENDING role.
089: */
090: public static final String PREFERENCES_PENDING = "pending";
091: /**
092: * Key to get/set the portlet preferences for a user in BANNED role.
093: */
094: public static final String PREFERENCES_BANNED = "banned";
095: /**
096: * Key to get/set the portlet preferences when the community is in DISABLED state.
097: */
098: public static final String PREFERENCES_DISABLED_COMMUNITY = "disabled_community";
099: /**
100: * Key to get/set the portlet preferences when the community is marked for deletion i.e.in DELETED state.
101: */
102: public static final String PREFERENCES_DELETED_COMMUNITY = "deleted_community";
103:
104: private String _communityPrincipalId;
105: private String _portletName;
106: private String _portleInstanceName;
107: private Map _provisionProperties;
108: private SSOToken _ssoToken;
109: private HttpServletRequest _request;
110: private String _eventType;
111:
112: /**
113: * Public constructor
114: */
115: public PortletProvisionEvent(String eventType,
116: HttpServletRequest request, String communityPrincipalId,
117: String portletName, String portleInstanceName,
118: Map provisionProperties, SSOToken ssoToken) {
119: _communityPrincipalId = communityPrincipalId;
120: _portletName = portletName;
121: _portleInstanceName = portleInstanceName;
122: _provisionProperties = provisionProperties;
123: _ssoToken = ssoToken;
124: _request = request;
125: _eventType = eventType;
126:
127: }
128:
129: /**
130: *
131: * @return Id of the community
132: */
133: public String getCommunityPrincipalId() {
134: return _communityPrincipalId;
135: }
136:
137: /**
138: *
139: * @return name of the portlet
140: */
141: public String getPortletName() {
142: return _portletName;
143: }
144:
145: /**
146: *
147: * @return name of the channel.
148: */
149: public String getPortletInstanceName() {
150: return _portleInstanceName;
151: }
152:
153: /**
154: * This method returns the PortletProvisionPreferences if available. Otherwise, it returns null.
155: * Possible values for key are the defined constants starting with PREFERENCES_*.
156: * @param key static string constants defined in this class.
157: * @return Instance of PortletProvisionPreferences for the role specified.
158: */
159: public PortletProvisionPreferences getPortletProvisionPreferences(
160: String key) {
161: if (_provisionProperties != null) {
162: return (PortletProvisionPreferences) _provisionProperties
163: .get(key);
164: } else {
165: return null;
166: }
167: }
168:
169: /**
170: *
171: * @return SSOToken
172: */
173: public SSOToken getSSOToken() {
174: return _ssoToken;
175: }
176:
177: /**
178: *
179: * @return servlet request.
180: */
181: public HttpServletRequest getHttpServletRequest() {
182: return _request;
183: }
184:
185: /**
186: * Possible values are static constant defined starting with EVENT_TYPE.
187: * @return community event type.
188: */
189: public String getType() {
190: return _eventType;
191: }
192:
193: /**
194: *
195: *
196: */
197: public String toString() {
198: StringBuffer buffer = new StringBuffer(30);
199: buffer.append("\n\tCommunityId:" + getCommunityPrincipalId());
200: buffer.append("\n\tPortletName:" + getPortletName());
201: buffer.append("\n\tPortletInstanceName:"
202: + getPortletInstanceName());
203: buffer.append("\n\tSSOToken:" + getSSOToken().toString());
204: buffer.append("\n\tEventType:" + getType().toString());
205: buffer.append("\n\tProvisionRoles:" + _provisionProperties);
206: return buffer.toString();
207: }
208:
209: }
|