0001: /**
0002: * $Id: PortalConfigData.java,v 1.57 2007/01/26 03:48:30 portalbld Exp $
0003: * Copyright 2004 Su n Microsystems, Inc. All
0004: * rights reserved. Use of this product is subject
0005: * to license terms. Federal Acquisitions:
0006: * Commercial Software -- Government Users
0007: * Subject to Standard License Terms and
0008: * Conditions.
0009: *
0010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0011: * are trademarks or registered trademarks of Sun Microsystems,
0012: * Inc. in the United States and other countries.
0013: */package com.sun.portal.fabric.config;
0014:
0015: import java.io.File;
0016: import java.io.FileInputStream;
0017: import java.io.FileNotFoundException;
0018: import java.io.FileOutputStream;
0019: import java.io.IOException;
0020: import java.io.InputStreamReader;
0021: import java.util.ArrayList;
0022: import java.util.Enumeration;
0023: import java.util.HashMap;
0024: import java.util.Iterator;
0025: import java.util.List;
0026: import java.util.Map;
0027: import java.util.Properties;
0028:
0029: import org.jdom.Attribute;
0030: import org.jdom.Document;
0031: import org.jdom.Element;
0032: import org.jdom.JDOMException;
0033: import org.jdom.input.SAXBuilder;
0034:
0035: import com.sun.portal.fabric.util.XMLJdomUtil;
0036: import com.sun.portal.fabric.util.XMLJdomFileCreationException;
0037: import com.sun.portal.fabric.util.FileUtil;
0038: import com.sun.portal.util.Platform;
0039:
0040: import com.sun.portal.fabric.tasks.ConfigurationException;
0041:
0042: public class PortalConfigData {
0043:
0044: private Document doc = null;
0045: private Map hash = null;
0046: private Element portalConfigDetails;
0047: private Element sharedCompDetails;
0048: private Element amInstallDetails;
0049: private Element amAccessInfo;
0050: private Element psConfigInfo;
0051: private Element psInstallDetails;
0052: private Element sraCompDetails;
0053: private Element certificateInfo;
0054: private Element psComponentsToConfigure;
0055: private List searchServers = null;
0056: private List netletProxyInfo = null;
0057: private List rewriterProxyInfo = null;
0058: private List gatewayInfo = null;
0059: private List portals;
0060:
0061: // Constructor for Reader
0062: public PortalConfigData(String sFilePath)
0063: throws ConfigurationException {
0064:
0065: try {
0066: XMLJdomUtil xmlJdomUtil = new XMLJdomUtil();
0067: doc = xmlJdomUtil.readXMLFile(sFilePath);
0068: } catch (XMLJdomFileCreationException e) {
0069: throw new ConfigurationException(e.getMessage());
0070: }
0071:
0072: // TODO - High probability of NPEs here.
0073: // Needs a fix for chars per line.
0074: portalConfigDetails = doc.getRootElement()
0075: .getChild("Configure");
0076: if (portalConfigDetails != null) {
0077:
0078: sharedCompDetails = portalConfigDetails
0079: .getChild("SharedComponents");
0080: String sMFWKLibDir = (sharedCompDetails != null) ? sharedCompDetails
0081: .getAttributeValue("MFWKLibDir")
0082: : null;
0083: if (sMFWKLibDir != null) {
0084:
0085: String sMFWKBinDir = (sharedCompDetails != null) ? sharedCompDetails
0086: .getAttributeValue("MFWKBinDir")
0087: : null;
0088: if (sMFWKBinDir == null) {
0089:
0090: String OSStr = Platform.name;
0091: if ((OSStr.indexOf("Linux") != -1)
0092: || (OSStr.indexOf("HP-UX") != -1)) {
0093: sMFWKBinDir = "/opt/sun/mfwk/bin";
0094: } else {
0095: // solaris
0096: sMFWKBinDir = "/opt/SUNWmfwk/bin";
0097: }
0098: }
0099:
0100: sharedCompDetails.setAttribute("MFWKBinDir",
0101: sMFWKBinDir);
0102: }
0103:
0104: amInstallDetails = portalConfigDetails.getChild(
0105: "AccessManager").getChild("InstallationDirectory");
0106: amAccessInfo = portalConfigDetails
0107: .getChild("AccessManager").getChild(
0108: "UserCredentials");
0109: psConfigInfo = portalConfigDetails
0110: .getChild("PortalConfiguration");
0111: psInstallDetails = psConfigInfo
0112: .getChild("InstallationDirectory");
0113: searchServers = psConfigInfo.getChildren("SearchServer");
0114: portals = psConfigInfo.getChildren("PortalServer");
0115: sraCompDetails = psConfigInfo
0116: .getChild("SecureRemoteAccessCore");
0117: gatewayInfo = psConfigInfo.getChildren("Gateway");
0118: netletProxyInfo = psConfigInfo.getChildren("NetletProxy");
0119: rewriterProxyInfo = psConfigInfo
0120: .getChildren("RewriterProxy");
0121: certificateInfo = psConfigInfo
0122: .getChild("CertificateInformation");
0123:
0124: psComponentsToConfigure = psConfigInfo
0125: .getChild("ComponentsToConfigure");
0126:
0127: } else {
0128:
0129: portalConfigDetails = doc.getRootElement().getChild(
0130: "Unconfigure");
0131: amAccessInfo = portalConfigDetails
0132: .getChild("AccessManager").getChild(
0133: "UserCredentials");
0134: psConfigInfo = portalConfigDetails
0135: .getChild("PortalConfiguration");
0136: psComponentsToConfigure = psConfigInfo
0137: .getChild("ComponentsToConfigure");
0138: searchServers = psConfigInfo.getChildren("SearchServer");
0139: portals = psConfigInfo.getChildren("PortalServer");
0140: gatewayInfo = psConfigInfo.getChildren("Gateway");
0141: netletProxyInfo = psConfigInfo.getChildren("NetletProxy");
0142: rewriterProxyInfo = psConfigInfo
0143: .getChildren("RewriterProxy");
0144: }
0145: }
0146:
0147: /**
0148: * @return Access Manager Product Dir
0149: */
0150: public String getAMProdDir() {
0151: return trim(amInstallDetails.getAttributeValue("ProdDir"));
0152: }
0153:
0154: /**
0155: * @return Access Manager Config File
0156: */
0157: public String getAMConfigFile() {
0158: return trim(amInstallDetails.getAttributeValue("ConfigFile"));
0159: }
0160:
0161: /**
0162: * @return Access Manager Config Dir
0163: */
0164: public String getAMConfigDir() {
0165: return trim(amInstallDetails.getAttributeValue("ConfigDir"));
0166: }
0167:
0168: /**
0169: * @return Access Manager Data Dir
0170: */
0171: public String getAMDataDir() {
0172: return trim(amInstallDetails.getAttributeValue("DataDir"));
0173: }
0174:
0175: /**
0176: * @return Access Manager Admin UserID
0177: */
0178: public String getAMAdmin() {
0179: return trim(amAccessInfo.getAttributeValue("AdministratorUID"));
0180: }
0181:
0182: /**
0183: * @return Access Manager Admin User Password
0184: */
0185: public String getAMAdminPassword() {
0186: return trim(amAccessInfo
0187: .getAttributeValue("AdministratorUserPassword"));
0188: }
0189:
0190: /**
0191: * @return Access Manager LDAP UserID
0192: */
0193: public String getLDAPUserId() {
0194: return trim(amAccessInfo.getAttributeValue("LDAPUserId"));
0195: }
0196:
0197: /**
0198: * @return Access Manager LDAP User Password
0199: */
0200: public String getLDAPUserPassword() {
0201: return trim(amAccessInfo
0202: .getAttributeValue("LDAPUserIdPassword"));
0203: }
0204:
0205: /**
0206: * @return Directory Manager DN
0207: */
0208: public String getDirectoryManagerDN() {
0209: return trim(amAccessInfo
0210: .getAttributeValue("DirectoryManagerDn"));
0211: }
0212:
0213: /**
0214: * @return Directory Manager Password
0215: */
0216: public String getDirectoryManagerPassword() {
0217: return trim(amAccessInfo
0218: .getAttributeValue("DirectoryManagerPassword"));
0219: }
0220:
0221: /**
0222: * @return Portal Configuration Mode. Possible return values are configure,
0223: * unconfigure and upgrade.
0224: */
0225: public String getPSConfigMode() {
0226:
0227: List configmode = doc.getRootElement().getChildren();
0228: Iterator it = configmode.iterator();
0229: String mode = null;
0230: if (it.hasNext()) {
0231:
0232: Element configurationType = (Element) it.next();
0233: if (configurationType.getName().equals("Configure")) {
0234: mode = "Configure";
0235: }
0236: if (configurationType.getName().equals("Unconfigure")) {
0237: mode = "Unconfigure";
0238: }
0239: }
0240: return mode;
0241: }
0242:
0243: /**
0244: * @return Portal Server Product Dir
0245: */
0246: public String getPSProdDir() {
0247: return trim(psInstallDetails.getAttributeValue("ProdDir"));
0248: }
0249:
0250: /**
0251: * @return Portal Server Config Dir
0252: */
0253: public String getPSConfigDir() {
0254: return trim(psInstallDetails.getAttributeValue("ConfigDir"));
0255: }
0256:
0257: /**
0258: * @return Portal Server Data Dir
0259: */
0260: public String getPSDataDir() {
0261: return trim(psInstallDetails.getAttributeValue("DataDir"));
0262: }
0263:
0264: /**
0265: * @return Map sharedCompDetails
0266: */
0267: public Map getsharedCompDetails() {
0268:
0269: Iterator it = sharedCompDetails.getAttributes().iterator();
0270:
0271: HashMap hm = new HashMap();
0272:
0273: while (it.hasNext()) {
0274: Attribute Attr = (Attribute) it.next();
0275: hm.put(Attr.getName(), trim(Attr.getValue()));
0276: }
0277:
0278: return hm;
0279: }
0280:
0281: /**
0282: * @return Java Home Dir
0283: */
0284: public String getJavaHome() {
0285: return trim(sharedCompDetails.getAttributeValue("JavaHome"));
0286: }
0287:
0288: /**
0289: * @return Cacao Server Home Dir
0290: */
0291: public String getCacaoProdDir() {
0292: return trim(sharedCompDetails.getAttributeValue("CacaoProdDir"));
0293: }
0294:
0295: /**
0296: * @return Cacao Server Config Dir
0297: */
0298: public String getCacaoConfigDir() {
0299: return trim(sharedCompDetails
0300: .getAttributeValue("CacaoConfigDir"));
0301: }
0302:
0303: /**
0304: * @return Shared Components Lib Location
0305: */
0306: public String getShareLibDir() {
0307: return trim(sharedCompDetails.getAttributeValue("SharedLibDir"));
0308: }
0309:
0310: /**
0311: * @return Shared Components private Lib Location
0312: */
0313: public String getPrivateLibDir() {
0314: return trim(sharedCompDetails
0315: .getAttributeValue("PrivateLibDir"));
0316: }
0317:
0318: /**
0319: * @return JDMK Component Lib Location
0320: */
0321: public String getJDMKLibDir() {
0322: return trim(sharedCompDetails.getAttributeValue("JDMKLibDir"));
0323: }
0324:
0325: /**
0326: * @return NSS Component Lib Location
0327: */
0328: public String getNSSLibDir() {
0329: return trim(sharedCompDetails.getAttributeValue("NSSLibDir"));
0330: }
0331:
0332: /**
0333: * @return JSS Component Jar Location
0334: */
0335: public String getJSSJarDir() {
0336: return trim(sharedCompDetails.getAttributeValue("JSSJarDir"));
0337: }
0338:
0339: /**
0340: * @return KT-Search Shared Component Lib Location
0341: */
0342: public String getKTSearchLibDir() {
0343: return trim(sharedCompDetails
0344: .getAttributeValue("KTSearchLibDir"));
0345: }
0346:
0347: /**
0348: * @return WEB-NFS Shared Component Lib Location
0349: */
0350: public String getWebNFSLibDir() {
0351: return trim(sharedCompDetails.getAttributeValue("WebNFSLibDir"));
0352: }
0353:
0354: /**
0355: * @return ANT Shared Component Lib Location
0356: */
0357: public String getAntLibDir() {
0358: return trim(sharedCompDetails.getAttributeValue("AntLibDir"));
0359: }
0360:
0361: /**
0362: * @return Derby Shared Component Lib Location
0363: */
0364: public String getDerbyLibDir() {
0365: return trim(sharedCompDetails.getAttributeValue("DerbyLibDir"));
0366: }
0367:
0368: /**
0369: * @return ANT Home Dir
0370: */
0371: public String getAntHomeDir() {
0372: return trim(sharedCompDetails.getAttributeValue("AntHomeDir"));
0373: }
0374:
0375: /**
0376: * @return Registry Shared Component Lib Location
0377: */
0378: public String getRegistryLibDir() {
0379: return trim(sharedCompDetails
0380: .getAttributeValue("RegistryLibDir"));
0381: }
0382:
0383: /**
0384: * @return Monitoring framework Lib Location
0385: */
0386: public String getMFWKLibDir() {
0387:
0388: String sMfwkLibdir = trim(sharedCompDetails
0389: .getAttributeValue("MFWKLibDir"));
0390: if (sMfwkLibdir == null) {
0391: sMfwkLibdir = "";
0392: }
0393:
0394: return sMfwkLibdir;
0395: }
0396:
0397: public String getMFWKBinDir() {
0398:
0399: String sMfwkBinDir = trim(sharedCompDetails
0400: .getAttributeValue("MFWKBinDir"));
0401: if (sMfwkBinDir == null) {
0402: sMfwkBinDir = "";
0403: }
0404:
0405: return sMfwkBinDir;
0406: }
0407:
0408: /**
0409: * @return JAX Lib Location. Currently used to return the JAX-XWSS jar files location
0410: */
0411: public String getJAXLibDir() {
0412:
0413: String sJAXLibdir = trim(sharedCompDetails
0414: .getAttributeValue("JAXLibDir"));
0415: if (sJAXLibdir == null) {
0416: sJAXLibdir = "";
0417: }
0418:
0419: return sJAXLibdir;
0420: }
0421:
0422: /**
0423: * @return List of Portal Components To Configure
0424: */
0425: public List getPSComponentsToConfigure() {
0426:
0427: List components = new ArrayList();
0428: if (psComponentsToConfigure != null) {
0429: Iterator componentsItr = psComponentsToConfigure
0430: .getChildren("component").iterator();
0431: while (componentsItr.hasNext()) {
0432: Element comp = (Element) componentsItr.next();
0433: components.add(comp.getTextTrim());
0434: }
0435: }
0436: return components;
0437: }
0438:
0439: /**
0440: * @return List of Portal Components To UnConfigure
0441: */
0442: public List getPSComponentsToUnConfigure() {
0443:
0444: List components = new ArrayList();
0445: Iterator componentsItr = psComponentsToConfigure.getChildren(
0446: "component").iterator();
0447: while (componentsItr.hasNext()) {
0448: Element comp = (Element) componentsItr.next();
0449: components.add(comp.getTextTrim());
0450: }
0451: return components;
0452: }
0453:
0454: /**
0455: * @return Portal Server HostName
0456: */
0457: public String getConfigHostName() {
0458: return trim(portalConfigDetails
0459: .getAttributeValue("ConfigurationHostName"));
0460: }
0461:
0462: /**
0463: * @return SystemUser
0464: */
0465: public String getSystemUser() {
0466: return trim(portalConfigDetails.getAttributeValue("SystemUser"));
0467: }
0468:
0469: /**
0470: * @return SystemGroup
0471: */
0472: public String getSystemGroup() {
0473: return trim(portalConfigDetails
0474: .getAttributeValue("SystemGroup"));
0475: }
0476:
0477: /**
0478: * @return SystemGroup
0479: */
0480: public String isValidateData() {
0481: return portalConfigDetails.getAttributeValue("Validate");
0482: }
0483:
0484: public String getportalAccessURL() {
0485: String portalAccessURL = null;
0486:
0487: if (psConfigInfo.getChildText("PortalServer") != null) {
0488: if (psConfigInfo.getChild("PortalServer")
0489: .getAttributeValue("PortalAccessURL") != null)
0490: portalAccessURL = trim(psConfigInfo.getChild(
0491: "PortalServer").getAttributeValue(
0492: "PortalAccessURL"));
0493: }
0494:
0495: return portalAccessURL;
0496: }
0497:
0498: /**
0499: * @return the main portal host in case of cluster lb scenarios
0500: * where portalAccessURL is not same as primaryPortalHost
0501: */
0502: public String getPrimaryPortalHost() {
0503: String portalHost = null;
0504:
0505: if (psConfigInfo.getChildText("PortalServer") != null) {
0506: if (psConfigInfo.getChild("PortalServer")
0507: .getAttributeValue("PrimaryPortalHost") != null)
0508: portalHost = psConfigInfo.getChild("PortalServer")
0509: .getAttributeValue("PrimaryPortalHost");
0510: }
0511:
0512: return portalHost;
0513: }
0514:
0515: /**
0516: * @return a Map of Web Container Properties
0517: */
0518: public Map getPSWebContainerProp(List portalInstances) {
0519:
0520: Iterator it = portalInstances.iterator();
0521: Map hm = new HashMap();
0522: String instanceID;
0523: while (it.hasNext()) {
0524: Properties prop = new Properties();
0525: Element wcinfo = (Element) it.next();
0526: instanceID = trim(wcinfo.getAttributeValue("InstanceID"));
0527: List webcont = wcinfo.getChild("WebContainerProperties")
0528: .getAttributes();
0529: Iterator webcontItr = webcont.iterator();
0530:
0531: while (webcontItr.hasNext()) {
0532: Attribute Attr = (Attribute) webcontItr.next();
0533: prop.setProperty(Attr.getName(), trim(Attr.getValue()));
0534: }
0535: hm.put(instanceID, prop);
0536: }
0537: return hm;
0538: }
0539:
0540: /**
0541: * @return a Map of Search Server Properties.
0542: */
0543: public Map getSearchServerDetails() {
0544:
0545: Iterator it = searchServers.iterator();
0546: HashMap hm = new HashMap();
0547: String searchID;
0548:
0549: while (it.hasNext()) {
0550: Properties prop = new Properties();
0551: Element searchInfo = (Element) it.next();
0552: searchID = trim(searchInfo
0553: .getAttributeValue("SearchServerID"));
0554:
0555: Element wcinfo = searchInfo
0556: .getChild("WebContainerProperties");
0557: List webcont = wcinfo.getAttributes();
0558: Iterator webcontItr = webcont.iterator();
0559:
0560: while (webcontItr.hasNext()) {
0561: Attribute Attr = (Attribute) webcontItr.next();
0562: prop.setProperty(Attr.getName(), trim(Attr.getValue()));
0563: }
0564: hm.put(searchID, prop);
0565: }
0566: return hm;
0567: }
0568:
0569: /**
0570: * @return Portal Server Data.
0571: */
0572: public Map getPortalServerData() {
0573:
0574: Iterator it = portals.iterator();
0575: HashMap hm = new HashMap();
0576: Map portalInstancesData = new HashMap();
0577: List portalInstances = new ArrayList();
0578: String portalID;
0579:
0580: while (it.hasNext()) {
0581: List portalDeploymentInfo = new ArrayList();
0582: Element portal = (Element) it.next();
0583: portalID = trim(portal.getAttributeValue("PortalID"));
0584:
0585: portalDeploymentInfo.add(trim(portal
0586: .getAttributeValue("PortalWebappURI")));
0587: portalDeploymentInfo.add(trim(portal
0588: .getAttributeValue("PortalAccessURL")));
0589: portalInstances = portal.getChildren("Instance");
0590: portalInstancesData = getPSWebContainerProp(portalInstances);
0591: portalDeploymentInfo.add(portalInstancesData);
0592: portalDeploymentInfo.add(trim(portal
0593: .getAttributeValue("SearchServerID")));
0594: hm.put(portalID, portalDeploymentInfo);
0595: }
0596: return hm;
0597: }
0598:
0599: /**
0600: * Returns a Map of portalIDs
0601: * With an ArrayList of instanceIDs per portalID
0602: */
0603: public Map getPortalInstances() {
0604:
0605: Iterator it = portals.iterator();
0606: HashMap hm = new HashMap();
0607: List portalInstances = new ArrayList();
0608: String instanceID = "";
0609: String portalID;
0610:
0611: while (it.hasNext()) {
0612:
0613: Element portal = (Element) it.next();
0614: portalID = trim(portal.getAttributeValue("PortalID"));
0615: portalInstances = portal.getChildren("Instance");
0616: Iterator itr = portalInstances.iterator();
0617: ArrayList portalIDInstances = new ArrayList();
0618:
0619: while (itr.hasNext()) {
0620: Element instance = (Element) itr.next();
0621: instanceID = trim(instance
0622: .getAttributeValue("InstanceID"));
0623: portalIDInstances.add(instanceID);
0624: }
0625:
0626: hm.put(portalID, portalIDInstances);
0627:
0628: }
0629:
0630: return hm;
0631: }
0632:
0633: /**
0634: * @return Portal Server Data.
0635: */
0636: public Map getSamplePortalData() {
0637:
0638: Iterator it = portals.iterator();
0639: HashMap hm = new HashMap();
0640: Map portalInstancesData = new HashMap();
0641: List portalInstances = new ArrayList();
0642: String portalID;
0643: Element samplePortal;
0644: Element profiler;
0645: Element mail;
0646: Element calendar;
0647: Element addressBook;
0648: Element instantMessenger;
0649: String enterprisePortal = "false";
0650: String developerPortal = "false";
0651: String communityPortal = "false";
0652:
0653: while (it.hasNext()) {
0654: List portalDeploymentInfo = new ArrayList();
0655: Element portal = (Element) it.next();
0656: portalID = trim(portal.getAttributeValue("PortalID"));
0657:
0658: portalDeploymentInfo.add(trim(portal
0659: .getAttributeValue("PortalWebappURI")));
0660: portalDeploymentInfo.add(trim(portal
0661: .getAttributeValue("PortalAccessURL")));
0662: portalDeploymentInfo.add(trim(portal
0663: .getAttributeValue("SearchServerID")));
0664:
0665: samplePortal = portal.getChild("SamplePortal");
0666: profiler = portal.getChild("Profiler");
0667: mail = portal.getChild("MailServer");
0668: calendar = portal.getChild("CalendarServer");
0669: addressBook = portal.getChild("AddressBookServer");
0670: instantMessenger = portal
0671: .getChild("InstantMessagingServer");
0672:
0673: if (samplePortal != null) {
0674: List samples = new ArrayList();
0675: samples = samplePortal.getChildren("Sample");
0676: Iterator itr = samples.iterator();
0677: while (itr.hasNext()) {
0678: Element sample = (Element) itr.next();
0679: String sampleName = trim(sample
0680: .getAttributeValue("Name"));
0681: if (sampleName.equals("DeveloperPortal")
0682: || sampleName.equals("CommunityPortal")
0683: || sampleName.equals("EnterprisePortal")) {
0684: if (sampleName.equals("DeveloperPortal")) {
0685: developerPortal = "true";
0686: }
0687: if (sampleName.equals("EnterprisePortal")) {
0688: enterprisePortal = "true";
0689: }
0690: if (sampleName.equals("CommunityPortal")) {
0691: communityPortal = "true";
0692: }
0693: }
0694: }
0695: }
0696: portalDeploymentInfo.add(developerPortal);
0697: portalDeploymentInfo.add(enterprisePortal);
0698: portalDeploymentInfo.add(communityPortal);
0699:
0700: if (profiler != null) {
0701: portalDeploymentInfo.add(profiler.getAttributes());
0702: } else {
0703: portalDeploymentInfo.add(new ArrayList());
0704: }
0705: if (mail != null) {
0706: portalDeploymentInfo.add(mail.getAttributes());
0707: } else {
0708: portalDeploymentInfo.add(new ArrayList());
0709: }
0710: if (calendar != null) {
0711: portalDeploymentInfo.add(calendar.getAttributes());
0712: } else {
0713: portalDeploymentInfo.add(new ArrayList());
0714: }
0715: if (addressBook != null) {
0716: portalDeploymentInfo.add(addressBook.getAttributes());
0717: } else {
0718: portalDeploymentInfo.add(new ArrayList());
0719: }
0720: if (instantMessenger != null) {
0721: portalDeploymentInfo.add(instantMessenger
0722: .getAttributes());
0723: } else {
0724: portalDeploymentInfo.add(new ArrayList());
0725: }
0726:
0727: portalInstances = portal.getChildren("Instance");
0728: portalInstancesData = getPSWebContainerProp(portalInstances);
0729: portalDeploymentInfo.add(portalInstancesData);
0730: hm.put(portalID, portalDeploymentInfo);
0731: }
0732:
0733: return hm;
0734: }
0735:
0736: /**
0737: * If <sra component details> element is not present then
0738: * the configurator configures sra with default values
0739: */
0740: public String getSRAGatewayProtocol() {
0741: if (sraCompDetails == null)
0742: return "https";
0743: else
0744: return trim(sraCompDetails
0745: .getAttributeValue("GatewayProtocol"));
0746: }
0747:
0748: public String getSRAPortalServerDomain()
0749: throws ConfigurationException {
0750: if (sraCompDetails == null) {
0751: String host = getConfigHostName();
0752: if ((host != null) && (host.indexOf(".") > -1)) {
0753: String domain = host.substring(host.indexOf(".") + 1);
0754: return domain;
0755: } else {
0756: throw new ConfigurationException("Invalid Domain");
0757: }
0758: } else {
0759: return trim(sraCompDetails
0760: .getAttributeValue("PortalServerDomain"));
0761: }
0762:
0763: }
0764:
0765: public String getSRAGatewayPortNo() {
0766: if (sraCompDetails == null)
0767: return "443";
0768: else
0769: return trim(sraCompDetails.getAttributeValue("GatewayPort"));
0770: }
0771:
0772: public String getSRAGatewayProfileName() {
0773: if (sraCompDetails == null) {
0774: System.out.println("sraCompDetails is null");
0775: return "default";
0776: } else
0777: return trim(sraCompDetails
0778: .getAttributeValue("GatewayProfileName"));
0779: }
0780:
0781: public String getSRALogUserPassword() {
0782: if (sraCompDetails == null)
0783: return getAMAdminPassword();
0784: else
0785: return trim(sraCompDetails
0786: .getAttributeValue("LogUserPassword"));
0787: }
0788:
0789: /**
0790: * @return SRAStatus
0791: * returns "on" when <sra component details> element
0792: * exists or if SRAStatus is set to on
0793: * returns "off" when <sra component details> element
0794: * is missing or if SRAStatus is explicitly set to off
0795: */
0796: public final String getSRAStatus() {
0797: if (sraCompDetails == null)
0798: return "off";
0799: else {
0800: String sSRAStatus = sraCompDetails
0801: .getAttributeValue("SRAStatus");
0802: return (sSRAStatus == null) ? "on" : sSRAStatus;
0803: }
0804: }
0805:
0806: public boolean isConfiguringSearchalone() {
0807: return portals.isEmpty();
0808: }
0809:
0810: /**
0811: * @return a Map of Gateway Properties.
0812: */
0813: public Map getGatewayDetails() {
0814:
0815: Iterator it = gatewayInfo.iterator();
0816: HashMap hm = new HashMap();
0817: String profileName;
0818:
0819: while (it.hasNext()) {
0820: Properties prop = new Properties();
0821: Element gatewayData = (Element) it.next();
0822: profileName = trim(gatewayData.getAttributeValue("Profile"));
0823:
0824: Element instanceinfo = gatewayData.getChild("SRAInstance");
0825: List instanceProp = instanceinfo.getAttributes();
0826: Iterator instancePropItr = instanceProp.iterator();
0827:
0828: while (instancePropItr.hasNext()) {
0829: Attribute Attr = (Attribute) instancePropItr.next();
0830: prop.setProperty(Attr.getName(), trim(Attr.getValue()));
0831: }
0832: hm.put(profileName, prop);
0833: }
0834: return hm;
0835: }
0836:
0837: /**
0838: * @return a Map of NetletProxy Properties.
0839: */
0840: public Map getNetletProxyDetails() {
0841:
0842: Iterator it = netletProxyInfo.iterator();
0843: HashMap hm = new HashMap();
0844: String profileName;
0845:
0846: while (it.hasNext()) {
0847: Properties prop = new Properties();
0848: Element netletProxyData = (Element) it.next();
0849: profileName = trim(netletProxyData
0850: .getAttributeValue("Profile"));
0851:
0852: Element instanceinfo = netletProxyData
0853: .getChild("SRAInstance");
0854: List instanceProp = instanceinfo.getAttributes();
0855: Iterator instancePropItr = instanceProp.iterator();
0856:
0857: while (instancePropItr.hasNext()) {
0858: Attribute Attr = (Attribute) instancePropItr.next();
0859: prop.setProperty(Attr.getName(), trim(Attr.getValue()));
0860: }
0861: hm.put(profileName, prop);
0862: }
0863: return hm;
0864: }
0865:
0866: /**
0867: * @return a Map of RewriterProxy Properties.
0868: */
0869: public Map getRewriterProxyDetails() {
0870:
0871: Iterator it = rewriterProxyInfo.iterator();
0872: HashMap hm = new HashMap();
0873: String profileName;
0874:
0875: while (it.hasNext()) {
0876: Properties prop = new Properties();
0877: Element rewriterProxyData = (Element) it.next();
0878: profileName = trim(rewriterProxyData
0879: .getAttributeValue("Profile"));
0880:
0881: Element instanceinfo = rewriterProxyData
0882: .getChild("SRAInstance");
0883: List instanceProp = instanceinfo.getAttributes();
0884: Iterator instancePropItr = instanceProp.iterator();
0885:
0886: while (instancePropItr.hasNext()) {
0887: Attribute Attr = (Attribute) instancePropItr.next();
0888: prop.setProperty(Attr.getName(), trim(Attr.getValue()));
0889: }
0890: hm.put(profileName, prop);
0891: }
0892: return hm;
0893: }
0894:
0895: public String getcertificateOrganization() {
0896: return trim(certificateInfo.getAttributeValue("Organization"));
0897: }
0898:
0899: public String getcertificateDivision() {
0900: return trim(certificateInfo.getAttributeValue("Division"));
0901: }
0902:
0903: public String getcertificateCityOrLocality() {
0904: return trim(certificateInfo.getAttributeValue("CityOrLocality"));
0905: }
0906:
0907: public String getcertificateStateProvince() {
0908: return trim(certificateInfo.getAttributeValue("StateProvince"));
0909: }
0910:
0911: public String getcertificateCountryCode() {
0912: return trim(certificateInfo.getAttributeValue("CountryCode"));
0913: }
0914:
0915: public String getCertifcateDBPassword() {
0916: return trim(certificateInfo
0917: .getAttributeValue("CertificateDatabasePassword"));
0918: }
0919:
0920: public String getIsUnconfigureAll() {
0921: return portalConfigDetails.getAttributeValue("UnconfigureAll");
0922: }
0923:
0924: public List getSearchSeversToDelete() {
0925:
0926: Iterator it = searchServers.iterator();
0927: List searchServerslist = new ArrayList();
0928: String searchID;
0929:
0930: while (it.hasNext()) {
0931: Element searchInfo = (Element) it.next();
0932: searchID = trim(searchInfo
0933: .getAttributeValue("SearchServerID"));
0934: searchServerslist.add(searchID);
0935: }
0936: return searchServerslist;
0937: }
0938:
0939: public Map getSRAComponentInstancesToDelete(
0940: String sraComponentToDelete, String hostname) {
0941:
0942: Map sraComponentInstances = new HashMap();
0943: String instanceName;
0944: List sraComponentInfo = new ArrayList();
0945:
0946: if (sraComponentToDelete.equals("gateway")) {
0947: sraComponentInfo = gatewayInfo;
0948: }
0949:
0950: if (sraComponentToDelete.equals("netletproxy")) {
0951: sraComponentInfo = netletProxyInfo;
0952: }
0953:
0954: if (sraComponentToDelete.equals("rewriterproxy")) {
0955: sraComponentInfo = rewriterProxyInfo;
0956: }
0957:
0958: Iterator it = sraComponentInfo.iterator();
0959:
0960: while (it.hasNext()) {
0961: Element sraComponent = (Element) it.next();
0962: instanceName = trim(sraComponent
0963: .getAttributeValue("Profile"));
0964: sraComponentInstances.put(instanceName, hostname);
0965: }
0966: return sraComponentInstances;
0967: }
0968:
0969: /**
0970: * returns true if only SRA components(GW/NLP/RWP) without SRACore is installed
0971: **/
0972: public boolean isOnlySRAComponentInstalled() {
0973: String fs = Platform.fs;
0974: boolean onlySRAComponentInstalled = false;
0975:
0976: //Assumes that ProdDir validation is successful
0977: String libDir = getPSProdDir() + fs + "lib";
0978: String webInfLibDir = getPSProdDir() + fs + "web-src" + fs
0979: + "WEB-INF" + fs + "lib";
0980:
0981: //Check if GW/NLP/RWP is installed
0982: //Check for gateway.jar
0983: //Note gateway.jar is found on all GW/NLP/RWP nodes
0984: if (FileUtil.fileExists(libDir + fs + "gateway.jar")) {
0985: onlySRAComponentInstalled = true;
0986:
0987: //Now check if SRA Core is installed - check for netletprovider.jar
0988: if (FileUtil.fileExists(webInfLibDir + fs
0989: + "netletprovider.jar")) {
0990: onlySRAComponentInstalled = false;
0991: }
0992: }
0993:
0994: return onlySRAComponentInstalled;
0995: }
0996:
0997: private String trim(String str) {
0998: if (str != null) {
0999: return str.trim();
1000: }
1001:
1002: return str;
1003: }
1004: }
|