001: /**
002: * $Id: CreateContainerBean.java,v 1.13 2005/10/24 18:52:19 cathywu 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.desktop;
014:
015: import java.beans.*;
016:
017: import java.util.Map;
018: import java.util.Set;
019: import java.util.Iterator;
020: import java.util.LinkedList;
021: import java.util.logging.Level;
022:
023: //JMX
024: import javax.management.MBeanServerConnection;
025: import javax.management.ObjectName;
026: import javax.management.InstanceNotFoundException;
027: import javax.management.MBeanException;
028: import javax.management.ReflectionException;
029: import javax.management.MalformedObjectNameException;
030: import javax.management.RuntimeErrorException;
031:
032: import com.sun.web.ui.model.Option;
033:
034: import com.sun.portal.admin.common.util.AdminClientUtil;
035: import com.sun.portal.admin.common.PSMBeanException;
036:
037: import com.sun.portal.admin.console.fabric.ListPortalsBean;
038:
039: /**
040: * @author cathywu
041: */
042: public class CreateContainerBean extends ChannelContainerBaseBean {
043: private String containerName;
044: private Option[] contProviders;
045:
046: public CreateContainerBean() {
047: //setup initial screen
048: contProviders = setupContProviders();
049: }
050:
051: /**
052: * Container providers methods
053: */
054: public Option[] setupContProviders() {
055: dn = (String) getCurrentDN();
056: Object[] params = { dn };
057: String[] signature = { "java.lang.String" };
058: ObjectName on = null;
059: Set ps = null;
060:
061: contProviders = null;
062: try {
063: on = AdminClientUtil.getDisplayProfileMBeanObjectName(
064: getDomain(), portalId);
065: ps = (Set) mbsc.invoke(on, "getExistingContainerProviders",
066: params, signature);
067: } catch (Exception e) {
068: return contProviders;
069: }
070:
071: int size = ps.size();
072: if (size != 0) {
073: contProviders = new Option[size];
074: int ind = 0;
075: for (Iterator i = ps.iterator(); i.hasNext();) {
076: String next = (String) i.next();
077: contProviders[ind] = new Option(next, next);
078: ind++;
079: }
080: }
081:
082: return contProviders;
083: }
084:
085: /**
086: * createChannel methods
087: */
088: public boolean createContainer(CreateChannelBean cb,
089: String selectedContainer, String createdContainer,
090: String provider) {
091: try {
092: Object[] params = { dn, createdContainer, provider };
093: String[] signature = { "java.lang.String",
094: "java.lang.String", "java.lang.String" };
095:
096: log(Level.INFO,
097: "CreateContainerBean.createContainer(),container name: "
098: + createdContainer);
099: log(Level.INFO,
100: "CreateContainerBean.createContainer(),container provider: "
101: + provider);
102:
103: ObjectName on = AdminClientUtil
104: .getDisplayProfileMBeanObjectName(getDomain(),
105: portalId);
106:
107: mbsc.invoke(on, "createContainer", params, signature);
108:
109: //cb.setupAlert(null, "createContainer.summary",
110: // "createContainer.completed","information",
111: // null);
112: setCancelText((String) rbMap.get("close.button"));
113: setDisableCreate(true);
114: setRegenerate(true);
115: return true;
116: } catch (MBeanException me) {
117: log(Level.SEVERE,
118: "CreateContainerBean.createContainer(): Failed to create container "
119: + createdContainer
120: + " due to MBeanException ", me);
121: String alertDetailKey = null;
122: Object[] tokens = null;
123: String message = null;
124:
125: if (me.getCause() != null
126: && me.getCause() instanceof PSMBeanException) {
127: alertDetailKey = ((PSMBeanException) me.getCause())
128: .getErrorKey();
129: tokens = ((PSMBeanException) me.getCause()).getTokens();
130: message = composeLogMessage(((PSMBeanException) me
131: .getCause()));
132: } else {
133: message = composeLogMessage(me);
134: }
135:
136: if (alertDetailKey == null) {
137: alertDetailKey = "error.createChannel.failed.checkLogs";
138: tokens = new Object[] { createdContainer };
139: }
140:
141: cb.setupAlert(tokens, "error.createChannel.summary",
142: alertDetailKey, "error",
143: "error.createChannel.failed.checkLogs", message);
144: return false;
145: } catch (Exception e) {
146: cb.setupAlert(new Object[] { createdContainer },
147: "error.createContainer.summary",
148: "error.createContainer.failed.checkLogs", "error",
149: null, composeLogMessage(e));
150: log(
151: Level.SEVERE,
152: "Exception in CreateContainerBean.createContainer()",
153: e);
154: return false;
155: }
156: }
157:
158: }
|