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

DomainXMLVerificationCollector

public class DomainXMLVerificationCollector extends Object implements Collector
Captures output of verify-domain-xml command.
author
mu125243

Fields Summary
private String
xmlFile
private String
destFolder
Constructors Summary
public DomainXMLVerificationCollector(String repository, String destFolder)
Creates a new instance of DomainXMLVerificationCollector

param
destFolder destination folder in which outpur of verify-domain-xml command

        this.destFolder = destFolder;
        this.xmlFile = repository + Constants.DOMAIN_XML;
    
Methods Summary
public com.sun.enterprise.diagnostics.Datacapture()
Captures output

throw
DiagnosticException

        if(destFolder != null) {
            File destFolderObj = new File(destFolder);
            String destFile = destFolder + 
                    Defaults.DOMAIN_XML_VERIFICATION_OUTPUT;
            PrintStream out = System.out;

            if(!destFolderObj.exists()) {
                destFolderObj.mkdirs();
            }
            
            try {
                out = new PrintStream(
                    new BufferedOutputStream(new FileOutputStream(destFile)), true);
            } catch(FileNotFoundException fnfe) {
                System.out.println(" File Not Found Exception ");
                //ignore as output stream is set to System.out
                fnfe.printStackTrace();
            }

            try {
                String className = "com.sun.enterprise.config.serverbeans.validation.DomainXmlVerifier";
                Class classObj = Class.forName(className);
                
                Constructor[] constructors = classObj.getDeclaredConstructors();
                constructors = classObj.getConstructors(); 
                Constructor constructor = 
                        classObj.getConstructor(
                        new Class[]{String.class, PrintStream.class});
                        
                Object obj = constructor.newInstance(new Object[]{xmlFile,out});
                Method method = classObj.getMethod("invokeConfigValidator",(java.lang.Class[]) null);
                method.invoke(obj, (java.lang.Object[] ) null);
                return new FileData(new File(destFile).getName(),
                        DataType.DOMAIN_VALIDATION_DETAILS);
              
            } catch (Exception  ce) {
                Throwable cause = ce.getCause();
                while(cause!=null && !(cause instanceof org.xml.sax.SAXParseException))
                    cause = cause.getCause();
                if(cause!=null)
                    out.println("XML: "+cause.getMessage());
                else
                    ce.printStackTrace();
                throw new DiagnosticException(ce.getMessage());
            }finally {
                out.flush();
                out.close();
            }
        }
        return null;