001: /**
002: * $Id: ProducerBaseBean.java,v 1.2 2005/08/16 23:43:35 yue 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.admin.console.wsrp.producer;
014:
015: import java.util.ArrayList;
016: import java.util.Collections;
017: import java.util.LinkedList;
018: import java.util.List;
019: import java.util.ResourceBundle;
020:
021: import javax.faces.context.FacesContext;
022: import javax.faces.el.ValueBinding;
023: import javax.servlet.http.HttpServletRequest;
024:
025: import com.sun.data.provider.RowKey;
026: import com.sun.portal.admin.common.util.AdminUtil;
027: import com.sun.portal.admin.console.common.PSBaseBean;
028: import com.sun.web.ui.model.Option;
029:
030: public abstract class ProducerBaseBean extends PSBaseBean {
031: public static final String INFORMATION = "information";
032: public static final String WARNING = "warning";
033: public static final String ERROR = "error";
034: public static final String COMPONENT = "producer";
035: public static final String TRUE = Boolean.TRUE.toString();
036: public static final String FALSE = Boolean.FALSE.toString();
037: public static final String ENABLED = "Enabled";
038: public static final String DISABLED = "Disabled";
039: public static final String REQUIRED = "Required";
040: public static final String NOT_REQUIRED = "NotRequired";
041: public static final String SUPPORTED = "Supported";
042: public static final String UNSUPPORTED = "Unsupported";
043: public static final String PRODUCER_MANAGER = "ProducerManager";
044: public static final String PRODUCER = "Producer";
045:
046: public static final String PRODUCER_MANAGER_TYPE = AdminUtil.PORTAL_MBEAN_TYPE
047: + "." + PRODUCER_MANAGER;
048:
049: public static final String PRODUCER_TYPE = PRODUCER_MANAGER_TYPE
050: + "." + PRODUCER;
051:
052: protected ResourceBundle rb = null;
053: protected String portalID = null;
054:
055: public ProducerBaseBean() {
056: rb = getRBundle(COMPONENT);
057: portalID = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
058: }
059:
060: protected HttpServletRequest getRequest() {
061: return (HttpServletRequest) FacesContext.getCurrentInstance()
062: .getExternalContext().getRequest();
063: }
064:
065: protected void setRequestAttributeInSession(String attrName) {
066: setSessionAttribute(attrName, getRequest().getParameter(
067: attrName));
068: }
069:
070: protected List getProducerManagerPath() {
071: LinkedList path = new LinkedList();
072: path.addFirst(getDomain());
073: path.addFirst(getSessionAttribute(ATTR_SELECTED_PORTAL));
074: path.addFirst(PRODUCER_MANAGER);
075: return path;
076: }
077:
078: protected List getProducerPath() {
079: LinkedList path = new LinkedList();
080: path.addFirst(getDomain());
081: path.addFirst(getSessionAttribute(ATTR_SELECTED_PORTAL));
082: path.addFirst(PRODUCER_MANAGER);
083: path.addFirst(getSessionAttribute(ATTR_SELECTED_PRODUCER));
084: return path;
085: }
086:
087: protected Option[] getStatusOptionArray() {
088: return new Option[] {
089: new Option(ENABLED, rb
090: .getString("generic.label.enabled")),
091: new Option(DISABLED, rb
092: .getString("generic.label.disabled")) };
093: }
094:
095: protected Option[] getRegistrationOptionArray() {
096: return new Option[] {
097: new Option(REQUIRED, rb
098: .getString("generic.label.required")),
099: new Option(NOT_REQUIRED, rb
100: .getString("generic.label.notRequired")) };
101: }
102:
103: protected Option[] getSupportOptionArray() {
104: return new Option[] {
105: new Option(SUPPORTED, rb
106: .getString("generic.label.supported")),
107: new Option(UNSUPPORTED, rb
108: .getString("generic.label.unsupported")) };
109: }
110:
111: protected RowKey getTableRow(String row) {
112: FacesContext context = FacesContext.getCurrentInstance();
113: ValueBinding vb = context.getApplication().createValueBinding(
114: row);
115: return (RowKey) vb.getValue(context);
116: }
117:
118: protected List arrayToList(String[] stringArray) {
119: if ((stringArray == null) || (stringArray.length == 0)) {
120: return Collections.EMPTY_LIST;
121: }
122:
123: List result = new ArrayList(stringArray.length);
124:
125: for (int i = 0; i < stringArray.length; i++) {
126: result.add(stringArray[i]);
127: }
128:
129: return result;
130: }
131: }
|