Fixed some annoyances and abbeyances:

- log information to the log service in case a generic action like "store" or
  "revert" fails;
- in case a login fails due to problems with the backend, do not show the main
  grid (causing multiple grids to appear when trying to login again);
- show more information about the state changes of a target in the status line
  (instead of `Target foo null` message).



git-svn-id: https://svn.apache.org/repos/asf/ace/trunk@1801736 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
index 220bca4..b9e813a 100644
--- a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
+++ b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/LoginWindow.java
@@ -18,6 +18,9 @@
  */
 package org.apache.ace.webui.vaadin;
 
+import static org.osgi.service.log.LogService.LOG_INFO;
+import static org.osgi.service.log.LogService.LOG_WARNING;
+
 import java.util.Map;
 
 import org.osgi.service.log.LogService;
@@ -40,7 +43,7 @@
  */
 public class LoginWindow extends Window {
     /**
-     *  
+     *
      */
     public static interface LoginFunction {
         boolean login(String name, String password);
@@ -53,7 +56,7 @@
 
     /**
      * Creates a new {@link LoginWindow} instance.
-     * 
+     *
      * @param log
      *            the log service to use;
      * @param loginFunction
@@ -109,12 +112,12 @@
                     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);
+                        m_log.log(LOG_INFO, "Apache Ace WebUI succesfull login by user: " + username);
 
                         closeWindow();
                     }
                     else {
-                        m_log.log(LogService.LOG_WARNING, "Apache Ace WebUI invalid username or password entered.");
+                        m_log.log(LOG_WARNING, "Apache Ace WebUI invalid username or password entered.");
 
                         m_additionalInfo.setValue("Invalid username or password!");
 
@@ -145,7 +148,7 @@
 
     /**
      * Shows this login window on screen.
-     * 
+     *
      * @param parent
      *            the parent window, cannot be <code>null</code>.
      */
diff --git a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
index 2cdc630..59a8471 100644
--- a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
+++ b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinClient.java
@@ -106,7 +106,6 @@
 /**
  * Main application entry point.
  */
-@SuppressWarnings("serial")
 public class VaadinClient extends com.vaadin.Application implements AssociationManager, LoginFunction {
 
     // basic session ID generator
@@ -116,7 +115,7 @@
 
     /**
      * Remove the given directory and all it's files and subdirectories
-     * 
+     *
      * @param directory
      *            the name of the directory to remove
      */
@@ -202,9 +201,9 @@
 
     /**
      * Creates a new {@link VaadinClient} instance.
-     * 
+     *
      * @param m_manager2
-     * 
+     *
      * @param aceHost
      *            the hostname where the management service can be reached;
      * @param obrUrl
@@ -470,7 +469,7 @@
 
     /**
      * Create a new distribution in the distribution repository
-     * 
+     *
      * @param name
      *            the name of the new distribution;
      * @param description
@@ -486,7 +485,7 @@
 
     /**
      * Create a new feature in the feature repository.
-     * 
+     *
      * @param name
      *            the name of the new feature;
      * @param description
@@ -502,7 +501,7 @@
 
     /**
      * Create a new target in the stateful target repository.
-     * 
+     *
      * @param name
      *            the name of the new target;
      */
@@ -573,9 +572,9 @@
 
     /**
      * Create a button to show a pop window for adding new features.
-     * 
+     *
      * @param user
-     * 
+     *
      * @param main
      *            Main Window
      * @return Button
@@ -594,9 +593,9 @@
     /**
      * Create a button to show a popup window for adding a new distribution. On success this calls the
      * createDistribution() method.
-     * 
+     *
      * @param user
-     * 
+     *
      * @return the add-distribution button instance.
      */
     private Button createAddDistributionButton() {
@@ -624,9 +623,9 @@
 
     /***
      * Create a button to show popup window for adding a new feature. On success this calls the createFeature() method.
-     * 
+     *
      * @param user
-     * 
+     *
      * @return the add-feature button instance.
      */
     private Button createAddFeatureButton() {
@@ -653,9 +652,9 @@
 
     /**
      * Create a button to show a popup window for adding a new target. On success this calls the createTarget() method
-     * 
+     *
      * @param user
-     * 
+     *
      * @return the add-target button instance.
      */
     private Button createAddTargetButton() {
@@ -977,6 +976,11 @@
                 return m_admin;
             }
 
+            @Override
+            protected void log(int level, String msg, Exception e, Object... args) {
+                m_log.log(level, String.format(msg, args), e);
+            }
+
             private void updateTableData() {
                 m_artifactsPanel.populate();
                 m_featuresPanel.populate();
@@ -990,7 +994,7 @@
 
     /**
      * Authenticates the given user by creating all dependent services.
-     * 
+     *
      * @param user
      * @throws IOException
      *             in case of I/O problems.
@@ -1010,9 +1014,10 @@
             // @formatter:on
 
             m_admin.login(context);
-            initGrid();
             m_admin.checkout();
 
+            initGrid();
+
             return true;
         }
         catch (Exception e) {
diff --git a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
index 4002af1..8e07c6a 100644
--- a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
+++ b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/MainActionToolbar.java
@@ -18,6 +18,9 @@
  */
 package org.apache.ace.webui.vaadin.component;
 
+import static org.osgi.service.log.LogService.LOG_ERROR;
+import static org.osgi.service.log.LogService.LOG_WARNING;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -87,7 +90,7 @@
 
         /**
          * Does the actual logout of the user.
-         * 
+         *
          * @throws IOException
          *             in case of I/O problems during the logout.
          */
@@ -140,7 +143,7 @@
 
         /**
          * Does the actual retrieval of the latest version.
-         * 
+         *
          * @throws IOException
          *             in case of I/O problems during the retrieve.
          */
@@ -193,7 +196,7 @@
 
         /**
          * Does the actual revert of changes.
-         * 
+         *
          * @throws IOException
          *             in case of problems during I/O exception.
          */
@@ -234,7 +237,7 @@
 
         /**
          * Does the actual commit of changes.
-         * 
+         *
          * @throws IOException
          *             in case of I/O problems during the commit.
          */
@@ -256,10 +259,10 @@
 
     /**
      * Creates a new {@link MainActionToolbar} instance.
-     * 
+     *
      * @param user
      * @param manager
-     * 
+     *
      * @param showLogoutButton
      *            <code>true</code> if a logout button should be shown, <code>false</code> if it should not.
      */
@@ -317,28 +320,28 @@
 
     /**
      * Called after a commit/store has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterCommit() throws IOException;
 
     /**
      * Called after a logout has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterLogout() throws IOException;
 
     /**
      * Called after a retrieve has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterRetrieve() throws IOException;
 
     /**
      * Called after a revert has taken place, allows additional UI-updates to be performed.
-     * 
+     *
      * @throws IOException
      */
     protected abstract void doAfterRevert() throws IOException;
@@ -375,8 +378,7 @@
         component.add(dm.createServiceDependency()
             .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY + "=" + UIExtensionFactory.EXTENSION_POINT_VALUE_MENU + ")")
             .setCallbacks("add", "remove")
-            .setRequired(false)
-        );
+            .setRequired(false));
     }
 
     protected final void remove(ServiceReference<UIExtensionFactory> ref, UIExtensionFactory factory) {
@@ -393,13 +395,21 @@
         else {
             sb.append("<br/>unknown error!");
         }
+        log(LOG_ERROR, message, e);
         getWindow().showNotification(title, sb.toString(), Notification.TYPE_ERROR_MESSAGE);
     }
 
     protected void showWarning(String title, String message) {
+        log(LOG_WARNING, message);
         getWindow().showNotification(title, String.format("<br/>%s", message), Notification.TYPE_WARNING_MESSAGE);
     }
 
+    protected final void log(int level, String msg, Object... args) {
+        log(level, msg, null, args);
+    }
+
+    protected abstract void log(int level, String msg, Exception e, Object... args);
+
     private void addCrossPlatformShortcut(Button button, int key, String description) {
         // ACE-427 - NPE when using getMainWindow() if no authentication is used...
         WebApplicationContext context = (WebApplicationContext) getApplication().getContext();
diff --git a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java
index e6f57e2..fbc7665 100644
--- a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java
+++ b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/component/StatusLine.java
@@ -36,7 +36,6 @@
 /**
  * Denotes a status line in which a short summary of the latest actions in the UI are displayed.
  */
-@SuppressWarnings("unchecked")
 public class StatusLine extends Label implements EventHandler {
 
     /**
@@ -52,22 +51,25 @@
         RepositoryObject entity = (RepositoryObject) event.getProperty(RepositoryObject.EVENT_ENTITY);
 
         String type = getType(topic);
+        if (type == null) {
+            // Nothing to do...
+            return;
+        }
+
         String action = getAction(topic);
         String name = getName(entity);
 
-        if (type != null) {
-            if (name != null) {
-                setStatus("%s '%s' %s...", type, name, action);
-            }
-            else if (action != null) {
-                setStatus("%s %s...", type, action);
-            }
+        if (name != null && action != null) {
+            setStatus("%s '%s' %s...", type, name, action);
+        }
+        else if (action != null) {
+            setStatus("%s %s...", type, action);
         }
     }
 
     /**
      * Sets the status to the given message.
-     * 
+     *
      * @param msg
      *            the message;
      * @param args
@@ -82,15 +84,23 @@
      * @return
      */
     private String getAction(String topic) {
-        if (topic.endsWith("/" + RepositoryObject.TOPIC_REMOVED_SUFFIX)) {
+        if (topic.endsWith("/REMOVED")) {
             return "removed";
         }
-        else if (topic.endsWith("/" + RepositoryObject.TOPIC_ADDED_SUFFIX)) {
+        else if (topic.endsWith("/ADDED")) {
             return "added";
         }
-        else if (topic.endsWith("/" + RepositoryObject.TOPIC_CHANGED_SUFFIX)) {
+        else if (topic.endsWith("/CHANGED")) {
             return "changed";
         }
+        else if (topic.endsWith("/STATUS_CHANGED")) {
+            // for stateful target objects only...
+            return "status updated";
+        }
+        else if (topic.endsWith("/AUDITEVENTS_CHANGED")) {
+            // for stateful target objects only...
+            return "audit log updated";
+        }
         return null;
     }