Source Code Cross Referenced for Portal.java in  » Portal » Open-Portal » com » sun » portal » fabric » mbeans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.fabric.mbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * $Id: Portal.java,v 1.50 2007/01/26 03:48:31 portalbld Exp $
0003:         * Copyright 2004 Sun Microsystems, Inc. All
0004:         * rights reserved. Use of this product is subject
0005:         * to license terms. Federal Acquisitions:
0006:         * Commercial Software -- Government Users
0007:         * Subject to Standard License Terms and
0008:         * Conditions.
0009:         *
0010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0011:         * are trademarks or registered trademarks of Sun Microsystems,
0012:         * Inc. in the United States and other countries.
0013:         */package com.sun.portal.fabric.mbeans;
0014:
0015:        import javax.management.MBeanServer;
0016:        import javax.management.MBeanServerConnection;
0017:        import javax.management.MBeanException;
0018:        import javax.management.ObjectName;
0019:        import javax.management.remote.JMXConnector;
0020:
0021:        import java.io.File;
0022:        import java.io.FileWriter;
0023:        import java.io.IOException;
0024:        import java.util.Collections;
0025:        import java.util.Map;
0026:        import java.util.Set;
0027:        import java.util.TreeSet;
0028:        import java.util.List;
0029:        import java.util.HashMap;
0030:        import java.util.ArrayList;
0031:        import java.util.Properties;
0032:        import java.util.ResourceBundle;
0033:        import java.util.Iterator;
0034:        import java.util.logging.Level;
0035:        import java.util.logging.Logger;
0036:        import java.util.logging.LogRecord;
0037:
0038:        import com.sun.portal.log.common.PortalLogger;
0039:        import com.sun.portal.log.common.PortalLogManager;
0040:        import com.sun.portal.admin.common.util.AdminUtil;
0041:        import com.sun.portal.admin.common.util.AdminClientUtil;
0042:        import com.sun.portal.admin.common.InstanceAttributes;
0043:        import com.sun.portal.admin.common.PSConfigConstants;
0044:        import com.sun.portal.admin.common.PortalAttributes;
0045:        import com.sun.portal.admin.common.context.PortalDomainContext;
0046:        import com.sun.portal.admin.common.context.PSConfigContext;
0047:        import com.sun.portal.admin.common.context.PortalDomainContextException;
0048:        import com.sun.portal.admin.common.PSMBeanException;
0049:        import com.sun.portal.admin.common.AttrOptionConstants;
0050:        import com.sun.portal.admin.server.mbeans.PSResource;
0051:        import com.sun.portal.admin.server.PASModule;
0052:        import com.sun.portal.admin.server.AdminServerUtil;
0053:        import com.sun.portal.fabric.common.AttributeHandler;
0054:        import com.sun.portal.fabric.common.AttributeHandlerFactory;
0055:        import com.sun.portal.fabric.tasks.WebContainer;
0056:        import com.sun.portal.fabric.tasks.WebContainerFactory;
0057:        import com.sun.portal.fabric.tasks.PortalWar;
0058:        import com.sun.portal.fabric.tasks.PortalFileHandler;
0059:        import com.sun.portal.fabric.tasks.PortalInstance;
0060:        import com.sun.portal.fabric.tasks.ConfigurationException;
0061:        import com.sun.portal.fabric.util.ClasspathGenUtil;
0062:        import com.sun.portal.fabric.util.FileUtil;
0063:        import com.sun.portal.fabric.util.XMLJdomUtil;
0064:        import com.sun.portal.fabric.util.XMLJdomFileCreationException;
0065:
0066:        public class Portal extends PSResource implements  PortalMBean {
0067:
0068:            private static Logger logger = PortalLogger.getLogger(Portal.class);
0069:            // Object used to lock the portal filesystem zip operation
0070:            private Object pZiplock = new Object();
0071:            private String portalDir = null;
0072:            private String portalConfigDir = null;
0073:            private String sPortalID = null;
0074:            private String sDomainID = null;
0075:
0076:            public void init(PSConfigContext cc, PortalDomainContext pdc,
0077:                    List path) {
0078:                super .init(cc, pdc, path);
0079:                sPortalID = getID();
0080:                sDomainID = getDomainID();
0081:                portalDir = cc.getPSDataDir() + fs + "portals" + fs + sPortalID;
0082:                portalConfigDir = portalDir + fs + "config";
0083:            }
0084:
0085:            public List getInstances() throws PSMBeanException {
0086:                // Return the list of instances in the portal from data in the PDC
0087:                try {
0088:                    Set instances = pdc.getResourceIDs(
0089:                            PortalServerInstanceMBean.TYPE, path);
0090:                    return new ArrayList(instances);
0091:                } catch (Exception e) {
0092:                    if (logger.isLoggable(Level.SEVERE)) {
0093:                        LogRecord record = new LogRecord(Level.SEVERE,
0094:                                "PSFB_CSPFM1121");
0095:                        record.setParameters(new Object[] { sPortalID });
0096:                        record.setThrown(e);
0097:                        record.setLoggerName(logger.getName());
0098:                        logger.log(record);
0099:                    }
0100:                    throw new PSMBeanException("admin.error.getInstances", e
0101:                            .getMessage(), e, new Object[] { sPortalID });
0102:                }
0103:            }
0104:
0105:            /**
0106:             * This method returns a true if this Portal has an instance on the host
0107:             * where this mbean is executing
0108:             */
0109:            public Boolean hasLocalInstance() {
0110:                return new Boolean(false);
0111:            }
0112:
0113:            /**
0114:             * This method returns a list of hostnames that are running instances of
0115:             * this portal.
0116:             */
0117:            public Set getHosts() throws PSMBeanException {
0118:                Set hosts = new TreeSet();
0119:                try {
0120:                    // gets all instance names
0121:                    Iterator it = getInstances().iterator();
0122:                    MBeanServer mbs = PASModule.getMBeanServer();
0123:                    while (it.hasNext()) {
0124:                        String instanceID = (String) it.next();
0125:                        // Instance MBean object name
0126:                        ObjectName iObjectName = AdminUtil
0127:                                .getInstanceMBeanObjectName(sDomainID,
0128:                                        sPortalID, instanceID);
0129:                        String host = (String) mbs.getAttribute(iObjectName,
0130:                                InstanceAttributes.HOST);
0131:                        if (!hosts.contains(host)) {
0132:                            hosts.add(host);
0133:                        }
0134:                    }
0135:                } catch (Exception e) {
0136:                    throw new PSMBeanException("error.get.instances", e
0137:                            .getMessage(), e);
0138:                }
0139:                return hosts;
0140:            }
0141:
0142:            public synchronized String createPortalWebApp()
0143:                    throws PSMBeanException {
0144:
0145:                // Set the default value of the uri and webapp name
0146:                String portalUri = "/portal";
0147:                String warFileName = "portal.war";
0148:
0149:                try {
0150:                    portalUri = pdc.getAttributeValue(TYPE, path,
0151:                            PortalAttributes.PORTAL_URI);
0152:                    if (portalUri != null && portalUri.startsWith("/")) {
0153:                        warFileName = portalUri.substring(1) + ".war";
0154:                    }
0155:
0156:                    String psConfig = cc.getPSConfigDir() + fs
0157:                            + PSConfigConstants.PS_CONFIG_FILE;
0158:                    PortalWar pwar = new PortalWar(sPortalID, psConfig);
0159:                    pwar.create(warFileName);
0160:
0161:                } catch (Exception e) {
0162:                    if (logger.isLoggable(Level.SEVERE)) {
0163:                        LogRecord record = new LogRecord(Level.SEVERE,
0164:                                "PSFB_CSPFM1122");
0165:                        record.setParameters(new Object[] { sPortalID });
0166:                        record.setThrown(e);
0167:                        record.setLoggerName(logger.getName());
0168:                        logger.log(record);
0169:                    }
0170:                    throw new PSMBeanException("admin.error.create.portal.war",
0171:                            e.getMessage(), e, new Object[] { sPortalID });
0172:                }
0173:
0174:                return portalUri;
0175:            }
0176:
0177:            /**
0178:             * This method create a Zip file out of the portal filesystem data
0179:             */
0180:            public String zipFilesystem() throws PSMBeanException {
0181:
0182:                String zipPath = cc.getPSDataDir() + fs + "tmp" + fs
0183:                        + sPortalID + ".zip";
0184:                synchronized (pZiplock) {
0185:                    PortalFileHandler.zipFilesystem(portalDir, zipPath);
0186:                }
0187:                File output = new File(zipPath);
0188:                if (!output.exists()) {
0189:                    throw new PSMBeanException("Failed creating zip file");
0190:                }
0191:
0192:                return zipPath;
0193:            }
0194:
0195:            /**
0196:             * This method for consumption from the configurator
0197:             * Attempts to create an instance on the local host. The webcontainer is
0198:             * configured, and the instance is registered but the webapps are not
0199:             * deployed by this method
0200:             */
0201:            public synchronized void createInstance(String instanceID,
0202:                    Properties wcProp) throws PSMBeanException {
0203:
0204:                Map attributes = new HashMap(wcProp);
0205:                String host = (String) attributes.get(InstanceAttributes.HOST);
0206:
0207:                if (instanceID == null || instanceID.trim().equals("")) {
0208:                    // Get the host and port numbers from the config properties
0209:                    String port = wcProp.getProperty(InstanceAttributes.PORT);
0210:                    instanceID = generateID(host, port);
0211:                }
0212:
0213:                //Checking if the instance already exists
0214:                List instances = new ArrayList();
0215:                instances = getInstances();
0216:                if (instances.contains(instanceID)) {
0217:                    logger.log(Level.SEVERE, "PSFB_CSPFM1026", instanceID);
0218:                    throw new PSMBeanException("admin.error.create.instance",
0219:                            "Portal Instance already exists",
0220:                            new Object[] { instanceID });
0221:                }
0222:
0223:                logger.log(Level.INFO, "PSFB_CSPFM1027", instanceID);
0224:                String containerType = (String) attributes
0225:                        .get(InstanceAttributes.WEB_CONTAINER_TYPE);
0226:                PortalInstance pInstance = new PortalInstance(sPortalID,
0227:                        instanceID, host, containerType, cc);
0228:
0229:                try {
0230:                    pInstance.setupInstanceConfigFiles();
0231:                } catch (ConfigurationException ce) {
0232:                    logger.log(Level.SEVERE, "PSFB_CSPFM1028", ce);
0233:                    throw new PSMBeanException(
0234:                            "admin.error.configure.instance",
0235:                            getStackTrace(ce), ce, new Object[] { instanceID });
0236:                }
0237:
0238:                // Set the instanceID into the attributes that get persisted
0239:                // when the instance is registed with the domain repository
0240:                //and also passed to the webcontainer implementations
0241:                attributes.put(InstanceAttributes.NAME, instanceID);
0242:                attributes.put(InstanceAttributes.DESCRIPTION, instanceID);
0243:                // Set the DomainID, portalID, instanceID into the attributes that passed
0244:                //to the webcontainer implementations
0245:                attributes.put(WebContainer.DOMAIN_ID, sDomainID);
0246:                attributes.put(WebContainer.PORTAL_ID, sPortalID);
0247:
0248:                File fwcConfigData = null;
0249:                try {
0250:                    // Create instance of webcontainer
0251:                    WebContainer wc = WebContainerFactory.getWebContainer(
0252:                            attributes, true);
0253:                    if (wc.isPortalConfigured()) {
0254:
0255:                        ResourceBundle resourceBundle = logger.getLogger(
0256:                                PortalLogManager.DEBUG_ROOT_LOGGER)
0257:                                .getResourceBundle();
0258:                        String msg = resourceBundle.getString("PSFB_CSPFM1023");
0259:                        java.text.MessageFormat form = new java.text.MessageFormat(
0260:                                msg);
0261:                        msg = form.format(new String[] {
0262:                                wc.getWebContainerType(),
0263:                                wc.getPrintableWebContainerInstanceName() });
0264:                        XMLJdomFileCreationException e1 = new XMLJdomFileCreationException(
0265:                                msg);
0266:                        throw new PSMBeanException(
0267:                                "admin.error.configure.instance", msg, e1);
0268:                    }
0269:
0270:                    // Read the Web Container Config Data from the PAS and store it in a file
0271:                    // <install_loc>/SUNWportal/portals/<portal_id>/config/WebContainerConfigData.xml
0272:                    String swcConfigDataR = null;
0273:                    try {
0274:                        swcConfigDataR = pdc.getAttributeValue(
0275:                                PortalMBean.TYPE, path,
0276:                                PortalAttributes.WEB_CONTAINER_CONFIG_DATA);
0277:                    } catch (PortalDomainContextException pde) {
0278:                        // Ignore it. The attribute may not exist.
0279:                        swcConfigDataR = null;
0280:                    }
0281:
0282:                    String swcConfigDataFile = portalConfigDir + fs
0283:                            + "WebContainerConfigData.xml";
0284:                    fwcConfigData = new File(swcConfigDataFile);
0285:                    if (fwcConfigData.exists()) {
0286:
0287:                        fwcConfigData.delete();
0288:                    }
0289:
0290:                    logger.log(Level.INFO, "PSFB_CSPFM1020", new String[] {
0291:                            "createInstance",
0292:                            (swcConfigDataR == null) ? "" : swcConfigDataR });
0293:
0294:                    long lOldFileLength = 0;
0295:                    if ((swcConfigDataR != null)
0296:                            && (swcConfigDataR.trim().length() > 0)) {
0297:
0298:                        FileWriter fw = new FileWriter(fwcConfigData);
0299:                        fw.write(swcConfigDataR);
0300:                        fw.close();
0301:                        lOldFileLength = fwcConfigData.length();
0302:                    }
0303:
0304:                    // Invoke configure method to setup the classpath for Portal
0305:                    // and Access Manager SDK
0306:                    wc.configure(cc);
0307:
0308:                    // Write the Web Container Config Data to the PAS.
0309:                    fwcConfigData = new File(swcConfigDataFile);
0310:                    long lNewFileLength = fwcConfigData.length();
0311:                    if (lOldFileLength != lNewFileLength) {
0312:
0313:                        String swcConfigDataW = null;
0314:                        try {
0315:                            XMLJdomUtil xmlJdomUtil = new XMLJdomUtil();
0316:                            xmlJdomUtil
0317:                                    .readXMLFileLessSchemaValidation(swcConfigDataFile);
0318:                            swcConfigDataW = xmlJdomUtil
0319:                                    .getXMLJdomDocumentAsString();
0320:                        } catch (XMLJdomFileCreationException e0) {
0321:                            logger.log(Level.SEVERE, e0.getMessage());
0322:                            swcConfigDataW = null;
0323:                        }
0324:
0325:                        // Set the set of deployed URIs into the instance data
0326:                        if ((swcConfigDataW != null)
0327:                                && (swcConfigDataW.trim().length() > 0)) {
0328:
0329:                            logger.log(Level.INFO, "PSFB_CSPFM1021",
0330:                                    new String[] {
0331:                                            "Configure Portal",
0332:                                            (swcConfigDataW == null) ? ""
0333:                                                    : swcConfigDataW });
0334:                            logger.log(Level.INFO, "Type=" + PortalMBean.TYPE);
0335:                            logger.log(Level.INFO, "List=" + path);
0336:                            pdc.setAttributeValue(PortalMBean.TYPE, path,
0337:                                    PortalAttributes.WEB_CONTAINER_CONFIG_DATA,
0338:                                    swcConfigDataW);
0339:                        } else {
0340:
0341:                            ResourceBundle resourceBundle = logger.getLogger(
0342:                                    PortalLogManager.DEBUG_ROOT_LOGGER)
0343:                                    .getResourceBundle();
0344:                            String msg = resourceBundle
0345:                                    .getString("PSFB_CSPFM1022");
0346:                            XMLJdomFileCreationException e1 = new XMLJdomFileCreationException(
0347:                                    msg);
0348:                            throw new PSMBeanException(
0349:                                    "admin.error.configure.instance", msg, e1);
0350:                        }
0351:                    }
0352:
0353:                    // Remove the DomainID, portalID attributes from the attributes map
0354:                    // so that these dont get persisted whenwhen the instance is registed
0355:                    // with the domain repository
0356:                    attributes.remove(WebContainer.DOMAIN_ID);
0357:                    attributes.remove(WebContainer.PORTAL_ID);
0358:                } catch (PortalDomainContextException pde0) {
0359:                    logger.log(Level.SEVERE, "PSFB_CSPFM1029", pde0);
0360:                    throw new PSMBeanException(
0361:                            "admin.error.configure.instance",
0362:                            getStackTrace(pde0), pde0,
0363:                            new Object[] { instanceID });
0364:                } catch (IOException ioe) {
0365:                    logger.log(Level.SEVERE, "PSFB_CSPFM1030", ioe);
0366:                    throw new PSMBeanException(
0367:                            "admin.error.configure.instance",
0368:                            getStackTrace(ioe), ioe,
0369:                            new Object[] { instanceID });
0370:                } catch (ConfigurationException ce) {
0371:                    logger.log(Level.SEVERE, "PSFB_CSPFM1030", ce);
0372:                    throw new PSMBeanException(
0373:                            "admin.error.configure.instance",
0374:                            getStackTrace(ce), ce, new Object[] { instanceID });
0375:                } finally {
0376:                    if ((fwcConfigData != null) && fwcConfigData.isFile()) {
0377:
0378:                        fwcConfigData.delete();
0379:                    }
0380:                }
0381:
0382:                try {
0383:                    setupPortletApps(sPortalID, pdc.getAttributeValue(TYPE,
0384:                            path, PortalAttributes.PORTAL_URI));
0385:                } catch (Exception e) {
0386:                    String message = "Error creating instance " + instanceID;
0387:                    logger.log(Level.SEVERE, message, e);
0388:                    throw new PSMBeanException("admin.error.create.instance",
0389:                            getStackTrace(e), new Object[] { instanceID });
0390:                }
0391:
0392:                try {
0393:
0394:                    // Create entry in the domain repository representing the instance            
0395:                    logger.log(Level.INFO, "PSFB_CSPFM1031");
0396:                    pdc.createResource(PortalServerInstanceMBean.TYPE, path,
0397:                            instanceID, attributes);
0398:
0399:                    List instancePath = AdminUtil
0400:                            .getChildPath(path, instanceID);
0401:
0402:                    pdc.createResource(AdminUtil.MONITORING_MBEAN_TYPE,
0403:                            instancePath, "Monitoring", Collections.EMPTY_MAP);
0404:
0405:                    // Reload all the MBeans to ensure that the and MBean object
0406:                    // representing the newly registered Portal Server Instance is
0407:                    // instantiated           
0408:                    logger.log(Level.INFO, "PSFB_CSPFM1032");
0409:                    PASModule.reloadMBeans(pdc, PortalServerInstanceMBean.TYPE,
0410:                            path);
0411:
0412:                } catch (Exception e) {
0413:                    if (logger.isLoggable(Level.SEVERE)) {
0414:                        LogRecord rec = new LogRecord(Level.SEVERE,
0415:                                "PSFB_CSPFM1033");
0416:                        rec.setLoggerName(logger.getName());
0417:                        rec.setParameters(new Object[] { instanceID });
0418:                        rec.setThrown(e);
0419:                        logger.log(rec);
0420:                    }
0421:                    throw new PSMBeanException("admin.error.create.instance",
0422:                            getStackTrace(e), e, new Object[] { instanceID });
0423:                }
0424:            }
0425:
0426:            private String generateID(String host, String port) {
0427:
0428:                String instanceID = "psInstance";
0429:                //Prepare the instance name from the hostname and the port
0430:                if (host != null && host.trim().length() > 0) {
0431:                    int idx = host.indexOf('.');
0432:                    if (idx > 0) {
0433:                        instanceID = host.substring(0, idx) + "-" + port;
0434:                    } else {
0435:                        instanceID = host + "-" + port;
0436:                    }
0437:                    instanceID = instanceID.replace('_', '-');
0438:                }
0439:
0440:                return instanceID;
0441:            }
0442:
0443:            /**
0444:             * The console and CLI are consumers of this method.
0445:             * Attempts to create an instance on the host attribute specified in the
0446:             * webconfig properties object passed as param.
0447:             * The webcontainer is configured, and the instance is registered,
0448:             * the wecontainer instance is restarted and the webapps are  deployed
0449:             * by this method.
0450:             */
0451:            public synchronized void createAndFinalizeInstance(
0452:                    String instanceID, Properties wcProp)
0453:                    throws PSMBeanException {
0454:
0455:                String iHost = (String) wcProp.get(InstanceAttributes.HOST);
0456:                logger.log(Level.FINEST, "PSFB_CSPFM1034", iHost);
0457:
0458:                try {
0459:                    if (iHost != null && !AdminUtil.isLocal(iHost)) {
0460:                        logger.log(Level.FINEST, "PSFB_CSPFM1035");
0461:                        ObjectName pObjectName = AdminUtil
0462:                                .getPortalMBeanObjectName(sDomainID, sPortalID);
0463:                        Object[] params = { instanceID, wcProp };
0464:                        String[] signature = { "java.lang.String",
0465:                                "java.util.Properties" };
0466:                        invokeRemoteOperation(iHost, pObjectName,
0467:                                "createAndFinalizeInstance", params, signature);
0468:                        return;
0469:                    }
0470:                } catch (Exception e) {
0471:                    throw new PSMBeanException("admin.error.create.instance",
0472:                            getStackTrace(e), new Object[] { instanceID });
0473:                }
0474:
0475:                // Check if the filesystem data exists for this portal. 
0476:                File portalConfig = new File(portalConfigDir);
0477:                // If the filesystem does not exist then a remote instance is being
0478:                // created. Create the Portal filestructure on this host by fetching
0479:                // a zip file from a host where the portal filesystem exists
0480:                if (!portalConfig.exists()) {
0481:                    logger.log(Level.FINEST, "PSFB_CSPFM1036");
0482:                    // Get the set of hosts running instances for this portal
0483:                    Set portalHosts = getHosts();
0484:                    Iterator itr = portalHosts.iterator();
0485:                    JMXConnector connector = null;
0486:                    MBeanServerConnection mbsc = null;
0487:                    // Iterate the set of hosts until able to make a successful 
0488:                    // mbean server connection to one of the hosts
0489:                    while (itr.hasNext()) {
0490:                        String host = (String) itr.next();
0491:                        try {
0492:                            logger.log(Level.FINEST, "PSFB_CSPFM1037", host);
0493:                            connector = AdminServerUtil.getJMXConnector(host);
0494:                            mbsc = connector.getMBeanServerConnection();
0495:                            break;
0496:                        } catch (Exception e) {
0497:                            logger.log(Level.SEVERE, "PSFB_CSPFM1038", e);
0498:                        }
0499:                    }
0500:
0501:                    String failMsg = "Unable to create data directory from remote host";
0502:
0503:                    // If successful in connecting to the host.
0504:                    if (mbsc != null) {
0505:                        try {
0506:                            // Invoke the method on this host to create a Zip file of
0507:                            // the portal filesystructure.
0508:                            ObjectName pObjectName = AdminUtil
0509:                                    .getPortalMBeanObjectName(sDomainID,
0510:                                            sPortalID);
0511:                            String[] signature = {};
0512:                            Object[] params = {};
0513:
0514:                            // Call the method to create a zip file of the portal data
0515:                            // on portal mbean in remote host                    
0516:                            logger.log(Level.FINEST, "PSFB_CSPFM1039");
0517:                            String zipPath = (String) mbsc.invoke(pObjectName,
0518:                                    "zipFilesystem", params, signature);
0519:                            // Name the downloaded file to <portal_id>.zip in the tmp dir
0520:                            String localPath = cc.getPSDataDir() + fs + "tmp"
0521:                                    + fs + sPortalID + ".zip";
0522:                            // Download this zip file from the remote host                    
0523:                            logger.log(Level.FINEST, "PSFB_CSPFM1040");
0524:                            AdminClientUtil.downloadFile(mbsc, sDomainID,
0525:                                    zipPath, 0, localPath);
0526:                            // Unzip the downloaded file                    
0527:                            logger.log(Level.FINEST, "PSFB_CSPFM1041");
0528:                            PortalFileHandler.unzipFilesystem(portalDir,
0529:                                    localPath);
0530:                        } catch (Exception e) {
0531:                            throw new PSMBeanException(
0532:                                    "admin.error.create.instance", failMsg,
0533:                                    new Object[] { instanceID });
0534:                        } finally {
0535:                            try {
0536:                                connector.close();
0537:                            } catch (Exception e) {
0538:                                logger.log(Level.SEVERE, "PSFB_CSPFM1042", e);
0539:                            }
0540:                        }
0541:
0542:                    } else {
0543:                        throw new PSMBeanException(
0544:                                "admin.error.create.instance", failMsg,
0545:                                new Object[] { instanceID });
0546:                    }
0547:                } else {
0548:                    logger.log(Level.FINEST, "PSFB_CSPFM1043");
0549:                    logger.log(Level.FINEST, "PSFB_CSPFM1044");
0550:                }
0551:
0552:                try {
0553:                    // If instanceID passed is null. Try to prepare an instanceID by
0554:                    // mangling the host and port values. If these are missing too bad.
0555:                    // Create instance will have to fail
0556:                    if (instanceID == null || instanceID.trim().equals("")) {
0557:                        // Get the host and port numbers from the config properties
0558:                        String host = wcProp
0559:                                .getProperty(InstanceAttributes.HOST);
0560:                        String port = wcProp
0561:                                .getProperty(InstanceAttributes.PORT);
0562:                        instanceID = generateID(host, port);
0563:                    }
0564:
0565:                    createInstance(instanceID, wcProp);
0566:                    //Get the MBean object for the newly created portal Instance
0567:                    ObjectName mBeanName = AdminUtil
0568:                            .getInstanceMBeanObjectName(sDomainID, sPortalID,
0569:                                    instanceID);
0570:                    String[] signature = {};
0571:                    Object[] params = {};
0572:
0573:                    // Get the MBean server object
0574:                    MBeanServer mbs = PASModule.getMBeanServer();
0575:                    logger.log(Level.INFO, "PSFB_CSPFM1045", mBeanName);
0576:                    mbs.invoke(mBeanName, "restart", params, signature);
0577:
0578:                    JMXConnector connector1 = AdminServerUtil
0579:                            .getJMXConnector(wcProp
0580:                                    .getProperty(InstanceAttributes.HOST));
0581:                    MBeanServerConnection s = connector1
0582:                            .getMBeanServerConnection();
0583:
0584:                    logger.log(Level.INFO, "PSFB_CSPFM1046", mBeanName);
0585:                    s.invoke(mBeanName, "deployAll", params, signature);
0586:                    connector1.close();
0587:
0588:                } catch (Exception e) {
0589:                    if (logger.isLoggable(Level.SEVERE)) {
0590:                        LogRecord rec = new LogRecord(Level.SEVERE,
0591:                                "PSFB_CSPFM1047");
0592:                        rec.setLoggerName(logger.getName());
0593:                        rec.setParameters(new Object[] { instanceID });
0594:                        rec.setThrown(e);
0595:                        logger.log(rec);
0596:                    }
0597:                    throw new PSMBeanException("admin.error.create.instance",
0598:                            getStackTrace(e), new Object[] { instanceID });
0599:                }
0600:
0601:            }
0602:
0603:            public synchronized void deleteInstance(String instanceID)
0604:                    throws PSMBeanException {
0605:
0606:                try {
0607:                    // Reload all the MBeans to ensure that the and MBean object
0608:                    // representing the newly registered Portal Server Instance is
0609:                    // instantiated            
0610:                    logger.log(Level.INFO, "PSFB_CSPFM1048");
0611:                    PASModule.reloadMBeans(pdc, PortalServerInstanceMBean.TYPE,
0612:                            path);
0613:
0614:                    // Get the MBean server object
0615:                    MBeanServer mbs = PASModule.getMBeanServer();
0616:
0617:                    ObjectName iObjectName = AdminUtil
0618:                            .getInstanceMBeanObjectName(sDomainID, sPortalID,
0619:                                    instanceID);
0620:                    String host = (String) mbs.getAttribute(iObjectName,
0621:                            InstanceAttributes.HOST);
0622:
0623:                    if (host != null && !AdminUtil.isLocal(host)) {
0624:                        ObjectName pObjectName = AdminUtil
0625:                                .getPortalMBeanObjectName(sDomainID, sPortalID);
0626:                        Object[] params = { instanceID };
0627:                        String[] signature = { "java.lang.String" };
0628:                        invokeRemoteOperation(host, pObjectName,
0629:                                "deleteInstance", params, signature);
0630:                        return;
0631:                    }
0632:
0633:                    // Invoke the deploy operation on the newly created Portal Instance            
0634:                    logger.log(Level.INFO, "PSFB_CSPFM1049", iObjectName);
0635:                    String[] signature = {};
0636:                    Object[] params = {};
0637:                    mbs.invoke(iObjectName, "undeployAll", params, signature);
0638:                } catch (MBeanException me) {
0639:                    logger.log(Level.SEVERE, "PSFB_CSPFM1050", me);
0640:                    throw (PSMBeanException) me.getTargetException();
0641:                } catch (Exception e) {
0642:                    if (logger.isLoggable(Level.SEVERE)) {
0643:                        LogRecord rec = new LogRecord(Level.SEVERE,
0644:                                "PSFB_CSPFM1051");
0645:                        rec.setLoggerName(logger.getName());
0646:                        rec.setParameters(new Object[] { instanceID });
0647:                        rec.setThrown(e);
0648:                        logger.log(rec);
0649:                    }
0650:                }
0651:
0652:                Map wcInfoMap = new HashMap(WebContainer.wcAttrKeys.length);
0653:                try {
0654:                    // Get the webcontainer attributes from PDC and set into Map
0655:                    for (int i = 0; i < WebContainer.wcAttrKeys.length; i++) {
0656:                        String attrVal = "";
0657:                        String attrKey = WebContainer.wcAttrKeys[i];
0658:                        try {
0659:                            attrVal = pdc.getAttributeValue(
0660:                                    PortalServerInstanceMBean.TYPE, AdminUtil
0661:                                            .getChildPath(path, instanceID),
0662:                                    attrKey);
0663:                        } catch (PortalDomainContextException pde) {
0664:                            // Ignore it. Attr may not exist
0665:                        }
0666:
0667:                        if (attrVal != null && attrVal.length() > 0) {
0668:                            wcInfoMap.put(attrKey, attrVal);
0669:                        }
0670:                    }
0671:
0672:                    // setting domainid, portalid, instanceid before creating webcontainer object
0673:                    wcInfoMap.put(InstanceAttributes.NAME, instanceID);
0674:                    wcInfoMap.put(WebContainer.DOMAIN_ID, sDomainID);
0675:                    wcInfoMap.put(WebContainer.PORTAL_ID, sPortalID);
0676:
0677:                    File fwcConfigData = null;
0678:                    try {
0679:                        // delete the instance of webcontainer
0680:                        WebContainer wc = WebContainerFactory.getWebContainer(
0681:                                wcInfoMap, false);
0682:                        if (!wc.isPortalConfigured()) {
0683:                            // Fix for CR6405934: The delete instance
0684:                            // operation should continue to clean up as much
0685:                            // as possible even if the web container instance
0686:                            // is not configured for any portal server instance.
0687:                            //ResourceBundle resourceBundle = logger.getLogger(PortalLogManager.DEBUG_ROOT_LOGGER).getResourceBundle();
0688:                            //String msg = resourceBundle.getString("PSFB_CSPFM1024");
0689:                            //java.text.MessageFormat form = new java.text.MessageFormat(msg);
0690:                            //msg = form.format(new String[] { wc.getWebContainerType(),
0691:                            //                                 wc.getPrintableWebContainerInstanceName() });
0692:                            //XMLJdomFileCreationException e1 = new XMLJdomFileCreationException(msg);
0693:                            //throw new PSMBeanException("admin.error.delete.instance", msg, e1);
0694:                            logger
0695:                                    .log(
0696:                                            Level.SEVERE,
0697:                                            "PSFB_CSPFM1024",
0698:                                            new String[] {
0699:                                                    wc.getWebContainerType(),
0700:                                                    wc
0701:                                                            .getPrintableWebContainerInstanceName() });
0702:                        }
0703:
0704:                        // Read the Web Container Config Data from the PAS and store it in a file
0705:                        // <install_loc>/SUNWportal/portals/<portal_id>/config/WebContainerConfigData.xml
0706:                        String swcConfigDataR = null;
0707:                        try {
0708:                            swcConfigDataR = pdc.getAttributeValue(
0709:                                    PortalMBean.TYPE, path,
0710:                                    PortalAttributes.WEB_CONTAINER_CONFIG_DATA);
0711:                        } catch (PortalDomainContextException pde) {
0712:                            // Ignore it. The attribute may not exist.
0713:                            swcConfigDataR = null;
0714:                        }
0715:
0716:                        logger.log(Level.INFO, "PSFB_CSPFM1020",
0717:                                new String[] {
0718:                                        "deleteInstance",
0719:                                        (swcConfigDataR == null) ? ""
0720:                                                : swcConfigDataR });
0721:
0722:                        if ((swcConfigDataR == null)
0723:                                || swcConfigDataR.trim().equals("")) {
0724:                            // This should not be the case. Period.
0725:                            ResourceBundle resourceBundle = logger.getLogger(
0726:                                    PortalLogManager.DEBUG_ROOT_LOGGER)
0727:                                    .getResourceBundle();
0728:                            String msg = resourceBundle
0729:                                    .getString("PSFB_CSPFM1025");
0730:                            XMLJdomFileCreationException e1 = new XMLJdomFileCreationException(
0731:                                    msg);
0732:                            throw new PSMBeanException(
0733:                                    "admin.error.configure.instance", msg, e1);
0734:                        }
0735:
0736:                        String swcConfigDataFile = portalConfigDir + fs
0737:                                + "WebContainerConfigData.xml";
0738:                        fwcConfigData = new File(swcConfigDataFile);
0739:                        if (fwcConfigData.exists()) {
0740:
0741:                            fwcConfigData.delete();
0742:                        }
0743:
0744:                        FileWriter fw = new FileWriter(fwcConfigData);
0745:                        fw.write(swcConfigDataR);
0746:                        fw.close();
0747:
0748:                        // Invoke unconfigure method
0749:                        wc.unconfigure(cc);
0750:                    } catch (ConfigurationException ce) {
0751:                        throw new PSMBeanException(
0752:                                "admin.error.delete.instance",
0753:                                getStackTrace(ce), ce);
0754:                    }
0755:
0756:                    // TODO - If this is the last instance on this host then the 
0757:                    // filesystem should be cleanedup for this portal
0758:
0759:                    // Remove the instance from the portal domain context
0760:                    pdc.removeResource(PortalServerInstanceMBean.TYPE,
0761:                            AdminUtil.getChildPath(path, instanceID));
0762:
0763:                    PASModule.reloadMBeans(pdc, PortalServerInstanceMBean.TYPE,
0764:                            path);
0765:                } catch (Exception e) {
0766:                    if (logger.isLoggable(Level.SEVERE)) {
0767:                        LogRecord rec = new LogRecord(Level.SEVERE,
0768:                                "PSFB_CSPFM1051");
0769:                        rec.setLoggerName(logger.getName());
0770:                        rec.setParameters(new Object[] { instanceID });
0771:                        rec.setThrown(e);
0772:                        logger.log(rec);
0773:                    }
0774:                    throw new PSMBeanException("admin.error.delete.instance",
0775:                            getStackTrace(e), new Object[] { instanceID });
0776:                }
0777:            }
0778:
0779:            public Boolean configureInstances(String confDir)
0780:                    throws PSMBeanException {
0781:
0782:                // TODO - Store the instance container configuration in the PAS
0783:
0784:                Boolean retVal = new Boolean(true);
0785:                // Calling PortalServerInstance configureContainer() for all instances
0786:                Iterator instances = getInstances().iterator();
0787:                while (instances.hasNext()) {
0788:                    String instanceID = (String) instances.next();
0789:                    try {
0790:                        // Get the MBean server object
0791:                        MBeanServer mbs = PASModule.getMBeanServer();
0792:                        // Access the PortalServerInstance Mbean
0793:                        ObjectName mBeanName = AdminUtil
0794:                                .getInstanceMBeanObjectName(sDomainID,
0795:                                        sPortalID, instanceID);
0796:
0797:                        // Invoke the configureContainer method on the
0798:                        // PortalServerInstance Mbean
0799:                        Object[] params = new Object[] { confDir, instanceID };
0800:                        String[] signature = new String[] { "java.lang.String",
0801:                                "java.lang.String" };
0802:                        Boolean instRetVal = (Boolean) mbs.invoke(mBeanName,
0803:                                "configureContainer", params, signature);
0804:
0805:                        //If configuration of any of the instances fail
0806:                        //log the failure, continue with the configuration of other
0807:                        //instances. Finally return failure condition
0808:                        if (instRetVal == null || !instRetVal.booleanValue()) {
0809:                            logger.log(Level.SEVERE, "PSFB_CSPFM1052",
0810:                                    mBeanName);
0811:                            retVal = new Boolean(false);
0812:                        }
0813:                    } catch (Exception e) {
0814:                        if (logger.isLoggable(Level.SEVERE)) {
0815:                            LogRecord rec = new LogRecord(Level.SEVERE,
0816:                                    "PSFB_CSPFM1051");
0817:                            rec.setLoggerName(logger.getName());
0818:                            rec.setParameters(new Object[] { instanceID });
0819:                            rec.setThrown(e);
0820:                            logger.log(rec);
0821:                        }
0822:                    }
0823:                }
0824:                return retVal;
0825:            }
0826:
0827:            /**
0828:             * Deploy all the portal web applications to the web container
0829:             *
0830:             * @param instance Instance id. If specified, only deploy to this
0831:             * instance
0832:             */
0833:            public void deployAllWebApps(String instance)
0834:                    throws PSMBeanException {
0835:                String instanceID = null;
0836:                if (instance != null && instance.length() > 0) {
0837:                    instanceID = instance;
0838:                    doDeployAll(instanceID);
0839:                } else {
0840:                    Iterator instances = getInstances().iterator();
0841:                    while (instances.hasNext()) {
0842:                        instanceID = (String) instances.next();
0843:                        doDeployAll(instanceID);
0844:                    }
0845:                }
0846:            }
0847:
0848:            /**
0849:             * Calls PortalServerInstanceMBean.deployAll() to deploy all web 
0850:             * applications for the instance.
0851:             */
0852:            private void doDeployAll(String instanceID) throws PSMBeanException {
0853:                try {
0854:                    // Get the MBean server object
0855:                    MBeanServer mbs = PASModule.getMBeanServer();
0856:                    // Access the PortalServerInstance Mbean
0857:                    ObjectName mBeanName = AdminUtil
0858:                            .getResourceMBeanObjectName(
0859:                                    PortalServerInstanceMBean.TYPE, AdminUtil
0860:                                            .getChildPath(path, instanceID));
0861:
0862:                    // Invoke the deployAll method on instance
0863:                    Object[] params = new Object[] {};
0864:                    String[] signature = new String[] {};
0865:                    mbs.invoke(mBeanName, "deployAll", params, signature);
0866:                } catch (Exception e) {
0867:                    if (logger.isLoggable(Level.SEVERE)) {
0868:                        LogRecord rec = new LogRecord(Level.SEVERE,
0869:                                "PSFB_CSPFM1053");
0870:                        rec.setLoggerName(logger.getName());
0871:                        rec.setParameters(new Object[] { instanceID });
0872:                        rec.setThrown(e);
0873:                        logger.log(rec);
0874:                    }
0875:                    throw new PSMBeanException("admin.error.deploy.all",
0876:                            getStackTrace(e), new Object[] { instanceID });
0877:                }
0878:            }
0879:
0880:            /**
0881:             * Uneploy all the portal web applications to the web container
0882:             *
0883:             * @param instance Instance id. If specified, only undeploy from this
0884:             * instance
0885:             */
0886:            public void undeployAllWebApps(String instance)
0887:                    throws PSMBeanException {
0888:                String instanceID = null;
0889:                if (instance != null && instance.length() > 0) {
0890:                    instanceID = instance;
0891:                    logger.log(Level.INFO,
0892:                            "Portal.undeployAllWebApps(), deploy single instance:"
0893:                                    + instanceID);
0894:                    doUndeployAll(instanceID);
0895:                } else {
0896:                    Iterator instances = getInstances().iterator();
0897:                    while (instances.hasNext()) {
0898:                        instanceID = (String) instances.next();
0899:                        logger.log(Level.INFO,
0900:                                "Portal.undeployAllWebApps(), instance:"
0901:                                        + instanceID);
0902:                        doUndeployAll(instanceID);
0903:                    }
0904:                }
0905:            }
0906:
0907:            public void doUndeployAll(String instanceID)
0908:                    throws PSMBeanException {
0909:                try {
0910:                    // Get the MBean server object
0911:                    MBeanServer mbs = PASModule.getMBeanServer();
0912:                    // Access the PortalServerInstance Mbean
0913:                    ObjectName mBeanName = AdminUtil
0914:                            .getResourceMBeanObjectName(
0915:                                    PortalServerInstanceMBean.TYPE, AdminUtil
0916:                                            .getChildPath(path, instanceID));
0917:
0918:                    // Invoke the undeployAll method on instance
0919:                    Object[] params = new Object[] {};
0920:                    String[] signature = new String[] {};
0921:                    mbs.invoke(mBeanName, "undeployAll", params, signature);
0922:                } catch (Exception e) {
0923:                    if (logger.isLoggable(Level.SEVERE)) {
0924:                        LogRecord rec = new LogRecord(Level.SEVERE,
0925:                                "PSFB_CSPFM1054");
0926:                        rec.setLoggerName(logger.getName());
0927:                        rec.setParameters(new Object[] { instanceID });
0928:                        rec.setThrown(e);
0929:                        logger.log(rec);
0930:                    }
0931:                    throw new PSMBeanException("admin.error.undeploy.all",
0932:                            getStackTrace(e), new Object[] { instanceID });
0933:                }
0934:            }
0935:
0936:            public void deployPortalWebApp() throws PSMBeanException {
0937:                Iterator instances = getInstances().iterator();
0938:                String instanceID = null;
0939:
0940:                while (instances.hasNext()) {
0941:                    try {
0942:                        instanceID = (String) instances.next();
0943:                        List instancePath = AdminUtil.getChildPath(path,
0944:                                instanceID);
0945:                        String host = pdc.getAttributeValue(
0946:                                PortalServerInstanceMBean.TYPE, instancePath,
0947:                                InstanceAttributes.HOST);
0948:                        //Create portal war 
0949:                        if (AdminUtil.isLocal(host)) {
0950:                            createPortalWebApp();
0951:                        } else {
0952:                            ObjectName iObjName = AdminUtil
0953:                                    .getResourceMBeanObjectName(TYPE, path);
0954:                            invokeRemoteOperation(host, iObjName,
0955:                                    "createPortalWebApp", new Object[] {},
0956:                                    new String[] {});
0957:
0958:                        }
0959:
0960:                        // Get the MBean server object
0961:                        MBeanServer mbs = PASModule.getMBeanServer();
0962:                        // Access the PortalServerInstance Mbean
0963:                        ObjectName mBeanName = AdminUtil
0964:                                .getResourceMBeanObjectName(
0965:                                        PortalServerInstanceMBean.TYPE,
0966:                                        AdminUtil
0967:                                                .getChildPath(path, instanceID));
0968:
0969:                        String portalUri = pdc.getAttributeValue(TYPE, path,
0970:                                PortalAttributes.PORTAL_URI);
0971:                        // Invoke the undeployAll method on instance
0972:                        Object[] params = new Object[] { portalUri };
0973:                        String[] signature = new String[] { "java.lang.String" };
0974:                        mbs.invoke(mBeanName, "deploy", params, signature);
0975:                    } catch (MBeanException me) {
0976:                        if (logger.isLoggable(Level.SEVERE)) {
0977:                            LogRecord rec = new LogRecord(Level.SEVERE,
0978:                                    "PSFB_CSPFM1107");
0979:                            rec.setLoggerName(logger.getName());
0980:                            rec.setParameters(new Object[] { instanceID });
0981:                            rec.setThrown(me);
0982:                            logger.log(rec);
0983:                        }
0984:                        throw (PSMBeanException) me.getTargetException();
0985:                    } catch (Exception e) {
0986:                        if (logger.isLoggable(Level.SEVERE)) {
0987:                            LogRecord rec = new LogRecord(Level.SEVERE,
0988:                                    "PSFB_CSPFM1055");
0989:                            rec.setLoggerName(logger.getName());
0990:                            rec.setParameters(new Object[] { instanceID });
0991:                            rec.setThrown(e);
0992:                            logger.log(rec);
0993:                        }
0994:                        throw new PSMBeanException("admin.error.deploy.portal",
0995:                                getStackTrace(e), new Object[] { instanceID });
0996:                    }
0997:                }
0998:            }
0999:
1000:            public void undeployPortalWebApp() throws PSMBeanException {
1001:                Iterator instances = getInstances().iterator();
1002:                while (instances.hasNext()) {
1003:                    String instanceID = (String) instances.next();
1004:                    try {
1005:                        // Get the MBean server object
1006:                        MBeanServer mbs = PASModule.getMBeanServer();
1007:                        // Access the PortalServerInstance Mbean
1008:                        ObjectName mBeanName = AdminUtil
1009:                                .getResourceMBeanObjectName(
1010:                                        PortalServerInstanceMBean.TYPE,
1011:                                        AdminUtil
1012:                                                .getChildPath(path, instanceID));
1013:
1014:                        String portalUri = pdc.getAttributeValue(TYPE, path,
1015:                                PortalAttributes.PORTAL_URI);
1016:
1017:                        // Invoke the undeployAll method on instance
1018:                        Object[] params = new Object[] { portalUri };
1019:                        String[] signature = new String[] { "java.lang.String" };
1020:                        mbs.invoke(mBeanName, "undeploy", params, signature);
1021:                    } catch (MBeanException me) {
1022:                        if (logger.isLoggable(Level.SEVERE)) {
1023:                            LogRecord rec = new LogRecord(Level.SEVERE,
1024:                                    "PSFB_CSPFM1110");
1025:                            rec.setLoggerName(logger.getName());
1026:                            rec.setParameters(new Object[] { instanceID });
1027:                            rec.setThrown(me);
1028:                            logger.log(rec);
1029:                        }
1030:                        throw (PSMBeanException) me.getTargetException();
1031:                    } catch (Exception e) {
1032:                        if (logger.isLoggable(Level.SEVERE)) {
1033:                            LogRecord rec = new LogRecord(Level.SEVERE,
1034:                                    "PSFB_CSPFM1056");
1035:                            rec.setLoggerName(logger.getName());
1036:                            rec.setParameters(new Object[] { instanceID });
1037:                            rec.setThrown(e);
1038:                            logger.log(rec);
1039:                        }
1040:                        throw new PSMBeanException(
1041:                                "admin.error.undeploy.portal",
1042:                                getStackTrace(e), new Object[] { instanceID });
1043:                    }
1044:                }
1045:            }
1046:
1047:            public List getAttribute(Map optionsMap) throws PSMBeanException {
1048:                List values = null;
1049:                String compName = (String) optionsMap
1050:                        .get(AttrOptionConstants.OPT_COMPONENT);
1051:                logger.log(Level.FINEST, "PSFB_CSPFM1057", compName);
1052:                AttributeHandler handler = AttributeHandlerFactory
1053:                        .getComponentAttrHandler(compName,
1054:                                getPSConfigContext(), sDomainID, sPortalID);
1055:                handler.validate(null, optionsMap);
1056:                values = handler.getAttribute(optionsMap);
1057:                return values;
1058:            }
1059:
1060:            public Map getAttributes(Map optionsMap) throws PSMBeanException {
1061:                Map values = null;
1062:                String compName = (String) optionsMap
1063:                        .get(AttrOptionConstants.OPT_COMPONENT);
1064:                logger.log(Level.FINEST, "PSFB_CSPFM1058", compName);
1065:                AttributeHandler handler = AttributeHandlerFactory
1066:                        .getComponentAttrHandler(compName,
1067:                                getPSConfigContext(), sDomainID, sPortalID);
1068:                handler.validate(null, optionsMap);
1069:                values = handler.getAttributes(optionsMap);
1070:                return values;
1071:            }
1072:
1073:            public synchronized void setAttribute(List values, Map optionsMap)
1074:                    throws PSMBeanException {
1075:                String compName = (String) optionsMap
1076:                        .get(AttrOptionConstants.OPT_COMPONENT);
1077:                logger.log(Level.FINEST, "PSFB_CSPFM1059", compName);
1078:                AttributeHandler handler = AttributeHandlerFactory
1079:                        .getComponentAttrHandler(compName,
1080:                                getPSConfigContext(), sDomainID, sPortalID);
1081:                handler.validate(values, optionsMap);
1082:                handler.setAttribute(values, optionsMap);
1083:            }
1084:
1085:            public synchronized void setAttributes(Map nameValues,
1086:                    Map optionsMap) throws PSMBeanException {
1087:                String compName = (String) optionsMap
1088:                        .get(AttrOptionConstants.OPT_COMPONENT);
1089:                logger.log(Level.FINEST, "PSFB_CSPFM1060", compName);
1090:                AttributeHandler handler = AttributeHandlerFactory
1091:                        .getComponentAttrHandler(compName,
1092:                                getPSConfigContext(), sDomainID, sPortalID);
1093:                handler.validate(null, optionsMap);
1094:                handler.setAttributes(nameValues, optionsMap);
1095:            }
1096:
1097:            public Map listAttributes(Map optionsMap) throws PSMBeanException {
1098:                Map values = null;
1099:                String compName = (String) optionsMap
1100:                        .get(AttrOptionConstants.OPT_COMPONENT);
1101:                logger.log(Level.FINEST, "PSFB_CSPFM1061", compName);
1102:                AttributeHandler handler = AttributeHandlerFactory
1103:                        .getComponentAttrHandler(compName,
1104:                                getPSConfigContext(), sDomainID, sPortalID);
1105:                handler.validate(null, optionsMap);
1106:                values = handler.listAttributes(optionsMap);
1107:                return values;
1108:            }
1109:
1110:            private void setupPortletApps(String portalID,
1111:                    String portalWebAppURI) throws Exception {
1112:                String srcDirName = cc.getPSBaseDir() + fs + "portletapps";
1113:                String destDirName = cc.getPSDataDir() + fs + "portals" + fs
1114:                        + portalID + fs + "portletapps";
1115:                if (FileUtil.copyDir(srcDirName, destDirName)) {
1116:                    File inputProperties = new File(destDirName + fs
1117:                            + "input.properties");
1118:                    FileUtil.replaceTokenInFile(inputProperties, "%PORTAL_ID%",
1119:                            portalID);
1120:                    FileUtil.replaceTokenInFile(inputProperties,
1121:                            "%PORTAL_WEBAPP_URI%", portalWebAppURI);
1122:                    FileUtil.replaceTokenInFile(inputProperties,
1123:                            "%PS_CONFIG_LOCATION%", cc.getPSConfigDir());
1124:                    FileUtil.replaceTokenInFile(inputProperties,
1125:                            "%AM_ADMIN_DN%", cc.getAdminUserDN());
1126:
1127:                    File destDir = new File(destDirName);
1128:                    File[] files = destDir.listFiles();
1129:                    if (files.length > 0) {
1130:                        File derbyProperties = new File(cc.getPSDataDir() + fs
1131:                                + "derby" + fs + "derby.properties");
1132:                        String derbyPort = FileUtil.extractPatternTillEOL(
1133:                                derbyProperties, "derby.drda.portNumber", "=");
1134:                        String derbyHost = FileUtil.extractPatternTillEOL(
1135:                                derbyProperties, "derby.drda.host", "=");
1136:
1137:                        for (int i = 0; i < files.length; i++) {
1138:                            File file = (File) files[i];
1139:                            if (file.isDirectory()) {
1140:                                File tokenProperties = new File(file
1141:                                        .getAbsolutePath()
1142:                                        + fs + "tokens.properties");
1143:                                FileUtil.replaceTokenInFile(tokenProperties,
1144:                                        "%DERBY_LIB_DIR%", cc.getDerbyLibDir());
1145:                                FileUtil.replaceTokenInFile(tokenProperties,
1146:                                        "%DERBY_HOST%", derbyHost);
1147:                                FileUtil.replaceTokenInFile(tokenProperties,
1148:                                        "%DERBY_PORT%", derbyPort);
1149:                                FileUtil.replaceTokenInFile(tokenProperties,
1150:                                        "%PORTAL_ID%", portalID);
1151:                                FileUtil.replaceTokenInFile(tokenProperties,
1152:                                        "%PORTAL_DATA_DIR%", cc.getPSDataDir());
1153:                            }
1154:                        }
1155:                    }
1156:                }
1157:            }
1158:
1159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.