Source Code Cross Referenced for SraServerImpl.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) 


0001:        package com.sun.portal.sra.admin.mbeans;
0002:
0003:        import java.io.File;
0004:        import java.io.FileInputStream;
0005:        import java.io.FileReader;
0006:        import java.io.FileWriter;
0007:        import java.io.IOException;
0008:        import java.io.LineNumberReader;
0009:        import java.io.PrintWriter;
0010:        import java.net.MalformedURLException;
0011:        import java.net.Socket;
0012:        import java.net.URL;
0013:        import java.util.*;
0014:        import java.util.logging.Level;
0015:        import java.util.logging.Logger;
0016:
0017:        import com.iplanet.sso.SSOException;
0018:        import com.iplanet.sso.SSOToken;
0019:        import com.sun.identity.sm.SMSException;
0020:        import com.sun.portal.admin.common.AttrOptionConstants;
0021:        import com.sun.portal.admin.common.PSMBeanException;
0022:        import com.sun.portal.admin.common.util.AdminUtil;
0023:        import com.sun.portal.admin.common.context.PSConfigContext;
0024:        import com.sun.portal.admin.server.AdminServerUtil;
0025:        import com.sun.portal.admin.server.mbeans.PSResource;
0026:        import com.sun.portal.fabric.util.FileUtil;
0027:        import com.sun.portal.fabric.util.ExecuteUtil;
0028:        import com.sun.portal.log.common.PortalLogger;
0029:        import com.sun.portal.sra.admin.attribute.handlers.GatewayAttributeOperations;
0030:        import com.sun.portal.sra.admin.context.AMPropertyContext;
0031:        import com.sun.portal.sra.admin.context.SRAFileContext;
0032:        import com.sun.portal.sra.admin.context.SRAFileContextImpl;
0033:        import com.sun.portal.sra.admin.context.SRAPropertyContext;
0034:        import com.sun.portal.sra.admin.util.OSDefaults;
0035:        import com.sun.portal.sra.admin.util.SystemDefaults;
0036:
0037:        import javax.management.MalformedObjectNameException;
0038:        import javax.management.ObjectName;
0039:
0040:        /**
0041:         * Author: fa151985 Date: Mar 31, 2005 Time: 3:31:36 PM
0042:         */
0043:        public class SraServerImpl extends PSResource {
0044:
0045:            public SraServerImpl() {
0046:            }
0047:
0048:            protected SRAPropertyContext pc = null;
0049:
0050:            protected SRAFileContext fc = null;
0051:
0052:            protected PSConfigContext cc = null;
0053:
0054:            protected AMPropertyContext amc = null;
0055:
0056:            public static final String FORWARD_SLASH = "/";
0057:
0058:            public static final char FORWARD_SLASH_CHAR = '/';
0059:
0060:            public static final String BACK_SLASH = "\\";
0061:
0062:            public static final char BACK_SLASH_CHAR = '\\';
0063:
0064:            public static String fs = SRAFileContext.fs;
0065:
0066:            private static OSDefaults _osDefaults;
0067:
0068:            private static String loggerName = "debug.com.sun.portal.admin.mbeans";
0069:
0070:            private ExecuteUtil execUtil = new ExecuteUtil();
0071:
0072:            static {
0073:                _osDefaults = SystemDefaults.getSystemDefaults();
0074:            }
0075:
0076:            private static Logger logger = PortalLogger
0077:                    .getLogger(SraServerImpl.class);
0078:
0079:            public SraServerImpl(SRAPropertyContext pc, SRAFileContext fc,
0080:                    PSConfigContext cc) {
0081:                this .pc = pc;
0082:                this .fc = fc;
0083:                this .cc = cc;
0084:                try {
0085:                    amc = fc.getAMPropertyContext();
0086:                } catch (Exception e) {
0087:                    e.printStackTrace();
0088:                    // DebugContext.error("Error in getting AMConfig.properties");
0089:                    logger.severe("PSSR_CSPS_ADM_MBEANS052");
0090:                }
0091:            }
0092:
0093:            private static boolean is_Windows() {
0094:                return System.getProperty("os.name").indexOf("indows") != -1;
0095:            }
0096:
0097:            public SraServerImpl(SRAPropertyContext pc, PSConfigContext cc) {
0098:                this .pc = pc;
0099:                this .fc = new SRAFileContextImpl(pc, cc);
0100:                this .cc = cc;
0101:                try {
0102:                    amc = fc.getAMPropertyContext();
0103:                } catch (Exception e) {
0104:                    e.printStackTrace();
0105:                    // DebugContext.error("Error in getting AMConfig.properties");
0106:                    logger.severe("PSSR_CSPS_ADM_MBEANS053");
0107:                }
0108:            }
0109:
0110:            public Boolean createIdentitySDKInstance() {
0111:                Boolean result = Boolean.TRUE;
0112:                File fSrc = new File(fc.getInstanceIdentityPropertiesFile());
0113:                if (fSrc.exists()) {
0114:                    // DebugContext.error("Identity properties instance file <" +
0115:                    // fSrc.getAbsolutePath() + "> already exists!");
0116:                    Object[] params2 = { fSrc.getAbsolutePath(),
0117:                            "> already exists!" };
0118:                    logger
0119:                            .log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS054",
0120:                                    params2);
0121:                    result = Boolean.FALSE;
0122:                }
0123:                if (result.booleanValue()) {
0124:                    Boolean reCopy = (fc.existsGWInstance(pc.getInstanceName())
0125:                            .booleanValue()
0126:                            || fc.existsNLPInstance(pc.getInstanceName())
0127:                                    .booleanValue() || fc.existsRWPInstance(
0128:                            pc.getInstanceName()).booleanValue()) ? Boolean.FALSE
0129:                            : Boolean.TRUE;
0130:                    result = copyFile(fc.getTemplateIdentityPropertiesFile(),
0131:                            fc.getInstanceIdentityPropertiesFile(), reCopy);
0132:                }
0133:                if (result.booleanValue()) {
0134:                    String[][] nameValues = { {
0135:                            "com.sun.identity.jss.donotInstallAtHighestPriority",
0136:                            "true" } };
0137:                    replaceTokens(fc.getInstanceIdentityPropertiesFile());
0138:                    try {
0139:                        addOrReplaceNameValues(fc
0140:                                .getInstanceIdentityPropertiesFile(),
0141:                                nameValues);
0142:                    } catch (IOException e) {
0143:                        e.printStackTrace(); // To change body of catch statement use
0144:                        // File | Settings | File Templates.
0145:                    }
0146:                }
0147:                return result;
0148:            }
0149:
0150:            public Boolean removeIdentitySDKInstance() {
0151:                if (FileUtil.deleteDir(fc.getInstanceIdentityPropertiesFile()))
0152:                    return Boolean.TRUE;
0153:                return Boolean.FALSE;
0154:            }
0155:
0156:            public Boolean createInstanceSignature() {
0157:                return Boolean.TRUE;
0158:            }
0159:
0160:            public String replaceBackSlash(String pathName) {
0161:                String result = null;
0162:
0163:                result = pathName.replace(BACK_SLASH_CHAR, FORWARD_SLASH_CHAR);
0164:
0165:                return result;
0166:            }
0167:
0168:            public Properties load(String fileName) throws IOException {
0169:                File pf = new File(fileName);
0170:                Properties result = new Properties();
0171:
0172:                FileInputStream fis = new FileInputStream(pf);
0173:                result.load(fis);
0174:                fis.close();
0175:
0176:                return result;
0177:            }
0178:
0179:            public Boolean createLoggingUserAuthenticationEntry() {
0180:                Boolean result = Boolean.TRUE;
0181:                if (amc == null) {
0182:                    try {
0183:                        amc = fc.getAMPropertyContext();
0184:                    } catch (Exception e) {
0185:                        e.printStackTrace();
0186:                        // DebugContext.error("Error in getting AMConfig.properties");
0187:                        logger.severe("PSSR_CSPS_ADM_MBEANS055");
0188:                    }
0189:                }
0190:                String chmodCommand = null;
0191:                chmodCommand = _osDefaults.getValue("chmod") + " 755 "
0192:                        + fc.getInstanceCertificatesDirectory();
0193:
0194:                try {
0195:                    if (!is_Windows())
0196:                        exec(chmodCommand);
0197:                } catch (Exception e) {
0198:                    e.printStackTrace();
0199:                    // DebugContext.error("Confiugration Error: Failed to change
0200:                    // permissions!");
0201:                    logger.severe("PSSR_CSPS_ADM_MBEANS056");
0202:                    result = Boolean.FALSE;
0203:                }
0204:
0205:                String extraLibs = fc.getExtraLibs(amc.getJDKPath());
0206:
0207:                String libraryPath = fc
0208:                        .getCreateSelfSignedCertificateLibraryPath()
0209:                        + File.pathSeparator + extraLibs;
0210:                libraryPath += File.pathSeparator
0211:                        + replaceBackSlash(System
0212:                                .getProperty("java.library.path"));
0213:
0214:                String classPath = fc.getCreateSelfSignedCertificateClassPath();
0215:
0216:                String args[] = new String[7];
0217:                String command = replaceBackSlash(amc.getJDKPath())
0218:                        + FORWARD_SLASH + "bin" + FORWARD_SLASH + "java";
0219:                args[0] = "-classpath";
0220:                args[1] = classPath;
0221:                args[2] = "com.sun.portal.cli.cert.CertUtil";
0222:                args[3] = "-option=createloguserpassword";
0223:                args[4] = fc.getInstancePlatformConfigurationFile();
0224:                args[5] = fc.getInstanceCertificatesDirectory();
0225:                args[6] = pc.getLogUserPassword();
0226:
0227:                String[] cmdArray = new String[8];
0228:                // DebugContext.message("Command = " + command);
0229:                Object[] params5 = { command };
0230:                logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS057", params5);
0231:                cmdArray[0] = command;
0232:
0233:                // DebugContext.message("Command arguments...");
0234:                logger.info("PSSR_CSPS_ADM_MBEANS058");
0235:                for (int i = 0; i < args.length; i++) {
0236:                    // DebugContext.message(i + " = " + args[i]);
0237:                    Object[] params7;
0238:                    if (i == 6) {
0239:                        params7 = new Object[] { " = ", "******" };//skip logging clear text password cr 6391672
0240:                    } else {
0241:                        params7 = new Object[] { " = ", args[i] };
0242:                    }
0243:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS059", params7);
0244:                    cmdArray[i + 1] = args[i];
0245:                }
0246:
0247:                String[] envp = new String[2];
0248:                envp[0] = "LD_LIBRARY_PATH=" + libraryPath;
0249:                envp[1] = "SHLIB_PATH=" + libraryPath;
0250:                if (is_Windows())
0251:                    envp[1] = "PATH=" + libraryPath;
0252:
0253:                // DebugContext.message("Command envp parameters are...");
0254:                logger.info("PSSR_CSPS_ADM_MBEANS060");
0255:                for (int i = 0; i < envp.length; i++) {
0256:                    // DebugContext.message(i + " = " + envp[i]);
0257:                    Object[] params9 = { " = ", envp[i] };
0258:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS061", params9);
0259:                }
0260:
0261:                try {
0262:                    int exitValue = -1;
0263:                    if (is_Windows()) {
0264:                        exitValue = execUtil.exec(command, args, envp);
0265:                    } else {
0266:                        exitValue = exec(cmdArray, envp);
0267:                    }
0268:                    if (exitValue != 0) {
0269:                        // DebugContext.error("Update logging user authentication entry
0270:                        // command returned <" + exitValue + ">");
0271:                        Object[] params10 = { exitValue + "", ">" };
0272:                        logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS062",
0273:                                params10);
0274:                        result = Boolean.FALSE;
0275:                    } else {
0276:                        // DebugContext.message("Updated logging user authentication
0277:                        // entry successfully.");
0278:                        logger.info("PSSR_CSPS_ADM_MBEANS063");
0279:                    }
0280:                } catch (Exception e) {
0281:                    e.printStackTrace();
0282:                    // DebugContext.error("Confiugration Error: Could not update logging
0283:                    // user authentication entry!");
0284:                    logger.severe("PSSR_CSPS_ADM_MBEANS064");
0285:                    result = Boolean.FALSE;
0286:                }
0287:                return result;
0288:            }
0289:
0290:            public Boolean createSelfSignedCertificate() {
0291:                Boolean result = Boolean.TRUE;
0292:                if (amc == null) {
0293:                    try {
0294:                        amc = fc.getAMPropertyContext();
0295:                    } catch (Exception e) {
0296:                        e.printStackTrace();
0297:                        // DebugContext.error("Configuration Error: Error in reading
0298:                        // AMConfig.properties!");
0299:                        logger.severe("PSSR_CSPS_ADM_MBEANS065");
0300:                    }
0301:                }
0302:                String chmodCommand = null;
0303:                chmodCommand = _osDefaults.getValue("chmod") + " 755 "
0304:                        + fc.getInstanceCertificatesDirectory();
0305:
0306:                try {
0307:                    if (!is_Windows())
0308:                        exec(chmodCommand);
0309:                } catch (Exception e) {
0310:                    e.printStackTrace();
0311:                    // DebugContext.error("Configuration Error: Failed to change
0312:                    // permissions!");
0313:                    logger.severe("PSSR_CSPS_ADM_MBEANS066");
0314:                    result = Boolean.FALSE;
0315:                }
0316:                Boolean reCopy = (fc.existsGWInstance(pc.getInstanceName())
0317:                        .booleanValue()
0318:                        || fc.existsNLPInstance(pc.getInstanceName())
0319:                                .booleanValue() || fc.existsRWPInstance(
0320:                        pc.getInstanceName()).booleanValue()) ? Boolean.FALSE
0321:                        : Boolean.TRUE;
0322:                result = copyFile(fc.getSourceRootCACertificatesFile(), fc
0323:                        .getDestinationRootCACertificatesFile(), reCopy);
0324:
0325:                if (result.booleanValue()) {
0326:                    String extraLibs = fc.getExtraLibs(amc.getJDKPath());
0327:
0328:                    String libraryPath = fc
0329:                            .getCreateSelfSignedCertificateLibraryPath()
0330:                            + File.pathSeparator + extraLibs;
0331:                    libraryPath += File.pathSeparator
0332:                            + replaceBackSlash(System
0333:                                    .getProperty("java.library.path"));
0334:
0335:                    String classPath = fc
0336:                            .getCreateSelfSignedCertificateClassPath();
0337:
0338:                    String args[] = new String[11];
0339:                    String command = replaceBackSlash(amc.getJDKPath())
0340:                            + FORWARD_SLASH + "bin" + FORWARD_SLASH + "java";
0341:                    args[0] = "-classpath";
0342:                    args[1] = classPath;
0343:                    args[2] = "com.sun.portal.cli.cert.CertUtil";
0344:                    args[3] = "-option=createselfsigncert";
0345:                    args[4] = fc.getInstanceCertificatesDirectory();
0346:                    args[5] = pc.getCertificateDatabasePassword();
0347:                    args[6] = "en_US";
0348:                    args[7] = pc.getSelfSignedCertificateInformation();
0349:                    args[8] = "";
0350:                    args[9] = "server-cert";
0351:                    args[10] = "6";
0352:
0353:                    String[] cmdArray = new String[12];
0354:                    // DebugContext.message("Command = " + command);
0355:                    Object[] params15 = { command };
0356:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS067", params15);
0357:                    cmdArray[0] = command;
0358:
0359:                    // DebugContext.message("Command arguments...");
0360:                    logger.info("PSSR_CSPS_ADM_MBEANS068");
0361:                    for (int i = 0; i < args.length; i++) {
0362:                        // DebugContext.message(i + " = " + args[i]);
0363:                        Object[] params17;
0364:                        if (i == 5) {
0365:                            params17 = new Object[] { " = ", "******" };//skip logging clear text password cr 6391672
0366:                        } else {
0367:                            params17 = new Object[] { " = ", args[i] };
0368:                        }
0369:
0370:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS069",
0371:                                params17);
0372:                        cmdArray[i + 1] = args[i];
0373:                    }
0374:
0375:                    String[] envp = new String[2];
0376:                    envp[0] = "LD_LIBRARY_PATH=" + libraryPath;
0377:                    envp[1] = "SHLIB_PATH=" + libraryPath;
0378:                    if (is_Windows())
0379:                        envp[1] = "PATH=" + libraryPath;
0380:
0381:                    // DebugContext.message("Command envp parameters are...");
0382:                    logger.info("PSSR_CSPS_ADM_MBEANS070");
0383:                    for (int i = 0; i < envp.length; i++) {
0384:                        // DebugContext.message(i + " = " + envp[i]);
0385:                        Object[] params19 = { " = ", envp[i] };
0386:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS071",
0387:                                params19);
0388:                    }
0389:
0390:                    try {
0391:                        int exitValue = -1;
0392:                        // args[8] is an empty argument. " needs to be there
0393:                        //for separating each argument in windows. args[7] itself
0394:                        //is having the ". So args[7] replaced with \" and 
0395:                        //" added for all arguments.
0396:                        if (is_Windows()) {
0397:                            args[7] = args[7].replaceAll("\"", "\\\\\\\"");
0398:                            String[] cmdArr = new String[args.length];
0399:                            for (int i = 0; i < args.length; i++) {
0400:                                cmdArr[i] = "\"" + args[i] + "\"";
0401:                            }
0402:                            exitValue = execUtil.exec(command, cmdArr, envp);
0403:                        } else {
0404:                            exitValue = exec(cmdArray, envp);
0405:                        }
0406:                        if (exitValue != 0) {
0407:                            // DebugContext.error("Create self signed certificate
0408:                            // command returned <" + exitValue + ">");
0409:                            Object[] params20 = { exitValue + "", ">" };
0410:                            logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS072",
0411:                                    params20);
0412:                            result = Boolean.FALSE;
0413:                        } else {
0414:                            // DebugContext.message("Created self signed certificate
0415:                            // successfully.");
0416:                            logger.info("PSSR_CSPS_ADM_MBEANS073");
0417:                        }
0418:                    } catch (Exception e) {
0419:                        e.printStackTrace();
0420:                        // DebugContext.error("Confiugration Error: Could not create
0421:                        // self signed certificate!");
0422:                        logger.severe("PSSR_CSPS_ADM_MBEANS074");
0423:                        result = Boolean.FALSE;
0424:                    }
0425:
0426:                }
0427:
0428:                String key3Db = fc.getInstanceCertificatesDirectory()
0429:                        + "/key3.db";
0430:                String cert8Db = fc.getInstanceCertificatesDirectory()
0431:                        + "/cert8.db";
0432:                String secmodDb = fc.getInstanceCertificatesDirectory()
0433:                        + "/secmod.db";
0434:                File key3DbFile = new File(key3Db);
0435:                if (key3DbFile.exists()) {
0436:                    String cmd = null;
0437:                    cmd = _osDefaults.getValue("chmod") + " 644 " + key3Db
0438:                            + " " + cert8Db + " " + secmodDb;
0439:                    try {
0440:                        if (!is_Windows())
0441:                            exec(cmd);
0442:                    } catch (Exception e) {
0443:                        e.printStackTrace();
0444:                        // DebugContext.error("Confiugration Error: Failed to change
0445:                        // permissions!");
0446:                        logger.severe("PSSR_CSPS_ADM_MBEANS075");
0447:                        result = Boolean.FALSE;
0448:                    }
0449:                }
0450:                return result;
0451:            }
0452:
0453:            public Boolean native2Ascii() {
0454:                Boolean result = Boolean.TRUE;
0455:                String cmd = null;
0456:                String fromFile = fc.getInstanceIdentityPropertiesFile();
0457:                String toFile = fc.getInstanceIdentityPropertiesFile() + "+";
0458:                if (amc == null) {
0459:                    try {
0460:                        amc = fc.getAMPropertyContext();
0461:                    } catch (Exception e) {
0462:                        e.printStackTrace();
0463:                        // DebugContext.error("Configuration Error: Error in reading
0464:                        // AMConfig.properties");
0465:                        logger.severe("PSSR_CSPS_ADM_MBEANS076");
0466:                    }
0467:                }
0468:                cmd = fc.getNative2Ascii(amc.getJDKPath()) + " " + fromFile
0469:                        + " " + toFile;
0470:                try {
0471:                    int exitValue = exec(cmd);
0472:                    if (exitValue != 0) {
0473:                        // DebugContext.error("Failed to execute native2ascii <" +
0474:                        // exitValue + ">");
0475:                        Object[] params25 = { exitValue + "", ">" };
0476:                        logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS077",
0477:                                params25);
0478:                        result = Boolean.FALSE;
0479:                    } else {
0480:                        copyFile(toFile, fromFile, Boolean.TRUE);
0481:                        FileUtil.deleteDir(toFile);
0482:                    }
0483:                } catch (Exception e) {
0484:                    e.printStackTrace();
0485:                    // DebugContext.error("Confiugration Error: Unable to execute
0486:                    // native2ascii");
0487:                    logger.severe("PSSR_CSPS_ADM_MBEANS078");
0488:                    result = Boolean.FALSE;
0489:                }
0490:                return result;
0491:            }
0492:
0493:            public Boolean copyFile(String src, String dst, Boolean recopy) {
0494:                Boolean result = Boolean.TRUE;
0495:
0496:                File fSrc = new File(src);
0497:                if (!fSrc.exists()) {
0498:                    // DebugContext.error("Installation error: Cannot find <" +
0499:                    // fSrc.getAbsolutePath() + ">!");
0500:                    Object[] params27 = { fSrc.getAbsolutePath(), ">!" };
0501:                    logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS079",
0502:                            params27);
0503:                    result = Boolean.FALSE;
0504:                }
0505:
0506:                if (result.booleanValue()) {
0507:                    File fDst = new File(dst);
0508:
0509:                    if (!recopy.booleanValue()) {
0510:                        if (fDst.exists()) {
0511:                            // DebugContext.message("File <" + fDst.getAbsolutePath() +
0512:                            // "> already exists. Not re-copying.");
0513:                            Object[] params28 = { fDst.getAbsolutePath(),
0514:                                    "> already exists. Not re-copying." };
0515:                            logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS080",
0516:                                    params28);
0517:                            result = Boolean.FALSE;
0518:                        }
0519:                    }
0520:
0521:                    if (result.booleanValue()) {
0522:                        FileUtil.copyFile(fSrc, fDst);
0523:                    }
0524:                }
0525:
0526:                return result;
0527:            }
0528:
0529:            Boolean CheckPortalInstance() {
0530:                Properties instancePlatformConfigProperties;
0531:                Boolean result = Boolean.FALSE;
0532:                try {
0533:                    instancePlatformConfigProperties = load(fc
0534:                            .getInstancePlatformConfigurationFile());
0535:                    String PORTAL_HOST = instancePlatformConfigProperties
0536:                            .getProperty("portal.server.host");
0537:                    String PORTAL_PORT = instancePlatformConfigProperties
0538:                            .getProperty("portal.server.port");
0539:                    String no_of_tries = instancePlatformConfigProperties
0540:                            .getProperty("gateway.retries");
0541:                    return CheckPort(PORTAL_HOST, PORTAL_PORT, Integer
0542:                            .parseInt(no_of_tries));
0543:                } catch (Exception e) {
0544:                    e.printStackTrace();
0545:                    // DebugContext.error("Confiugration Error: Error reading instance
0546:                    // platform.conf file!");
0547:                    logger.severe("PSSR_CSPS_ADM_MBEANS081");
0548:                    return result;
0549:                }
0550:            }
0551:
0552:            Boolean CheckPort(String host, String port, int numRetries) {
0553:                Object[] params30 = { host, ":", port, " is alive or not" };
0554:                logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS082", params30);
0555:
0556:                for (int i = 0; i < numRetries; i++) {
0557:                    try {
0558:                        Socket s = new Socket(host, Integer.parseInt(port));
0559:                        Object[] params31 = { host, ":", port, " is alive!!!" };
0560:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS083",
0561:                                params31);
0562:                        s.close();
0563:                        return Boolean.TRUE;
0564:
0565:                    } catch (Exception e) {
0566:                        logger.info("PSSR_CSPS_ADM_MBEANS084");
0567:                        continue;
0568:                    }
0569:                }
0570:
0571:                return Boolean.FALSE;
0572:            }
0573:
0574:            public Boolean replaceTokens(String file) {
0575:                Boolean result = Boolean.TRUE;
0576:                if (amc == null) {
0577:                    try {
0578:                        amc = fc.getAMPropertyContext();
0579:                    } catch (Exception e) {
0580:                        e.printStackTrace();
0581:                        // DebugContext.error("Confiugration Error: Error in reading
0582:                        // AMConfig.properties");
0583:                        logger.severe("PSSR_CSPS_ADM_MBEANS085");
0584:                        return result;
0585:                    }
0586:                }
0587:                String userNamingAttr = amc.getUserNamingAttr();
0588:                int endIndx = userNamingAttr.indexOf("=");
0589:                String userNamingAttrVal = userNamingAttr.substring(0, endIndx);
0590:                String values[][] = {
0591:                        { "TEMP_DIR_PREFIX", "/var" },
0592:                        { "${JAVA_BASE_DIR}",
0593:                                replaceBackSlash(amc.getJDKPath()) },
0594:                        { "${IS_PRODUCT_DIR}", cc.getISBaseDir() },
0595:                        { "${PS_PRODUCT_DIR}", cc.getPSBaseDir() },
0596:                        { "${PS_VAR_DIR}", cc.getPSDataDir() },
0597:                        { "DEBUG_LEVEL", amc.getDebugLevel() },
0598:                        {
0599:                                "SERVER_URL",
0600:                                pc.getPortalProtocol() + "://"
0601:                                        + pc.getPortalHost() + ":"
0602:                                        + pc.getPortalPort() },
0603:                        { "DEBUG_DIR_PREFIX",
0604:                                fc.getISVarDir() + SRAFileContext.fs + "debug" },
0605:                        { "IS_INSTALL_VARDIR/IS_PRODNAME/debug",
0606:                                fc.getISVarDir() + SRAFileContext.fs + "debug" },
0607:                        { "INST_ORGANIZATION", amc.getDefaultOrganization() },
0608:                        { "SERVER_PROTO", amc.getAMServerProtocol() },
0609:                        { "SERVER_HOST", amc.getAMServerHost() },
0610:                        { "SERVER_PORT", amc.getAMServerPort() },
0611:                        { "HOST_NAME", pc.getPortalHost() },
0612:                        {
0613:                                "PROFILE_URLSERVER_DEPLOY_URI",
0614:                                amc.getAMServerProtocol() + "://"
0615:                                        + amc.getAMServerHost() + ":"
0616:                                        + amc.getAMServerPort()
0617:                                        + amc.getAMServerDeployURI() },
0618:                        {
0619:                                "NOTIFICATION_URL",
0620:                                amc.getAMServerProtocol() + "://"
0621:                                        + amc.getAMServerHost() + ":"
0622:                                        + amc.getAMServerPort()
0623:                                        + amc.getAMServerDeployURI()
0624:                                        + "/notificationservice" },
0625:                        { "CURRENT_PLATFORM_LOCALE", amc.getPlatformLocale() },
0626:                        { "JDK_PATH", replaceBackSlash(amc.getJDKPath()) },
0627:                        { "ORG_BASE", amc.getDefaultOrganization() },
0628:                        { "USER_NAMING_ATTR", userNamingAttrVal },
0629:                        { "AM_ENC_PWD", amc.getEncryptionKey() },
0630:                        { "CONSOLE_PROTO", pc.getPortalProtocol() },
0631:                        { "CONSOLE_HOST", pc.getPortalHost() },
0632:                        { "CONSOLE_PORT", pc.getPortalPort() },
0633:                        { "PROFILE_HOST", pc.getPortalHost() },
0634:                        { "PROFILE_PORT", pc.getPortalPort() },
0635:                        { "BASEDIR/PRODUCT_DIR", cc.getISBaseDir() },
0636:                        { "SERVER_DEPLOY_URI", amc.getAMServerDeployURI() },
0637:                        { "APPSERVERDEPLOYMENT", "false" },
0638:                        { "FULLHOSTNAME", pc.getPortalHost() },
0639:                        { "DEPLOY_URI", pc.getPortalDeployURI() },
0640:                        { "DPRO_VERSION", amc.getDPROVersion() },
0641:                        { "GW_PROTOCOL", pc.getProtocol() },
0642:                        { "GW_HOST", pc.getHost() },
0643:                        { "GW_PORT", pc.getPort() },
0644:                        { "SSL_CONNECTION", "true" },
0645:                        { "GW_VIRTUAL_HOST", pc.getHost() + " " + pc.getIP() },
0646:                        { "GATEWAY_IPADDR", pc.getIP() },
0647:                        { "CERT_DB_DIR", fc.getInstanceCertificatesDirectory() },
0648:                        { "GW_INSTANCE_NAME", pc.getInstanceName() },
0649:                        { "WEBSERVER_HOST", pc.getPortalHost() } };
0650:                try {
0651:                    replaceTokens(file, values);
0652:                } catch (IOException ioe) {
0653:                    return Boolean.FALSE;
0654:                }
0655:
0656:                return result;
0657:            }
0658:
0659:            public int exec(String command) throws IOException {
0660:                Process process = Runtime.getRuntime().exec(command);
0661:                return getExitValue(process);
0662:            }
0663:
0664:            protected int getExitValue(Process process) {
0665:                int result = 0;
0666:                try {
0667:                    // DebugContext.message("Waiting for child process to finish...");
0668:                    logger.info("PSSR_CSPS_ADM_MBEANS086");
0669:                    result = process.waitFor();
0670:                    // DebugContext.message("Child process finished.");
0671:                    logger.info("PSSR_CSPS_ADM_MBEANS087");
0672:                } catch (InterruptedException ie) {
0673:                    if (is_Windows())
0674:                        process.destroy();
0675:                }
0676:                return result;
0677:            }
0678:
0679:            public int exec(String[] cmdArray, String[] envp)
0680:                    throws IOException {
0681:                Process process = Runtime.getRuntime().exec(cmdArray, envp);
0682:                return getExitValue(process);
0683:            }
0684:
0685:            public Boolean replaceTokens(String fileName, String[][] nameValues)
0686:                    throws IOException {
0687:                Boolean result = Boolean.TRUE;
0688:                File f = new File(fileName);
0689:                LineNumberReader lnr = new LineNumberReader(new FileReader(f));
0690:                File fParent = f.getParentFile();
0691:                File t = File.createTempFile("SRA", null, fParent);
0692:                PrintWriter pw = new PrintWriter(new FileWriter(t));
0693:
0694:                String line = "";
0695:                StringBuffer fb = null;
0696:                do {
0697:                    line = lnr.readLine();
0698:                    if (line == null)
0699:                        break;
0700:
0701:                    fb = null;
0702:                    for (int i = 0; i < nameValues.length; i++) {
0703:                        int location = line.indexOf(nameValues[i][0]);
0704:                        while (location != -1) {
0705:                            fb = new StringBuffer(line.substring(0, location));
0706:                            fb.append(nameValues[i][1]);
0707:                            fb.append(line.substring(location
0708:                                    + nameValues[i][0].length()));
0709:                            line = fb.toString();
0710:
0711:                            location = line.indexOf(nameValues[i][0]);
0712:                        }
0713:                    }
0714:
0715:                    if (fb == null)
0716:                        pw.println(line);
0717:                    else {
0718:                        // DebugContext.message("Updated line <" + line + ">");
0719:                        Object[] params36 = { line, ">" };
0720:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS088",
0721:                                params36);
0722:                        pw.println(line);
0723:                    }
0724:                } while (true);
0725:
0726:                lnr.close();
0727:                pw.close();
0728:
0729:                result = f.delete() ? Boolean.TRUE : Boolean.FALSE;
0730:                if (result.booleanValue()) {
0731:                    copyFile(t.getAbsolutePath(), f.getAbsolutePath(),
0732:                            Boolean.TRUE);
0733:                    result = t.delete() ? Boolean.TRUE : Boolean.FALSE;
0734:                    if (!result.booleanValue()) {
0735:                        // DebugContext.message("Could not delete <" +
0736:                        // t.getAbsolutePath() + ">!");
0737:                        Object[] params37 = { t.getAbsolutePath(), ">!" };
0738:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS089",
0739:                                params37);
0740:                        // DebugContext.message("Please delete <" + t.getAbsolutePath()
0741:                        // + ">");
0742:                        Object[] params38 = { t.getAbsolutePath(), ">" };
0743:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS090",
0744:                                params38);
0745:                    }
0746:                } else {
0747:                    // DebugContext.message("Could not delete <" + f.getAbsolutePath() +
0748:                    // ">!");
0749:                    Object[] params39 = { f.getAbsolutePath(), ">!" };
0750:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS091", params39);
0751:                    // DebugContext.message("Please copy <" + t.getAbsolutePath() + ">
0752:                    // to <" + f.getAbsolutePath() + ">");
0753:                    Object[] params40 = { t.getAbsolutePath(), "> to <",
0754:                            f.getAbsolutePath(), ">" };
0755:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS092", params40);
0756:                }
0757:
0758:                return result;
0759:            }
0760:
0761:            public Boolean addOrReplaceNameValues(String fileName,
0762:                    String[][] nameValues) throws IOException {
0763:                Boolean result = Boolean.TRUE;
0764:                Boolean[] updated = new Boolean[nameValues.length];
0765:                for (int i = 0; i < nameValues.length; i++)
0766:                    updated[i] = Boolean.FALSE;
0767:
0768:                File f = new File(fileName);
0769:                LineNumberReader lnr = new LineNumberReader(new FileReader(f));
0770:
0771:                File fParent = f.getParentFile();
0772:                File t = File.createTempFile("SRA", null, fParent);
0773:                PrintWriter pw = new PrintWriter(new FileWriter(t));
0774:
0775:                String line = "";
0776:                do {
0777:                    line = lnr.readLine();
0778:                    if (line == null)
0779:                        break;
0780:
0781:                    int x = 0;
0782:                    int y = 0;
0783:                    for (int i = 0; i < nameValues.length; i++) {
0784:                        x = line.indexOf(nameValues[i][0]);
0785:                        y = line.indexOf("=");
0786:
0787:                        if ((x == -1) || (y == -1)) {
0788:                            continue;
0789:                        }
0790:
0791:                        if (x > y) {
0792:                            continue;
0793:                        }
0794:
0795:                        line = nameValues[i][0] + "=" + nameValues[i][1];
0796:                        updated[i] = Boolean.TRUE;
0797:                        break;
0798:                    }
0799:
0800:                    pw.println(line);
0801:                } while (true);
0802:
0803:                lnr.close();
0804:                pw.close();
0805:
0806:                result = f.delete() ? Boolean.TRUE : Boolean.FALSE;
0807:                if (result.booleanValue()) {
0808:                    copyFile(t.getAbsolutePath(), f.getAbsolutePath(),
0809:                            Boolean.FALSE);
0810:
0811:                    if (result.booleanValue()) {
0812:                        result = t.delete() ? Boolean.TRUE : Boolean.FALSE;
0813:                        if (!result.booleanValue()) {
0814:                            // DebugContext.message("Could not delete <" +
0815:                            // t.getAbsolutePath() + ">!");
0816:                            Object[] params41 = { t.getAbsolutePath(), ">!" };
0817:                            logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS093",
0818:                                    params41);
0819:                            // DebugContext.message("Please delete <" +
0820:                            // t.getAbsolutePath() + ">");
0821:                            Object[] params42 = { t.getAbsolutePath(), ">" };
0822:                            logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS094",
0823:                                    params42);
0824:                        }
0825:                    }
0826:                } else {
0827:                    // DebugContext.message("Could not delete <" + f.getAbsolutePath() +
0828:                    // ">!");
0829:                    Object[] params43 = { f.getAbsolutePath(), ">!" };
0830:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS095", params43);
0831:                    // DebugContext.message("Please copy <" + t.getAbsolutePath() + ">
0832:                    // to <" + f.getAbsolutePath() + ">");
0833:                    Object[] params44 = { t.getAbsolutePath(), "> to <",
0834:                            f.getAbsolutePath(), ">" };
0835:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS096", params44);
0836:                }
0837:
0838:                // Append not-updated name/value pairs...
0839:                if (result.booleanValue()) {
0840:                    pw = new PrintWriter(new FileWriter(fileName, true));
0841:                    pw.println();
0842:
0843:                    for (int i = 0; i < nameValues.length; i++) {
0844:                        if (!updated[i].booleanValue())
0845:                            pw.println(nameValues[i][0] + "="
0846:                                    + nameValues[i][1]);
0847:                    }
0848:
0849:                    pw.close();
0850:                }
0851:
0852:                return result;
0853:            }
0854:
0855:            public static void removeHostNameIPFromServerList(SSOToken token,
0856:                    HashMap testMap, String hostName, String ipAddress)
0857:                    throws SSOException, SMSException, Exception {
0858:                GatewayAttributeOperations test = new GatewayAttributeOperations(
0859:                        token);
0860:
0861:                String component = (String) testMap
0862:                        .get(AttrOptionConstants.OPT_COMPONENT);
0863:                String attribute = (String) testMap
0864:                        .get(AttrOptionConstants.OPT_ATTR_NAME);
0865:
0866:                List attrList = test
0867:                        .getAttribute(component, attribute, testMap);
0868:
0869:                String itemToRemove = hostName + "|" + ipAddress;
0870:                attrList.remove(itemToRemove);
0871:                test.setAttribute(component, attribute, attrList, testMap);
0872:                System.out.println(attrList);
0873:
0874:            }
0875:
0876:            public static void addHostNameIPFromServerList(SSOToken token,
0877:                    HashMap testMap, String hostName, String ipAddress)
0878:                    throws SSOException, SMSException, Exception {
0879:                GatewayAttributeOperations test = new GatewayAttributeOperations(
0880:                        token);
0881:
0882:                String component = (String) testMap
0883:                        .get(AttrOptionConstants.OPT_COMPONENT);
0884:                String attribute = (String) testMap
0885:                        .get(AttrOptionConstants.OPT_ATTR_NAME);
0886:
0887:                List attrList = test
0888:                        .getAttribute(component, attribute, testMap);
0889:
0890:                // If hostname and ip address both do not exist in the attribute then
0891:                // add them else leave
0892:                if (!isHostNameOrIPInList(attrList, hostName, ipAddress)) {
0893:                    // DebugContext.message(hostName + " or " + ipAddress + " does not
0894:                    // exist in the list");
0895:                    Object[] params45 = { " or ", ipAddress,
0896:                            " does not exist in the list" };
0897:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS097", params45);
0898:                    String itemToAdd = hostName + "|" + ipAddress;
0899:                    attrList.add(itemToAdd);
0900:                    test.setAttribute(component, attribute, attrList, testMap);
0901:                }
0902:
0903:                // test.setAttribute()
0904:                System.out.println(attrList);
0905:            }
0906:
0907:            private static boolean isHostNameOrIPInList(List attrList,
0908:                    String hostName, String ipAddress) {
0909:                boolean retValue = false;
0910:                Iterator iter = attrList.iterator();
0911:
0912:                while (iter.hasNext()) {
0913:                    String attrValue = (String) iter.next();
0914:                    // DebugContext.message("Attribute Value " + attrValue);
0915:                    Object[] params46 = { attrValue };
0916:                    logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS098", params46);
0917:
0918:                    StringTokenizer st = new StringTokenizer(attrValue, "|");
0919:                    String host, ip;
0920:                    // Each element in this list should have a hostName|ipAddress format
0921:                    if (st.hasMoreTokens()) {
0922:                        host = st.nextToken();
0923:                        if (host.equals(hostName)) {
0924:                            // DebugContext.message("Hostname exists in the attribute
0925:                            // list");
0926:                            logger.info("PSSR_CSPS_ADM_MBEANS099");
0927:                            retValue = true;
0928:                            return retValue;
0929:                        }
0930:                    }
0931:
0932:                    if (st.hasMoreTokens()) {
0933:                        ip = st.nextToken();
0934:                        if (ip.equals(ipAddress)) {
0935:                            // DebugContext.message("IP Address exists in the attribute
0936:                            // list");
0937:                            logger.info("PSSR_CSPS_ADM_MBEANS100");
0938:                            retValue = true;
0939:                            return retValue;
0940:                        }
0941:                    }
0942:
0943:                }
0944:
0945:                return retValue;
0946:            }
0947:
0948:            public void addServerInstanceInfoToProfile(String component,
0949:                    String attributeName) {
0950:                // Add the hostname and ip to the LDAP
0951:                HashMap testMap = new HashMap();
0952:                testMap.put("component", component);
0953:                testMap.put("gateway-profile", pc.getInstanceName());
0954:                testMap.put("attribute-name", attributeName);
0955:
0956:                try {
0957:                    addHostNameIPFromServerList(AdminServerUtil.getSSOToken(),
0958:                            testMap, pc.getHost(), pc.getIP());
0959:                } catch (Exception exp) {
0960:                    // DebugContext.error("Error in configuring the gateway instance");
0961:                    logger.severe("PSSR_CSPS_ADM_MBEANS101");
0962:                }
0963:            }
0964:
0965:            public void deleteServerInstanceInfoFromProfile(String component,
0966:                    String attributeName) {
0967:                // Add the hostname and ip to the LDAP
0968:                HashMap testMap = new HashMap();
0969:                testMap.put("component", component);
0970:                testMap.put("gateway-profile", pc.getInstanceName());
0971:                testMap.put("attribute-name", attributeName);
0972:
0973:                try {
0974:                    removeHostNameIPFromServerList(AdminServerUtil
0975:                            .getSSOToken(), testMap, pc.getHost(), pc.getIP());
0976:                } catch (Exception exp) {
0977:                    // DebugContext.error("Error in configuring the gateway instance");
0978:                    logger.severe("PSSR_CSPS_ADM_MBEANS102");
0979:                }
0980:            }
0981:
0982:            public static List getHostNameIPFromServerList(SSOToken token,
0983:                    HashMap testMap) throws SSOException, SMSException,
0984:                    Exception {
0985:
0986:                GatewayAttributeOperations test = new GatewayAttributeOperations(
0987:                        token);
0988:
0989:                String component = (String) testMap
0990:                        .get(AttrOptionConstants.OPT_COMPONENT);
0991:                String attribute = (String) testMap
0992:                        .get(AttrOptionConstants.OPT_ATTR_NAME);
0993:
0994:                List attrList = test
0995:                        .getAttribute(component, attribute, testMap);
0996:
0997:                /*
0998:                 * Iterator iter = attrList.iterator(); while (iter.hasNext()) { String
0999:                 * attrValue = (String) iter.next(); Object[] params46 = { attrValue };
1000:                 * logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS098", params46);
1001:                 * StringTokenizer st = new StringTokenizer(attrValue, "|"); String
1002:                 * host, ip; // Each element in this list should have a
1003:                 * hostName|ipAddress format if (st.hasMoreTokens()) { host =
1004:                 * st.nextToken(); } if (st.hasMoreTokens()) { ip = st.nextToken(); } }
1005:                 */
1006:                return attrList;
1007:            }
1008:
1009:            public static List getServerInstanceInfoFromProfile(
1010:                    String component, String attributeName, String instanceName) {
1011:                HashMap testMap = new HashMap();
1012:                testMap.put("component", component);
1013:                testMap.put("gateway-profile", instanceName);
1014:                testMap.put("attribute-name", attributeName);
1015:
1016:                try {
1017:                    return getHostNameIPFromServerList(AdminServerUtil
1018:                            .getSSOToken(), testMap);
1019:                } catch (Exception exp) {
1020:                    // DebugContext.error("Error in configuring the gateway instance");
1021:                    logger.severe("PSSR_CSPS_ADM_MBEANS101");
1022:                }
1023:                return null;
1024:            }
1025:
1026:            public boolean isStarted(String hostname, int portNumber) {
1027:                return CheckPort(hostname, portNumber + "", 2) == Boolean.TRUE ? true
1028:                        : false;
1029:            }
1030:
1031:            public boolean isStopped(String hostname, int portNumber) {
1032:                return CheckPort(hostname, portNumber + "", 2) == Boolean.TRUE ? false
1033:                        : true;
1034:            }
1035:
1036:            public void setAttribute(String host, String profile,
1037:                    String attributeName, String hostName, String ipAddress) {
1038:                try {
1039:                    HashMap testMap = new HashMap();
1040:                    testMap.put("component", Gateway.COMPONENT_NAME);
1041:                    testMap.put("gateway-profile", profile);
1042:                    testMap.put("attribute-name", attributeName);
1043:
1044:                    List attrList = getAttribute(host, profile, attributeName);
1045:
1046:                    if (!isHostNameOrIPInList(attrList, hostName, ipAddress)) {
1047:                        // DebugContext.message(hostName + " or " + ipAddress + " does not
1048:                        // exist in the list");
1049:                        Object[] params45 = { " or ", ipAddress,
1050:                                " does not exist in the list" };
1051:                        logger.log(Level.INFO, "PSSR_CSPS_ADM_MBEANS097",
1052:                                params45);
1053:                        String itemToAdd = hostName + "|" + ipAddress;
1054:                        attrList.add(itemToAdd);
1055:                        setAttributeRemote(attrList, testMap, host);
1056:
1057:                    }
1058:                    return;
1059:                } catch (Exception e) {
1060:                    logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS103", e);
1061:                }
1062:                return;
1063:            }
1064:
1065:            public void setAttributeRemote(List attrList, HashMap testMap,
1066:                    String host) throws MalformedObjectNameException,
1067:                    PSMBeanException {
1068:                ObjectName domainObj = AdminUtil
1069:                        .getPortalDomainMBeanObjectName(AdminUtil.DEFAULT_DOMAIN);
1070:                Object[] params = { attrList, testMap };
1071:                String[] signature = { "java.util.List", "java.util.Map" };
1072:
1073:                invokeRemoteOperation(host, domainObj, "setAttribute", params,
1074:                        signature);
1075:            }
1076:
1077:            public void deleteAttribute(String host, String profile,
1078:                    String attributeName, String hostName, String ipAddress) {
1079:                try {
1080:                    HashMap testMap = new HashMap();
1081:                    testMap.put("component", Gateway.COMPONENT_NAME);
1082:                    testMap.put("gateway-profile", profile);
1083:                    testMap.put("attribute-name", attributeName);
1084:
1085:                    List attrList = getAttribute(host, profile, attributeName);
1086:
1087:                    String itemToRemove = hostName + "|" + ipAddress;
1088:                    attrList.remove(itemToRemove);
1089:
1090:                    setAttributeRemote(attrList, testMap, host);
1091:                } catch (Exception e) {
1092:                    logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS103", e);
1093:                }
1094:            }
1095:
1096:            public List getAttribute(String host, String profile,
1097:                    String attributeName) {
1098:                try {
1099:                    HashMap testMap = new HashMap();
1100:                    testMap.put("component", Gateway.COMPONENT_NAME);
1101:                    testMap.put("gateway-profile", profile);
1102:                    testMap.put("attribute-name", attributeName);
1103:
1104:                    return getAttributeRemote(host, testMap);
1105:
1106:                } catch (Exception e) {
1107:                    logger.log(Level.SEVERE, "PSSR_CSPS_ADM_MBEANS103", e);
1108:                }
1109:                return null;
1110:            }
1111:
1112:            public List getAttributeRemote(String host, HashMap testMap)
1113:                    throws MalformedObjectNameException, PSMBeanException {
1114:                ObjectName domainObj = AdminUtil
1115:                        .getPortalDomainMBeanObjectName(AdminUtil.DEFAULT_DOMAIN);
1116:                Object[] params = { testMap };
1117:                String[] signature = { "java.util.Map" };
1118:
1119:                return (List) invokeRemoteOperation(host, domainObj,
1120:                        "getAttribute", params, signature);
1121:            }
1122:
1123:            protected List getNotificationURL(String defGwNotifyUrl,
1124:                    String defAmNotifyUrl,
1125:                    Properties instancePlatformConfigProperties) {
1126:                String gatewayNotificationUrl = defGwNotifyUrl;
1127:                String amNotificationUrl = defAmNotifyUrl;
1128:                /*
1129:                 * The following piece of code is added to solve RFE 6322201 regarding
1130:                 * the Notification URLs (both AM and Gateway) This RFE talks about
1131:                 * having absolute url in gateway.notification.url (of platform.conf) to
1132:                 * point to any external notification server. Also, there is another RFE
1133:                 * from a customer that if a loadbalancer is present before gateway,
1134:                 * then both notification urls should be pointing to the loadbalancer
1135:                 * irrespective of the gateway.notification.url being absolute or not.
1136:                 * If gateway.notification.url is absolute url, then this is the URL
1137:                 * that is always used as the AM Notification URL.
1138:                 * 
1139:                 * If gateway.notification.url is a relative URL, then the logic is as
1140:                 * follows * If custom http url is specified, then the URL specified in
1141:                 * that field is used as the begining of the notificatin url for AM, and
1142:                 * the relative part of the url being the value of the
1143:                 * gateway.notification.url field.
1144:                 * 
1145:                 * If no custom url is specified then the AM notification url is
1146:                 * constucted from the gateway protocol, gateway host, gateway port and
1147:                 * the relative url specified in the gateway.notification.url value
1148:                 * 
1149:                 */
1150:
1151:                boolean IsLoadBalancerPresent = instancePlatformConfigProperties
1152:                        .getProperty("gateway.enable.customurl")
1153:                        .equalsIgnoreCase("true");
1154:                boolean IsAbsoluteUrl = false;
1155:                String urlPath = gatewayNotificationUrl;
1156:                try {
1157:                    URL tempUrl = new URL(gatewayNotificationUrl);
1158:                    IsAbsoluteUrl = true;
1159:                    urlPath = tempUrl.getPath();
1160:                    if (urlPath.startsWith("/"))
1161:                        urlPath = urlPath.replaceFirst("/", "");
1162:                } catch (MalformedURLException me) {
1163:                }
1164:
1165:                if (IsAbsoluteUrl)
1166:                    amNotificationUrl = gatewayNotificationUrl;
1167:                else if (IsLoadBalancerPresent)
1168:                    amNotificationUrl = instancePlatformConfigProperties
1169:                            .getProperty("gateway.httpurl")
1170:                            + "/" + urlPath;
1171:
1172:                gatewayNotificationUrl = urlPath;
1173:
1174:                ArrayList list = new ArrayList(2);
1175:                list.add(0, gatewayNotificationUrl);
1176:                list.add(1, amNotificationUrl);
1177:
1178:                return list;
1179:
1180:            }
1181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.