1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import com.sun.enterprise.util.SystemPropertyConstants; 28 import com.sun.enterprise.config.serverbeans.validation.DomainXmlVerifier; 29 30 import java.io.File ; 32 33 37 public class VerifyDomainXmlCommand extends BaseLifeCycleCommand 38 { 39 40 private static final String VERBOSE = "verbose"; 41 private static final String DOMAINDIR = "domaindir"; 42 private static final String CONFIG = "config"; 43 private static final String DOMAIN_XML = "domain.xml"; 44 45 49 50 public void runCommand() 51 throws CommandException, CommandValidationException 52 { 53 validateOptions(); 54 boolean verbose = getBooleanOption(VERBOSE); 55 String domainXMLFile = getDomainXMLFile(); 56 File f = new File (domainXMLFile); 57 if(!f.exists()) 58 throw new CommandException(getLocalizedString("DomainXMLDoesNotExist", 59 new Object []{getDomainName()})); 60 else { 61 try { 62 DomainXmlVerifier validator = new DomainXmlVerifier(domainXMLFile); 63 validator.setDebug(verbose); 64 validator.invokeConfigValidator(); 65 CLILogger.getInstance().printDetailMessage(getLocalizedString( 66 "CommandSuccessful", 67 new Object [] {name})); 68 } catch(Exception e){ 69 throw new CommandException(e.getMessage()); 70 } 71 } 72 } 73 74 81 public boolean validateOptions() throws CommandValidationException 82 { 83 return super.validateOptions(); 84 } 85 86 90 private String getDomainXMLFile() throws CommandException 91 { 92 String domainDir = getDomainsRoot(); 93 String domainName = getDomainName(); 94 String domainXMLFile = domainDir + File.separator + domainName + File.separator + 95 CONFIG + File.separator + DOMAIN_XML; 96 CLILogger.getInstance().printDebugMessage("Domain XML file = " + domainXMLFile); 97 return domainXMLFile; 98 } 99 100 } 101 | Popular Tags |