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


001:        package com.sun.portal.sra.admin.mbeans;
002:
003:        import java.io.BufferedReader;
004:        import java.io.File;
005:        import java.io.IOException;
006:        import java.io.InputStreamReader;
007:        import java.util.*;
008:        import java.util.logging.Level;
009:        import java.util.logging.Logger;
010:        import java.net.URL;
011:        import java.net.MalformedURLException;
012:
013:        import com.sun.portal.admin.common.context.PSConfigContext;
014:        import com.sun.portal.admin.common.PSMBeanException;
015:        import com.sun.portal.fabric.util.FileUtil;
016:        import com.sun.portal.fabric.tasks.MonitoringConfigurationHelper;
017:        import com.sun.portal.log.common.PortalLogger;
018:        import com.sun.portal.log.common.PortalLogManager;
019:        import com.sun.portal.sra.admin.context.RWPPropertyContext;
020:        import com.sun.portal.sra.admin.context.SRAFileContextImpl;
021:        import com.sun.portal.sra.admin.context.SRAPropertyContext;
022:        import com.sun.portal.sra.admin.util.OSDefaults;
023:        import com.sun.portal.sra.admin.util.SystemDefaults;
024:        import com.sun.portal.fabric.util.ExecuteUtil;
025:
026:        /**
027:         * @version 1.0
028:         * @created 04-Mar-2005 9:58:14 PM
029:         * @author Sandeep Soni
030:         */
031:        public class RewriterProxy extends SraServerImpl implements  SraServer {
032:            private static final String _mainClass = "com.sun.portal.rproxy.rewriterproxy.HTTPProxy";
033:
034:            private String _classPath = new String();
035:
036:            private String _instanceName = new String();
037:
038:            private String _jvmProperties = new String();
039:
040:            private Properties _platformConfProperties = new Properties();
041:
042:            private HashMap _systemProperties = new HashMap();
043:
044:            private static OSDefaults _osDefaults;
045:
046:            private static String FS;
047:
048:            public static final String COMPONENT_NAME = "gateway";//ldap attribute is stored in the same component type
049:
050:            public static final String ATTRIBUTE_RWP_LISTS = "sunPortalGatewayRWPHostsAndIPs";
051:
052:            private static String loggerName = "debug.com.sun.portal.admin.mbeans";
053:
054:            private ExecuteUtil execUtil = new ExecuteUtil();
055:
056:            static {
057:                _osDefaults = SystemDefaults.getSystemDefaults();
058:                FS = _osDefaults.getValue("fs");
059:            }
060:
061:            private static Logger logger = PortalLogger
062:                    .getLogger(RewriterProxy.class);
063:
064:            /**
065:             * @param instanceName
066:             */
067:            protected RewriterProxy(String instanceName, PSConfigContext cc) {
068:                this .cc = cc;
069:                _instanceName = instanceName;
070:                populateForNamedInstance();
071:            }
072:
073:            protected RewriterProxy(SRAPropertyContext pc, PSConfigContext cc) {
074:                super (pc, cc);
075:            }
076:
077:            protected RewriterProxy(PSConfigContext cc) {
078:                this .cc = cc;
079:            }
080:
081:            private static boolean is_Windows() {
082:                return System.getProperty("os.name").indexOf("indows") != -1;
083:            }
084:
085:            /**
086:             * @param configFileProperties
087:             * @return
088:             */
089:            public SraServer createInstance(Properties configFileProperties)
090:                    throws PSMBeanException {
091:                pc = new RWPPropertyContext(configFileProperties);
092:                fc = new SRAFileContextImpl(pc, cc);
093:                _instanceName = pc.getInstanceName();
094:                Boolean reCopy = (fc.existsGWInstance(pc.getInstanceName())
095:                        .booleanValue()
096:                        || fc.existsNLPInstance(pc.getInstanceName())
097:                                .booleanValue() || fc.existsRWPInstance(
098:                        pc.getInstanceName()).booleanValue()) ? Boolean.FALSE
099:                        : Boolean.TRUE;
100:                if (fc.existsRWPInstance(pc.getInstanceName()).booleanValue()) {
101:                    throw new PSMBeanException(
102:                            "psadmin.error.sra.create.instanceExists");
103:                }
104:                if (CheckPort(pc.getHost(), pc.getPort(), 50) == Boolean.TRUE) {
105:                    String token[] = { pc.getPort() };
106:                    throw new PSMBeanException(
107:                            "psadmin.error.sra.create.portAlreadyInUse", token);
108:                }
109:
110:                copyFile(fc.getTemplatePlatformConfigurationFile(), fc
111:                        .getInstancePlatformConfigurationFile(), reCopy);
112:                replaceTokens(fc.getInstancePlatformConfigurationFile());
113:                if (!pc.doCreateNewIdentitySDKInstance().booleanValue()) {
114:                    String[][] appendNameValues = new String[][] {
115:                            { "rewriterproxy.port", pc.getPort() },
116:                            { "gateway.bindipaddress", pc.getIP() },
117:                            { "gateway.sockretries", "3" },
118:                            { "rewriterproxy.protocol", pc.getProtocol() },
119:                            { "rewriterproxy.accept.from.gateways", "" },
120:                            { "rewriterproxy.checkacl", "false" } };
121:                    try {
122:                        addOrReplaceNameValues(fc
123:                                .getInstancePlatformConfigurationFile(),
124:                                appendNameValues);
125:                    } catch (IOException ioe) {
126:                        throw new PSMBeanException(
127:                                "psadmin.error.sra.create.platformConfMissing");
128:                    }
129:                } else {
130:                    createIdentitySDKInstance();
131:                    native2Ascii();
132:                    String[][] appendNameValues = new String[][] {
133:                            { "rewriterproxy.port", pc.getPort() },
134:                            { "gateway.bindipaddress", pc.getIP() },
135:                            { "gateway.sockretries", "3" },
136:                            { "portal.server.instance", pc.getInstanceName() },
137:                            { "rewriterproxy.protocol", pc.getProtocol() },
138:                            { "rewriterproxy.accept.from.gateways", "" },
139:                            { "rewriterproxy.checkacl", "false" } };
140:                    try {
141:                        addOrReplaceNameValues(fc
142:                                .getInstancePlatformConfigurationFile(),
143:                                appendNameValues);
144:                    } catch (IOException ioe) {
145:                        throw new PSMBeanException(
146:                                "psadmin.error.sra.create.platformConfMissing");
147:                    }
148:                }
149:                if (pc.doCreateSelfSignedCertificate().booleanValue()) {
150:                    FileUtil.makeDir(fc.getInstanceCertificatesDirectory());
151:                    if (createSelfSignedCertificate().booleanValue()) {
152:                        createLoggingUserAuthenticationEntry();
153:                    }
154:                }
155:                createInstanceSignature();
156:                //addServerInstanceInfoToProfile(COMPONENT_NAME, ATTRIBUTE_RWP_LISTS);
157:                setAttribute(pc.getPortalHost(), pc.getInstanceName(),
158:                        ATTRIBUTE_RWP_LISTS, pc.getHost(), pc.getIP());
159:                pc.write(fc.getInstanceRWPConfigurationPropertiesFile(), fc
160:                        .getInstanceRWPConfigurationPropertiesFile());
161:                String MonitoringFileName = cc.getPSConfigDir()
162:                        + File.separator + pc.getInstanceName()
163:                        + File.separator + "rwproxy" + File.separator
164:                        + "monitoring.properties";
165:                File MonitoringFile = new File(MonitoringFileName);
166:                if (!MonitoringFile.exists()) {
167:                    copyFile(cc.getPSBaseDir() + File.separator + "template"
168:                            + File.separator + "sra" + File.separator
169:                            + "monitoring.properties", MonitoringFileName,
170:                            Boolean.FALSE);
171:                    FileUtil.replaceTokenInFile(MonitoringFile,
172:                            "%INSTANCE_CONFIG_DIR%", cc.getPSConfigDir() + FS
173:                                    + pc.getInstanceName() + FS + "rwproxy");
174:                    MonitoringConfigurationHelper.configurePropertyFile(
175:                            MonitoringFileName, pc.getHost(), cc);
176:                }
177:                populateForNamedInstance();
178:                if (is_Windows())
179:                    createWindowsService();
180:                if (pc.doStartAfterInstall().booleanValue())
181:                    start();
182:                return this ;
183:            }
184:
185:            public boolean deleteInstance() throws PSMBeanException {
186:                boolean status = true;
187:                stop();
188:                PortalLogManager.deleteSRALoggersList(fc
189:                        .getInstancePlatformConfigurationFile(), "rwproxy");
190:                removeInstanceSignature();
191:                //deleteServerInstanceInfoFromProfile(COMPONENT_NAME, ATTRIBUTE_RWP_LISTS);
192:                deleteAttribute(pc.getPortalHost(), pc.getInstanceName(),
193:                        ATTRIBUTE_RWP_LISTS, pc.getHost(), pc.getIP());
194:                if (is_Windows())
195:                    deleteWindowsService();
196:                return status;
197:            }
198:
199:            /*
200:             * (non-Javadoc)
201:             * 
202:             * @see java.lang.Object#equals(java.lang.Object)
203:             */
204:            public boolean equals(Object obj) {
205:                boolean ret = false;
206:                if (obj instanceof  Gateway) {
207:                    Gateway g = (Gateway) obj;
208:                    if (g.getInstanceName().equals(_instanceName))
209:                        ret = true;
210:                }
211:                return ret;
212:            }
213:
214:            public String getclassPath() {
215:                return _classPath;
216:            }
217:
218:            private void createWindowsService() throws PSMBeanException {
219:                StringBuffer sb = new StringBuffer();
220:
221:                String classPath = getclassPath();
222:                if (getclassPath() == null
223:                        || classPath.trim().equalsIgnoreCase("")) {
224:                    setClassPath(); // sets the default classPath for Gateway component
225:                    classPath = getclassPath();
226:                }
227:                setJVMProperties();
228:
229:                String command = cc.getPSBaseDir() + File.separator + "lib"
230:                        + File.separator + "srasvc.exe";
231:                String extraLibs = fc.getExtraLibs(amc.getJDKPath());
232:                String libraryPath = fc
233:                        .getCreateSelfSignedCertificateLibraryPath()
234:                        + File.pathSeparator + extraLibs;
235:                libraryPath += File.pathSeparator
236:                        + replaceBackSlash(System
237:                                .getProperty("java.library.path"));
238:                String[] envp = new String[7];
239:
240:                String DEFINES = " -Drwproxyd.profilename="
241:                        + pc.getInstanceName();
242:                sb.append(DEFINES);
243:                sb.append(" -classpath ");
244:                sb.append(classPath);
245:                sb.append(" ");
246:                sb.append(_jvmProperties);
247:                sb.append(" ");
248:                sb.append(_mainClass.trim());
249:                // DebugContext.message("Command = " + sb.toString());
250:                Object[] params2 = { sb.toString() };
251:                logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS038", params2);
252:
253:                envp[0] = "servicename=SRA.Rewriter." + pc.getInstanceName();
254:                envp[1] = "serviceshowname=Portal SRA Rewriter "
255:                        + pc.getInstanceName() + " instance";
256:                envp[2] = "servicedesname=Sun Java System Portal SRA's Rewriter "
257:                        + pc.getInstanceName() + " instance";
258:                envp[3] = "javahome="
259:                        + _platformConfProperties
260:                                .getProperty("gateway.jdk.dir");
261:                envp[4] = "jvmoptions=" + sb.toString();
262:                envp[5] = "workingdirectory=" + cc.getPSConfigDir()
263:                        + File.separator + pc.getInstanceName()
264:                        + File.separator + "gateway";
265:                envp[6] = "prefixpath=" + libraryPath;
266:
267:                try {
268:                    String args[] = { "install" };
269:                    execUtil.exec(command, args, envp);
270:                } catch (Exception e) {
271:                    throw new PSMBeanException(e.toString());
272:                }
273:            }
274:
275:            // delete windows service
276:            private void deleteWindowsService() throws PSMBeanException {
277:
278:                String command = cc.getPSBaseDir() + File.separator + "lib"
279:                        + File.separator + "srasvc.exe";
280:                try {
281:                    String args[] = { "uninstall", "servicename",
282:                            "SRA.Rewriter." + pc.getInstanceName() };
283:                    execUtil.exec(command, args);
284:                } catch (Exception e) {
285:                    throw new PSMBeanException(e.toString());
286:                }
287:            }
288:
289:            /*
290:             * (non-Javadoc)
291:             * 
292:             * @see com.sun.portal.sra.mbeans.SraServer#getInstanceName()
293:             */
294:            public String getInstanceName() {
295:                return new String(_instanceName);
296:            }
297:
298:            public String getjvmProperties() {
299:                return _jvmProperties;
300:            }
301:
302:            public String getmainClass() {
303:                return _mainClass;
304:            }
305:
306:            /*
307:             * (non-Javadoc)
308:             * 
309:             * @see com.sun.portal.sra.mbeans.SraServerComponent#getPlatformConfProperties()
310:             */
311:            public Properties getPlatformConfProperties() {
312:                return (Properties) _platformConfProperties.clone();
313:            }
314:
315:            public HashMap getSystemProperties() {
316:                return _systemProperties;
317:            }
318:
319:            /*
320:             * (non-Javadoc)
321:             * 
322:             * @see com.sun.portal.sra.mbeans.SraServerComponent#populateForNamedInstance(java.lang.String)
323:             */
324:            private void populateForNamedInstance() {
325:                try {
326:                    String instancePropertiesFile = cc.getPSConfigDir()
327:                            + SRAFileContextImpl.fs + "RWPConfig-"
328:                            + _instanceName + ".properties";
329:                    pc = new RWPPropertyContext(load(instancePropertiesFile));
330:                    fc = new SRAFileContextImpl(pc, cc);
331:                    _platformConfProperties = load(fc
332:                            .getInstancePlatformConfigurationFile());
333:                    _jvmProperties = _platformConfProperties
334:                            .getProperty("rewriterproxy.jvm.flags");
335:                    _classPath = _platformConfProperties
336:                            .getProperty("rewriterproxy.jvm.classpath");
337:                    try {
338:                        amc = fc.getAMPropertyContext();
339:                    } catch (Exception e) {
340:                        e.printStackTrace();
341:                        // DebugContext.error("Error in getting AMConfig.properties");
342:                        logger.severe("PSSR_CSPS_ADM_MBEANS036");
343:                    }
344:                } catch (IOException ioe) {
345:                    // DebugContext.message("Error in populating the rewriterproxy
346:                    // instance!");
347:                    logger.info("PSSR_CSPS_ADM_MBEANS037");
348:                }
349:                setClassPath();
350:                setJVMProperties();
351:            }
352:
353:            private void setClassPath() {
354:                _classPath = _platformConfProperties
355:                        .getProperty("rewriterproxy.jvm.classpath");
356:                String IDSAME_CONFIG_DIR = cc.getISConfigDir();
357:                String IS_HOME = cc.getISBaseDir();
358:
359:                String IS_CLASSPATH = IDSAME_CONFIG_DIR + File.pathSeparator;
360:                IS_CLASSPATH = IS_CLASSPATH + IS_HOME + fs + "lib"
361:                        + File.pathSeparator;
362:                IS_CLASSPATH = IS_CLASSPATH + IS_HOME + fs + "locale"
363:                        + File.pathSeparator;
364:                IS_CLASSPATH = IS_CLASSPATH + IS_HOME + fs + "lib" + fs
365:                        + "am_sdk.jar" + File.pathSeparator;
366:                IS_CLASSPATH = IS_CLASSPATH + IS_HOME + fs + "lib" + fs
367:                        + "am_services.jar" + File.pathSeparator;
368:                IS_CLASSPATH = IS_CLASSPATH + IS_HOME + fs + "lib" + fs
369:                        + "am_logging.jar" + File.pathSeparator;
370:                IS_CLASSPATH = IS_CLASSPATH + IS_HOME + fs + "lib" + fs
371:                        + "servlet.jar" + File.pathSeparator;
372:
373:                String JCE_CLASSPATH = IS_HOME + fs + "lib" + fs
374:                        + "jce1_2_1.jar" + File.pathSeparator;
375:                JCE_CLASSPATH = JCE_CLASSPATH + IS_HOME + fs + "lib" + fs
376:                        + "local_policy.jar" + File.pathSeparator;
377:                JCE_CLASSPATH = JCE_CLASSPATH + IS_HOME + fs + "lib" + fs
378:                        + "US_export_policy.jar" + File.pathSeparator;
379:                JCE_CLASSPATH = JCE_CLASSPATH + IS_HOME + fs + "lib" + fs
380:                        + "sunjce_provider.jar" + File.pathSeparator;
381:
382:                String PS_HOME = cc.getPSBaseDir();
383:
384:                String RW_JAR = PS_HOME + fs + "lib" + fs + "rewriter.jar"
385:                        + File.pathSeparator;
386:                String LOGGING_CLASSPATH = PS_HOME + fs + "lib" + fs
387:                        + "pslogcommon.jar" + File.pathSeparator;
388:
389:                String JDMK_LIB_DIR = fc.getJdmkLibLocation();
390:                String MONITORING_JAR = PS_HOME + fs + "lib" + fs
391:                        + "monitoring.jar" + File.pathSeparator;
392:                MONITORING_JAR = MONITORING_JAR + JDMK_LIB_DIR + fs + "jmx.jar"
393:                        + File.pathSeparator;
394:                MONITORING_JAR = MONITORING_JAR + PS_HOME + fs + "lib" + fs
395:                        + "javax77.jar" + File.pathSeparator;
396:                MONITORING_JAR = MONITORING_JAR + JDMK_LIB_DIR + fs
397:                        + "jdmkrt.jar" + File.pathSeparator;
398:                MONITORING_JAR = MONITORING_JAR + JDMK_LIB_DIR + fs
399:                        + "jmxremote.jar" + File.pathSeparator;
400:                MONITORING_JAR = MONITORING_JAR + JDMK_LIB_DIR + fs
401:                        + "jmxremote_optional.jar" + File.pathSeparator;
402:                MONITORING_JAR = MONITORING_JAR + JDMK_LIB_DIR + fs
403:                        + "sunsasl.jar" + File.pathSeparator;
404:                MONITORING_JAR = MONITORING_JAR + JDMK_LIB_DIR + fs
405:                        + "sasl.jar" + File.pathSeparator;
406:
407:                String RWP_CLASSPATH = PS_HOME + fs + "lib"
408:                        + File.pathSeparator;
409:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "locale"
410:                        + File.pathSeparator;
411:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "lib" + fs
412:                        + "rwproxy.jar" + File.pathSeparator;
413:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "lib" + fs
414:                        + "ps_util.jar" + File.pathSeparator;
415:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "lib" + fs
416:                        + "rwportal.jar" + File.pathSeparator;
417:                RWP_CLASSPATH = RWP_CLASSPATH + RW_JAR;
418:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "lib" + fs
419:                        + "gateway.jar" + File.pathSeparator;
420:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "lib" + fs
421:                        + "certadmin.jar" + File.pathSeparator;
422:                RWP_CLASSPATH = RWP_CLASSPATH + PS_HOME + fs + "lib" + fs
423:                        + "js.jar" + File.pathSeparator;
424:
425:                String JSS_JAR = fc.getJSSJARDir() + fs + "jss4.jar"
426:                        + File.pathSeparator + fc.getJSSJARFile()
427:                        + File.pathSeparator;
428:                RWP_CLASSPATH = IS_CLASSPATH + JCE_CLASSPATH + JSS_JAR
429:                        + LOGGING_CLASSPATH + MONITORING_JAR + RWP_CLASSPATH;
430:                if (_classPath != null)
431:                    _classPath += File.pathSeparator + RWP_CLASSPATH;
432:                else
433:                    _classPath = RWP_CLASSPATH;
434:            }
435:
436:            private void setJVMProperties() {
437:                _jvmProperties = _platformConfProperties
438:                        .getProperty("rewriterproxy.jvm.flags");
439:                if (_jvmProperties == null
440:                        || _jvmProperties.trim().equalsIgnoreCase("")) {
441:                    _jvmProperties = "-ms64m ";
442:                    _jvmProperties += "-mx128m ";
443:                }
444:                String IS_HOME = cc.getISBaseDir();
445:
446:                String DEFINES1 = "-Dsun.net.inetaddr.ttl=0 -Djava.protocol.handler.pkgs=com.iplanet.services.comm";
447:                Properties instancePlatformConfigProperties;
448:                try {
449:                    instancePlatformConfigProperties = load(fc
450:                            .getInstancePlatformConfigurationFile());
451:                } catch (IOException ioe) {
452:                    return;
453:                }
454:                String gatewayNotificationUrl = instancePlatformConfigProperties
455:                        .getProperty("gateway.notification.url");
456:
457:                String amNotificationUrl = instancePlatformConfigProperties
458:                        .getProperty("gateway.protocol")
459:                        + "://"
460:                        + instancePlatformConfigProperties
461:                                .getProperty("gateway.host")
462:                        + ":"
463:                        + instancePlatformConfigProperties
464:                                .getProperty("rewriterproxy.port")
465:                        + FS
466:                        + gatewayNotificationUrl;
467:
468:                List notificationUrlList = getNotificationURL(
469:                        gatewayNotificationUrl, amNotificationUrl,
470:                        instancePlatformConfigProperties);
471:                if (notificationUrlList != null) {
472:                    gatewayNotificationUrl = (String) notificationUrlList
473:                            .get(0);
474:                    amNotificationUrl = (String) notificationUrlList.get(1);
475:                }
476:
477:                String DIRECTORY_CERT_DB = instancePlatformConfigProperties
478:                        .getProperty("gateway.certdir");
479:                String FILE_CERT_DB_PASSWORD = DIRECTORY_CERT_DB + fs
480:                        + ".jsspass";
481:                String FILE_CERT_NICKNAME = DIRECTORY_CERT_DB + fs
482:                        + ".nickname";
483:
484:                String DEFINES2 = "-Dcom.iplanet.am.notification.url="
485:                        + amNotificationUrl + " -Dgateway.notification.url="
486:                        + gatewayNotificationUrl;
487:                String DEFINES3 = "-Dgateway.keybase=" + DIRECTORY_CERT_DB
488:                        + " -Dgateway.pass=" + FILE_CERT_DB_PASSWORD
489:                        + " -Dgateway.nickname=" + FILE_CERT_NICKNAME;
490:
491:                //      Identity Log Manager was being used instead of Portal Log Manager and hence the logs were not going into the portal logs
492:
493:                /*String DEFINES4 = "-Djava.util.logging.manager=com.sun.identity.log.LogManager  -Djava.util.logging.config.file=" + IS_HOME + fs + "lib" + fs
494:                        + "LogConfig.properties" + " -Dcom.sun.portal.log.config.file=" + fc.getInstancePlatformConfigurationFile();*/
495:                String DEFINES4 = " -Dcom.sun.portal.log.config.file="
496:                        + fc.getInstancePlatformConfigurationFile();
497:                /*DEFINES4 = DEFINES4 + " -Dcom.sun.portal.monitoring.MonitoringContext.configuration.directory=" + cc.getPSConfigDir() + fs
498:                        + pc.getInstanceName() + fs + "rwp";*/
499:                String DEFINES5 = " -Dgateway.profilename="
500:                        + pc.getInstanceName() + " -Dconf.suffix="
501:                        + pc.getInstanceName();
502:
503:                String IS_CONFIG_NAME = instancePlatformConfigProperties
504:                        .getProperty("portal.server.instance");
505:                if (IS_CONFIG_NAME != null
506:                        && !IS_CONFIG_NAME.trim().equalsIgnoreCase("")) {
507:                    DEFINES5 = DEFINES5 + " -Dserver.name=" + IS_CONFIG_NAME;
508:                }
509:
510:                StringBuffer sb = new StringBuffer();
511:                sb.append(DEFINES1);
512:                sb.append(" ");
513:                sb.append(DEFINES2);
514:                sb.append(" ");
515:                sb.append(DEFINES3);
516:                sb.append(" ");
517:                sb.append(DEFINES4);
518:                sb.append(" ");
519:                sb.append(DEFINES5);
520:                sb.append(" ");
521:                sb.append("-DSRAP_CONFIG_DIR=" + cc.getPSConfigDir());
522:
523:                if (_jvmProperties != null) {
524:                    _jvmProperties += " ";
525:                    _jvmProperties += sb.toString();
526:                } else
527:                    _jvmProperties = sb.toString();
528:            }
529:
530:            private String getExecCommand() {
531:                StringBuffer sb = new StringBuffer();
532:
533:                String classPath = getclassPath();
534:                if (getclassPath() == null
535:                        || classPath.trim().equalsIgnoreCase("")) {
536:                    setClassPath(); // sets the default classPath for RewriterProxy
537:                    // component
538:                    classPath = getclassPath();
539:                }
540:                setJVMProperties();
541:                String command = _platformConfProperties
542:                        .getProperty("gateway.jdk.dir")
543:                        + FORWARD_SLASH + "bin" + FORWARD_SLASH + "java";
544:                String DEFINES = " -Drwproxyd.profilename="
545:                        + pc.getInstanceName();
546:                sb.append(command);
547:                sb.append(DEFINES);
548:                sb.append(" -classpath ");
549:                sb.append(classPath);
550:                sb.append(" ");
551:                sb.append(_jvmProperties);
552:                sb.append(" ");
553:                sb.append(_mainClass.trim());
554:                // DebugContext.message("Command = " + sb.toString());
555:                Object[] params2 = { sb.toString() };
556:                logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS038", params2);
557:
558:                return sb.toString();
559:            }
560:
561:            public boolean start() throws PSMBeanException {
562:                boolean retCode = true;
563:                if (_instanceName.length() > 0) {
564:                    String command = getExecCommand();
565:                    String extraLibs = fc.getExtraLibs(amc.getJDKPath());
566:                    String libraryPath = fc
567:                            .getCreateSelfSignedCertificateLibraryPath()
568:                            + File.pathSeparator + extraLibs;
569:                    libraryPath += File.pathSeparator
570:                            + replaceBackSlash(System
571:                                    .getProperty("java.library.path"));
572:                    String[] envp = new String[2];
573:                    envp[0] = "LD_LIBRARY_PATH=" + libraryPath;
574:                    envp[1] = "SHLIB_PATH=" + libraryPath;
575:                    // Execute the command here.
576:                    String instance = pc.getInstanceName();
577:                    String pid = getInstancePID(instance);
578:                    if (!pid.trim().equalsIgnoreCase("")) {
579:                        // DebugContext.error("Info: Rewriter Proxy instance already
580:                        // running!");
581:                        logger.severe("PSSR_CSPS_ADM_MBEANS039");
582:                        String token[] = { instance };
583:                        throw new PSMBeanException(
584:                                "psadmin.error.sra.start.instanceAlreadyRunning",
585:                                token);
586:                    } else if (CheckPort(pc.getHost(), pc.getPort(), 50) == Boolean.TRUE) {
587:                        String token[] = { "rwproxy", pc.getPort() };
588:                        throw new PSMBeanException(
589:                                "psadmin.error.sra.start.portAlreadyInUse",
590:                                token);
591:                    } else {
592:                        if (!is_Windows())
593:                            command = command.trim() + " &";
594:                        else {
595:                            command = "net";
596:                            try {
597:                                String args[] = { "start",
598:                                        "SRA.Rewriter." + pc.getInstanceName() };
599:                                execUtil.exec(command, args, envp);
600:                            } catch (Exception e) {
601:                                logger.severe("PSSR_CSPS_ADM_MBEANS028");
602:                                String token[] = { instance, "nlproxy" };
603:                                throw new PSMBeanException(
604:                                        "psadmin.error.sra.start.instance",
605:                                        token);
606:                            }
607:                        }
608:                        Object[] params2 = { "export " + envp[0] + ";"
609:                                + command };
610:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS038",
611:                                params2);
612:
613:                        // DebugContext.message(command);
614:                        logger.info("PSSR_CSPS_ADM_MBEANS040");
615:                        if (!is_Windows()) {
616:                            try {
617:                                Runtime.getRuntime().exec(command, envp);
618:                                Thread.sleep(10000L);
619:                            } catch (Exception e) {
620:                                logger.severe("PSSR_CSPS_ADM_MBEANS044");
621:                                String token[] = { instance, "rwproxy" };
622:                                throw new PSMBeanException(
623:                                        "psadmin.error.sra.start.instance",
624:                                        token);
625:                            }
626:                        }
627:                        if (CheckPort(pc.getHost(), pc.getPort(), 50) == Boolean.TRUE) {
628:                            pid = getInstancePID(pc.getInstanceName());
629:                            if (pid.trim().equalsIgnoreCase("")) {
630:                                String token[] = { "rwproxy", pc.getPort() };
631:                                throw new PSMBeanException(
632:                                        "psadmin.error.sra.start.portAlreadyInUse",
633:                                        token);
634:                            }
635:                            // DebugContext.message("Rewriter Proxy started
636:                            // successfully .");
637:                            logger.info("PSSR_CSPS_ADM_MBEANS041");
638:                        } else {
639:                            // DebugContext.message("Rewriter Proxy failed to start
640:                            // due to some internal errors .");
641:                            logger.info("PSSR_CSPS_ADM_MBEANS042");
642:                            pid = getInstancePID(pc.getInstanceName());
643:                            if (!pid.trim().equalsIgnoreCase("")) {
644:                                String token[] = { "rewriter proxy", pid };
645:                                throw new PSMBeanException(
646:                                        "psadmin.error.sra.start.instanceRunningButNotListening",
647:                                        token);
648:                            }
649:                            return false;
650:                        }
651:                    }
652:                }
653:                return retCode;
654:            }
655:
656:            public boolean stop() throws PSMBeanException {
657:                boolean retCode = true;
658:                if (_instanceName.length() > 0) {
659:                    // Execute the command here.to stop the instance
660:                    String pid = getInstancePID(pc.getInstanceName());
661:                    if (!pid.equalsIgnoreCase("")) {
662:                        String command = _osDefaults.getValue("kill") + " -9 "
663:                                + pid;
664:                        try {
665:                            int exitValue = 0;
666:                            if (!is_Windows()) {
667:                                exitValue = exec(command);
668:                            } else {
669:                                command = "net";
670:                                String args[] = { "stop",
671:                                        "SRA.Rewriter." + pc.getInstanceName() };
672:                                exitValue = execUtil.exec(command, args);
673:                            }
674:                            if (exitValue != 0) {
675:                                // DebugContext.error("Failed on stop instance <" +
676:                                // exitValue + ">");
677:                                Object[] params9 = { exitValue + "", ">" };
678:                                logger.log(Level.SEVERE,
679:                                        "PSSR_CSPS_ADM_MBEANS045", params9);
680:                                return false;
681:                            } else {
682:                                // DebugContext.message("Stopped the instance.");
683:                                logger.info("PSSR_CSPS_ADM_MBEANS046");
684:                            }
685:                        } catch (Exception e) {
686:                            e.printStackTrace();
687:                            // DebugContext.error("Confiugration Error: Failed to stop
688:                            // the instance " + pc.getInstanceName());
689:                            Object[] params11 = { pc.getInstanceName() };
690:                            logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS047",
691:                                    params11);
692:                            return false;
693:                        }
694:                    }
695:
696:                }
697:                return retCode;
698:            }
699:
700:            public String toString() {
701:                super .toString();
702:                StringBuffer sb = new StringBuffer();
703:                sb.append("	Java VM Properties : " + _jvmProperties + "\n");
704:                sb.append("	System Properties : " + _systemProperties + "\n");
705:                sb.append("	Classpath : " + _classPath + "\n");
706:                return sb.toString();
707:            }
708:
709:            /*
710:             * (non-Javadoc)
711:             * 
712:             * @see com.sun.portal.sra.mbeans.SraServer#getServiceIdentifier()
713:             */
714:            public int getServiceIdentifier() {
715:                return SraServer.INSTANCE_TYPE_REWRITER_PROXY;
716:            }
717:
718:            /*
719:             * (non-Javadoc)
720:             * 
721:             * @see com.sun.portal.sra.mbeans.SraServer#isGateway()
722:             */
723:            public boolean isGateway() {
724:                return false;
725:            }
726:
727:            /*
728:             * (non-Javadoc)
729:             * 
730:             * @see com.sun.portal.sra.mbeans.SraServer#isRewriterProxy()
731:             */
732:            public boolean isRewriterProxy() {
733:                return true;
734:            }
735:
736:            /*
737:             * (non-Javadoc)
738:             * 
739:             * @see com.sun.portal.sra.mbeans.SraServer#isNetletProxy()
740:             */
741:            public boolean isNetletProxy() {
742:                return false;
743:            }
744:
745:            public String getInstancePID(String instance) {
746:                String result = "";
747:                String pscommand = _osDefaults.getValue("pid");
748:                // DebugContext.message(pscommand);
749:                logger.info("PSSR_CSPS_ADM_MBEANS048");
750:                Process ps_process = null;
751:                try {
752:                    if (!is_Windows()) {
753:                        ps_process = Runtime.getRuntime().exec(pscommand);
754:
755:                        BufferedReader br = new BufferedReader(
756:                                new InputStreamReader(ps_process
757:                                        .getInputStream()));
758:                        String s = "";
759:                        while ((s = br.readLine()) != null) {
760:                            // -Dgateway.profilename= (for gateway)
761:                            // -Dnetletd.profilename= (for rwp)
762:                            if (s.indexOf("-Drwproxyd.profilename=" + instance
763:                                    + " ") != -1) {
764:                                result = s;
765:                                // DebugContext.message("Line : " + s);
766:                                Object[] params13 = { s };
767:                                logger.log(Level.INFO,
768:                                        "PSSR_CSPS_ADM_MBEANS049", params13);
769:                                break;
770:                            }
771:                        }
772:
773:                    } else {
774:                        ps_process = Runtime.getRuntime().exec("net START");
775:
776:                        BufferedReader br = new BufferedReader(
777:                                new InputStreamReader(ps_process
778:                                        .getInputStream()));
779:                        String s = "";
780:                        while ((s = br.readLine()) != null) {
781:                            if (s.indexOf("Portal SRA Rewriter " + instance
782:                                    + " ") != -1) {
783:                                result = "100";
784:                                // DebugContext.message("Line : " + s);
785:                                Object[] params16 = { s };
786:                                logger.log(Level.INFO,
787:                                        "PSSR_CSPS_ADM_MBEANS016", params16);
788:                                break;
789:                            }
790:                        }
791:                    }
792:                } catch (IOException e) {
793:                    e.printStackTrace();
794:                    return result;
795:                }
796:                StringTokenizer st = new StringTokenizer(result);
797:                try {
798:                    result = st.nextToken();
799:                    // DebugContext.message("Process Id : " + result);
800:                    Object[] params14 = { result };
801:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS050", params14);
802:                } catch (NoSuchElementException nsee) {
803:                    // DebugContext.message("No RWP instance is running!!!");
804:                    logger.info("PSSR_CSPS_ADM_MBEANS051");
805:                }
806:                return result;
807:            }
808:
809:            public Boolean removeInstanceSignature() {
810:                Boolean result = Boolean.TRUE;
811:                try {
812:                    FileUtil.deleteDir(fc
813:                            .getInstanceRWPConfigurationPropertiesFile());
814:                    if (!fc.existsNLPInstance(pc.getInstanceName())
815:                            .booleanValue()
816:                            && !fc.existsGWInstance(pc.getInstanceName())
817:                                    .booleanValue()) {
818:                        FileUtil.deleteDir(fc
819:                                .getInstanceCertificatesDirectory());
820:                        FileUtil.deleteDir(fc
821:                                .getInstancePlatformConfigurationFile());
822:                        FileUtil.deleteDir(cc.getPSConfigDir() + FS
823:                                + pc.getInstanceName());
824:                        removeIdentitySDKInstance();
825:                    } else {
826:                        String[][] appendNameValues = new String[][] {
827:                                { "rewriterproxy.port", "" },
828:                                { "rewriterproxy.protocol", "" },
829:                                { "rewriterproxy.accept.from.gateways", "" },
830:                                { "rewriterproxy.checkacl", "false" } };
831:                        addOrReplaceNameValues(fc
832:                                .getInstancePlatformConfigurationFile(),
833:                                appendNameValues);
834:                        FileUtil.deleteDir(cc.getPSConfigDir() + File.separator
835:                                + pc.getInstanceName() + File.separator
836:                                + "rwproxy");
837:                    }
838:                } catch (Exception e) {
839:                    e.printStackTrace();
840:                    result = Boolean.FALSE;
841:                }
842:                return result;
843:            }
844:
845:            public Boolean createLoggingUserAuthenticationEntry() {
846:                return super .createLoggingUserAuthenticationEntry();
847:            }
848:
849:            public boolean isStarted(String hostname, int portNumber) {
850:                String pid = getInstancePID(this ._instanceName);
851:                return ((pid != null && !pid.equalsIgnoreCase("")) && super 
852:                        .isStarted(hostname, portNumber));
853:            }
854:
855:            public boolean isStopped(String hostname, int portNumber) {
856:                return super.isStopped(hostname, portNumber);
857:            }
858:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.