Source Code Cross Referenced for ConfigurePortal.java in  » Portal » Open-Portal » com » sun » portal » fabric » config » 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.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: ConfigurePortal.java,v 1.72.2.4 2007/04/18 09:17:33 ns208321 Exp $
003:         * Copyright 2004 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.fabric.config;
014:
015:        import java.util.LinkedList;
016:        import java.util.List;
017:        import java.util.Map;
018:        import java.util.Properties;
019:        import java.util.logging.Level;
020:        import java.util.logging.Logger;
021:        import java.util.logging.LogRecord;
022:
023:        import java.io.File;
024:        import java.io.IOException;
025:        import java.io.FileNotFoundException;
026:        import java.io.BufferedReader;
027:        import java.io.InputStream;
028:        import java.io.OutputStream;
029:        import java.io.PrintWriter;
030:        import java.io.StringWriter;
031:        import java.io.FileOutputStream;
032:        import java.io.InputStreamReader;
033:
034:        import java.lang.reflect.Method;
035:
036:        import java.net.URL;
037:        import java.net.URLClassLoader;
038:
039:        import javax.management.InstanceNotFoundException;
040:        import javax.management.MBeanException;
041:        import javax.management.MBeanServerConnection;
042:        import javax.management.ObjectName;
043:
044:        import com.sun.portal.admin.common.PSConfigConstants;
045:        import com.sun.portal.admin.common.PSMBeanException;
046:        import com.sun.portal.admin.common.context.PSConfigContext;
047:        import com.sun.portal.admin.common.util.AdminClientUtil;
048:        import com.sun.portal.util.Platform;
049:        import com.sun.portal.fabric.util.LogConfigUtil;
050:        import com.sun.portal.fabric.util.os.OSTasks;
051:        import com.sun.portal.fabric.util.os.OSTasksFactory;
052:        import com.sun.portal.fabric.tasks.ConfigurationException;
053:        import com.sun.portal.log.common.PortalLogger;
054:
055:        public class ConfigurePortal {
056:
057:            private static PortalConfigData pci = null;
058:            private static PortalConfigurator pc = null;
059:            private static List components = null;
060:            private static Logger configLogger = null;
061:            private static final char SEPARATOR = '/';
062:            private static Properties psConfigProps = new Properties();
063:            private static MBeanServerConnection msc;
064:            private static OSTasks osTasks = null;
065:
066:            public static void main(String[] args) {
067:                try {
068:                    //??configLogger = PortalLogger.getLogger(ConfigurePortal.class);
069:
070:                    // Initialize error code to success
071:                    int exitCode = 1;
072:                    boolean newPortal = true;
073:                    if (args == null || args.length < 1) {
074:                        System.err
075:                                .println("Configuration Failed : Missing arguments. Please provide the config XML file location.");
076:                        //??configLogger.log(Level.SEVERE, "PSFB_CSPFC0306");
077:                        // Exit current VM with error
078:                        System.exit(exitCode);
079:                    }
080:
081:                    try {
082:                        pci = new PortalConfigData(args[0]);
083:                    } catch (Exception e) {
084:                        System.err.println("Configuration Failed : "
085:                                + e.getMessage());
086:
087:                        /*??if (configLogger.isLoggable(Level.SEVERE)) {
088:                            LogRecord record = new LogRecord(Level.SEVERE, "PSFB_CSPFC0307");
089:                            record.setParameters(new String[] { e.getMessage() });
090:                            record.setThrown(e);
091:                            record.setLoggerName(configLogger.getName());
092:                            configLogger.log(record);
093:                        }??*/
094:
095:                        // Exit current VM with error
096:                        System.exit(exitCode);
097:                    }
098:                    String psconfigMode = pci.getPSConfigMode();
099:
100:                    if (psconfigMode != null
101:                            && psconfigMode.equals("Configure")) {
102:
103:                        // Set the list of components to be configured
104:                        components = pci.getPSComponentsToConfigure();
105:
106:                        // Passwords/UIDs/Host Name
107:                        String sAMAdminUID = pci.getAMAdmin();
108:                        String sAMAdminPassword = pci.getAMAdminPassword();
109:                        String sConfigHostName = pci.getConfigHostName();
110:
111:                        configLogger = PortalLogger
112:                                .getLogger(ConfigurePortal.class);
113:                        System.out.println("Logs redirected to "
114:                                + pci.getPSDataDir()
115:                                + "/logs/config/portal.fabric.0.0.log");
116:                        try {
117:
118:                            // Create the PSConfig file thats needed for bootstrapping the
119:                            // configurator
120:                            createPSConfigFile(pci);
121:
122:                            // Now setup the classpath for the configurator to load all its
123:                            // dependencies
124:                            setClassPath();
125:
126:                            // Create Portal Directories
127:                            PortalConfigurator.createPortalDirectories(pci);
128:
129:                            // Create Property Files
130:                            PortalConfigurator.preparePropertyFiles(pci);
131:                            pc = new PortalConfigurator();
132:
133:                            // Validate config XML File
134:                            if (pci.isValidateData().equals("true")
135:                                    || pci.isValidateData().equals("1")) {
136:                                System.out
137:                                        .println("Validating the Input Config XML File");
138:                                configLogger.log(Level.INFO, "PSFB_CSPFC0048");
139:                                new ValidatePortalInputData(pci);
140:                            }
141:
142:                            Map searchServerDetails = null;
143:                            Map portalServerData = null;
144:
145:                            if (components.contains("portalserver")) {
146:                                searchServerDetails = pci
147:                                        .getSearchServerDetails();
148:                                configLogger.log(Level.INFO,
149:                                        "Validating Search Server Data");
150:                                pc.validateSearchData(searchServerDetails);
151:
152:                                portalServerData = pci.getPortalServerData();
153:                                configLogger
154:                                        .log(Level.INFO,
155:                                                "Validating Portal Server WebContainer Data");
156:                                pc.validateWebContainerData(portalServerData);
157:                            }
158:
159:                            pc.updatePSConfigFile(psConfigProps, pci);
160:
161:                            // call the preconfig task
162:                            OSTasksFactory osTasksFactory = OSTasksFactory
163:                                    .getInstance();
164:
165:                            // Get the PSConfigContext
166:                            PSConfigContext pcc = pc.getPSConfigContext();
167:                            osTasks = osTasksFactory.getOSTasks(pcc);
168:                            osTasks.preconfig();
169:
170:                            configLogger.log(Level.INFO, "PSFB_CSPFC0002");
171:                            System.out
172:                                    .println("Configuring Cacao Agent for Portal Software");
173:                            pc.configureHost(pci);
174:
175:                            // Creation and Starting of derby server instance
176:                            pc.configDerby(pcc, sConfigHostName);
177:
178:                            if (components.contains("portalserver")) {
179:
180:                                System.out
181:                                        .println("Connecting to Cacao MBean Server");
182:                                configLogger.log(Level.INFO, "PSFB_CSPFC0004");
183:                                msc = pc.getMbeanServerConnection(sAMAdminUID,
184:                                        sAMAdminPassword, sConfigHostName);
185:
186:                                SearchServerConfigurationThread ssConfThread = null;
187:                                if (!pci.getSearchServerDetails().isEmpty()) {
188:
189:                                    ssConfThread = new SearchServerConfigurationThread(
190:                                            msc);
191:                                    ssConfThread.start();
192:                                }
193:
194:                                if (portalServerData != null) {
195:
196:                                    System.out.println("Creating Portals");
197:                                    newPortal = pc.configurePortal(msc,
198:                                            portalServerData);
199:                                }
200:
201:                                if (ssConfThread != null) {
202:
203:                                    ssConfThread.join();
204:
205:                                    Exception searchException = ssConfThread
206:                                            .getException();
207:                                    if (searchException != null) {
208:
209:                                        throw searchException;
210:                                    }
211:                                }
212:                                if (newPortal) {
213:                                    msc = pc.getMbeanServerConnection(
214:                                            sAMAdminUID, sAMAdminPassword,
215:                                            sConfigHostName);
216:                                    System.out.println("Configuring Samples");
217:                                    pc.configureSamplePortal(msc, pci
218:                                            .getSamplePortalData(), pcc,
219:                                            sAMAdminPassword, pci
220:                                                    .getLDAPUserPassword(),
221:                                            sConfigHostName, portalServerData);
222:                                } else {
223:                                    configLogger
224:                                            .log(Level.INFO,
225:                                                    "Creating an instance only. So not configuring Sample Portals");
226:                                }
227:                                System.out
228:                                        .println("Performing Post Configuration Tasks");
229:                                configLogger.log(Level.INFO, "PSFB_CSPFC0073");
230:                                pc.postConfigurationTasks(pcc,
231:                                        sAMAdminPassword, sConfigHostName);
232:
233:                                configLogger.log(Level.INFO, "PSFB_CSPFC0227");
234:                                pc.closeMbeanServerConnection();
235:                                configLogger.log(Level.INFO, "PSFB_CSPFC0015");
236:
237:                                if (newPortal) {
238:                                    // SRA Core
239:                                    try {
240:
241:                                        // Get the MBean Server connection
242:                                        msc = pc.getMbeanServerConnection(
243:                                                sAMAdminUID, sAMAdminPassword,
244:                                                sConfigHostName);
245:
246:                                        pc.configureSRA(msc, pci, pcc);
247:
248:                                        System.out
249:                                                .println("Connecting to Cacao MBean Server");
250:
251:                                        //Load SRA RewriterRuleSets
252:                                        System.out
253:                                                .println("Configuring SRA core");
254:                                        configLogger.log(Level.INFO,
255:                                                "PSFB_CSPFC0203");
256:                                        pc.loadSRARewriterRulseSet(msc, pcc);
257:                                        configLogger.log(Level.INFO,
258:                                                "PSFB_CSPFC0204");
259:
260:                                        System.out
261:                                                .println("Closing the MBean Server Connection");
262:                                        configLogger.log(Level.INFO,
263:                                                "PSFB_CSPFC0227");
264:                                        pc.closeMbeanServerConnection();
265:                                        configLogger.log(Level.INFO,
266:                                                "PSFB_CSPFC0015");
267:                                    } catch (ConfigurationException e) {
268:                                        // Log the excetion
269:                                        configLogger.log(Level.SEVERE,
270:                                                "PSFB_CSPFC0198");
271:                                    }
272:                                } else {
273:                                    configLogger
274:                                            .log(Level.INFO,
275:                                                    "Creating an instance only. So not configuring SRA core.");
276:                                }
277:                            }
278:
279:                            msc = null;
280:                            if (components.contains("gateway")
281:                                    || components.contains("netletproxy")
282:                                    || components.contains("rewriterproxy")) {
283:
284:                                // Get the MBean Server connection
285:                                System.out
286:                                        .println("Connecting to Cacao MBean Server");
287:                                configLogger.log(Level.INFO, "PSFB_CSPFC0004");
288:                                msc = pc.getMbeanServerConnection(sAMAdminUID,
289:                                        sAMAdminPassword, sConfigHostName);
290:                            }
291:
292:                            SRAInstanceConfigurationThread gwConfigThread = null;
293:                            if (components.contains("gateway")) {
294:
295:                                gwConfigThread = new SRAInstanceConfigurationThread(
296:                                        "configureGateway", "Gateway", msc);
297:                                gwConfigThread.start();
298:                            }
299:
300:                            SRAInstanceConfigurationThread nlpConfigThread = null;
301:                            if (components.contains("netletproxy")) {
302:
303:                                nlpConfigThread = new SRAInstanceConfigurationThread(
304:                                        "configureNetletProxy", "NetletProxy",
305:                                        msc);
306:                                nlpConfigThread.start();
307:                            }
308:
309:                            SRAInstanceConfigurationThread rwpConfigThread = null;
310:                            if (components.contains("rewriterproxy")) {
311:
312:                                rwpConfigThread = new SRAInstanceConfigurationThread(
313:                                        "configureRewriterProxy",
314:                                        "RewriterProxy", msc);
315:                                rwpConfigThread.start();
316:                            }
317:
318:                            Exception exception = null;
319:                            if (gwConfigThread != null) {
320:
321:                                gwConfigThread.join();
322:                                exception = gwConfigThread.getException();
323:                            }
324:
325:                            if (nlpConfigThread != null) {
326:
327:                                nlpConfigThread.join();
328:                                if (exception == null) {
329:                                    exception = nlpConfigThread.getException();
330:                                }
331:                            }
332:
333:                            if (rwpConfigThread != null) {
334:
335:                                rwpConfigThread.join();
336:                                if (exception == null) {
337:                                    exception = rwpConfigThread.getException();
338:                                }
339:                            }
340:
341:                            if (msc != null) {
342:
343:                                try {
344:                                    System.out
345:                                            .println("Closing the MBean Server Connection");
346:                                    configLogger.log(Level.INFO,
347:                                            "PSFB_CSPFC0227");
348:                                    pc.closeMbeanServerConnection();
349:                                    configLogger.log(Level.INFO,
350:                                            "PSFB_CSPFC0015");
351:                                } catch (Exception e) {
352:                                    StringWriter sw = new StringWriter();
353:                                    PrintWriter pw = new PrintWriter(sw);
354:                                    e.printStackTrace(pw);
355:                                    configLogger.log(Level.SEVERE, sw
356:                                            .toString());
357:                                }
358:                            }
359:
360:                            if (exception != null) {
361:                                throw exception;
362:                            }
363:
364:                            exitCode = 0;
365:                        } catch (Exception e) {
366:                            System.err.println("Configuration Failed : "
367:                                    + e.getMessage());
368:                            configLogger.log(Level.SEVERE, "PSFB_CSPFC0014", e);
369:                        } finally {
370:                            if (exitCode == 0) {
371:
372:                                try {
373:                                    System.err
374:                                            .println("Closing MBean Server connection ...");
375:                                    configLogger.log(Level.INFO,
376:                                            "PSFB_CSPFC0227");
377:                                    pc.closeMbeanServerConnection();
378:                                    osTasks.postconfig();
379:                                    configLogger.log(Level.INFO,
380:                                            "PSFB_CSPFC0015");
381:                                } catch (Exception e) {
382:                                    // The connection might already be closed.
383:                                    // Ignore and proceed
384:                                    osTasks.postconfig();
385:                                    System.err
386:                                            .println("Unable to Close MBean Server Connection");
387:                                }
388:
389:                                try {
390:                                    System.err
391:                                            .println("Resetting log level ...");
392:                                    resetLogLevel(sAMAdminUID,
393:                                            sAMAdminPassword, sConfigHostName);
394:                                } catch (Exception e) {
395:                                    System.err
396:                                            .println("Unable to reset log level ...");
397:                                }
398:
399:                                System.err.println("Configuration Successful");
400:                            }
401:                        }
402:                    } else {
403:                        if (psconfigMode != null) {
404:                            System.err
405:                                    .println("Configuration Failed : Invalid input file. XML has a \'"
406:                                            + pci.getPSConfigMode()
407:                                            + "\' Element.");
408:                        } else {
409:                            System.err
410:                                    .println("Configuration Failed : Invalid input file");
411:                        }
412:                        exitCode = 1;
413:                    }
414:                    System.exit(exitCode);
415:                } catch (Exception e) {
416:                    System.err.println("Configuration failed");
417:                    StringWriter sw = new StringWriter();
418:                    PrintWriter pw = new PrintWriter(sw);
419:                    e.printStackTrace(pw);
420:                    if (configLogger != null) {
421:                        configLogger.log(Level.SEVERE, sw.toString());
422:                    } else {
423:                        String msg = (e.getMessage() == null) ? "A serious Exception has occured."
424:                                : e.getMessage();
425:                        System.out.println("Configuration Failed: " + msg);
426:
427:                    }
428:                    System.exit(1);
429:                }
430:            }
431:
432:            private static void resetLogLevel(final String sAMAdminUID,
433:                    final String sAMAdminPassword, final String sConfigHostName)
434:                    throws ConfigurationException {
435:
436:                try {
437:
438:                    String defaultLevel = LogConfigUtil.getDefaultLogLevel();
439:                    // Get the MBean Server connection
440:                    MBeanServerConnection msc = pc.getMbeanServerConnection(
441:                            sAMAdminUID, sAMAdminPassword, sConfigHostName);
442:
443:                    LinkedList path = new LinkedList();
444:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
445:                    path.addFirst("portalLogConfigurator");
446:
447:                    ObjectName objName = AdminClientUtil
448:                            .getResourceMBeanObjectName(
449:                                    "PortalDomain.PortalLogConfigurator", path);
450:                    Object[] params = { "pas", "", "", "debug.com.sun.portal",
451:                            defaultLevel };
452:                    String[] signature = { "java.lang.String",
453:                            "java.lang.String", "java.lang.String",
454:                            "java.lang.String", "java.lang.String" };
455:                    msc.invoke(objName, "setLevel", params, signature);
456:                    configLogger
457:                            .log(Level.INFO, "PSFB_CSPFC0242", defaultLevel);
458:                    configLogger.log(Level.INFO, "PSFB_CSPFC0227");
459:                    pc.closeMbeanServerConnection();
460:                    configLogger
461:                            .log(Level.INFO, "PSFB_CSPFC0015", defaultLevel);
462:                } catch (Exception e) {
463:                    configLogger.log(Level.SEVERE, "PSFB_CSPFC0243", e);
464:                    throw new ConfigurationException(e);
465:                }
466:            }
467:
468:            protected static void setClassPath() throws ConfigurationException {
469:
470:                BufferedReader reader = null;
471:                try {
472:                    // Get the system classloader.
473:                    URLClassLoader sysloader = (URLClassLoader) ClassLoader
474:                            .getSystemClassLoader();
475:                    InputStream ins = sysloader
476:                            .getResourceAsStream("psconfig.classpath");
477:                    InputStreamReader classpathJarsList = new InputStreamReader(
478:                            ins);
479:                    reader = new BufferedReader(classpathJarsList);
480:
481:                    Class sysclass = URLClassLoader.class;
482:                    Class[] parameters = new Class[] { URL.class };
483:                    // Get the method object for the addURL method.
484:                    Method method = sysclass.getDeclaredMethod("addURL",
485:                            parameters);
486:                    method.setAccessible(true);
487:
488:                    // Get the system classpath and create a string buffer out of it
489:                    String sysClasspath = System.getProperty("java.class.path");
490:                    StringBuffer cPathBuf = new StringBuffer(sysClasspath);
491:
492:                    String line = null;
493:                    while ((line = reader.readLine()) != null) {
494:
495:                        line.trim();
496:                        // Parse the line that was read and create a file path out of it
497:                        int index = line.indexOf(SEPARATOR);
498:                        // Get the token in this line that needs to be replaced
499:                        String key = line.substring(0, index);
500:
501:                        String src = line.substring(index);
502:                        src = psConfigProps.getProperty(key, "") + src;
503:
504:                        // Get the system path separator
505:                        String ps = Platform.pathSep;
506:
507:                        // Check if the jar file is already in classpath.
508:                        if (sysClasspath.indexOf(src) == -1) {
509:                            // Create file object from the JAR file
510:                            File jarFile = new File(src);
511:                            // Set the File URL into the URLClassloader
512:                            method.invoke(sysloader, new Object[] { jarFile
513:                                    .toURL() });
514:                            // Append the JAR file path to the classpath string buffer
515:                            cPathBuf.append(ps);
516:                            cPathBuf.append(src);
517:                        }
518:                    }
519:
520:                    // Set the system classpath
521:                    System.setProperty("java.class.path", cPathBuf.toString());
522:                } catch (Exception ex) {
523:                    throw new ConfigurationException(ex.toString());
524:                } finally {
525:                    try {
526:                        reader.close();
527:                    } catch (IOException ioe) {
528:                        throw new ConfigurationException(ioe.toString());
529:                    }
530:                }
531:            }
532:
533:            private static void createPSConfigFile(PortalConfigData pci)
534:                    throws ConfigurationException {
535:
536:                File psConfigDir = new File(pci.getPSConfigDir());
537:                File psConfigFile = new File(pci.getPSConfigDir() + Platform.fs
538:                        + PSConfigConstants.PS_CONFIG_FILE);
539:                try {
540:
541:                    // If portal configuration directory does not exist create it
542:                    if (!psConfigDir.exists()) {
543:                        System.out
544:                                .println("Creating directory: " + psConfigDir);
545:                        psConfigDir.mkdirs();
546:                    } else {
547:                        if (psConfigDir.isFile()) {
548:                            throw new ConfigurationException(
549:                                    "Please remove file:" + psConfigDir);
550:                        }
551:                    }
552:
553:                    OutputStream out = new FileOutputStream(psConfigFile);
554:
555:                    psConfigProps.setProperty("java.home", pci.getJavaHome());
556:                    psConfigProps.setProperty("ps.product.location", pci
557:                            .getPSProdDir());
558:                    psConfigProps.setProperty("ps.data.location", pci
559:                            .getPSDataDir());
560:                    psConfigProps.setProperty("ps.config.location", pci
561:                            .getPSConfigDir());
562:                    psConfigProps.setProperty("ps.default.portal", "Upgraded");
563:
564:                    psConfigProps.setProperty("am.product.location", pci
565:                            .getAMProdDir());
566:                    psConfigProps.setProperty("am.data.location", pci
567:                            .getAMDataDir());
568:                    psConfigProps.setProperty("am.config.location", pci
569:                            .getAMConfigDir());
570:
571:                    psConfigProps.setProperty("cacao.product.location", pci
572:                            .getCacaoProdDir());
573:                    psConfigProps.setProperty("cacao.config.location", pci
574:                            .getCacaoConfigDir());
575:
576:                    psConfigProps.setProperty("shared.lib.location", pci
577:                            .getShareLibDir());
578:                    psConfigProps.setProperty("private.lib.location", pci
579:                            .getPrivateLibDir());
580:
581:                    psConfigProps.setProperty("jdmk.lib.location", pci
582:                            .getJDMKLibDir());
583:
584:                    String sMFWKLibDir = pci.getMFWKLibDir();
585:                    if ((sMFWKLibDir != null) && !sMFWKLibDir.trim().equals("")) {
586:                        psConfigProps.setProperty("jesmf.lib.location",
587:                                sMFWKLibDir);
588:                        psConfigProps.setProperty("jesmf.bin.location", pci
589:                                .getMFWKBinDir());
590:                    }
591:
592:                    String jaxLibDir = pci.getJAXLibDir();
593:                    if ((jaxLibDir != null) && !jaxLibDir.trim().equals("")) {
594:                        psConfigProps
595:                                .setProperty("jax.lib.location", jaxLibDir);
596:                    }
597:
598:                    psConfigProps.setProperty("jss.nss.lib.location", pci
599:                            .getNSSLibDir());
600:                    psConfigProps.setProperty("jss.jar.location", pci
601:                            .getJSSJarDir());
602:
603:                    psConfigProps.setProperty("webnfs.lib.location", pci
604:                            .getWebNFSLibDir());
605:
606:                    psConfigProps.setProperty("ant.home.location", pci
607:                            .getAntHomeDir());
608:                    psConfigProps.setProperty("ant.lib.location", pci
609:                            .getAntLibDir());
610:                    psConfigProps.setProperty("derby.lib.location", pci
611:                            .getDerbyLibDir());
612:                    psConfigProps.setProperty("registry.lib.location", pci
613:                            .getRegistryLibDir());
614:
615:                    if (components.contains("sracore")) {
616:                        psConfigProps.setProperty("portal.server.domain", pci
617:                                .getSRAPortalServerDomain());
618:                    }
619:
620:                    psConfigProps.store(out, "");
621:                    out.close();
622:
623:                    System.out
624:                            .println("Successfully created PSConfig.properties file");
625:                } catch (FileNotFoundException e) {
626:                    throw new ConfigurationException(e);
627:                } catch (IOException ioe) {
628:                    throw new ConfigurationException(ioe);
629:                }
630:            }
631:
632:            private static class SearchServerConfigurationThread extends Thread {
633:
634:                MBeanServerConnection mbConnection = null;
635:                ConfigurationException exception = null;
636:
637:                public SearchServerConfigurationThread(MBeanServerConnection msc) {
638:
639:                    mbConnection = msc;
640:                }
641:
642:                public final ConfigurationException getException() {
643:
644:                    return exception;
645:                }
646:
647:                public void run() {
648:
649:                    Map searchServerDetails = pci.getSearchServerDetails();
650:                    if (!searchServerDetails.isEmpty()) {
651:
652:                        try {
653:
654:                            pc.createSearchServer(mbConnection,
655:                                    searchServerDetails);
656:                        } catch (ConfigurationException e) {
657:
658:                            configLogger.log(Level.SEVERE, e.getMessage());
659:                            exception = e;
660:                        }
661:                    }
662:                }
663:            }
664:
665:            private static class SRAInstanceConfigurationThread extends Thread {
666:
667:                private Exception exception = null;
668:                private MBeanServerConnection msc = null;
669:                private String sSraCompMethod = null;
670:                private String sSraCompDesc = null;
671:
672:                public SRAInstanceConfigurationThread(
673:                        final String sraCompMethod, final String sraCompDesc,
674:                        MBeanServerConnection msc) {
675:
676:                    sSraCompMethod = sraCompMethod;
677:                    sSraCompDesc = sraCompDesc;
678:                    this .msc = msc;
679:                }
680:
681:                public Exception getException() {
682:
683:                    return exception;
684:                }
685:
686:                public void run() {
687:
688:                    try {
689:
690:                        System.out.println("Configuring " + sSraCompDesc);
691:                        configLogger.log(Level.INFO, "PSFB_CSPFC0009",
692:                                new String[] { sSraCompDesc });
693:
694:                        Class cls = Class
695:                                .forName("com.sun.portal.fabric.config.PortalConfigurator");
696:                        Class paratypes[] = new Class[2];
697:                        paratypes[0] = MBeanServerConnection.class;
698:                        paratypes[1] = PortalConfigData.class;
699:
700:                        configLogger.log(Level.INFO, "Creating Method object '"
701:                                + sSraCompMethod + "'...");
702:                        Method meth = null;
703:                        try {
704:                            meth = cls.getMethod(sSraCompMethod, paratypes);
705:                        } catch (NoSuchMethodException e0) {
706:                            configLogger.log(Level.INFO, e0.getMessage());
707:                            throw e0;
708:                        } catch (SecurityException e1) {
709:                            configLogger.log(Level.INFO, e1.getMessage());
710:                            throw e1;
711:                        }
712:                        configLogger.log(Level.INFO, "Method object '"
713:                                + sSraCompMethod + "' created...");
714:
715:                        Object[] arglist = new Object[] { msc, pci };
716:                        meth.invoke(pc, arglist);
717:                    } catch (Exception e0) {
718:                        // Anyways log the exception message
719:                        System.out.println("SRA Configuration failed "
720:                                + e0.getMessage());
721:                        configLogger.log(Level.SEVERE, e0.getMessage());
722:                        exception = e0;
723:                    }
724:                }
725:            }
726:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.