ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1536530 - in /ace/trunk/org.apache.ace.webui.vaadin: resources/VAADIN/themes/reindeer/ src/org/apache/ace/webui/vaadin/ src/org/apache/ace/webui/vaadin/component/
Date Mon, 28 Oct 2013 21:13:15 GMT
Author: jawi
Date: Mon Oct 28 21:13:14 2013
New Revision: 1536530

URL: http://svn.apache.org/r1536530
Log:
Some cleanups and improvements:

- inlined the redundant ArtifactTable (didn't provide any real logic);
- made the login window a little more friendly with respect to its 
  error messages by showing them inline in the login window;
- made the session timeout configurable for the web UI;
- redirect to the login window when a session timeout occors;
- disable the store/revert buttons by default.


Removed:
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/ArtifactTable.java
Modified:
    ace/trunk/org.apache.ace.webui.vaadin/resources/VAADIN/themes/reindeer/styles.css
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinResourceHandler.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/resources/VAADIN/themes/reindeer/styles.css
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/resources/VAADIN/themes/reindeer/styles.css?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/resources/VAADIN/themes/reindeer/styles.css (original)
+++ ace/trunk/org.apache.ace.webui.vaadin/resources/VAADIN/themes/reindeer/styles.css Mon
Oct 28 21:13:14 2013
@@ -6019,3 +6019,7 @@ textarea.v-textarea-readonly,
 .v-selected .v-table-row-odd.vtable-cell-content-description {
 	color: white;
 }
+.v-label-alert {
+	font-weight: bold;
+	color: red;
+}

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java (original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java Mon
Oct 28 21:13:14 2013
@@ -37,6 +37,12 @@ import com.vaadin.ui.Label;
 import com.vaadin.ui.VerticalLayout;
 
 public class Activator extends DependencyActivatorBase {
+    private static final String PID = "org.apache.ace.webui.vaadin";
+
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception
{
+    }
+
     @Override
     public void init(BundleContext context, DependencyManager manager) throws Exception {
         manager.add(createComponent()
@@ -51,7 +57,7 @@ public class Activator extends Dependenc
             .setInterface(Servlet.class.getName(), null)
             .setImplementation(VaadinServlet.class)
             .add(createConfigurationDependency()
-                .setPid(VaadinServlet.PID).setPropagate(true))
+                .setPid(PID).setPropagate(true))
             );
 
         Properties props = new Properties();
@@ -81,8 +87,4 @@ public class Activator extends Dependenc
             })
             );
     }
-
-    @Override
-    public void destroy(BundleContext context, DependencyManager manager) throws Exception
{
-    }
 }

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/AddArtifactWindow.java
Mon Oct 28 21:13:14 2013
@@ -93,14 +93,19 @@ abstract class AddArtifactWindow extends
         m_artifactsTable.addContainerProperty(PROPERTY_VERSION, String.class, null);
         m_artifactsTable.addContainerProperty(PROPERTY_PURGE, Button.class, null);
         m_artifactsTable.setSizeFull();
-        m_artifactsTable.setSelectable(true);
-        m_artifactsTable.setMultiSelect(true);
+        m_artifactsTable.setSelectable(false);
+        m_artifactsTable.setMultiSelect(false);
         m_artifactsTable.setImmediate(true);
         m_artifactsTable.setHeight("15em");
 
-        final Table uploadedArtifacts = new ArtifactTable();
-        uploadedArtifacts.setCaption("Uploaded artifacts");
+        final Table uploadedArtifacts = new Table("Uploaded artifacts");
+        uploadedArtifacts.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null);
+        uploadedArtifacts.addContainerProperty(PROPERTY_VERSION, String.class, null);
+        uploadedArtifacts.setSizeFull();
         uploadedArtifacts.setSelectable(false);
+        uploadedArtifacts.setMultiSelect(false);
+        uploadedArtifacts.setImmediate(true);
+        uploadedArtifacts.setHeight("15em");
 
         final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir)
{
             @Override
@@ -115,8 +120,8 @@ abstract class AddArtifactWindow extends
                         URL artifact = handle.getFile().toURI().toURL();
 
                         Item item = uploadedArtifacts.addItem(artifact);
-                        item.getItemProperty(ArtifactTable.PROPERTY_SYMBOLIC_NAME).setValue(handle.getFilename());
-                        item.getItemProperty(ArtifactTable.PROPERTY_VERSION).setValue("");
+                        item.getItemProperty(PROPERTY_SYMBOLIC_NAME).setValue(handle.getFilename());
+                        item.getItemProperty(PROPERTY_VERSION).setValue("");
 
                         m_uploadedArtifacts.add(handle.getFile());
                     }
@@ -160,7 +165,7 @@ abstract class AddArtifactWindow extends
                 dataSource.removeAllContainerFilters();
 
                 if (searchValue != null && searchValue.trim().length() > 0) {
-                    dataSource.addContainerFilter(ArtifactTable.PROPERTY_SYMBOLIC_NAME, searchValue,
+                    dataSource.addContainerFilter(PROPERTY_SYMBOLIC_NAME, searchValue,
                         true /* ignoreCase */, false /* onlyMatchPrefix */);
                 }
             }
@@ -251,8 +256,8 @@ abstract class AddArtifactWindow extends
                 catch (Exception exception) {
                     Item item = artifacts.getItem(itemID);
 
-                    Object symbolicName = item.getItemProperty(ArtifactTable.PROPERTY_SYMBOLIC_NAME).getValue();
-                    Object version = item.getItemProperty(ArtifactTable.PROPERTY_VERSION).getValue();
+                    Object symbolicName = item.getItemProperty(PROPERTY_SYMBOLIC_NAME).getValue();
+                    Object version = item.getItemProperty(PROPERTY_VERSION).getValue();
 
                     showErrorNotification("Import artifact failed", "Artifact " + symbolicName
+ " " + version
                         + "<br />could not be imported into the repository."

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
Mon Oct 28 21:13:14 2013
@@ -18,34 +18,48 @@
  */
 package org.apache.ace.webui.vaadin;
 
+import java.util.Map;
+
 import org.osgi.service.log.LogService;
 
+import com.vaadin.event.FieldEvents;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
 import com.vaadin.event.ShortcutAction.KeyCode;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
 import com.vaadin.ui.PasswordField;
 import com.vaadin.ui.TextField;
 import com.vaadin.ui.VerticalLayout;
 import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
 
 /**
  * Provides a simple login dialog.
  */
 public class LoginWindow extends Window {
-
-    public interface LoginFunction {
+    /**
+     *  
+     */
+    public static interface LoginFunction {
         boolean login(String name, String password);
     }
 
-    private volatile LogService m_log;
+    private final LogService m_log;
+    private final LoginFunction m_loginFunction;
 
-    private TextField m_name;
-    private PasswordField m_password;
-    private Button m_loginButton;
-    private LoginFunction m_loginFunction;
+    private final Label m_additionalInfo;
 
-    public LoginWindow(final LogService log, final LoginFunction loginFunction) {
+    /**
+     * Creates a new {@link LoginWindow} instance.
+     * 
+     * @param log
+     *            the log service to use;
+     * @param loginFunction
+     *            the login callback to use.
+     */
+    public LoginWindow(LogService log, LoginFunction loginFunction) {
         super("Apache ACE Login");
 
         m_log = log;
@@ -54,29 +68,45 @@ public class LoginWindow extends Window 
         setResizable(false);
         setClosable(false);
         setModal(true);
-        setWidth("15em");
+        setWidth("20em");
 
-        m_name = new TextField("Name", "");
-        m_name.setImmediate(true);
+        m_additionalInfo = new Label("");
+        m_additionalInfo.setImmediate(true);
+        m_additionalInfo.setStyleName("alert");
+        m_additionalInfo.setHeight("1.2em");
+        // Ensures the information message disappears when starting typing...
+        FieldEvents.TextChangeListener changeListener = new FieldEvents.TextChangeListener()
{
+            @Override
+            public void textChange(TextChangeEvent event) {
+                m_additionalInfo.setValue("");
+            }
+        };
 
-        m_password = new PasswordField("Password", "");
-        m_password.setImmediate(true);
+        final TextField nameField = new TextField("Name", "");
+        nameField.addListener(changeListener);
+        nameField.setImmediate(true);
+        nameField.setWidth("100%");
+
+        final PasswordField passwordField = new PasswordField("Password", "");
+        passwordField.addListener(changeListener);
+        passwordField.setImmediate(true);
+        passwordField.setWidth("100%");
 
-        m_loginButton = new Button("Login");
-        m_loginButton.setImmediate(true);
+        Button loginButton = new Button("Login");
+        loginButton.setImmediate(true);
         // Allow enter to be used to login directly...
-        m_loginButton.setClickShortcut(KeyCode.ENTER);
+        loginButton.setClickShortcut(KeyCode.ENTER);
         // Highlight this button as the default one...
-        m_loginButton.addStyleName("primary");
+        loginButton.addStyleName(Reindeer.BUTTON_DEFAULT);
 
-        m_loginButton.addListener(new Button.ClickListener() {
+        loginButton.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
-                final Button button = event.getButton();
+                Button button = event.getButton();
                 button.setEnabled(false);
 
                 try {
-                    String username = (String) m_name.getValue();
-                    String password = (String) m_password.getValue();
+                    String username = (String) nameField.getValue();
+                    String password = (String) passwordField.getValue();
 
                     if (m_loginFunction.login(username, password)) {
                         m_log.log(LogService.LOG_INFO, "Apache Ace WebUI succesfull login
by user: " + username);
@@ -86,8 +116,10 @@ public class LoginWindow extends Window 
                     else {
                         m_log.log(LogService.LOG_WARNING, "Apache Ace WebUI invalid username
or password entered.");
 
-                        getParent().showNotification("Invalid username or password!");
-                        setRelevantFocus();
+                        m_additionalInfo.setValue("Invalid username or password!");
+
+                        nameField.focus();
+                        nameField.selectAll();
                     }
                 }
                 finally {
@@ -101,27 +133,42 @@ public class LoginWindow extends Window 
         content.setMargin(true);
         content.setSizeFull();
 
-        content.addComponent(m_name);
-        content.addComponent(m_password);
-        content.addComponent(m_loginButton);
+        content.addComponent(nameField);
+        content.addComponent(passwordField);
+        content.addComponent(m_additionalInfo);
+        content.addComponent(loginButton);
 
-        content.setComponentAlignment(m_loginButton, Alignment.BOTTOM_CENTER);
+        content.setComponentAlignment(loginButton, Alignment.BOTTOM_CENTER);
 
-        setRelevantFocus();
+        nameField.focus();
     }
 
     /**
-     * Gives the username field the current focus.
+     * Shows this login window on screen.
+     * 
+     * @param parent
+     *            the parent window, cannot be <code>null</code>.
      */
-    void setRelevantFocus() {
-        m_name.focus();
-        m_name.selectAll();
+    public void openWindow(Window parent) {
+        parent.addParameterHandler(this);
+        parent.addWindow(this);
+
+        center();
     }
 
     /**
      * Closes this login window.
      */
     public void closeWindow() {
+        getParent().removeParameterHandler(this);
         getParent().removeWindow(this);
     }
-}
\ No newline at end of file
+
+    @Override
+    public void handleParameters(Map<String, String[]> parameters) {
+        if (parameters.containsKey("sessionTimedOut")) {
+            m_additionalInfo.setValue("Session timed out!");
+        }
+        super.handleParameters(parameters);
+    }
+}

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
Mon Oct 28 21:13:14 2013
@@ -30,6 +30,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.ace.authentication.api.AuthenticationService;
 import org.apache.ace.client.repository.RepositoryAdmin;
@@ -98,7 +99,8 @@ public class VaadinClient extends com.va
 
     private static final long serialVersionUID = 1L;
 
-    private static long SESSION_ID = 1;
+    private static final AtomicLong SESSION_ID = new AtomicLong(1L);
+
     private static final String targetRepo = "target";
     private static final String shopRepo = "shop";
     private static final String deployRepo = "deployment";
@@ -108,7 +110,7 @@ public class VaadinClient extends com.va
 
     // basic session ID generator
     private static long generateSessionID() {
-        return SESSION_ID++;
+        return SESSION_ID.getAndIncrement();
     }
 
     /**
@@ -197,7 +199,7 @@ public class VaadinClient extends com.va
      * @param userName
      *            the hardcoded username to use when authentication is disabled.
      */
-    public VaadinClient(DependencyManager manager, URL aceHost, URL obrUrl, String repositoryXML,
boolean useAuth, String userName) {
+    public VaadinClient(DependencyManager manager, URL aceHost, URL obrUrl, String repositoryXML,
boolean useAuth, String userName, String password) {
         m_manager = manager;
         try {
             m_repository = new URL(aceHost, endpoint);
@@ -1073,8 +1075,6 @@ public class VaadinClient extends com.va
     private void showLoginWindow() {
         LoginWindow loginWindow = new LoginWindow(m_log, this);
 
-        m_mainWindow.addWindow(loginWindow);
-
-        loginWindow.center();
+        loginWindow.openWindow(getMainWindow());
     }
 }

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinResourceHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinResourceHandler.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinResourceHandler.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinResourceHandler.java
Mon Oct 28 21:13:14 2013
@@ -32,8 +32,8 @@ import org.osgi.service.http.NamespaceEx
 public class VaadinResourceHandler {
     private volatile HttpService m_http;
     private HttpContext m_context;
-	private BundleContext m_bundleContext;
-    
+    private BundleContext m_bundleContext;
+
     public void start() {
         m_context = m_http.createDefaultHttpContext();
         try {
@@ -43,14 +43,13 @@ public class VaadinResourceHandler {
                 }
 
                 /**
-                 * ACE uses a slightly modified version of the 'reindeer' theme. To avoid
having
-                 * to copy all resources in the Vaadin jar, we only override the files we
changed
-                 * and do replace the theme name 'ace' with 'reindeer' before we go looking
for the
-                 * original files.
+                 * ACE uses a slightly modified version of the 'reindeer' theme. To avoid
having to copy all resources
+                 * in the Vaadin jar, we only override the files we changed and do replace
the theme name 'ace' with
+                 * 'reindeer' before we go looking for the original files.
                  * 
-                 * When updating to a new Vaadin version, usually you need to copy the styles.css
-                 * file from the original archive again and append the ACE changes to the
end, as this
-                 * file tends to change considerably between versions.
+                 * When updating to a new Vaadin version, usually you need to copy the styles.css
file from the original
+                 * archive again and append the ACE changes to the end, as this file tends
to change considerably
+                 * between versions.
                  */
                 public URL getResource(String name) {
                     URL resource = null;
@@ -59,8 +58,8 @@ public class VaadinResourceHandler {
                     if (!name.startsWith("/")) {
                         name = "/" + name;
                     }
-					if (name.startsWith(prefix)) {
-                    	String originalName = name.replace("/ace/", "/reindeer/");
+                    if (name.startsWith(prefix)) {
+                        String originalName = name.replace("/ace/", "/reindeer/");
                         resource = m_bundleContext.getBundle().getEntry(originalName);
                         if (resource == null) {
                             // try to find the resource in the Vaadin bundle instead
@@ -72,7 +71,8 @@ public class VaadinResourceHandler {
 
                 public boolean handleSecurity(HttpServletRequest request, HttpServletResponse
response) throws IOException {
                     return m_context.handleSecurity(request, response);
-                }});
+                }
+            });
         }
         catch (NamespaceException e) {
             e.printStackTrace();

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
Mon Oct 28 21:13:14 2013
@@ -31,34 +31,113 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.ManagedService;
 
 import com.vaadin.Application;
+import com.vaadin.Application.CustomizedSystemMessages;
+import com.vaadin.Application.SystemMessages;
 import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
 import com.vaadin.terminal.gwt.server.WebApplicationContext;
 
 public class VaadinServlet extends AbstractApplicationServlet implements ManagedService {
-    private static final int SESSION_TIMEOUT = 300; // in seconds (so 120 = 2 minutes)
     private static final long serialVersionUID = 1L;
-    public static final String PID = "org.apache.ace.webui.vaadin";
 
+    /** denotes what endpoint we're serving this servlet. */
+    private static final String KEY_SERVLET_ENDPOINT = "org.apache.ace.server.servlet.endpoint";
     /** A boolean denoting whether or not authentication is enabled. */
     private static final String KEY_USE_AUTHENTICATION = "ui.authentication.enabled";
-
     /** Name of the user to log in as. */
     private static final String KEY_USER_NAME = "ui.authentication.user.name";
-
+    /** Password of the user to log in as. */
+    private static final String KEY_USER_PASSWORD = "ui.authentication.user.password";
     /** A string denoting the host name of the management service. */
     private static final String KEY_ACE_HOST = "ace.host";
-
     /** A string denoting the URL to the management server's OBR. */
     private static final String KEY_OBR_URL = "obr.url";
-
     /** A string denoting the URL to the management server's OBR. */
     private static final String KEY_OBR_XML = "obr.xml";
+    /** The timeout (in seconds) of a session. */
+    private static final String KEY_SESSION_TIMEOUT = "session.timeout";
+
+    private static final boolean DEFAULT_USE_AUTHENTICATION = false;
+    private static final String DEFAULT_USER_NAME = "";
+    private static final String DEFAULT_PASSWORD = "";
+    private static final URL DEFAULT_ACE_HOST;
+    private static final URL DEFAULT_OBR_URL;
+    private static final String DEFAULT_OBR_XML = "repository.xml";
+    private static final String DEFAULT_SERVLET_ENDPOINT = "/ace";
+    private static final int DEFAULT_SESSION_TIMEOUT = 300; // in seconds.
+
+    static {
+        try {
+            DEFAULT_ACE_HOST = new URL("http://localhost:8080/");
+            DEFAULT_OBR_URL = new URL("http://localhost:8080/obr/");
+        }
+        catch (MalformedURLException exception) {
+            throw new RuntimeException("Should never happen!");
+        }
+    }
+
     private volatile DependencyManager m_manager;
     private volatile boolean m_useAuth;
     private volatile String m_userName;
+    private volatile String m_password;
     private volatile URL m_aceHost;
     private volatile URL m_obrUrl;
     private volatile String m_repositoryXML;
+    private volatile String m_servletEndpoint;
+    private volatile int m_sessionTimeout;
+
+    /**
+     * Creates a new {@link VaadinServlet} instance.
+     */
+    public VaadinServlet() {
+        m_useAuth = DEFAULT_USE_AUTHENTICATION;
+        m_userName = DEFAULT_USER_NAME;
+        m_password = DEFAULT_PASSWORD;
+        m_aceHost = DEFAULT_ACE_HOST;
+        m_obrUrl = DEFAULT_OBR_URL;
+        m_repositoryXML = DEFAULT_OBR_XML;
+        m_servletEndpoint = DEFAULT_SERVLET_ENDPOINT;
+        m_sessionTimeout = DEFAULT_SESSION_TIMEOUT;
+    }
+
+    @Override
+    public void updated(Dictionary dictionary) throws ConfigurationException {
+        boolean useAuth = DEFAULT_USE_AUTHENTICATION;
+        String userName = DEFAULT_USER_NAME;
+        String password = DEFAULT_PASSWORD;
+        URL aceHost = DEFAULT_ACE_HOST;
+        URL obrUrl = DEFAULT_OBR_URL;
+        String repositoryXML = DEFAULT_OBR_XML;
+        String servletEndpoint = DEFAULT_SERVLET_ENDPOINT;
+        int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
+
+        if (dictionary != null) {
+            useAuth = getBoolean(dictionary, KEY_USE_AUTHENTICATION);
+            userName = getOptionalString(dictionary, KEY_USER_NAME);
+            password = getOptionalString(dictionary, KEY_USER_PASSWORD);
+            aceHost = getURL(dictionary, KEY_ACE_HOST);
+            obrUrl = getURL(dictionary, KEY_OBR_URL);
+            repositoryXML = getOptionalString(dictionary, KEY_OBR_XML);
+            servletEndpoint = getOptionalString(dictionary, KEY_SERVLET_ENDPOINT);
+            sessionTimeout = getInteger(dictionary, KEY_SESSION_TIMEOUT);
+        }
+
+        if ("".equals(repositoryXML)) {
+            repositoryXML = DEFAULT_OBR_XML;
+        }
+
+        if ("".equals(userName) && !useAuth) {
+            throw new ConfigurationException(KEY_USER_NAME, "Missing value; authentication
is disabled!");
+        }
+
+        m_useAuth = useAuth;
+        m_userName = userName;
+        m_password = password;
+        m_aceHost = aceHost;
+        m_obrUrl = obrUrl;
+        m_repositoryXML = repositoryXML;
+        m_servletEndpoint = servletEndpoint;
+        m_sessionTimeout = sessionTimeout;
+    }
 
     @Override
     protected Class<? extends Application> getApplicationClass() {
@@ -66,72 +145,69 @@ public class VaadinServlet extends Abstr
     }
 
     @Override
+    protected WebApplicationContext getApplicationContext(HttpSession session) {
+        session.setMaxInactiveInterval(m_sessionTimeout);
+
+        return super.getApplicationContext(session);
+    }
+
+    @Override
     protected Application getNewApplication(HttpServletRequest request) throws ServletException
{
-        return new VaadinClient(m_manager, m_aceHost, m_obrUrl, m_repositoryXML, m_useAuth,
-            m_userName);
+        return new VaadinClient(m_manager, m_aceHost, m_obrUrl, m_repositoryXML, m_useAuth,
m_userName, m_password);
     }
 
     @Override
-    protected WebApplicationContext getApplicationContext(HttpSession session) {
-        if (session.getMaxInactiveInterval() != SESSION_TIMEOUT) {
-            session.setMaxInactiveInterval(SESSION_TIMEOUT);
-        }
+    protected SystemMessages getSystemMessages() {
+        CustomizedSystemMessages msgs = new CustomizedSystemMessages();
+        msgs.setSessionExpiredNotificationEnabled(false);
+        msgs.setSessionExpiredURL(m_servletEndpoint.concat("/?sessionTimedOut"));
+        return msgs;
+    }
 
-        return super.getApplicationContext(session);
+    private boolean getBoolean(Dictionary dictionary, String key) throws ConfigurationException
{
+        Object value = dictionary.get(key);
+        if (value == null || !(value instanceof String)) {
+            throw new ConfigurationException(key, "Missing property");
+        }
+        String valueStr = ((String) value).trim();
+        if (!("true".equalsIgnoreCase(valueStr) || "false".equalsIgnoreCase(valueStr))) {
+            throw new ConfigurationException(key, "Invalid value!");
+        }
+        return Boolean.parseBoolean(valueStr);
     }
 
-    public void updated(Dictionary dictionary) throws ConfigurationException {
-        if (dictionary == null) {
-            return;
+    private int getInteger(Dictionary dictionary, String key) throws ConfigurationException
{
+        Object value = dictionary.get(key);
+        if (value == null || !(value instanceof String)) {
+            throw new ConfigurationException(key, "Missing property");
         }
-        URL aceHost;
         try {
-            String aceHostString = (String) dictionary.get(KEY_ACE_HOST);
-            if (aceHostString == null) {
-                throw new ConfigurationException(KEY_ACE_HOST, "Missing property");
-            }
-            aceHost = new URL(aceHostString);
+            String valueStr = ((String) value).trim();
+            return Integer.parseInt(valueStr);
         }
-        catch (MalformedURLException e) {
-            throw new ConfigurationException(KEY_ACE_HOST, "Is not a valid URL", e);
+        catch (NumberFormatException exception) {
+            throw new ConfigurationException(key, "Invalid value!");
         }
+    }
 
-        URL obrUrl;
-        try {
-            String obrUrlString = (String) dictionary.get(KEY_OBR_URL);
-            if (obrUrlString == null) {
-                throw new ConfigurationException(KEY_OBR_URL, "Missing property");
-            }
-            obrUrl = new URL(obrUrlString);
-        }
-        catch (MalformedURLException e) {
-            throw new ConfigurationException(KEY_OBR_URL, "Is not a valid URL", e);
+    private String getOptionalString(Dictionary dictionary, String key) throws ConfigurationException
{
+        Object value = dictionary.get(key);
+        if (value != null && !(value instanceof String)) {
+            throw new ConfigurationException(key, "Missing property");
         }
+        return (value == null) ? "" : ((String) value).trim();
+    }
 
-        String repositoryXML = (String) dictionary.get(KEY_OBR_XML);
-        if ((repositoryXML == null) ||
-            (repositoryXML.trim().length() == 0)) {
-            repositoryXML = "repository.xml";
+    private URL getURL(Dictionary dictionary, String key) throws ConfigurationException {
+        Object value = dictionary.get(key);
+        if (value == null || !(value instanceof String)) {
+            throw new ConfigurationException(key, "Missing property");
         }
-
-        String useAuthString = (String) dictionary.get(KEY_USE_AUTHENTICATION);
-        if ((useAuthString == null) ||
-            !("true".equalsIgnoreCase(useAuthString) ||
-            "false".equalsIgnoreCase(useAuthString))) {
-            throw new ConfigurationException(KEY_USE_AUTHENTICATION, "Missing or invalid
value!");
+        try {
+            return new URL((String) value);
         }
-
-        boolean useAuth = Boolean.parseBoolean(useAuthString);
-
-        String userNameString = (String) dictionary.get(KEY_USER_NAME);
-        if ((userNameString == null) && !useAuth) {
-            throw new ConfigurationException(KEY_USER_NAME, "Missing value; authentication
is disabled!");
+        catch (MalformedURLException e) {
+            throw new ConfigurationException(key, "Is not a valid URL", e);
         }
-
-        m_useAuth = useAuth;
-        m_userName = userNameString;
-        m_aceHost = aceHost;
-        m_obrUrl = obrUrl;
-        m_repositoryXML = repositoryXML;
     }
 }

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java?rev=1536530&r1=1536529&r2=1536530&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
Mon Oct 28 21:13:14 2013
@@ -326,6 +326,9 @@ public abstract class MainActionToolbar 
                 Notification.TYPE_ERROR_MESSAGE);
         }
 
+        // always enabled...
+        m_retrieveButton.setEnabled(true);
+        // only enabled when an actual change has been made...
         m_storeButton.setEnabled(modified);
         m_revertButton.setEnabled(modified);
     }
@@ -398,14 +401,17 @@ public abstract class MainActionToolbar 
      */
     private void initComponent() {
         m_retrieveButton = new Button("Retrieve");
+        m_retrieveButton.setEnabled(false);
         m_retrieveButton.addListener(new RetrieveButtonListener());
         addComponent(m_retrieveButton, 0, 0);
 
         m_storeButton = new Button("Store");
+        m_storeButton.setEnabled(false);
         m_storeButton.addListener(new StoreButtonListener());
         addComponent(m_storeButton, 1, 0);
 
         m_revertButton = new Button("Revert");
+        m_revertButton.setEnabled(false);
         m_revertButton.addListener(new RevertButtonListener());
         addComponent(m_revertButton, 2, 0);
 



Mime
View raw message