001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.subscriptions.admin;
007:
008: import java.util.List;
009: import java.util.ArrayList;
010: import java.util.Iterator;
011: import java.util.Set;
012: import java.util.logging.Level;
013: import java.util.logging.Logger;
014: import java.io.UnsupportedEncodingException;
015: import javax.servlet.http.HttpServletRequest;
016:
017: import com.iplanet.am.console.components.view.html.IPlanetButton;
018: import com.iplanet.am.console.components.view.html.DynamicGUI;
019: import com.iplanet.am.console.components.view.html.DynamicGUIComp;
020:
021: import com.iplanet.jato.model.ModelControlException;
022: import com.iplanet.jato.view.View;
023: import com.iplanet.jato.view.ViewBean;
024: import com.iplanet.jato.view.event.ChildDisplayEvent;
025: import com.iplanet.jato.view.event.RequestInvocationEvent;
026: import com.iplanet.jato.view.html.HREF;
027: import com.iplanet.jato.view.html.StaticTextField;
028: import com.iplanet.jato.util.Encoder;
029:
030: import com.iplanet.am.console.base.AMViewBeanBase;
031: import com.iplanet.am.console.service.SMDataView;
032: import com.iplanet.am.console.service.model.SMDataModel;
033:
034: import com.sun.portal.subscriptions.admin.model.SubscriptionsAdminServiceModelImpl;
035: import com.sun.portal.subscriptions.admin.SubscriptionsAdminConstants;
036: import com.sun.portal.log.common.PortalLogger;
037:
038: public class SubscriptionsAdminServiceView extends SMDataView {
039: public static final String CHILD_PROF_DESCRIPTION = "prof.description";
040: public static final String START_VIEW = "StartProfiler";
041: public static final String STOP_VIEW = "StopProfiler";
042:
043: private static Logger logger = PortalLogger
044: .getLogger(SubscriptionsAdminServiceView.class);
045: // used for debugging
046: public static final String CLASS_NAME = "SubscriptionsAdminServiceView.";
047:
048: /**
049: * This variable decides the type of view.
050: * The type which is one of GLOBAL_TYPE, ORG_TYPE, DYNAMIC_TYPE.
051: */
052: protected int viewType = 0;
053:
054: /*
055: * @param parent The reference of the parent container
056: * @param name The name of this view.
057: * @param type The type which is one of GLOBAL_TYPE, ORG_TYPE, DYNAMIC_TYPE.
058: */
059: public SubscriptionsAdminServiceView(View parent, String name,
060: int type) {
061: super (parent, name, type);
062:
063: viewType = type;
064: registerChildren();
065: }
066:
067: public void registerChildren() {
068: registerChild(CHILD_PROF_DESCRIPTION, StaticTextField.class);
069: registerChild(START_VIEW, ScheduleView.class);
070: registerChild(STOP_VIEW, ScheduleView.class);
071: }
072:
073: protected View createChild(String name) {
074: try {
075: if (name.equals(CHILD_PROF_DESCRIPTION)) {
076: return new StaticTextField(
077: this ,
078: CHILD_PROF_DESCRIPTION,
079: ((SubscriptionsAdminServiceViewBean) getParentViewBean())
080: .getLocalizedString(CHILD_PROF_DESCRIPTION));
081: } else if (name.equals(START_VIEW)) {
082: return new ScheduleView(this , START_VIEW);
083: } else if (name.equals(STOP_VIEW)) {
084: return new ScheduleView(this , STOP_VIEW);
085: } else {
086: if (logger.isLoggable(Level.WARNING))
087: logger.log(Level.WARNING, "PSSS_CSPSA0001", name);
088: return super .createChild(name);
089: }
090: } catch (Exception e) {
091: if (logger.isLoggable(Level.SEVERE))
092: logger.log(Level.SEVERE, "failing creating child-"
093: + name, e);
094: return null;
095: }
096: }
097:
098: /**
099: * Decides to show the subscriptions service attribute or not.
100: *
101: * @return true if the currently logged in user has the privilege to see it.
102: */
103: public boolean beginCcAttrSetDisplay(ChildDisplayEvent event)
104: throws ModelControlException {
105:
106: SMDataModel model = getModel();
107: // Check if it is the display profile attribute
108: boolean ret = true;
109: boolean success = model.setCurrentRow(viewType, getTileIndex());
110: if (success) {
111: String attrName = model.getAttrName();
112: if (attrName != null
113: && attrName
114: .equals(SubscriptionsAdminConstants.START_PROFILER)) {
115: ret = false;
116: } else if (attrName != null
117: && attrName
118: .equals(SubscriptionsAdminConstants.STOP_PROFILER)) {
119: ret = false;
120: }
121: }
122: return (ret);
123: }
124:
125: public List getDynamicCompList() {
126: HttpServletRequest req = getRequestContext().getRequest();
127: /* This becomes necessary here as the inherited getDynamicCompList can
128: * not be used, because it can handle only the dynamic guis and not
129: * a mix of dynamic and non-dynamic components. */
130: int nTiles = getModel().getSize(viewType);
131:
132: List dynamicGUIs = new ArrayList(nTiles);
133: int count = 0;
134: while (count < nTiles) {
135: DynamicGUI dGUI = DynamicGUIComp.createDynamicGUI(req,
136: getQualifiedName(), CC_ATTR_SET, count++);
137: if (dGUI != null) {
138: dynamicGUIs.add(dGUI);
139: }
140: }
141: return dynamicGUIs;
142: }
143:
144: public void handleBtnSaveRequest(RequestInvocationEvent event)
145: throws ModelControlException {
146: try {
147: ((SubscriptionsAdminServiceViewBean) getParentViewBean())
148: .handleBtnSaveRequest(event);
149: } catch (Exception e) {
150: logger.log(Level.SEVERE, "PSSS_CSPSA0005", e);
151: }
152: }
153: }
|