vgritsenko 2004/06/22 13:41:08
Modified: src/blocks/portal/java/org/apache/cocoon/portlet
CocoonPortlet.java
Log:
Sync with servlet, add portletContextURL into appContext
Revision Changes Path
1.7 +41 -16
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
Index: CocoonPortlet.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CocoonPortlet.java 18 Jun 2004 16:45:57 -0000 1.6
+++ CocoonPortlet.java 22 Jun 2004 20:41:08 -0000 1.7
@@ -15,10 +15,24 @@
*/
package org.apache.cocoon.portlet;
+import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
+import org.apache.avalon.excalibur.logger.LoggerManager;
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.LogKitLogger;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.cocoon.Cocoon;
import org.apache.cocoon.ConnectionResetException;
import org.apache.cocoon.Constants;
import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
import org.apache.cocoon.components.notification.Notifier;
import org.apache.cocoon.components.notification.Notifying;
@@ -32,20 +46,6 @@
import org.apache.cocoon.util.StringUtils;
import org.apache.cocoon.util.log.CocoonLogFormatter;
import org.apache.commons.lang.BooleanUtils;
-
-import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
-import org.apache.avalon.excalibur.logger.LoggerManager;
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.LogKitLogger;
-import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.instrument.InstrumentManager;
import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
import org.apache.log.ContextMap;
@@ -61,7 +61,6 @@
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -212,6 +211,11 @@
protected String portletContextPath;
/**
+ * This is the url to the portlet context directory
+ */
+ protected String portletContextURL;
+
+ /**
* The RequestFactory is responsible for wrapping multipart-encoded
* forms and for handing the file payload of incoming requests
*/
@@ -325,6 +329,26 @@
}
}
+ try {
+ if (path.indexOf(':') > 1) {
+ this.portletContextURL = path;
+ } else {
+ this.portletContextURL = new
File(path).toURL().toExternalForm();
+ }
+ } catch (MalformedURLException me) {
+ // VG: Novell has absolute file names starting with the
+ // volume name which is easily more then one letter.
+ // Examples: sys:/apache/cocoon or sys:\apache\cocoon
+ try {
+ this.portletContextURL = new
File(path).toURL().toExternalForm();
+ } catch (MalformedURLException ignored) {
+ throw new PortletException("Unable to determine servlet
context URL.", me);
+ }
+ }
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("URL for Root: " + this.portletContextURL);
+ }
+
this.forceLoadParameter = getInitParameter("load-class", null);
this.forceSystemProperty = getInitParameter("force-property", null);
@@ -340,6 +364,7 @@
}
}
this.appContext.put(Constants.CONTEXT_WORK_DIR, workDir);
+ this.appContext.put(ContextHelper.CONTEXT_ROOT_URL,
this.portletContextURL);
final String uploadDirParam =
conf.getInitParameter("upload-directory");
if (uploadDirParam != null) {