Skip to content
Open
37 changes: 1 addition & 36 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
limitations under the License.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>commons-jelly</groupId>
Expand Down Expand Up @@ -67,31 +67,6 @@
<artifactId>commons-lang</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>20030211.213356</version>
</dependency>
<dependency>
<groupId>forehead</groupId>
<artifactId>forehead</artifactId>
<version>1.0-beta-5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
Expand All @@ -107,15 +82,5 @@
<artifactId>commons-jexl</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.2</version>
</dependency>
</dependencies>
</project>
6 changes: 3 additions & 3 deletions core/src/main/java/org/apache/commons/jelly/Jelly.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public JellyContext getJellyContext() throws MalformedURLException {
*/
public URL getRootContext() throws MalformedURLException {
if (rootContext == null) {
rootContext = new File(SystemProperties.getUserDir()).toURL();
rootContext = new File(SystemProperties.getUserDir()).toURI().toURL();
}
return rootContext;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ protected void loadProperties(final InputStream is) throws IOException {
final JellyContext theContext = getJellyContext();
final Properties props = new Properties();
props.load(is);
final Enumeration propsEnum = props.propertyNames();
final Enumeration<?> propsEnum = props.propertyNames();
while (propsEnum.hasMoreElements()) {
final String key = (String) propsEnum.nextElement();
final String value = props.getProperty(key);
Expand All @@ -272,7 +272,7 @@ protected URL resolveURL(final String name) throws MalformedURLException {
}
final File file = new File(name);
if (file.exists()) {
return file.toURL();
return file.toURI().toURL();
}
return new URL(name);
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/apache/commons/jelly/JellyContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ protected URL createRelativeURL(final URL rootURL, final String relativeURI)
URL url = rootURL;
if (url == null) {
final File file = new File(System.getProperty("user.dir"));
url = file.toURL();
url = file.toURI().toURL();
}
final String urlText = url.toString() + relativeURI;
if ( log.isDebugEnabled() ) {
Expand Down Expand Up @@ -735,7 +735,7 @@ public void removeVariable(final String name, final String scopeName) {
*/
public JellyContext runScript(final File file, final XMLOutput output) throws JellyException {
try {
return runScript(file.toURL(), output, JellyContext.DEFAULT_EXPORT,
return runScript(file.toURI().toURL(), output, JellyContext.DEFAULT_EXPORT,
JellyContext.DEFAULT_INHERIT);
} catch (final MalformedURLException e) {
throw new JellyException(e.toString());
Expand All @@ -750,7 +750,7 @@ public JellyContext runScript(final File file, final XMLOutput output) throws Je
public JellyContext runScript(final File file, final XMLOutput output,
final boolean export, final boolean inherit) throws JellyException {
try {
return runScript(file.toURL(), output, export, inherit);
return runScript(file.toURI().toURL(), output, export, inherit);
} catch (final MalformedURLException e) {
throw new JellyException(e.toString());
}
Expand Down Expand Up @@ -1020,8 +1020,8 @@ public void setVariable(final String name, final String scopeName, final Object
public void setVariables(final Map variables) {
// I have seen this fail when the passed Map contains a key, value
// pair where the value is null
for (final Iterator iter = variables.entrySet().iterator(); iter.hasNext();) {
final Map.Entry element = (Map.Entry) iter.next();
for (Object o : variables.entrySet()) {
final Map.Entry element = (Map.Entry) o;
if (element.getValue() != null) {
this.variables.put(element.getKey(), element.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public JexlExpression(final Expression expression) {
@Override
public Object evaluate(final JellyContext context) {
try {
final JexlContext jexlContext = new JellyJexlContext( context );
final JexlContext jexlContext = new JellyJexlContext(context);
if (log.isDebugEnabled()) {
log.debug("Evaluating EL: " + expression.getExpression());
}
Expand All @@ -149,19 +149,11 @@ public Object evaluate(final JellyContext context) {
}

return value;
}
catch (final Exception e) {
if (context.isSuppressExpressionExceptions()) {
log.warn("Caught exception evaluating: " + expression + ". Reason: " + e, e);
return null;
}
} catch (final Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
}
if (e instanceof IllegalStateException) {
throw (IllegalStateException )e;
throw (RuntimeException) e;
}
throw (IllegalStateException)new IllegalStateException (e.getMessage(), e);
throw new IllegalStateException (e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,8 @@ public Object evaluate(final JellyContext context) {
}
catch (final JaxenException e)
{
if (!context.isSuppressExpressionExceptions()) {
throw (IllegalStateException)new IllegalStateException (e.getMessage(), e);
}
log.error("Error constructing xpath", e);
throw new IllegalStateException (e.getMessage(), e);
}

return null;
}

// Expression interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Embedded {
private OutputStream outputStream;
/** Output(default System.out) */
private XMLOutput output =
XMLOutput.createXMLOutput(new OutputStreamWriter(System.out));
XMLOutput.createXMLOutput(new OutputStreamWriter(System.out));
/** Exception thrown during compilation of script*/
Exception scriptCompilationException;
/** Boolean value indicating whether the script has been successfully compiled or NOT */
Expand Down Expand Up @@ -185,7 +185,7 @@ public void registerTagLibrary(final String namespaceURI, final TagLibrary tagli
private URL resolveURL(final String name) throws MalformedURLException {
final File file = new File(name);
if (file.exists()) {
return file.toURL();
return file.toURI().toURL();
}
return new URL(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,8 @@ protected void addExpressionScript(final ScriptBlock script, final Expression ex

final CompositeExpression compositeExpression
= (CompositeExpression) expression;
final Iterator iter = compositeExpression.getExpressions().iterator();
while (iter.hasNext()) {
addExpressionScript( newBlock, (Expression) iter.next() );
for (Object o : compositeExpression.getExpressions()) {
addExpressionScript(newBlock, (Expression) o);
}
}
else {
Expand Down Expand Up @@ -942,7 +941,7 @@ public void notationDecl(final String name, final String publicId, final String
* @throws SAXException if a parsing exception occurs
*/
public Script parse(final File file) throws IOException, SAXException {
return parse(file.toURL());
return parse(file.toURI().toURL());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.Parser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.jelly.Jelly;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
Expand Down Expand Up @@ -199,7 +199,7 @@ public CommandLine parseCommandLineOptions(final String[] args) throws ParseExce
filteredArgList.toArray(filterArgs);

// parse the command line
final Parser parser = new org.apache.commons.cli.GnuParser();
final DefaultParser parser = new DefaultParser();
return parser.parse(cmdLineOptions, filterArgs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Comparator;
import java.util.List;

import org.apache.commons.jelly.util.NestedRuntimeException;
import org.dom4j.Node;
import org.jaxen.JaxenException;
import org.jaxen.XPath;
Expand All @@ -34,7 +33,7 @@ public class XPathComparator implements Comparator {
/**
* My own runtime exception in case something goes wrong with sort.
*/
public static class XPathSortException extends NestedRuntimeException {
public static class XPathSortException extends RuntimeException {
public XPathSortException(final String message, final Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public JellyContext getJellyContext() throws MalformedURLException {
*/
public URL getRootContext() throws MalformedURLException {
if (rootContext == null) {
rootContext = new File(SystemProperties.getUserDir()).toURL();
rootContext = new File(SystemProperties.getUserDir()).toURI().toURL();
}
return rootContext;
}
Expand All @@ -157,7 +157,7 @@ public XMLOutput getXMLOutput() throws IOException {
protected URL resolveURL(final String name) throws MalformedURLException {
final File file = getProject().resolveFile(name);
if (file.exists()) {
return file.toURL();
return file.toURI().toURL();
}
return new URL(name);
}
Expand All @@ -166,7 +166,7 @@ protected URL resolveURL(final String name) throws MalformedURLException {
* Sets the script file to use
*/
public void setFile(final File file) throws MalformedURLException {
setUrl( file.toURL() );
setUrl( file.toURI().toURL() );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void configure( final Configuration config ) throws ConfigurationExceptio
URL url = null;
final File file = new File( scriptName );
if ( file.exists() ) {
url = file.toURL();
url = file.toURI().toURL();
}
else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ public XMLIntrospector getIntrospector() {
* as aliases to the common name mapping strategies or specify a class name String.
*/
public void setAttributeNameMapper(final NameMapper nameMapper) {
getIntrospector().setAttributeNameMapper(nameMapper);
getIntrospector().getConfiguration().setAttributeNameMapper(nameMapper);
}

/**
* Sets whether attributes or elements should be used for primitive types.
* The default is false.
*/
public void setAttributesForPrimitives(final boolean attributesForPrimitives) {
getIntrospector().setAttributesForPrimitives(attributesForPrimitives);
getIntrospector().getConfiguration().setAttributesForPrimitives(attributesForPrimitives);
}

// Implementation methods
Expand All @@ -179,7 +179,7 @@ public void setAttributesForPrimitives(final boolean attributesForPrimitives) {
* as aliases to the common name mapping strategies or specify a class name String.
*/
public void setElementNameMapper(final NameMapper nameMapper) {
getIntrospector().setElementNameMapper(nameMapper);
getIntrospector().getConfiguration().setElementNameMapper(nameMapper);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
Expand Down Expand Up @@ -58,10 +59,10 @@ public void doTag(final XMLOutput xmlOutput) throws JellyTagException {
final String bodyText = getBodyText();
if (httpMethod instanceof PostMethod) {
final PostMethod postMethod = (PostMethod) httpMethod;
postMethod.setRequestBody(bodyText);
postMethod.setRequestEntity(new StringRequestEntity(bodyText));
} else if (httpMethod instanceof PutMethod) {
final PutMethod putMethod = (PutMethod) httpMethod;
putMethod.setRequestBody(bodyText);
putMethod.setRequestEntity(new StringRequestEntity(bodyText));
} else {
throw new IllegalStateException("Http method from parent was "
+ "not post or put");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.params.*;
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
Expand Down Expand Up @@ -164,13 +165,26 @@ private HttpClient getHttpClient() {
HttpClient client = null;
if (session != null) {
client = session.getHttpClient();
client.setStrictMode(session.isStrictMode());
client.setParams(getClientParams());
} else {
client = new HttpClient();
}
return client;
}

/**
* Get the default parameters for the HttpClient to make it behave
* similar to Strict-Mode
*
* @return a HttpClientParams object with the strict parameters set
*/
private HttpClientParams getClientParams() {
HttpClientParams clientParams = new HttpClientParams();
clientParams.setParameters(new String[]{HttpClientParams.REJECT_RELATIVE_REDIRECT, HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, HttpMethodParams.UNAMBIGUOUS_STATUS_LINE, HttpMethodParams.SINGLE_COOKIE_HEADER, HttpMethodParams.STRICT_TRANSFER_ENCODING, HttpMethodParams.REJECT_HEAD_BODY, HttpMethodParams.WARN_EXTRA_INPUT}, Boolean.TRUE);
clientParams.setIntParameter(HttpMethodParams.STATUS_LINE_GARBAGE_LIMIT, 0);
return clientParams;
}

/**
* A method that must be implemented by subclasses to provide the
* {@link HttpMethod url method} implementation
Expand Down
Loading