001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.getc
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * any nuclear facility.
035: */
036:
037: package com.sun.portal.community;
038:
039: import javax.portlet.PortletRequest;
040: import javax.servlet.http.HttpServletRequest;
041: import javax.servlet.http.HttpServletResponse;
042:
043: import com.iplanet.sso.SSOToken;
044:
045: /**
046: * Factory class used to get references to various community objects.
047: */
048: public abstract class CommunityFactory {
049: public static final String COMMUNITY_ID_PREF = "ps.communityId";
050: public static final String COMMUNITY_ID_PARAM = "ps.communityId";
051:
052: private static CommunityFactory factory;
053:
054: public static CommunityFactory getInstance() {
055: if (factory == null) {
056: throw new IllegalStateException("factory unavailable");
057: }
058: return factory;
059: }
060:
061: protected static void setInstance(CommunityFactory factory) {
062: CommunityFactory.factory = factory;
063: }
064:
065: /**
066: * Get a community manager.
067: */
068: public abstract CommunityManager getCommunityManager(
069: PortletRequest preq) throws CommunityException;
070:
071: /**
072: * Get a community manager.
073: */
074: public abstract CommunityManager getCommunityManager(
075: HttpServletRequest req, HttpServletResponse res)
076: throws CommunityException;
077:
078: /**
079: * Get a community manager.
080: */
081: public abstract CommunityManager getCommunityManager(
082: HttpServletRequest req, HttpServletResponse res,
083: SSOToken ssoToken) throws CommunityException;
084:
085: /**
086: * Get a community.
087: * <p>
088: * The community ID is taken from the PortletPreferences that are
089: * associated with the given PortletRequest object.
090: */
091: public abstract Community getCommunity(PortletRequest preq)
092: throws CommunityDoesNotExistException, CommunityException;
093:
094: /**
095: * Get a community.
096: * <p>
097: * The community ID is taken from an HTTP parameter from the given
098: * HttpServletRequest object.
099: */
100: public abstract Community getCommunity(HttpServletRequest req,
101: HttpServletResponse res)
102: throws CommunityDoesNotExistException, CommunityException;
103:
104: /**
105: * Get a community.
106: */
107: public abstract Community getCommunity(HttpServletRequest req,
108: HttpServletResponse res, SSOToken ssoToken, CommunityId cid)
109: throws CommunityDoesNotExistException, CommunityException;
110:
111: /**
112: * Get a community user.
113: * <p>
114: * The user ID is taken from the SSOToken object that is associated with
115: * the PortletRequest object.
116: */
117: public abstract CommunityUser getCommunityUser(PortletRequest preq)
118: throws CommunityException;
119:
120: /**
121: * Get a community user.
122: * <p>
123: * The user ID and community ID are taken from the given request
124: * the PortletRequest object.
125: */
126: public abstract CommunityUser getCommunityUser(
127: HttpServletRequest req) throws CommunityException;
128:
129: /**
130: * Get a community user.
131: */
132: public abstract CommunityUser getCommunityUser(
133: HttpServletRequest req, String uid)
134: throws CommunityException;
135:
136: /**
137: * Get the community context.
138: * <p>
139: * The user ID and community ID are taken from the given PortletRequest
140: * object.
141: */
142: public abstract CommunityContext getCommunityContext(
143: PortletRequest preq) throws CommunityException;
144:
145: /**
146: * Get the community context.
147: * <p>
148: * The user ID and community ID are taken from the given request.
149: * object.
150: */
151: public abstract CommunityContext getCommunityContext(
152: HttpServletRequest req) throws CommunityException;
153:
154: /**
155: * Get the community context.
156: * <p>
157: * The user ID is taken from the given request.
158: * object.
159: */
160: public abstract CommunityContext getCommunityContext(
161: HttpServletRequest req, CommunityId cid)
162: throws CommunityException;
163:
164: /**
165: * Get the community context.
166: * <p>
167: * The user ID is taken from the given request.
168: * object.
169: */
170: public abstract CommunityContext getCommunityContext(
171: HttpServletRequest req, CommunityId cid, String userId)
172: throws CommunityException;
173: }
|