aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/demo/util/SampleDirectory.java
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-10-27 07:57:12 +0000
committerArtur Signell <artur.signell@itmill.com>2009-10-27 07:57:12 +0000
commit6a3c715dae922edd723c9423b4308d5d7948b74e (patch)
tree46a007274681a9803afccf135ace5554f3e01e3a /src/com/vaadin/demo/util/SampleDirectory.java
parent931d75fef69deb9b738fad97001cf5621de9f43e (diff)
downloadvaadin-framework-6a3c715dae922edd723c9423b4308d5d7948b74e.tar.gz
vaadin-framework-6a3c715dae922edd723c9423b4308d5d7948b74e.zip
Split demo and tests files to own source folders, for #3298
svn changeset:9390/svn branch:6.2
Diffstat (limited to 'src/com/vaadin/demo/util/SampleDirectory.java')
-rw-r--r--src/com/vaadin/demo/util/SampleDirectory.java73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/com/vaadin/demo/util/SampleDirectory.java b/src/com/vaadin/demo/util/SampleDirectory.java
deleted file mode 100644
index a82b9bedc8..0000000000
--- a/src/com/vaadin/demo/util/SampleDirectory.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.demo.util;
-
-import java.io.File;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.SystemError;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-
-/**
- * Provides sample directory based on application directory. If this fails then
- * sampleDirectory property is read. If no sample directory is resolved, then a
- * panel displaying error message is added to main window.
- *
- * @author IT Mill Ltd.
- *
- */
-public class SampleDirectory {
-
- /**
- * Get sample directory.
- *
- * @param application
- * @return file pointing to sample directory
- */
- public static File getDirectory(Application application) {
- String errorMessage = "Access to application "
- + "context base directory failed, "
- + "possible security constraint with Application "
- + "Server or Servlet Container.<br />";
- File file = application.getContext().getBaseDirectory();
- if ((file == null) || (!file.canRead())
- || (file.getAbsolutePath() == null)) {
- // cannot access example directory, possible security issue with
- // Application Server or Servlet Container
- // Try to read sample directory from web.xml parameter
- if (application.getProperty("sampleDirectory") != null) {
- file = new File(application.getProperty("sampleDirectory"));
- if ((file != null) && (file.canRead())
- && (file.getAbsolutePath() != null)) {
- // Success using property
- return file;
- }
- // Failure using property
- errorMessage += "Failed also to access sample directory <b>["
- + application.getProperty("sampleDirectory")
- + "]</b> defined in <b>sampleDirectory property</b>.";
- } else {
- // Failure using application context base dir, no property set
- errorMessage += "<b>Note: </b>You can set this manually in "
- + "web.xml by defining " + "sampleDirectory property.";
- }
- } else {
- // Success using application context base dir
- return file;
- }
- // Add failure notification as an Panel to main window
- final Panel errorPanel = new Panel("Demo application error");
- errorPanel.setStyleName("strong");
- errorPanel.setComponentError(new SystemError(
- "Cannot provide sample directory"));
- errorPanel.addComponent(new Label(errorMessage, Label.CONTENT_XHTML));
- // Remove all components from applications main window
- application.getMainWindow().getContent().removeAllComponents();
- // Add error panel
- application.getMainWindow().getContent().addComponent(errorPanel);
- return null;
- }
-}