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.
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.app.communityportlets.faces;
038:
039: import java.io.IOException;
040:
041: import javax.servlet.RequestDispatcher;
042: import javax.servlet.ServletException;
043: import javax.servlet.http.HttpServletRequest;
044: import javax.servlet.http.HttpServletResponse;
045:
046: import javax.faces.FacesException;
047: import javax.faces.application.NavigationHandler;
048: import javax.faces.context.FacesContext;
049: import javax.faces.context.ExternalContext;
050: import javax.faces.validator.Validator;
051: import javax.faces.validator.ValidatorException;
052: import javax.faces.event.AbortProcessingException;
053: import javax.faces.event.ValueChangeEvent;
054: import javax.faces.component.UIComponent;
055:
056: import com.sun.web.ui.event.WizardEvent;
057: import com.sun.web.ui.event.WizardEventListener;
058: import com.sun.web.ui.model.Option;
059:
060: import javax.portlet.PortletContext;
061: import javax.portlet.PortletRequest;
062: import javax.portlet.PortletResponse;
063: import javax.portlet.ActionResponse;
064:
065: import com.sun.portal.log.common.PortalLogger;
066:
067: import com.sun.portal.community.CommunityManager;
068: import com.sun.portal.community.CommunityFactory;
069: import com.sun.portal.community.CommunityException;
070: import com.sun.portal.community.CommunityServiceException;
071: import com.sun.portal.community.CommunityServiceExceptionEntry;
072: import com.sun.portal.community.CommunityId;
073: import com.sun.portal.community.RoleId;
074: import com.sun.portal.community.TemplateTokens;
075: import com.sun.portal.community.CommunityContainerName;
076:
077: import com.sun.portal.community.urlmanager.CommunityURLManagerFactory;
078: import com.sun.portal.community.urlmanager.CommunityURLManager;
079:
080: public class CommunityAccessHandler extends CommunityBaseHandler {
081:
082: public static final String ACCESS_TYPE_PUBLIC = "public";
083: public static final String ACCESS_TYPE_PRIVATE = "private";
084: public static final String ACCESS_TYPE_CUSTOM = "custom";
085:
086: private String accessType = ACCESS_TYPE_PUBLIC;
087: private String membershipType = ACCESS_TYPE_PUBLIC;
088: private String dataSecurityType = ACCESS_TYPE_PUBLIC;
089: private String listingType = ACCESS_TYPE_PUBLIC;
090:
091: public String getAccessTypePublic() {
092: return ACCESS_TYPE_PUBLIC;
093: }
094:
095: public String getAccessTypePrivate() {
096: return ACCESS_TYPE_PRIVATE;
097: }
098:
099: public String getAccessTypeCustom() {
100: return ACCESS_TYPE_CUSTOM;
101: }
102:
103: public String getAccessType() {
104: return this .accessType;
105: }
106:
107: public void setAccessType(String accessType) {
108: if (accessType != null) {
109: this .accessType = accessType;
110: }
111: }
112:
113: public String getMembershipType() {
114: return this .membershipType;
115: }
116:
117: public void setMembershipType(String membershipType) {
118: if (membershipType != null) {
119: this .membershipType = membershipType;
120: }
121: }
122:
123: public String getDataSecurityType() {
124: return this .dataSecurityType;
125: }
126:
127: public void setDataSecurityType(String dataSecurityType) {
128: if (dataSecurityType != null) {
129: this .dataSecurityType = dataSecurityType;
130: }
131: }
132:
133: public String getListingType() {
134: return this .listingType;
135: }
136:
137: public void setListingType(String listingType) {
138: if (listingType != null) {
139: this .listingType = listingType;
140: }
141: }
142:
143: public void clear() {
144: setAccessType(ACCESS_TYPE_PUBLIC);
145: setMembershipType(ACCESS_TYPE_PUBLIC);
146: setDataSecurityType(ACCESS_TYPE_PUBLIC);
147: setListingType(ACCESS_TYPE_PUBLIC);
148: }
149:
150: public boolean isMembershipRestricted() {
151: boolean isRestricted = false;
152: if (getAccessType().equals(ACCESS_TYPE_PRIVATE)) {
153: isRestricted = true;
154: } else if (getAccessType().equals(ACCESS_TYPE_CUSTOM)) {
155: isRestricted = getMembershipType().equals(
156: ACCESS_TYPE_PRIVATE);
157: }
158: return isRestricted;
159: }
160:
161: public boolean isListed() {
162: boolean isListed = true;
163: if (getAccessType().equals(ACCESS_TYPE_PRIVATE)) {
164: isListed = false;
165: } else if (getAccessType().equals(ACCESS_TYPE_CUSTOM)) {
166: isListed = getListingType().equals(ACCESS_TYPE_PUBLIC);
167: }
168: return isListed;
169: }
170:
171: public boolean isDataSecure() {
172: boolean isSecure = false;
173: if (getAccessType().equals(ACCESS_TYPE_PRIVATE)) {
174: isSecure = true;
175: } else if (getAccessType().equals(ACCESS_TYPE_CUSTOM)) {
176: isSecure = getDataSecurityType()
177: .equals(ACCESS_TYPE_PRIVATE);
178: }
179: return isSecure;
180: }
181: }
|