summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-04 16:59:24 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-05 11:39:35 +0300
commitb0b1a13247bf931eb7f33ff6d0a88fc1833144e9 (patch)
treeb00c4174fd4a9f2b0d77d45d835e4cc60469f994 /server/src
parentc71563c8a6e9993cbbdff3ddfdfccfee4aa34f7b (diff)
downloadvaadin-framework-b0b1a13247bf931eb7f33ff6d0a88fc1833144e9.tar.gz
vaadin-framework-b0b1a13247bf931eb7f33ff6d0a88fc1833144e9.zip
Move getBaseDirectory() to DeploymentConfiguration (#9402)
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/server/ApplicationContext.java15
-rw-r--r--server/src/com/vaadin/server/DeploymentConfiguration.java15
-rw-r--r--server/src/com/vaadin/server/PortletApplicationContext2.java30
-rw-r--r--server/src/com/vaadin/server/ServletApplicationContext.java16
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java26
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java11
6 files changed, 52 insertions, 61 deletions
diff --git a/server/src/com/vaadin/server/ApplicationContext.java b/server/src/com/vaadin/server/ApplicationContext.java
index 2c09ed3857..85a77241d9 100644
--- a/server/src/com/vaadin/server/ApplicationContext.java
+++ b/server/src/com/vaadin/server/ApplicationContext.java
@@ -15,7 +15,6 @@
*/
package com.vaadin.server;
-import java.io.File;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
@@ -149,20 +148,6 @@ public abstract class ApplicationContext implements HttpSessionBindingListener,
}
/**
- * Returns application context base directory.
- *
- * Typically an application is deployed in a such way that is has an
- * application directory. For web applications this directory is the root
- * directory of the web applications. In some cases applications might not
- * have an application directory (for example web applications running
- * inside a war).
- *
- * @return The application base directory or null if the application has no
- * base directory.
- */
- public abstract File getBaseDirectory();
-
- /**
* Gets the session to which this application context is currently
* associated.
*
diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java
index 1f202eb923..0a70ef09b3 100644
--- a/server/src/com/vaadin/server/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DeploymentConfiguration.java
@@ -16,6 +16,7 @@
package com.vaadin.server;
+import java.io.File;
import java.io.Serializable;
import java.util.Iterator;
@@ -123,4 +124,18 @@ public interface DeploymentConfiguration extends Serializable {
* @return the system messages object
*/
public SystemMessages getSystemMessages();
+
+ /**
+ * Returns application context base directory.
+ *
+ * Typically an application is deployed in a such way that is has an
+ * application directory. For web applications this directory is the root
+ * directory of the web applications. In some cases applications might not
+ * have an application directory (for example web applications running
+ * inside a war).
+ *
+ * @return The application base directory or null if the application has no
+ * base directory.
+ */
+ public File getBaseDirectory();
}
diff --git a/server/src/com/vaadin/server/PortletApplicationContext2.java b/server/src/com/vaadin/server/PortletApplicationContext2.java
index 6a12eafc47..f157dc9ae6 100644
--- a/server/src/com/vaadin/server/PortletApplicationContext2.java
+++ b/server/src/com/vaadin/server/PortletApplicationContext2.java
@@ -15,15 +15,11 @@
*/
package com.vaadin.server;
-import java.io.File;
import java.io.Serializable;
-import java.net.URL;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
@@ -69,28 +65,6 @@ public class PortletApplicationContext2 extends ApplicationContext {
private final Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>();
private final Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>();
- @Override
- public File getBaseDirectory() {
- PortletSession session = getPortletSession();
- String resultPath = session.getPortletContext().getRealPath("/");
- if (resultPath != null) {
- return new File(resultPath);
- } else {
- try {
- final URL url = session.getPortletContext().getResource("/");
- return new File(url.getFile());
- } catch (final Exception e) {
- // FIXME: Handle exception
- getLogger()
- .log(Level.INFO,
- "Cannot access base directory, possible security issue "
- + "with Application Server or Servlet Container",
- e);
- }
- }
- return null;
- }
-
protected PortletCommunicationManager getApplicationManager(
Application application) {
PortletCommunicationManager mgr = (PortletCommunicationManager) applicationToAjaxAppMgrMap
@@ -403,8 +377,4 @@ public class PortletApplicationContext2 extends ApplicationContext {
"Portlet mode can only be changed from a portlet request");
}
}
-
- private Logger getLogger() {
- return Logger.getLogger(PortletApplicationContext2.class.getName());
- }
}
diff --git a/server/src/com/vaadin/server/ServletApplicationContext.java b/server/src/com/vaadin/server/ServletApplicationContext.java
index 4184b68de4..910051a26b 100644
--- a/server/src/com/vaadin/server/ServletApplicationContext.java
+++ b/server/src/com/vaadin/server/ServletApplicationContext.java
@@ -16,7 +16,6 @@
package com.vaadin.server;
-import java.io.File;
import java.util.Enumeration;
import java.util.HashMap;
@@ -99,21 +98,6 @@ public class ServletApplicationContext extends ApplicationContext {
}
/**
- * Gets the application context base directory.
- *
- * @see com.vaadin.server.ApplicationContext#getBaseDirectory()
- */
- @Override
- public File getBaseDirectory() {
- final String realPath = VaadinServlet.getResourcePath(getHttpSession()
- .getServletContext(), "/");
- if (realPath == null) {
- return null;
- }
- return new File(realPath);
- }
-
- /**
* Gets the http-session application is running in.
*
* @return HttpSession this application context resides in.
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 923fcd3b71..5fb2340bc8 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -16,6 +16,7 @@
package com.vaadin.server;
import java.io.BufferedWriter;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -24,11 +25,13 @@ import java.io.PrintWriter;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.portlet.ActionRequest;
@@ -154,6 +157,29 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
public SystemMessages getSystemMessages() {
return ServletPortletHelper.DEFAULT_SYSTEM_MESSAGES;
}
+
+ @Override
+ public File getBaseDirectory() {
+ PortletContext context = getPortlet().getPortletContext();
+ String resultPath = context.getRealPath("/");
+ if (resultPath != null) {
+ return new File(resultPath);
+ } else {
+ try {
+ final URL url = context.getResource("/");
+ return new File(url.getFile());
+ } catch (final Exception e) {
+ // FIXME: Handle exception
+ getLogger()
+ .log(Level.INFO,
+ "Cannot access base directory, possible security issue "
+ + "with Application Server or Servlet Container",
+ e);
+ }
+ }
+ return null;
+ }
+
}
public static class WrappedHttpAndPortletRequest extends
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 3cf2c645a0..62fb8ba71e 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -16,6 +16,7 @@
package com.vaadin.server;
import java.io.BufferedWriter;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -140,6 +141,16 @@ public class VaadinServlet extends HttpServlet implements Constants {
public SystemMessages getSystemMessages() {
return ServletPortletHelper.DEFAULT_SYSTEM_MESSAGES;
}
+
+ @Override
+ public File getBaseDirectory() {
+ final String realPath = VaadinServlet.getResourcePath(
+ servlet.getServletContext(), "/");
+ if (realPath == null) {
+ return null;
+ }
+ return new File(realPath);
+ }
}
private static class AbstractApplicationServletWrapper implements Callback {