Initial revision
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
66e44f2734
commit
530c640d4f
821 files changed
+55754
No files matched your search
@@ -0,0 +1,184 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class to hold data about a struts action as found in the struts
|
||||
* configuration file
|
||||
*
|
||||
* @author dion
|
||||
* @version $Id: Action.java,v 1.1 2003/01/24 03:45:51 jvanzyl Exp $
|
||||
*/
|
||||
public class Action extends ObjectConfigurationEntry
|
||||
{
|
||||
/** context relative path of the submitted request */
|
||||
private String path;
|
||||
/** "request" or "session" - scope of the form bean for the action */
|
||||
private String scope;
|
||||
/** Whether the action is to be the default for the web app */
|
||||
private String unknown;
|
||||
/** Whether the form bean should be validated before the action is called */
|
||||
private String validate;
|
||||
|
||||
/** Creates a new instance of Action */
|
||||
public Action()
|
||||
{
|
||||
}
|
||||
|
||||
/** Getter for property scope.
|
||||
* @return Value of property scope.
|
||||
*/
|
||||
public String getScope()
|
||||
{
|
||||
return scope;
|
||||
}
|
||||
|
||||
/** Setter for property scope.
|
||||
* @param scope New value of property scope.
|
||||
*/
|
||||
public void setScope(String scope)
|
||||
{
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
/** Getter for property unknown.
|
||||
* @return Value of property unknown.
|
||||
*/
|
||||
public String getUnknown()
|
||||
{
|
||||
return unknown;
|
||||
}
|
||||
|
||||
/** Setter for property unknown.
|
||||
* @param unknown New value of property unknown.
|
||||
*/
|
||||
public void setUnknown(String unknown)
|
||||
{
|
||||
this.unknown = unknown;
|
||||
}
|
||||
|
||||
/** Getter for property validate.
|
||||
* @return Value of property validate.
|
||||
*/
|
||||
public String getValidate()
|
||||
{
|
||||
return validate;
|
||||
}
|
||||
|
||||
/** Setter for property validate.
|
||||
* @param validate New value of property validate.
|
||||
*/
|
||||
public void setValidate(String validate)
|
||||
{
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
/** Getter for property path.
|
||||
* @return Value of property path.
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
/** Setter for property path.
|
||||
* @param path New value of property path.
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/** whether the passed object is the same as this one. In the case of an
|
||||
* action object, the path is the unique qualifier. So two objects are equal
|
||||
* if they have equal paths
|
||||
* @param o any object
|
||||
* @return true if o is the same as this object, false otherwise
|
||||
*/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != o.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return getPath().equals(((Action) o).getPath());
|
||||
}
|
||||
|
||||
/** provides the hashCode of this object, which is determined by simply
|
||||
* delegating the responsibility to the <code>path</code> property
|
||||
* @return the hashCode of the name if not null, otherwise delegate to the
|
||||
* parent class
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
if (getPath() != null)
|
||||
{
|
||||
return getPath().hashCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class to hold common properties across struts config objects
|
||||
*
|
||||
* @author dion
|
||||
* @version $Id: ConfigurationEntry.java,v 1.1 2003/01/24 03:45:51 jvanzyl Exp $
|
||||
*/
|
||||
public class ConfigurationEntry
|
||||
{
|
||||
/** Fully qualified Java class name of the implementation class. */
|
||||
private String className;
|
||||
/** Unique identifier of the form bean, if any, associated with the action
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/** Creates a new instance of ConfigurationEntry */
|
||||
public ConfigurationEntry()
|
||||
{
|
||||
}
|
||||
|
||||
/** Getter for property className.
|
||||
* @return Value of property className.
|
||||
*/
|
||||
public String getClassName()
|
||||
{
|
||||
return className;
|
||||
}
|
||||
|
||||
/** Setter for property className.
|
||||
* @param className New value of property className.
|
||||
*/
|
||||
public void setClassName(String className)
|
||||
{
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/** Getter for property name.
|
||||
* @return Value of property name.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/** Setter for property name.
|
||||
* @param name New value of property name.
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/** whether the passed object is the same as this one. In the case of a
|
||||
* config object, the name is the unique qualifier. So two objects are equal
|
||||
* if they have equal names
|
||||
* @param o any object
|
||||
* @return true if o is the same as this object, false otherwise
|
||||
*/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != o.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return getName().equals(((ConfigurationEntry) o).getName());
|
||||
}
|
||||
|
||||
/** provides the hashCode of this object, which is determined by simply
|
||||
* delegating the responsibility to the name property
|
||||
* @return the hashCode of the name if not null, otherwise delegate to the
|
||||
* parent class
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
if (getName() != null)
|
||||
{
|
||||
return getName().hashCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class to hold data about a Struts form bean as found in the configuration
|
||||
* @author dion
|
||||
* @version $Id: FormBean.java,v 1.1 2003/01/24 03:45:51 jvanzyl Exp $
|
||||
*/
|
||||
public class FormBean extends ObjectConfigurationEntry
|
||||
{
|
||||
/** Creates a new instance of FormBean with null values for the properties
|
||||
*/
|
||||
public FormBean()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class to represent a global forward as stored in the Struts configuration
|
||||
*
|
||||
* @author dion
|
||||
* @version $Id: Forward.java,v 1.1 2003/01/24 03:45:51 jvanzyl Exp $
|
||||
*/
|
||||
public class Forward extends ConfigurationEntry
|
||||
{
|
||||
/** path to forward or redirect to */
|
||||
private String path;
|
||||
/** whether to redirect or forward to the path*/
|
||||
private String redirect;
|
||||
|
||||
/** Creates a new instance of Forward */
|
||||
public Forward()
|
||||
{
|
||||
}
|
||||
|
||||
/** Getter for property path.
|
||||
* @return Value of property path.
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
/** Setter for property path.
|
||||
* @param path New value of property path.
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/** Getter for property redirect.
|
||||
* @return Value of property redirect.
|
||||
*/
|
||||
public String getRedirect()
|
||||
{
|
||||
return redirect;
|
||||
}
|
||||
|
||||
/** Setter for property redirect.
|
||||
* @param redirect New value of property redirect.
|
||||
*/
|
||||
public void setRedirect(String redirect)
|
||||
{
|
||||
this.redirect = redirect;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* A struts configuration entry that ends up as a java object, and hence
|
||||
* has a <code>type</code> property that is a java class name.
|
||||
*
|
||||
* @author dion
|
||||
* @version
|
||||
* $Id: ObjectConfigurationEntry.java,v 1.1 2003/01/24 03:45:51 jvanzyl Exp $
|
||||
*/
|
||||
public class ObjectConfigurationEntry extends ConfigurationEntry
|
||||
{
|
||||
/** Fully qualified Java class name of the implementing object */
|
||||
private String type;
|
||||
|
||||
/** Creates a new instance of ObjectConfigurationEntry */
|
||||
public ObjectConfigurationEntry()
|
||||
{
|
||||
}
|
||||
|
||||
/** Getter for property type.
|
||||
* @return Value of property type.
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/** Setter for property type.
|
||||
* @param type New value of property type.
|
||||
*/
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
|
||||
import org.apache.maven.j2ee.WarFile;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
/**
|
||||
* Encapsulates a Struts 1.0 War File. Holds functionality to access Struts
|
||||
* specific resources and data in the war.
|
||||
* @author dion
|
||||
* @version $Id: Struts10WarFile.java,v 1.1 2003/01/24 03:45:53 jvanzyl Exp $
|
||||
*/
|
||||
public class Struts10WarFile extends WarFile
|
||||
{
|
||||
/** Default location of Struts configuration file in the war */
|
||||
public static final String DEFAULT_CONFIG = "WEB-INF/struts-config.xml";
|
||||
/** property for the location of the Struts configuration file in the war */
|
||||
private String config = Struts10WarFile.DEFAULT_CONFIG;
|
||||
/** Default name of the action servlet in web.xml */
|
||||
public static final String DEFAULT_ACTIONSERVLET_NAME = "action";
|
||||
/** name of the action servlet in web.xml */
|
||||
private String actionServletName =
|
||||
Struts10WarFile.DEFAULT_ACTIONSERVLET_NAME;
|
||||
|
||||
/**
|
||||
* Creates a new instance of Struts10WarFile
|
||||
* @param name the {@link File file} name of a war file containing a Struts
|
||||
* web application
|
||||
* @throws IOException when an I/O error occurs
|
||||
*/
|
||||
public Struts10WarFile(String name) throws IOException
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of Struts10WarFile
|
||||
* @param name the {@link File file} name of a war file containing a Struts
|
||||
* web application
|
||||
* @param verify whether or not to verify the war file if it is signed
|
||||
* @throws IOException when an I/O error occurs */
|
||||
public Struts10WarFile(String name, boolean verify) throws IOException
|
||||
{
|
||||
super(name, verify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of Struts10WarFile
|
||||
* @param warFile a J2EE .war {@link File file} containing a Struts web
|
||||
* application
|
||||
* @throws IOException when an I/O error occurs
|
||||
*/
|
||||
public Struts10WarFile(File warFile) throws IOException
|
||||
{
|
||||
super(warFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of Struts10WarFile
|
||||
* @param warFile a J2EE .war {@link File file} containing a Struts web
|
||||
* application
|
||||
* @param verify whether or not to verify the war file if it is signed
|
||||
* @throws IOException when an I/O error occurs
|
||||
*/
|
||||
public Struts10WarFile(File warFile, boolean verify) throws IOException
|
||||
{
|
||||
super(warFile, verify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of Struts10WarFile
|
||||
* @param warFile a J2EE .war {@link File file} containing a Struts web
|
||||
* application
|
||||
* @param verify whether or not to verify the war file if it is signed
|
||||
* @param mode the mode in which the file is to be opened
|
||||
* @throws IOException when an I/O error occurs
|
||||
*/
|
||||
public Struts10WarFile(File warFile, boolean verify, int mode)
|
||||
throws IOException
|
||||
{
|
||||
super(warFile, verify, mode);
|
||||
}
|
||||
|
||||
/** Provide the location of the Struts configuration file in the war.
|
||||
* @return Value of property config.
|
||||
*/
|
||||
public String getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
/** Set the location of the Struts configuration file in the war.
|
||||
* @param config New value of property config.
|
||||
*/
|
||||
public void setConfig(String config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the Struts configuration (as specified by the config property)
|
||||
* entry if it exists.
|
||||
* @return a {@link JarEntry} for Struts config
|
||||
*/
|
||||
public JarEntry getStrutsConfigEntry()
|
||||
{
|
||||
return getJarEntry(getConfig());
|
||||
}
|
||||
|
||||
/** Get the Struts configuration back as a dom4j Document, for easier
|
||||
* processing
|
||||
* @return a {@link Document} representing the web.xml
|
||||
* @throws IOException if there are any issues reading the web.xml
|
||||
* or producing the xml document
|
||||
*/
|
||||
private Document getStrutsConfig() throws IOException
|
||||
{
|
||||
if (getStrutsConfigEntry() == null)
|
||||
{
|
||||
throw new IOException("Attempted to get non-existent config");
|
||||
}
|
||||
try
|
||||
{
|
||||
SAXReader xmlReader = new SAXReader(false);
|
||||
xmlReader.setEntityResolver(new StrutsEntityResolver());
|
||||
InputStream configStream = getInputStream(getStrutsConfigEntry());
|
||||
Document configXml = xmlReader.read(configStream);
|
||||
return configXml;
|
||||
}
|
||||
catch (DocumentException de)
|
||||
{
|
||||
de.printStackTrace();
|
||||
throw new IOException(de.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/** retrieves the form beans defined in the struts configuration file
|
||||
* @return a collection of {@link FormBean form beans}
|
||||
* @throws IOException when there are problems reading from the war
|
||||
*/
|
||||
public List getFormBeans() throws IOException
|
||||
{
|
||||
List formBeans = new ArrayList();
|
||||
Document config = getStrutsConfig();
|
||||
List formBeanNodes = config.selectNodes(
|
||||
"/struts-config/form-beans/form-bean");
|
||||
Element formBeanNode = null;
|
||||
FormBean formBean = null;
|
||||
for (Iterator nodes = formBeanNodes.iterator(); nodes.hasNext();)
|
||||
{
|
||||
formBeanNode = (Element) nodes.next();
|
||||
formBean = new FormBean();
|
||||
formBean.setClassName(formBeanNode.attributeValue("className"));
|
||||
formBean.setName(formBeanNode.attributeValue("name"));
|
||||
formBean.setType(formBeanNode.attributeValue("type"));
|
||||
formBeans.add(formBean);
|
||||
}
|
||||
|
||||
return formBeans;
|
||||
}
|
||||
|
||||
/** retrieve the actions defined in the struts configuration file
|
||||
* @return a {@link List] of {@link Action actions}
|
||||
* @throws IOException when there are problems reading from the war
|
||||
*/
|
||||
public List getActions() throws IOException
|
||||
{
|
||||
List actions = new ArrayList();
|
||||
Document config = getStrutsConfig();
|
||||
List actionNodes = config.selectNodes(
|
||||
"/struts-config/action-mappings/action");
|
||||
Element actionNode = null;
|
||||
Action action = null;
|
||||
for (Iterator nodes = actionNodes.iterator(); nodes.hasNext();)
|
||||
{
|
||||
actionNode = (Element) nodes.next();
|
||||
action = new Action();
|
||||
action.setClassName(actionNode.attributeValue("className"));
|
||||
action.setName(actionNode.attributeValue("name"));
|
||||
action.setPath(actionNode.attributeValue("path"));
|
||||
action.setScope(actionNode.attributeValue("scope"));
|
||||
action.setType(actionNode.attributeValue("type"));
|
||||
action.setUnknown(actionNode.attributeValue("unknown"));
|
||||
action.setValidate(actionNode.attributeValue("validate"));
|
||||
actions.add(action);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
/** retrieves the type attribute of the <form-beans> element if
|
||||
* it exists, or null otherwise
|
||||
* @return the form-bean type attribute
|
||||
* @throws IOException when there are problems reading from the war
|
||||
*/
|
||||
public String getFormBeansType() throws IOException
|
||||
{
|
||||
String type = null;
|
||||
Element formBeans = (Element) getStrutsConfig().selectSingleNode(
|
||||
"/struts-config/form-beans");
|
||||
if (formBeans != null)
|
||||
{
|
||||
type = formBeans.attributeValue("type");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/** retrieves the type attribute of the <global-forwards> element if
|
||||
* it exists, or null otherwise
|
||||
* @return the global-forwards type attribute
|
||||
* @throws IOException when there are problems reading from the war
|
||||
*/
|
||||
public String getGlobalForwardsType() throws IOException
|
||||
{
|
||||
String type = null;
|
||||
Element forwards = (Element) getStrutsConfig().selectSingleNode(
|
||||
"/struts-config/global-forwards");
|
||||
if (forwards != null)
|
||||
{
|
||||
type = forwards.attributeValue("type");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/** retrieve the global forwards defined in the struts configuration
|
||||
* @return a {@link List} of {@link Forward forwards}
|
||||
* @throws IOException when there are problems reading from the war
|
||||
*/
|
||||
public List getForwards() throws IOException
|
||||
{
|
||||
List forwards = new ArrayList();
|
||||
Document config = getStrutsConfig();
|
||||
List nodes = config.selectNodes(
|
||||
"/struts-config/global-forwards/forward");
|
||||
Element element = null;
|
||||
Forward forward = null;
|
||||
for (int index = 0; index < nodes.size(); index++)
|
||||
{
|
||||
element = (Element) nodes.get(index);
|
||||
forward = new Forward();
|
||||
forward.setName(element.attributeValue("name"));
|
||||
forward.setPath(element.attributeValue("path"));
|
||||
if (element.attribute("className") != null)
|
||||
{
|
||||
forward.setClassName(element.attributeValue("className"));
|
||||
}
|
||||
if (element.attribute("redirect") != null)
|
||||
{
|
||||
forward.setRedirect(element.attributeValue("redirect"));
|
||||
}
|
||||
forwards.add(forward);
|
||||
}
|
||||
|
||||
return forwards;
|
||||
}
|
||||
|
||||
/** retrieve the url pattern for the action servlet, or null if not found
|
||||
* @return the <url-pattern> provided for the servlet named by
|
||||
* {@link #getActionServletName}
|
||||
* @throws IOException when there are problems reading from the war
|
||||
*/
|
||||
public String getActionServletPattern() throws IOException
|
||||
{
|
||||
return (String) getServletMappings().get(getActionServletName());
|
||||
}
|
||||
|
||||
/** Getter for property actionServletName.
|
||||
* @return Value of property actionServletName.
|
||||
*/
|
||||
public String getActionServletName()
|
||||
{
|
||||
return actionServletName;
|
||||
}
|
||||
|
||||
/** Setter for property actionServletName.
|
||||
* @param actionServletName New value of property actionServletName.
|
||||
*/
|
||||
public void setActionServletName(String actionServletName)
|
||||
{
|
||||
if (actionServletName == null)
|
||||
{
|
||||
throw new NullPointerException("action servlet name can't be null");
|
||||
}
|
||||
this.actionServletName = actionServletName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,478 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.j2ee.WarClassLoader;
|
||||
import org.apache.maven.j2ee.WarValidator;
|
||||
import org.apache.regexp.RE;
|
||||
import org.apache.regexp.RESyntaxException;
|
||||
|
||||
/**
|
||||
* A class that validates a Struts 1.0 War File. Specific validations performed
|
||||
* are:
|
||||
*
|
||||
* <ol>
|
||||
* <li>
|
||||
* Must pass validation as a 'standard' war file
|
||||
* </li>
|
||||
* <li>
|
||||
* File has a struts configuration file
|
||||
* </li>
|
||||
* <li>
|
||||
* <form-bean>s must have a valid <code>type</code> and
|
||||
* <code>className</code> that exist in the war
|
||||
* </li>
|
||||
* <li>
|
||||
* <action>s must have a valid <code>type</code>, <code>className</code>
|
||||
* that exist in the war
|
||||
* </li>
|
||||
* <li>
|
||||
* <action> <code>name</code>s must refer to a <form-bean> in the
|
||||
* struts configuraion
|
||||
* </li>
|
||||
* <li>
|
||||
* <action> <code>scope</code> must be either <code>request</code> or
|
||||
* <code>session</code>
|
||||
* </li>
|
||||
* <li>
|
||||
* <action> <code>unknown</code> and <code>validate</code> must be
|
||||
* <code>true</code> or <code>false</code>
|
||||
* </li>
|
||||
* <li>
|
||||
* <global-forwards> <code>type</code> must be a class in the war
|
||||
* </li>
|
||||
* <li>
|
||||
* <forward> <code>redirect</code> must be <code>true</code> or
|
||||
* <code>false</code>
|
||||
* </li>
|
||||
* <li>
|
||||
* <forward> <code>path</code> must refer to either a file in the war
|
||||
* (e.g. a jsp), or an action defined in the struts configuration
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* @version $Id: Struts10WarValidator.java,v 1.1 2003/01/24 03:45:53 jvanzyl Exp $
|
||||
* @author dion
|
||||
*/
|
||||
public class Struts10WarValidator extends WarValidator
|
||||
{
|
||||
//~ Instance variables ·····················································
|
||||
|
||||
/**
|
||||
* the location within the war of the Struts configuration file. By default
|
||||
* this takes the value of the {@link Struts10WarFile#DEFAULT_CONFIG
|
||||
* default config}
|
||||
*/
|
||||
private String config = Struts10WarFile.DEFAULT_CONFIG;
|
||||
|
||||
//~ Constructors ···························································
|
||||
|
||||
/**
|
||||
* Creates a new instance of Struts10WarValidator
|
||||
*/
|
||||
public Struts10WarValidator()
|
||||
{
|
||||
}
|
||||
|
||||
//~ Methods ································································
|
||||
|
||||
/**
|
||||
* Setter for config location within the war (no leading slash)
|
||||
*
|
||||
* @param config New value of property config.
|
||||
*/
|
||||
public void setConfig(String config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for Struts config location within the war (no leading slash).
|
||||
* e.g. <code>WEB-INF/struts-config.xml</code>
|
||||
*
|
||||
* @return Value of property config.
|
||||
*/
|
||||
public String getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate struts specific war features here
|
||||
*/
|
||||
protected void validateWarContents()
|
||||
{
|
||||
try
|
||||
{
|
||||
super.validateWarContents();
|
||||
|
||||
Struts10WarFile strutsWar = new Struts10WarFile(getWarFileName());
|
||||
strutsWar.setConfig(getConfig());
|
||||
validateStrutsConfig(strutsWar);
|
||||
validateFormBeans(strutsWar);
|
||||
validateActions(strutsWar);
|
||||
validateForwards(strutsWar);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
ioe.printStackTrace();
|
||||
error("Error reading struts war file");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate a string that must contain a boolean value or be null
|
||||
*
|
||||
* @param value the string to be validated
|
||||
*
|
||||
* @return true if the provided string is true, false or null
|
||||
*/
|
||||
private boolean isBoolean(String value)
|
||||
{
|
||||
return (value == null) || value.equals("true") || value.equals("false");
|
||||
}
|
||||
|
||||
/**
|
||||
* validate the provided action object
|
||||
*
|
||||
* @param action the action to be validated
|
||||
* @param formBeans the form beans for the war that the actions came from
|
||||
* @param loader a {@link ClassLoader} to verify classes are from the war
|
||||
*/
|
||||
private void validateAction(Action action, Map formBeans,
|
||||
ClassLoader loader)
|
||||
{
|
||||
info("validating action for path: '" + action.getPath() + "'");
|
||||
|
||||
// className must be a loadable class
|
||||
if (action.getClassName() != null)
|
||||
{
|
||||
validateClass(action.getClassName(), loader);
|
||||
}
|
||||
|
||||
// name must be the name of a form bean
|
||||
if ((action.getName() != null)
|
||||
&& (formBeans.get(action.getName()) == null))
|
||||
{
|
||||
error("action refers to a non-existent form bean: '"
|
||||
+ action.getName() + "'");
|
||||
}
|
||||
|
||||
// path must start with a '/'
|
||||
if (!action.getPath().startsWith("/"))
|
||||
{
|
||||
error("action path (" + action.getPath() + ") doesn't start "
|
||||
+ "with a '/'");
|
||||
}
|
||||
|
||||
// scope if specified must be request or session
|
||||
if ((action.getScope() != null)
|
||||
&& !(action.getScope().equals("request")
|
||||
|| action.getScope().equals("session")))
|
||||
{
|
||||
error("scope (" + action.getScope() + ") is not 'request' or "
|
||||
+ "'session'");
|
||||
}
|
||||
|
||||
// type must be a loadable class
|
||||
if (action.getType() != null)
|
||||
{
|
||||
validateClass(action.getType(), loader);
|
||||
}
|
||||
|
||||
// unknown must be true, false or null
|
||||
if (!isBoolean(action.getUnknown())) // true or false only
|
||||
{
|
||||
error("unknown attribute is not 'true' or 'false'");
|
||||
}
|
||||
|
||||
// validate must be true, false or null
|
||||
if (!isBoolean(action.getValidate())) // true or false only
|
||||
{
|
||||
error("validate attribute is not 'true' or 'false'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validations for the actions in the config
|
||||
*
|
||||
* @param war the struts web app being validated
|
||||
*
|
||||
* @throws IOException when there are problems reading the war
|
||||
*/
|
||||
private void validateActions(Struts10WarFile war) throws IOException
|
||||
{
|
||||
info("validating Struts Actions");
|
||||
|
||||
List actions = war.getActions();
|
||||
Action action = null;
|
||||
ClassLoader loader = new WarClassLoader(war,
|
||||
getClass().getClassLoader());
|
||||
List formBeans = war.getFormBeans();
|
||||
Map formBeansByName = new HashMap();
|
||||
|
||||
// put form beans into a map to find them easier
|
||||
FormBean formBean = null;
|
||||
|
||||
for (int index = 0; index < formBeans.size(); index++)
|
||||
{
|
||||
formBean = (FormBean) formBeans.get(index);
|
||||
formBeansByName.put(formBean.getName(), formBean);
|
||||
}
|
||||
|
||||
// check actions
|
||||
for (int index = 0; index < actions.size(); index++)
|
||||
{
|
||||
action = (Action) actions.get(index);
|
||||
|
||||
if (CollectionUtils.cardinality(action, actions) > 1)
|
||||
{
|
||||
error("action is a duplicate (by path)");
|
||||
}
|
||||
|
||||
validateAction(action, formBeansByName, loader);
|
||||
} // end for all actions
|
||||
} // end method
|
||||
|
||||
/**
|
||||
* validations for the form beans in the config
|
||||
*
|
||||
* @param strutsWar - the struts web app being validated
|
||||
*
|
||||
* @throws IOException when there are problems reading the war
|
||||
*/
|
||||
private void validateFormBeans(Struts10WarFile strutsWar) throws IOException
|
||||
{
|
||||
info("validating Struts Form Beans");
|
||||
|
||||
List formBeans = strutsWar.getFormBeans();
|
||||
FormBean bean = null;
|
||||
ClassLoader loader = new WarClassLoader(strutsWar,
|
||||
getClass().getClassLoader());
|
||||
|
||||
if (strutsWar.getFormBeansType() != null)
|
||||
{
|
||||
validateClass(strutsWar.getFormBeansType(), loader);
|
||||
}
|
||||
|
||||
for (int index = 0; index < formBeans.size(); index++)
|
||||
{
|
||||
bean = (FormBean) formBeans.get(index);
|
||||
|
||||
if (CollectionUtils.cardinality(bean, formBeans) > 1)
|
||||
{
|
||||
error("form bean is a duplicate (by name)");
|
||||
}
|
||||
|
||||
info("validating form bean: '" + bean.getName() + "', class: '"
|
||||
+ bean.getType() + "'");
|
||||
validateClass(bean.getType(), loader);
|
||||
|
||||
if (bean.getClassName() != null)
|
||||
{
|
||||
validateClass(bean.getClassName(), loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a single global forward.
|
||||
*
|
||||
* @param war the war file the forward is from
|
||||
* @param forward the forward to be validated
|
||||
* @param loader a class loader for validating classes are in the war
|
||||
*
|
||||
* @throws IOException when there are issues reading the war
|
||||
* @throws IllegalStateException If the regular expression used to check
|
||||
* that the forward matches the action servlet is malformed
|
||||
*/
|
||||
private void validateForward(Struts10WarFile war, Forward forward,
|
||||
ClassLoader loader) throws IOException
|
||||
{
|
||||
// check className, if provided
|
||||
if (forward.getClassName() != null)
|
||||
{
|
||||
validateClass(forward.getClassName(), loader);
|
||||
}
|
||||
|
||||
// check name
|
||||
if (StringUtils.isEmpty(forward.getName()))
|
||||
{
|
||||
error("name attribute is required");
|
||||
}
|
||||
|
||||
// check path
|
||||
String path = forward.getPath();
|
||||
int queryStringStart = path.indexOf("?");
|
||||
|
||||
if (queryStringStart != -1)
|
||||
{
|
||||
path = path.substring(0, queryStringStart);
|
||||
}
|
||||
|
||||
if (!war.hasFile(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
// could be an action - check to see if it matches the pattern
|
||||
// for action servlet, if it does, extract the action path, and
|
||||
// make sure it's in the list of actions
|
||||
String pattern = war.getActionServletPattern();
|
||||
|
||||
|
||||
// escape '.', as it has special meaning to regular exprs
|
||||
pattern = StringUtils.replace(pattern, ".", "\\.");
|
||||
|
||||
|
||||
// change * to (*) to group matching characters for access
|
||||
pattern = StringUtils.replace(pattern, "*", "(.*)");
|
||||
|
||||
RE regexp = new RE(pattern);
|
||||
|
||||
if (regexp.match(path))
|
||||
{
|
||||
String actionPath = regexp.getParen(1);
|
||||
Action dummyAction = new Action();
|
||||
dummyAction.setPath(actionPath);
|
||||
|
||||
if (!war.getActions().contains(dummyAction))
|
||||
{
|
||||
error("action path for forward (" + actionPath + ")"
|
||||
+ " not found");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error("No action or web resource found for '" + path + "'");
|
||||
}
|
||||
}
|
||||
catch (RESyntaxException e)
|
||||
{
|
||||
throw new IllegalStateException(
|
||||
"bad regular expression created"
|
||||
+ " from action servlet url-pattern in web.xml "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// check redirect
|
||||
if (!isBoolean(forward.getRedirect()))
|
||||
{
|
||||
error("redirect attribute is not 'true' or 'false'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate the global forwards in the configuration
|
||||
*
|
||||
* @param war the war file to be used for validating
|
||||
*
|
||||
* @throws IOException when there are problems reading the war
|
||||
*/
|
||||
private void validateForwards(Struts10WarFile war) throws IOException
|
||||
{
|
||||
info("validating global forwards");
|
||||
|
||||
ClassLoader loader = new WarClassLoader(war,
|
||||
getClass().getClassLoader());
|
||||
|
||||
if (war.getGlobalForwardsType() != null)
|
||||
{
|
||||
validateClass(war.getGlobalForwardsType(), loader);
|
||||
}
|
||||
|
||||
List forwards = war.getForwards();
|
||||
Forward forward = null;
|
||||
|
||||
for (int index = 0; index < forwards.size(); index++)
|
||||
{
|
||||
forward = (Forward) forwards.get(index);
|
||||
info("validating forward '" + forward.getName() + "', path: '"
|
||||
+ forward.getPath() + "'");
|
||||
|
||||
if (CollectionUtils.cardinality(forward, forwards) > 1)
|
||||
{
|
||||
error("forward is a duplicate (by name)");
|
||||
}
|
||||
|
||||
validateForward(war, forward, loader);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validations for the struts configuration file
|
||||
*
|
||||
* @param strutsWar - the struts web app being validated
|
||||
*/
|
||||
private void validateStrutsConfig(Struts10WarFile strutsWar)
|
||||
{
|
||||
info("validating Struts Configuration");
|
||||
|
||||
if (strutsWar.getStrutsConfigEntry() == null)
|
||||
{
|
||||
error("Struts Configuration: '" + strutsWar.getConfig()
|
||||
+ "' not found in the war file");
|
||||
}
|
||||
}
|
||||
} // end class
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.apache.maven.struts;
|
||||
|
||||
/* ====================================================================
|
||||
* 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 org.apache.maven.j2ee.J2EEEntityResolver;
|
||||
|
||||
/**
|
||||
* A class to resolve external entity definitions for struts artifacts.
|
||||
*
|
||||
* @author dion
|
||||
* @version $Id: StrutsEntityResolver.java,v 1.1 2003/01/24 03:45:53 jvanzyl Exp $
|
||||
*/
|
||||
public class StrutsEntityResolver extends J2EEEntityResolver
|
||||
{
|
||||
|
||||
/** Creates a new instance of StrutsEntityResolver, adding the
|
||||
*/
|
||||
public StrutsEntityResolver()
|
||||
{
|
||||
getIdToResource().put(
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN",
|
||||
"/struts-config_1_0.dtd");
|
||||
getIdToResource().put(
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN",
|
||||
"/struts-config_1_1.dtd");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user