You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2001/11/26 12:34:59 UTC
cvs commit: xml-cocoon2/src/org/apache/cocoon/environment AbstractEnvironment.java
cziegeler 01/11/26 03:34:59
Modified: src/org/apache/cocoon/environment Tag: cocoon_20_branch
AbstractEnvironment.java
Log:
Fixing bug #5051
Revision Changes Path
No revision
No revision
1.6.2.16 +41 -44 xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java
Index: AbstractEnvironment.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java,v
retrieving revision 1.6.2.15
retrieving revision 1.6.2.16
diff -u -r1.6.2.15 -r1.6.2.16
--- AbstractEnvironment.java 2001/10/25 19:31:25 1.6.2.15
+++ AbstractEnvironment.java 2001/11/26 11:34:59 1.6.2.16
@@ -24,7 +24,7 @@
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.6.2.15 $ $Date: 2001/10/25 19:31:25 $
+ * @version CVS $Revision: 1.6.2.16 $ $Date: 2001/11/26 11:34:59 $
*/
public abstract class AbstractEnvironment extends AbstractLoggable implements Environment {
@@ -170,56 +170,53 @@
/**
* Adds an prefix to the overall stripped off prefix from the request uri
*/
- public void changeContext(String prefix, String context)
+ public void changeContext(String prefix, String newContext)
throws MalformedURLException {
- String uri = this.uris;
- getLogger().debug("Changing Cocoon context(" + context + ") to prefix(" + prefix + ")");
+ getLogger().debug("Changing Cocoon context(" + newContext + ") to prefix(" + prefix + ")");
getLogger().debug("\tfrom context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")");
- getLogger().debug("\tat URI " + uri);
- if(prefix.length()>=1){
- if (uri.startsWith(prefix)) {
- this.prefix.append(prefix);
- uri = uri.substring(prefix.length());
-
- // check for a slash at the beginning to avoid problems with subsitemaps
- if (uri.startsWith("/") == true) {
- uri = uri.substring(1);
- this.prefix.append('/');
- }
-
- //if the resource is zipped into a war file (e.g. Weblogic temp deployment)
- if (this.context.getProtocol().equals("zip")) {
- this.context = new URL(this.context.toString() + context);
-
- // if we got a absolute context or one with a protocol resolve it
- } else {
- if (context.charAt(0) == '/') {
- this.context = new URL("file:" + context);
- } else if (context.indexOf(':') > 1) {
- this.context = new URL(context);
- } else {
- this.context = new URL(this.context, context);
- }
- File f = new File(this.context.getFile());
- if (f.isFile()) {
- this.context = f.getParentFile().toURL();
- } else {
- this.context = f.toURL();
- }
- }
- } else {
- getLogger().error("The current URI ("
- + uri + ") doesn't start with given prefix ("
+ getLogger().debug("\tat URI " + this.uris);
+ if (prefix.length() >= 1 && this.uris.startsWith(prefix) == false) {
+ this.getLogger().error("The current URI ("
+ + this.uris + ") doesn't start with given prefix ("
+ prefix + ")"
- );
- throw new RuntimeException("The current URI ("
- + uri + ") doesn't start with given prefix ("
+ );
+ throw new RuntimeException("The current URI ("
+ + this.uris + ") doesn't start with given prefix ("
+ prefix + ")"
- );
+ );
+ }
+ if (prefix.length() >= 1) {
+ this.prefix.append(prefix);
+ this.uris = this.uris.substring(prefix.length());
+
+ // check for a slash at the beginning to avoid problems with subsitemaps
+ if (this.uris.startsWith("/") == true) {
+ this.uris = this.uris.substring(1);
+ this.prefix.append('/');
}
}
+
+ //if the resource is zipped into a war file (e.g. Weblogic temp deployment)
+ if (this.context.getProtocol().equals("zip")) {
+ this.context = new URL(this.context.toString() + newContext);
+
+ // if we got a absolute context or one with a protocol resolve it
+ } else {
+ if (newContext.charAt(0) == '/') {
+ this.context = new URL("file:" + newContext);
+ } else if (newContext.indexOf(':') > 1) {
+ this.context = new URL(newContext);
+ } else {
+ this.context = new URL(this.context, newContext);
+ }
+ File f = new File(this.context.getFile());
+ if (f.isFile()) {
+ this.context = f.getParentFile().toURL();
+ } else {
+ this.context = f.toURL();
+ }
+ }
getLogger().debug("New context is " + this.context.toExternalForm());
- this.uris = uri;
}
/**
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org