001: package com.sun.portal.fabric.tasks;
002:
003: import java.io.File;
004:
005: import java.util.logging.Level;
006: import java.util.logging.Logger;
007: import java.util.logging.LogRecord;
008:
009: import com.sun.portal.fabric.util.XMLJdomUtil;
010: import com.sun.portal.fabric.util.XMLJdomFileCreationException;
011: import com.sun.portal.log.common.PortalLogger;
012: import com.sun.portal.util.Platform;
013:
014: public class ConfigDataConstants {
015:
016: protected static final String cps = File.pathSeparator;
017: protected static final String fs = Platform.fs;
018: protected static final String nl = System
019: .getProperty("line.separator");
020: protected static final String ts = "@";
021: protected static final String MODE_RECORD = "Record";
022: protected static final String MODE_PLAYBACK = "Playback";
023: protected static final String MODE_ERASE = "Erase";
024:
025: public static final String PASCONFIG_PORTAL_SERVER_CONFIGURATION = "WebContainerConfigData";
026: public static final String PASCONFIG_PATHS = "Paths";
027: public static final String PASCONFIG_JVM_OPTIONS = "Jvm_options";
028: public static final String PASCONFIG_RESOURCES = "Resources";
029:
030: public static final String PASCONFIG_ATTR_CLASSPATH = "classpath";
031: public static final String PASCONFIG_ATTR_NATIVE_LIB_PATH = "native_lib_path";
032: public static final String PASCONFIG_ATTR_RESOURCES_LIST = "resources_list";
033:
034: public static final String PASCONFIG_INSTANCE_ID = "@INSTANCE_ID@";
035:
036: protected XMLJdomUtil m_xmlJdomUtil = null;
037: protected String m_sPASFileLocation = null;
038: protected String m_sPASXSDFileLocation = null;
039: protected boolean m_bRecordingFound = false;
040:
041: private static Logger logger = PortalLogger
042: .getLogger(ConfigDataConstants.class);
043:
044: /**
045: * Constructor
046: *
047: * @param sPSLibDir Portal Server Lib Dir
048: * @param sPortalConfigDataDir Portal Config Dir
049: * @param logger Logger
050: */
051: protected ConfigDataConstants(final String sPSLibDir,
052: final String sPortalConfigDataDir)
053: throws ConfigDataRecorderPlaybackException {
054:
055: if ((sPSLibDir == null) || (sPSLibDir.trim().length() == 0)) {
056: // log message
057: logger.log(Level.SEVERE, "PSFB_CSPFT0207");
058: throw new ConfigDataRecorderPlaybackException(
059: "PS Lib Directory = Null/Empty");
060: }
061:
062: File fPSLibDir = new File(sPSLibDir);
063: if (!fPSLibDir.isDirectory()) {
064: // log message
065: logger.log(Level.SEVERE, "PSFB_CSPFT0208", sPSLibDir);
066: throw new ConfigDataRecorderPlaybackException("Directory '"
067: + sPSLibDir + "' can not be found!!!");
068: }
069:
070: m_sPASXSDFileLocation = sPSLibDir + fs + "PASconfig.xsd";
071: /*??File fPASXSDFileLocation = new File(m_sPASXSDFileLocation);
072: if (!fPASXSDFileLocation.isFile()) {
073: // log message
074: throw new ConfigDataRecorderPlaybackException("Schema file " + m_sPASXSDFileLocation + " can not be found!!!");
075: }??*/
076:
077: try {
078: m_xmlJdomUtil = new XMLJdomUtil();
079:
080: if ((sPortalConfigDataDir == null)
081: || (sPortalConfigDataDir.trim().length() == 0)) {
082: // log message
083: logger.log(Level.SEVERE, "PSFB_CSPFT0209");
084: throw new ConfigDataRecorderPlaybackException(
085: "Portal Config Dir = Null/Empty");
086: }
087:
088: File fDir = new File(sPortalConfigDataDir);
089: boolean bCreatePortalConfigDir = fDir.isDirectory() ? true
090: : fDir.mkdirs();
091: if (!bCreatePortalConfigDir) {
092: // log nessage
093: logger.log(Level.SEVERE, "PSFB_CSPFT0210",
094: sPortalConfigDataDir);
095: throw new ConfigDataRecorderPlaybackException(
096: "Failed to create Portal Config Dir '"
097: + sPortalConfigDataDir + "'");
098: }
099:
100: // Read Portal Config File if available
101: m_sPASFileLocation = sPortalConfigDataDir + fs
102: + "WebContainerConfigData.xml";
103: File fTmpFile = new File(m_sPASFileLocation);
104: if (fTmpFile.isFile()) {
105: System.out.println("File '"
106: + fTmpFile.getAbsolutePath() + "' found.");
107: //??m_xmlJdomUtil.readXMLFile(fTmpFile.getAbsolutePath());
108: m_xmlJdomUtil.readXMLFileLessSchemaValidation(fTmpFile
109: .getAbsolutePath());
110: m_bRecordingFound = true;
111: }
112: } catch (XMLJdomFileCreationException e) {
113: // log message
114: logger.log(Level.SEVERE, "PSFB_CSPFT0211", e);
115: throw new ConfigDataRecorderPlaybackException(e);
116: }
117: }
118:
119: public final boolean isRecordingFound() {
120:
121: return m_bRecordingFound;
122: }
123: }
|