FileDocCategorySizeDatePackage
ConfigCollector.javaAPI DocGlassfish v2 API6130Fri May 04 22:34:44 BST 2007com.sun.enterprise.diagnostics.collect

ConfigCollector

public class ConfigCollector extends Object implements Collector
Responsible for capturing domain.xml, sun-acc.xml, server.policy, login.conf
author
Manisha Umbarje

Fields Summary
private static final String
PASSWORD_REPLACEMENT
private static final String
PASSWORD
private String
repositoryDir
private String
reportDir
private static Logger
logger
Constructors Summary
public ConfigCollector(String repositoryDir, String reportDir)

param
repositoryDir central/local cache repository
param
reportDir directory in which config information is collected.
targetType
type of the target for which report generation is invoked instance

    
                                   
         
        this.repositoryDir = repositoryDir;
        this.reportDir = reportDir;
      
Methods Summary
public com.sun.enterprise.diagnostics.Datacapture()
Capture config information

throw
DiagnosticException

        WritableDataImpl dataImpl = new WritableDataImpl(DataType.CONFIG_DETAILS);
        
        dataImpl.addChild(captureXMLFile(Constants.DOMAIN_XML));
        dataImpl.addChild(captureFile(Constants.SERVER_POLICY));
        dataImpl.addChild(captureFile(Constants.LOGIN_CONF));
        dataImpl.addChild(captureFile(Constants.SUN_ACC));
        return dataImpl; 
     
public com.sun.enterprise.diagnostics.DatacaptureFile(java.lang.String fileName)
Copies file

param
fileName relative path of file to be copied
throw
DiagnosticException

        try {
             FileUtils.copyFile(repositoryDir + fileName,  
                    reportDir +fileName);
             return new FileData(reportDir + fileName, DataType.CONFIG_DETAILS);
        } catch(IOException ioe) {
            logger.log(Level.WARNING,ioe.getMessage());
        }
        return null;
   
public com.sun.enterprise.diagnostics.DatacaptureXMLFile(java.lang.String fileName)
Masks confidential information with **** and copies it to destination

param
fileName xml file to be captured.
throw
DiagnosticException

        try {
            String xmlFileToModify = repositoryDir + fileName;
            String destFile = reportDir + fileName;
            String domainXMLDTD = 
                    DiagnosticServiceHelper.getInstallationRoot() + 
                    Constants.DOMAIN_XML_DTD;

            Document serverXml = XmlUtils.loadXML(xmlFileToModify,
                     domainXMLDTD);
            XmlUtils.attrSearchReplace(serverXml.getDocumentElement(),
                    PASSWORD, PASSWORD_REPLACEMENT);
            XmlUtils.copyXMLFile(serverXml, destFile);
            return new FileData(destFile, DataType.CONFIG_DETAILS);
            
        } catch (SAXException se) {
            logger.log(Level.WARNING, se.getMessage());
        } catch (IOException ie) {
            logger.log(Level.WARNING, ie.getMessage());
        } catch (TransformerConfigurationException tce) {
            logger.log(Level.WARNING, tce.getMessage());
        } catch (TransformerException te) {
            logger.log(Level.WARNING,te.getMessage());
        } catch (ParserConfigurationException pce) {
            logger.log(Level.WARNING,pce.getMessage());
        }
        return null;