You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/02/12 21:56:56 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/environment AbstractEnvironment.java
vgritsenko 02/02/12 12:56:56
Modified: src/java/org/apache/cocoon/environment
AbstractEnvironment.java
Log:
Remove URL -> File -> URL conversion
Revision Changes Path
1.7 +26 -24 xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java
Index: AbstractEnvironment.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractEnvironment.java 4 Feb 2002 14:17:57 -0000 1.6
+++ AbstractEnvironment.java 12 Feb 2002 20:56:56 -0000 1.7
@@ -73,7 +73,7 @@
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: AbstractEnvironment.java,v 1.6 2002/02/04 14:17:57 cziegeler Exp $
+ * @version CVS $Id: AbstractEnvironment.java,v 1.7 2002/02/12 20:56:56 vgritsenko Exp $
*/
public abstract class AbstractEnvironment extends AbstractLoggable implements Environment {
@@ -228,22 +228,17 @@
*/
public void changeContext(String prefix, String newContext)
throws MalformedURLException {
- if (getLogger().isDebugEnabled())
- {
- getLogger().debug("Changing Cocoon context(" + newContext + ") to prefix(" + prefix + ")");
- getLogger().debug("\tfrom context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")");
- getLogger().debug("\tat URI " + this.uris);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Changing Cocoon context");
+ getLogger().debug(" from context(" + this.context.toExternalForm() + ") and prefix(" + this.prefix + ")");
+ getLogger().debug(" to context(" + newContext + ") and prefix(" + prefix + ")");
+ getLogger().debug(" at URI " + this.uris);
}
if (prefix.length() >= 1 && !this.uris.startsWith(prefix)) {
- if (getLogger().isErrorEnabled())
- {
- this.getLogger().error("The current URI ("
- + this.uris + ") doesn't start with given prefix ("
- + prefix + ")"
- );
- }
-
- throw new RuntimeException("The current URI doesn't start with given prefix");
+ String message = "The current URI (" + this.uris +
+ ") doesn't start with given prefix (" + prefix + ")";
+ getLogger().error(message);
+ throw new RuntimeException(message);
}
if (prefix.length() >= 1) {
this.prefix.append(prefix);
@@ -256,25 +251,31 @@
}
}
- //if the resource is zipped into a war file (e.g. Weblogic temp deployment)
if (this.context.getProtocol().equals("zip")) {
+ // if the resource is zipped into a war file (e.g. Weblogic temp deployment)
+ // FIXME (VG): Is this still required? Better to unify both cases.
+ getLogger().debug("Base context is zip: " + this.context);
this.context = new URL(this.context.toString() + newContext);
-
- // if we got a absolute context or one with a protocol resolve it
} else {
+ // if we got a absolute context or one with a protocol resolve it
if (newContext.charAt(0) == '/') {
+ // context starts with the '/' - absolute file URL
this.context = new URL("file:" + newContext);
} else if (newContext.indexOf(':') > 1) {
+ // context have ':' - absolute URL
this.context = new URL(newContext);
} else {
+ // context is relative to old one
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();
+
+ // Cut the file name part from context (if present)
+ String s = this.context.toString();
+ int i = s.lastIndexOf('/');
+ if (i != -1 && i + 1 < s.length()) {
+ s = s.substring(0, i + 1);
}
+ this.context = new URL(s);
}
if (getLogger().isDebugEnabled()) {
@@ -286,8 +287,9 @@
* Redirect the client to a new URL
*/
public abstract void redirect(boolean sessionmode, String newURL) throws IOException;
+
public void globalRedirect(boolean sessionmode, String newURL) throws IOException {
- redirect(sessionmode,newURL);
+ redirect(sessionmode, newURL);
}
// Request methods
----------------------------------------------------------------------
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