o Removing offending files. Removed plugin deps due to non distribution

issues but left the files in the repo.


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jvanzyl committed 2003-02-12 15:02:06 +00:00
1 parent 9d61d688e3
commit 318428618d
2 files changed
-381

No files matched your search

@@ -1,66 +0,0 @@
package org.apache.maven;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
public class ValidationException
extends Exception
{
public ValidationException(String message)
{
super(message);
}
}
@@ -1,315 +0,0 @@
package org.apache.maven;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.File;
import org.iso_relax.verifier.Schema;
import org.iso_relax.verifier.Verifier;
import org.iso_relax.verifier.VerifierFactory;
import org.iso_relax.verifier.VerifierFilter;
import org.iso_relax.verifier.VerifierHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
/** A general validating mechanism that can validate XML
* documents against XML DTD, XML Schema, RelaxNG, Relax Namespace,
* Relax Core and TREX.
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @version $Id: Validator.java,v 1.1 2003/01/24 03:44:33 jvanzyl Exp $
*/
public class Validator
{
/**
* The system ID to use when parsing the schema
*/
private String systemId;
/**
* The factory used to create new schema verifier objects
*/
private VerifierFactory factory;
/**
* The verifier that we will use to validate xml documents.
*/
private Verifier verifier;
/**
* The SAX ErrorHandler
*/
private ErrorHandler errorHandler;
public Validator()
{
}
public void execute()
throws Exception
{
try
{
verifier = createVerifier(new FileInputStream(validator));
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
if (verifier != null)
{
validate(new FileInputStream(projectDescriptor));
}
}
catch (ValidationException e)
{
throw new Exception(e.getMessage());
}
catch (Exception e)
{
e.printStackTrace();
}
}
private File validator;
public void setValidator(File validator)
{
this.validator = validator;
}
private File projectDescriptor;
public void setProjectDescriptor(File projectDescriptor)
{
this.projectDescriptor = projectDescriptor;
}
/**
* Sets the system ID used when parsing the schema
*/
public void setSystemId(String systemId)
{
this.systemId = systemId;
}
/**
* Sets the factory used to create new schema verifier objects. If none is
* provided then the default MSV factory is used.
*/
public void setFactory(VerifierFactory factory)
{
this.factory = factory;
}
/**
* Sets the schema Verifier that this tag will use to verify its body
*/
public void setVerifier(Verifier verifier)
{
this.verifier = verifier;
}
/**
* Sets the SAX ErrorHandler which is used to capture XML validation events.
* If an ErrorHandler is specified then this tag will output its body and
* redirect all error messages to the ErrorHandler. If no ErrorHandler is
* specified then this tag will just output the error messages as XML events
*/
public void setErrorHandler(ErrorHandler errorHandler)
{
this.errorHandler = errorHandler;
}
/**
* Description of the Method
*/
private Verifier createVerifier(InputStream schemaInputStream)
throws Exception
{
if (factory == null)
{
factory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
}
Schema schema = null;
if (systemId != null)
{
schema = factory.compileSchema(schemaInputStream, systemId);
}
else
{
schema = factory.compileSchema(schemaInputStream);
}
if (schema == null)
{
throw new Exception("Could not create a valid schema");
}
Verifier verifier = schema.newVerifier();
return verifier;
}
/**
* Description of the Method
*/
public void validate(InputStream xmlDocument)
throws ValidationException, Exception
{
boolean valid = false;
final StringBuffer errors = new StringBuffer();
// Use JAXP to find an available parser implementation and
// make the parser namespace aware. Reuse some of this instead
// of creating it every time.
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
// Create an input source from the supplied
// xmlDocument input stream.
InputSource is = new InputSource(xmlDocument);
if (errorHandler != null)
{
// we are redirecting errors to another handler
// so just filter the body
VerifierFilter filter = verifier.getVerifierFilter();
ContentHandler handler = filter.getContentHandler();
handler.startDocument();
xmlReader.setContentHandler(handler);
xmlReader.parse(is);
handler.endDocument();
valid = filter.isValid();
}
else
{
// outputting the errors to the current output
verifier.setErrorHandler(
new ErrorHandler()
{
public void error(SAXParseException exception)
throws SAXException
{
outputException("error", exception, errors);
}
public void fatalError(SAXParseException exception)
throws SAXException
{
outputException( "fatalError", exception, errors);
}
public void warning(SAXParseException exception)
throws SAXException
{
outputException("warning", exception, errors);
}
}
);
VerifierHandler handler = verifier.getVerifierHandler();
handler.startDocument();
xmlReader.setContentHandler(handler);
xmlReader.parse(is);
handler.endDocument();
valid = handler.isValid();
}
if (valid == false)
{
throw new ValidationException(errors.toString());
}
}
/**
* Outputs the given validation exception as XML to the output
*/
protected void outputException(String name, SAXParseException e, StringBuffer sb)
throws SAXException
{
sb.append(name).append("\n");
sb.append(e.getMessage()).append("\n");
sb.append(" Line: ").append(Integer.toString(e.getLineNumber())).append("\n");
sb.append("Column: ").append(Integer.toString(e.getColumnNumber())).append("\n");;
String publicID = e.getPublicId();
if (publicID != null && publicID.length() > 0)
{
sb.append(publicID);
}
String systemID = e.getSystemId();
if (systemID != null && systemID.length() > 0)
{
sb.append(systemID);
}
}
}