cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomek...@apache.org
Subject svn commit: r979031 [1/2] - in /cxf/sandbox/logbrowser: distribution/src/main/release/samples/logbrowser/ distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/ distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet...
Date Sun, 25 Jul 2010 12:20:38 GMT
Author: tomekopo
Date: Sun Jul 25 12:20:36 2010
New Revision: 979031

URL: http://svn.apache.org/viewvc?rev=979031&view=rev
Log:
CXF-2881: Refactored code of BootstrapStorage (for easier configuration) and "org.apache.cxf.management/web/logging/browser/client/settings" package. Moved "static file" servlet to BootstrapStorage as subresource. Additionaly remove dependency of XStream. Fixed minor bugs connected with restoring settings from BootstrapStorage.

Added:
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java
      - copied, changed from r960895, cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/AtomPullServerApp.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AbstractAuthenticationFilter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AuthenticationRequired.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorage.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorageServiceImpl.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsStorage.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsProvider.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleAuthenticationFilter.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockAuthenticationFilter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleXMLSettingsStorage.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockXMLSettingsProvider.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/AccessControl.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/AccessControl.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Credentials.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/Credentials.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorageImpl.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorage.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/RemoteStorage.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxy.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/RemoteStorageImpl.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxyImpl.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Settings.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/Settings.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Subscription.java
      - copied, changed from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/Subscription.java
    cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/MockApp.java
Removed:
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/AtomPullServerApp.java
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/AuthenticationFilter.java
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/BootstrapStorageApp.java
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/XMLSettingsProvider.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorageService.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorageServiceImpl.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsProvider.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/StaticContentServlet.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/helper/JSONCallback.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/helper/JSONWebService.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxy.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxyImpl.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/JOConverter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/JSOConverter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/JSOCredentials.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/JSOSettings.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/JSOSubscription.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorage.java
    cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/atom/MockAtomPullServerApp.java
    cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockAuthenticationFilter.java
    cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockBootstrapStorageApp.java
    cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockXMLSettingsProvider.java
Modified:
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/README.txt
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
    cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
    cxf/sandbox/logbrowser/rt/management-web/pom.xml
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Settings.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Subscription.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/Module.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/browser/AtomPullServerProxy.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/AccessControlPresenter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/BrowsePresenter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/PlaceManager.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/SettingsPresenter.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/SettingsManager.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/BrowseView.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/BrowseViewImpl.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/EditSubcriptionWidget.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/SettingsView.java
    cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/view/SettingsViewImpl.java
    cxf/sandbox/logbrowser/rt/management-web/src/test/resources/WEB-INF/web.xml

Modified: cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/README.txt
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/README.txt?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/README.txt (original)
+++ cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/README.txt Sun Jul 25 12:20:36 2010
@@ -20,7 +20,7 @@ Using either UNIX or Windows:
 1)  Build and run by typing in terminal
     mvn install
 2) Open browser and go to:
-    http://localhost:9002/logbrowser/LogBrowser.html
+    http://localhost:9002/log/bootstrapstorage/resources/LogBrowser.html
 3) Add new endpoint with URL:
     http://localhost:9002/log/logs
 4) To generate custom log entry open new browser's window and go to:

Copied: cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java (from r960895, cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/AtomPullServerApp.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java?p2=cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java&p1=cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/AtomPullServerApp.java&r1=960895&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/AtomPullServerApp.java (original)
+++ cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/App.java Sun Jul 25 12:20:36 2010
@@ -19,42 +19,91 @@
 
 package demo.logbrowser;
 
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 import javax.ws.rs.core.Application;
+import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.jaxrs.provider.AtomEntryProvider;
 import org.apache.cxf.jaxrs.provider.AtomFeedProvider;
-import org.apache.cxf.management.web.logging.atom.*;
-
-public class AtomPullServerApp extends Application {
-    private static final AtomPullServer SERVICE;
+import org.apache.cxf.jaxrs.provider.JSONProvider;
+import org.apache.cxf.management.web.logging.atom.AtomPullServer;
+import org.apache.cxf.management.web.logging.bootstrapping.BootstrapStorage;
+import org.apache.cxf.management.web.logging.bootstrapping.SimpleAuthenticationFilter;
+import org.apache.cxf.management.web.logging.bootstrapping.SimpleXMLSettingsStorage;
+
+@Provider
+public class App extends Application {
+    private static final AtomPullServer LOGS;
 
     static {
-        SERVICE = new AtomPullServer();
-        SERVICE.setPageSize(30);
-        SERVICE.setLoggers("demo");
-        SERVICE.init();
+        LOGS = new AtomPullServer();
+        LOGS.setPageSize(30);
+        LOGS.setLoggers("demo");
+        LOGS.init();
     }
 
     private static final AtomFeedProvider FEED = new AtomFeedProvider();
     private static final AtomEntryProvider ENTRY = new AtomEntryProvider();
 
+    private static final BootstrapStorage BOOTSTRAP_STORAGE =
+        new BootstrapStorage(new SimpleXMLSettingsStorage());
+
+    private static final SimpleAuthenticationFilter AUTHENTICATION =
+        new SimpleAuthenticationFilter(new HashMap<String, String>() {
+            {
+                put("admin", "admin");
+            }
+        });
+
+    private static final BootstrapStorage.StaticFileProvider STATIC_FILE =
+        new BootstrapStorage.StaticFileProvider();
+
+    private static final JSONProvider JSON = new JSONProvider();
+
+    static {
+        JSON.setIgnoreNamespaces(true);
+
+        JSON.setOutTransformElements(new HashMap<String, String>() {
+            {
+                put("{http://cxf.apache.org/log}*", "*");
+            }
+        });
+        JSON.setInTransformElements(new HashMap<String, String>() {
+            {
+                put("*", "{http://cxf.apache.org/log}*");
+            }
+        });
+
+        JSON.setSerializeAsArray(true);
+        JSON.setArrayKeys(Arrays.asList("subscriptions"));
+    }
+
     @Override
     public Set<Class<?>> getClasses() {
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(AtomPullServer.class);
         classes.add(AtomFeedProvider.class);
         classes.add(AtomEntryProvider.class);
+        classes.add(BootstrapStorage.class);
+        classes.add(SimpleAuthenticationFilter.class);
+        classes.add(BootstrapStorage.StaticFileProvider.class);
+        classes.add(JSONProvider.class);
         return classes;
     }
 
     @Override
     public Set<Object> getSingletons() {
         Set<Object> classes = new HashSet<Object>();
-        classes.add(SERVICE);
+        classes.add(LOGS);
         classes.add(FEED);
         classes.add(ENTRY);
+        classes.add(BOOTSTRAP_STORAGE);
+        classes.add(AUTHENTICATION);
+        classes.add(STATIC_FILE);
+        classes.add(JSON);
         return classes;
     }
-}
+}
\ No newline at end of file

Modified: cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java (original)
+++ cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/src/demo/logbrowser/servlet/Generate.java Sun Jul 25 12:20:36 2010
@@ -36,10 +36,6 @@ import org.apache.cxf.common.logging.Log
 public class Generate extends HttpServlet {
     private static final Logger LOGGER = LogUtils.getL7dLogger(Generate.class);
 
-    static {
-        LOGGER.setLevel(Level.FINE);    
-    }
-
     private static final String LEVEL = "level";
     private static final String MESSAGE = "message";
     private static final String EXCEPTION_MESSAGE = "exceptionMessage";

Modified: cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml (original)
+++ cxf/sandbox/logbrowser/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml Sun Jul 25 12:20:36 2010
@@ -24,57 +24,36 @@
 -->
 <!-- START SNIPPET: webxml -->
 <web-app>
-	<servlet>
-		<servlet-name>StaticServlet</servlet-name>
-		<display-name>Static Servlet</display-name>
-		<servlet-class>
-			org.apache.cxf.management.web.logging.bootstrapping.StaticContentServlet
-		</servlet-class>
-		<load-on-startup>1</load-on-startup>
-	</servlet>
-
-	<servlet-mapping>
-		<servlet-name>StaticServlet</servlet-name>
-		<url-pattern>/logbrowser/*</url-pattern>
-	</servlet-mapping>
 
 	<servlet>
-		<servlet-name>BootstrapStorage</servlet-name>
-		<display-name>BootstrapStorage</display-name>
+		<servlet-name>App</servlet-name>
+		<display-name>App</display-name>
 		<servlet-class>
 			org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
 		</servlet-class>
 		<init-param>
 			<param-name>javax.ws.rs.Application</param-name>
 			<param-value>
-                demo.logbrowser.BootstrapStorageApp
+                demo.logbrowser.App
             </param-value>
 		</init-param>
-		<load-on-startup>1</load-on-startup>
-	</servlet>
-
-	<servlet-mapping>
-		<servlet-name>BootstrapStorage</servlet-name>
-		<url-pattern>/rest/*</url-pattern>
-	</servlet-mapping>
-
-	<servlet>
-		<servlet-name>AtomPullServer</servlet-name>
-		<display-name>AtomPullServer</display-name>
-		<servlet-class>
-			org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
-		</servlet-class>
-		<init-param>
-			<param-name>javax.ws.rs.Application</param-name>
-			<param-value>
-                demo.logbrowser.AtomPullServerApp
+        <init-param>
+            <param-name>jaxrs.inInterceptors</param-name>
+            <param-value>
+                org.apache.cxf.interceptor.LoggingInInterceptor
             </param-value>
-		</init-param>
-		<load-on-startup>2</load-on-startup>
+        </init-param>
+        <init-param>
+            <param-name>jaxrs.outInterceptors</param-name>
+            <param-value>
+                org.apache.cxf.interceptor.LoggingOutInterceptor
+            </param-value>
+        </init-param>        
+		<load-on-startup>1</load-on-startup>
 	</servlet>
 
 	<servlet-mapping>
-		<servlet-name>AtomPullServer</servlet-name>
+		<servlet-name>App</servlet-name>
 		<url-pattern>/log/*</url-pattern>
 	</servlet-mapping>
 
@@ -84,7 +63,7 @@
 		<servlet-class>
 			demo.logbrowser.servlet.Generate
 		</servlet-class>
-		<load-on-startup>3</load-on-startup>
+		<load-on-startup>2</load-on-startup>
 	</servlet>
 
 	<servlet-mapping>

Modified: cxf/sandbox/logbrowser/rt/management-web/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/pom.xml?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/pom.xml (original)
+++ cxf/sandbox/logbrowser/rt/management-web/pom.xml Sun Jul 25 12:20:36 2010
@@ -37,7 +37,7 @@
         <artifactId>cxf-parent</artifactId>
         <version>2.3.0-SNAPSHOT</version>
         <relativePath>../../parent/pom.xml</relativePath>
-    </parent>
+    </parent> 
 
     <dependencies>
         <dependency>
@@ -144,7 +144,6 @@
                     <hostedWebapp>${gwt.hostedmode.dir}</hostedWebapp>
                     <runTarget>logbrowser/LogBrowser.html</runTarget>
                 </configuration>
-
             </plugin>
 
             <plugin>

Added: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AbstractAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AbstractAuthenticationFilter.java?rev=979031&view=auto
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AbstractAuthenticationFilter.java (added)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AbstractAuthenticationFilter.java Sun Jul 25 12:20:36 2010
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.management.web.logging.bootstrapping;
+
+import java.lang.reflect.Method;
+import javax.ws.rs.core.Response;
+import static javax.ws.rs.core.Response.Status.*;
+
+import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.message.Message;
+
+public abstract class AbstractAuthenticationFilter implements RequestHandler {
+    public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
+        OperationResourceInfo ori = m.getExchange().get(OperationResourceInfo.class);
+        if (ori == null) {
+            return null;
+        }
+        Method method = ori.getMethodToInvoke();
+        if (method.getAnnotation(AuthenticationRequired.class) != null
+                && !authenticate(m, resourceClass)) {
+            return Response.status(UNAUTHORIZED).build();
+        }
+        return null;
+    }
+
+    protected abstract boolean authenticate(Message m, ClassResourceInfo resourceClass);
+}

Added: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AuthenticationRequired.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AuthenticationRequired.java?rev=979031&view=auto
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AuthenticationRequired.java (added)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/AuthenticationRequired.java Sun Jul 25 12:20:36 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.management.web.logging.bootstrapping;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@interface AuthenticationRequired {
+}

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorage.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorageServiceImpl.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorage.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorage.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorageServiceImpl.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorageServiceImpl.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/BootstrapStorage.java Sun Jul 25 12:20:36 2010
@@ -19,41 +19,178 @@
 
 package org.apache.cxf.management.web.logging.bootstrapping;
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.zip.GZIPOutputStream;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Variant;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 
+import org.apache.commons.lang.Validate;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.ext.MessageContext;
 
-public class BootstrapStorageServiceImpl implements BootstrapStorageService {
-    private static final Logger LOGGER = LogUtils.getL7dLogger(BootstrapStorageServiceImpl.class);
+@Path("/bootstrapstorage")
+public class BootstrapStorage {
+    private static final Logger LOGGER = LogUtils.getL7dLogger(BootstrapStorage.class);
+    private final SettingsStorage storage;
+    
+    public BootstrapStorage(final SettingsStorage storage) {
+        Validate.notNull(storage, "provider is null");
+        
+        this.storage = storage;
+    }
+
+    @GET
+    @Path("/settings/{username}")
+    @Produces("application/json")
+    @AuthenticationRequired
+    public Settings getSettings(@PathParam("username") final String username) {
+        assert storage != null;
+        
+        Validate.notNull(username, "username is null");
+        Validate.notEmpty(username, "username is empty");
+        
+        LOGGER.fine(String.format("Retrieve settings, user='%s'", username));
+        
+        return storage.getSettings(username);
+    }
+
+    @PUT
+    @Path("/settings/{username}")
+    @Consumes("application/json")
+    @AuthenticationRequired
+    public Response setSettings(@PathParam("username") final String username, final Settings settings) {
+        assert storage != null;
+        
+        Validate.notNull(username, "username is null");
+        Validate.notEmpty(username, "username is empty");
+        Validate.notNull(settings, "settings is null");
+        
+        LOGGER.fine(String.format("Save settings, user='%s'; settings='%s'", username, settings));
+
+        storage.setSettings(username, settings);
+        return Response.ok().build();
+    }
 
-    private final SettingsProvider provider;
+    @GET
+    @Path("/resources/{resource:.*}")
+    public Response getResource(@Context final MessageContext mc,
+                                @PathParam("resource") final String resource) {
+        if (isLastModifiedRequest(mc)) {
+            return Response.notModified().build();
+        }
+
+        URL url;
+        URL jar = getClass().getProtectionDomain().getCodeSource().getLocation();
+
+        try {
+            url = new URL(String.format("jar:%s!/static-content/logbrowser/%s", jar, resource));
+        } catch (MalformedURLException e) {
+            return Response.status(Status.BAD_REQUEST).build();
+        }
 
-    public BootstrapStorageServiceImpl(final SettingsProvider provider) {
-        if (provider == null) {
-            throw new IllegalArgumentException("'provider' can't be null");
+        try {
+            JarURLConnection connection = (JarURLConnection) url.openConnection();
+            if (connection.getContentLength() == -1 || connection.getJarEntry() == null) {
+                return Response.status(Status.NOT_FOUND).build();
+            } else if (connection.getJarEntry().isDirectory()) {
+                return Response.status(Status.FORBIDDEN).build();
+            } else { // correct
+                MediaType mime = getMimeType(mc, resource);
+                StaticFile staticFile = new StaticFile(url, acceptsGzip(mc), mime);
+                
+                Response.ResponseBuilder builder = Response.ok(staticFile);
+                builder.variant(new Variant(mime , null, staticFile.isGzipEnabled() ? "gzip" : null));
+
+                return builder.build();
+            }
+        } catch (IOException e) {
+            LOGGER.log(Level.SEVERE, "Error occur while retrieve static file", e);
+            return Response.serverError().build();
         }
-        this.provider = provider;
     }
 
-    public Settings getSettings(final String username) {
-        assert provider != null;
-        if (username == null || "".equals(username)) {
-            throw new IllegalArgumentException("'username' can't be null");
+    private boolean isLastModifiedRequest(final MessageContext mc) {
+        return mc.getHttpServletRequest().getHeader("Last-Modified") != null;
+    }
+
+    private MediaType getMimeType(final MessageContext mc, final String resource) {
+        return MediaType.valueOf(mc.getServletContext().getMimeType(resource));
+    }
+
+    private boolean acceptsGzip(final MessageContext mc) {
+        String ae = mc.getHttpServletRequest().getHeader("Accept-Encoding");
+        return ae != null && ae.contains("gzip");
+    }
+
+    private final class StaticFile {
+        private URL url;
+        private boolean isGzipEnabled;
+
+        private StaticFile(URL url, boolean acceptsGzip, MediaType mime) {
+            Validate.notNull(url, "url is null");
+            Validate.notNull(acceptsGzip, "acceptsGzip is null");
+            Validate.notNull(mime, "mime is null");
+
+            this.url = url;
+            this.isGzipEnabled = acceptsGzip && "text".equals(mime.getType());
+        }
+
+        public URL getUrl() {
+            return this.url;
+        }
+
+        public boolean isGzipEnabled() {
+            return this.isGzipEnabled;
         }
-        LOGGER.info(String.format("Retrieve settings, user='%s'", username));
-        return provider.getSettings(username);
     }
 
-    public Response setSettings(final String username, final Settings settings) {
-        assert provider != null;
-        if (username == null || "".equals(username)) {
-            throw new IllegalArgumentException("'username' can't be null or empty");
-        } else if (settings == null) {
-            throw new IllegalArgumentException("'settings' can't be null");
+    @Provider
+    public static class StaticFileProvider implements MessageBodyWriter<StaticFile> {
+        
+        public boolean isWriteable(Class<?> type, Type genericType,
+                                   Annotation[] annotations, MediaType mediaType) {
+            return StaticFile.class.isAssignableFrom(type);
+        }
+
+        public long getSize(StaticFile staticFile, Class<?> type, Type genericType,
+                            Annotation[] annotations, MediaType mediaType) {
+            return -1;
+        }
+
+        public void writeTo(StaticFile staticFile, Class<?> clazz, Type genericType,
+                            Annotation[] annotations, MediaType type,
+                            MultivaluedMap<String, Object> headers, OutputStream os) throws IOException {
+            if (staticFile.isGzipEnabled()) {
+                GZIPOutputStream gzip = new GZIPOutputStream(os);
+                try {
+                    IOUtils.copyAndCloseInput(staticFile.getUrl().openStream(), gzip);
+                } finally {
+                    gzip.finish();
+                }
+            } else {
+                IOUtils.copyAndCloseInput(staticFile.getUrl().openStream(), os);
+            }
         }
-        LOGGER.info(String.format("Save settings, user='%s'; settings='%s'", username, settings));
-        provider.setSettings(username, settings);
-        return Response.ok().build();
     }
 }

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Settings.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Settings.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Settings.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Settings.java Sun Jul 25 12:20:36 2010
@@ -21,21 +21,14 @@ package org.apache.cxf.management.web.lo
 
 import java.util.ArrayList;
 import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-@XmlRootElement
+@XmlRootElement(namespace = "http://cxf.apache.org/log")
 public class Settings {
     private List<Subscription> subscriptions;
 
-    // private Object credentials;
-    // public Object getCredentials() {
-    // return credentials;
-    // }
-    //
-    // public void setCredentials(Object credentials) {
-    // this.credentials = credentials;
-    // }
-
+    @XmlElement(name = "subscriptions", namespace = "http://cxf.apache.org/log")
     public List<Subscription> getSubscriptions() {
         if (subscriptions == null) {
             subscriptions = new ArrayList<Subscription>();
@@ -46,13 +39,4 @@ public class Settings {
     public void setSubscriptions(List<Subscription> subscriptions) {
         this.subscriptions = subscriptions;
     }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Settings [subscriptions=");
-        builder.append(subscriptions);
-        builder.append("]");
-        return builder.toString();
-    }
 }

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsStorage.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsProvider.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsStorage.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsStorage.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsProvider.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsProvider.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SettingsStorage.java Sun Jul 25 12:20:36 2010
@@ -19,7 +19,7 @@
 
 package org.apache.cxf.management.web.logging.bootstrapping;
 
-public interface SettingsProvider {
+public interface SettingsStorage {
     Settings getSettings(String username);
 
     void setSettings(String username, Settings settings);

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleAuthenticationFilter.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockAuthenticationFilter.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleAuthenticationFilter.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleAuthenticationFilter.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockAuthenticationFilter.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockAuthenticationFilter.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleAuthenticationFilter.java Sun Jul 25 12:20:36 2010
@@ -19,47 +19,47 @@
 
 package org.apache.cxf.management.web.logging.bootstrapping;
 
+import java.util.Map;
 import java.util.logging.Logger;
-import javax.ws.rs.core.Response;
+
 import javax.ws.rs.ext.Provider;
-import static javax.ws.rs.core.Response.Status.UNAUTHORIZED;
 
+import org.apache.commons.lang.Validate;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.message.Message;
 
 @Provider
-public class MockAuthenticationFilter implements RequestHandler {
-    private static final Logger LOGGER = LogUtils.getL7dLogger(MockAuthenticationFilter.class);
+public class SimpleAuthenticationFilter extends AbstractAuthenticationFilter {
+    private static final Logger LOGGER = LogUtils.getL7dLogger(SimpleAuthenticationFilter.class);
 
-    private final String username;
-    private final String password;
+    private Map<String, String> authData;
 
-    public MockAuthenticationFilter(final String username, final String password) {
-        if (username == null) {
-            throw new IllegalArgumentException("'username' can't be null");
-        } else if (password == null) {
-            throw new IllegalArgumentException("'password' can't be null");
-        }
-        this.username = username;
-        this.password = password;
+    public SimpleAuthenticationFilter(final Map<String, String> authData) {
+        Validate.notNull(authData, "authData is null");
+        this.authData = authData;
     }
 
-    public Response handleRequest(final Message m, final ClassResourceInfo resourceClass) {
-        assert username != null;
-        assert password != null;
-        AuthorizationPolicy policy = (AuthorizationPolicy)m.get(AuthorizationPolicy.class);
+    @Override
+    protected boolean authenticate(Message m, ClassResourceInfo resourceClass) {
+        assert authData != null;
+        AuthorizationPolicy policy = (AuthorizationPolicy) m.get(AuthorizationPolicy.class);
         if (policy == null) {
-            LOGGER.info("No authentication data'");
-            return Response.status(UNAUTHORIZED).build();
-        } else if (!username.equals(policy.getUserName()) || !password.equals(policy.getPassword())) {
-            LOGGER.info(String.format("Failed authentication, username='%s'", policy.getUserName()));
-            return Response.status(UNAUTHORIZED).build();
+            LOGGER.fine("No authentication data'");
+            return false;
+        } else if (isValid(policy)) {
+            LOGGER.fine(String.format("Successful authentication, username='%s'", policy.getUserName()));
+            return true;
         } else {
-            LOGGER.info(String.format("Successful authentication, username='%s'", policy.getUserName()));
-            return null;
+            LOGGER.fine(String.format("Failed authentication, username='%s'", policy.getUserName()));
+            return false;
         }
     }
+
+    private boolean isValid(final AuthorizationPolicy policy) {
+        return authData.containsKey(policy.getUserName())
+            && authData.get(policy.getUserName()) != null
+            && authData.get(policy.getUserName()).equals(policy.getPassword());
+    }
 }

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleXMLSettingsStorage.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockXMLSettingsProvider.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleXMLSettingsStorage.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleXMLSettingsStorage.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockXMLSettingsProvider.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/test/java/org/apache/cxf/management/web/logging/bootstrapping/MockXMLSettingsProvider.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/SimpleXMLSettingsStorage.java Sun Jul 25 12:20:36 2010
@@ -19,188 +19,169 @@
 
 package org.apache.cxf.management.web.logging.bootstrapping;
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
+import java.util.GregorianCalendar;
 import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.commons.lang.Validate;
+
+public class SimpleXMLSettingsStorage implements SettingsStorage {
+    private static final String DEFAULT_FILENAME = "logbrowser-settings.xml";
+    private static final Settings DEFAULT_SETTINGS = new Settings();
+
+    private final String filename;
+    private final Marshaller marshaller;
+
+    private Entries entries;
+
+    public SimpleXMLSettingsStorage() {
+        this(DEFAULT_FILENAME);
+    }
+
+    public SimpleXMLSettingsStorage(final String filename) {
+        Validate.notNull(filename, "filename is null");
+        Validate.notEmpty(filename, "filename is empty");
+        this.filename = filename;
 
-import com.thoughtworks.xstream.XStream;
+        try {
+            JAXBContext context = JAXBContext.newInstance(Entries.class, Entry.class,
+                    Settings.class, Subscription.class);
 
-import org.apache.cxf.common.logging.LogUtils;
+            marshaller = context.createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            
+            File file = new File(filename);
+            if (file.exists()) {
+                Unmarshaller unmarshaller = context.createUnmarshaller();
+                entries = (Entries) unmarshaller.unmarshal(file);
+            }
 
-public class MockXMLSettingsProvider implements SettingsProvider {
-    private static final Logger LOGGER = LogUtils.getL7dLogger(MockXMLSettingsProvider.class);
-    private static final Settings DEFUALT_SETTINGS = new Settings();
-    private static final String DEFAULT_FILENAME = "logBrowserSettingsStorage.xml";    
+            if (entries == null) {
+                entries = new Entries();
+            }
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
-    private Map<String, Entry> cache = new HashMap<String, Entry>();
-    private volatile boolean cached;
-    private String filename;
+    public synchronized Settings getSettings(final String username) {
+        Validate.notNull(username, "username is null");
+        Validate.notEmpty(username, "username is empty");
 
-    public MockXMLSettingsProvider() {
-        this.filename = DEFAULT_FILENAME;
+        Entry entry = getCachedEntry(username);
+        return entry != null ? entry.getSettings() : DEFAULT_SETTINGS;
     }
 
-    public MockXMLSettingsProvider(final String filename) {
-        if (filename == null) {
-            throw new IllegalArgumentException("'filename' can't be null");
-        }
-        this.filename = filename;
-    }
+    public synchronized void setSettings(final String username, final Settings settings) {
+        Validate.notNull(username, "username is null");
+        Validate.notEmpty(username, "username is empty");
 
-    public void setSettings(final String username, final Settings settings) {
-        assert cache != null;
-        if (username == null || "".equals(username)) {
-            throw new IllegalArgumentException("'username' can't be null or empty");
-        } else if (settings == null) {
-            throw new IllegalArgumentException("'settings' can't be null");
-        }
-        load();
-        synchronized (cache) {
-            Entry entry = cache.get(username);
-            if (entry != null) {
-                entry.setSettings(settings);
-            } else {
-                cache.put(username, new Entry(username, settings));
-            }
+        Entry entry = getCachedEntry(username);
+        if (entry != null) {
+            entry.setSettings(settings);
+            entry.setModified(getCurrentTime());
+        } else {
+            entries.getEntries().add(new Entry(username, getCurrentTime(), settings));
         }
-        save();
-    }
 
-    public Settings getSettings(final String username) {
-        assert cache != null;
-        if (username == null || "".equals(username)) {
-            throw new IllegalArgumentException("'username' can't be null or empty");
-        }
-        load();
-        synchronized (cache) {
-            Entry entry = cache.get(username);
-            return entry != null && entry.getSettings() != null ? entry.getSettings() : DEFUALT_SETTINGS;
+        try {
+            marshaller.marshal(entries, new FileOutputStream(filename));
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
         }
     }
 
-    private void load() {
-        assert cache != null;
-        assert filename != null;
-        if (cached) {
-            return;
-        }
-        LOGGER.info(String.format("Load settings from file, filename='%s'", filename));
-        XStream xs = getConfiguredXStream();
-        Entries entries = null;
-        try {
-            FileReader fr = new FileReader(filename);
-            BufferedReader br = new BufferedReader(fr);
-            entries = (Entries)xs.fromXML(br);
-            br.close();
-        } catch (IOException ex) {
-            LOGGER.log(Level.SEVERE, "Error occur while loading settings", ex);
-        }
-        if (entries != null) {
-            for (Entry entry : entries.getEntries()) {
-                if (entry != null && entry.getUsername() != null) {
-                    synchronized (cache) {
-                        cache.put(entry.getUsername(), entry);
-                    }
-                }
+    private Entry getCachedEntry(final String username) {
+        assert username != null;
+        assert !"".equals(username);
+
+        for (Entry entry : entries.getEntries()) {
+            if (username.equals(entry.getUsername())) {
+                return entry;
             }
         }
-        cached = true;
+        return null;
     }
 
-    private void save() {
-        assert cache != null;
-        assert filename != null;
-        LOGGER.info(String.format("Persist settings to file, filename='%s'", filename));
-        XStream xs = getConfiguredXStream();
-        Entries entries;
-        synchronized (cache) {
-            entries = new Entries(cache.values());
-        }
+    private XMLGregorianCalendar getCurrentTime() {
         try {
-            FileWriter fw = new FileWriter(filename);
-            BufferedWriter bw = new BufferedWriter(fw);
-            synchronized (cache) {
-                xs.toXML(entries, bw);
-            }
-            bw.flush();
-            bw.close();
-        } catch (IOException ex) {
-            LOGGER.log(Level.SEVERE, "Error occur while saving settings", ex);
+            return DatatypeFactory.newInstance()
+                .newXMLGregorianCalendar((GregorianCalendar) GregorianCalendar.getInstance());
+        } catch (DatatypeConfigurationException e) {
+            throw new RuntimeException(e);
         }
     }
 
-    private XStream getConfiguredXStream() {
-        XStream xs = new XStream();
-        xs.alias("settings", Settings.class);
-        xs.addImplicitCollection(Settings.class, "subscriptions");
-        xs.alias("subscription", Subscription.class);
-        xs.alias("entries", Entries.class);
-        xs.alias("entry", Entry.class);
-        xs.useAttributeFor(Entry.class, "username");
-        xs.useAttributeFor(Entry.class, "modified");
-        xs.addImplicitCollection(Entries.class, "entries");
-        return xs;
+    @XmlRootElement(namespace = "http://cxf.apache.org/log")
+    private static class Entries {
+        private List<Entry> entries;
+
+        @XmlElement(name = "entry", namespace = "http://cxf.apache.org/log")
+        public List<Entry> getEntries() {
+            if (entries == null) {
+                entries = new ArrayList<Entry>();
+            }
+            return this.entries;
+        }
     }
 
-    static class Entry {
-        private String username;
-        private Date modified;
+    @XmlRootElement(namespace = "http://cxf.apache.org/log")
+    private static class Entry {
         private Settings settings;
+        private String username;
+        private XMLGregorianCalendar modified;
 
-        Entry(String username, Settings settings) {
-            this.username = username;
-            this.modified = new Date();
-            this.settings = settings;
-        }
-
-        String getUsername() {
-            return username;
+        Entry() {
         }
 
-        void setUsername(String username) {
+        Entry(final String username, final XMLGregorianCalendar modified, final Settings settings) {
+            this.settings = settings;
             this.username = username;
+            this.modified = modified;
         }
 
-        Date getModified() {
-            return modified;
-        }
-
-        Settings getSettings() {
+        @XmlElement(required = true, namespace = "http://cxf.apache.org/log")
+        public Settings getSettings() {
             return settings;
         }
 
-        void setSettings(Settings settings) {
-            this.settings = settings;
-            this.modified = new Date();
+        public void setSettings(Settings value) {
+            this.settings = value;
         }
-    }
 
-    static class Entries {
-        private List<Entry> entries;
+        @XmlAttribute(name = "username", namespace = "http://cxf.apache.org/log")
+        public String getUsername() {
+            return username;
+        }
 
-        Entries(Collection<Entry> entries) {
-            this.entries = new ArrayList<Entry>(entries);
+        public void setUsername(String value) {
+            this.username = value;
         }
 
-        List<Entry> getEntries() {
-            if (entries == null) {
-                entries = new ArrayList<Entry>();
-            }
-            return entries;
+        @XmlAttribute(name = "modified", namespace = "http://cxf.apache.org/log")
+        @XmlSchemaType(name = "date")        
+        public XMLGregorianCalendar getModified() {
+            return modified;
         }
 
-        void setEntries(List<Entry> entries) {
-            this.entries = entries;
+        public void setModified(XMLGregorianCalendar value) {
+            this.modified = value;
         }
     }
 }

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Subscription.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Subscription.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Subscription.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/bootstrapping/Subscription.java Sun Jul 25 12:20:36 2010
@@ -19,19 +19,13 @@
 
 package org.apache.cxf.management.web.logging.bootstrapping;
 
-public class Subscription {
+import javax.xml.bind.annotation.XmlElement;
+
+public class Subscription {    
     private String name;
     private String url;
-
-    // private Object credentials;
-    // public Object getCredentials() {
-    // return credentials;
-    // }
-    //
-    // public void setCredentials(Object credentials) {
-    // this.credentials = credentials;
-    // }
-
+                
+    @XmlElement(required = true, namespace = "http://cxf.apache.org/log")
     public String getName() {
         return name;
     }
@@ -40,6 +34,7 @@ public class Subscription {
         this.name = name;
     }
 
+    @XmlElement(required = true, namespace = "http://cxf.apache.org/log")
     public String getUrl() {
         return url;
     }
@@ -47,15 +42,4 @@ public class Subscription {
     public void setUrl(String url) {
         this.url = url;
     }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Subscription [name=");
-        builder.append(name);
-        builder.append(", url=");
-        builder.append(url);
-        builder.append("]");
-        return builder.toString();
-    }
 }

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/Module.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/Module.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/Module.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/Module.java Sun Jul 25 12:20:36 2010
@@ -23,8 +23,10 @@ import com.google.gwt.inject.client.Abst
 
 import org.apache.cxf.management.web.logging.browser.client.helper.DefaultEventBus;
 import org.apache.cxf.management.web.logging.browser.client.helper.EventBus;
-import org.apache.cxf.management.web.logging.browser.client.settings.BootstrapStorageProxy;
-import org.apache.cxf.management.web.logging.browser.client.settings.BootstrapStorageProxyImpl;
+import org.apache.cxf.management.web.logging.browser.client.settings.LocalStorage;
+import org.apache.cxf.management.web.logging.browser.client.settings.LocalStorageImpl;
+import org.apache.cxf.management.web.logging.browser.client.settings.RemoteStorage;
+import org.apache.cxf.management.web.logging.browser.client.settings.RemoteStorageImpl;
 import org.apache.cxf.management.web.logging.browser.client.view.AccessControlView;
 import org.apache.cxf.management.web.logging.browser.client.view.AccessControlViewImpl;
 import org.apache.cxf.management.web.logging.browser.client.view.BrowseView;
@@ -40,7 +42,8 @@ public class Module extends AbstractGinM
         bind(AccessControlView.class).to(AccessControlViewImpl.class);
         bind(SettingsView.class).to(SettingsViewImpl.class);
         bind(BrowseView.class).to(BrowseViewImpl.class);
-        bind(BootstrapStorageProxy.class).to(BootstrapStorageProxyImpl.class);
+        bind(RemoteStorage.class).to(RemoteStorageImpl.class);
+        bind(LocalStorage.class).to(LocalStorageImpl.class);
     }
 
 }

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/browser/AtomPullServerProxy.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/browser/AtomPullServerProxy.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/browser/AtomPullServerProxy.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/browser/AtomPullServerProxy.java Sun Jul 25 12:20:36 2010
@@ -25,7 +25,7 @@ import com.google.gwt.http.client.Reques
 import static com.google.gwt.http.client.RequestBuilder.GET;
 import static com.google.gwt.http.client.RequestBuilder.Method;
 
-import org.apache.cxf.management.web.logging.browser.client.model.Credentials;
+import org.apache.cxf.management.web.logging.browser.client.settings.Credentials;
 
 public class AtomPullServerProxy {
 

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/AccessControlPresenter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/AccessControlPresenter.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/AccessControlPresenter.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/AccessControlPresenter.java Sun Jul 25 12:20:36 2010
@@ -26,11 +26,10 @@ import org.apache.cxf.management.web.log
 import org.apache.cxf.management.web.logging.browser.client.event.AccessDeniedEventHandler;
 import org.apache.cxf.management.web.logging.browser.client.event.BrowseEvent;
 import org.apache.cxf.management.web.logging.browser.client.helper.EventBus;
-import org.apache.cxf.management.web.logging.browser.client.model.Credentials;
+import org.apache.cxf.management.web.logging.browser.client.settings.Credentials;
 import org.apache.cxf.management.web.logging.browser.client.settings.SettingsManager;
-import org.apache.cxf.management.web.logging.browser.client.settings.SettingsManager.StorageStrategy;
 import org.apache.cxf.management.web.logging.browser.client.view.AccessControlView;
-
+import static org.apache.cxf.management.web.logging.browser.client.settings.SettingsManager.StorageStrategy.*;
 public class AccessControlPresenter extends BasePresenter implements AccessControlView.Presenter {
     private final AccessControlView view;
     private final SettingsManager settings;
@@ -46,7 +45,8 @@ public class AccessControlPresenter exte
     }
 
     public void go(final HasWidgets container) {
-        if (settings.isFetched()) {
+        if (settings.isSettingsAlreadyInLocalStorage()) {
+            settings.initialize(LOCAL_AND_REMOTE, new Credentials());
             eventBus.fireEvent(new BrowseEvent());
         } else {
             container.clear();
@@ -60,12 +60,12 @@ public class AccessControlPresenter exte
 
         if (isNotEmpty(username) && isNotEmpty(password)) {
             Boolean rememberMe = view.getRememberMe().getValue();
+            Credentials credentials = new Credentials(username, password);
             if (rememberMe != null && rememberMe) {
-                settings.setStorageStrategy(StorageStrategy.STORE_LOCALLY_AND_REMOTELY);
+                settings.initialize(LOCAL_AND_REMOTE, credentials);
             } else {
-                settings.setStorageStrategy(StorageStrategy.STORE_REMOTELY);
+                settings.initialize(REMOTE, credentials);
             }
-            settings.fetchRemotely(new Credentials(username, password));
         }
     }
 

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/BrowsePresenter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/BrowsePresenter.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/BrowsePresenter.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/BrowsePresenter.java Sun Jul 25 12:20:36 2010
@@ -34,8 +34,8 @@ import org.apache.cxf.management.web.log
 import org.apache.cxf.management.web.logging.browser.client.event.SignOutEvent;
 import org.apache.cxf.management.web.logging.browser.client.helper.EventBus;
 import org.apache.cxf.management.web.logging.browser.client.helper.XmlCallback;
-import org.apache.cxf.management.web.logging.browser.client.model.Subscription;
 import org.apache.cxf.management.web.logging.browser.client.settings.SettingsManager;
+import org.apache.cxf.management.web.logging.browser.client.settings.Subscription;
 import org.apache.cxf.management.web.logging.browser.client.view.BrowseView;
 
 public class BrowsePresenter extends BasePresenter implements BrowseView.Presenter {

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/PlaceManager.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/PlaceManager.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/PlaceManager.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/PlaceManager.java Sun Jul 25 12:20:36 2010
@@ -105,7 +105,7 @@ public class PlaceManager implements Val
         eventBus.addHandler(SignOutEvent.TYPE, new SignOutEventHandler() {
 
             public void onSignOut(SignOutEvent event) {
-                settingsManager.flush();
+                settingsManager.cleanMemoryAndLocalStorage();
                 go(accessControlProvider.get());
 
             }

Modified: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/SettingsPresenter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/SettingsPresenter.java?rev=979031&r1=979030&r2=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/SettingsPresenter.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/presenter/SettingsPresenter.java Sun Jul 25 12:20:36 2010
@@ -25,19 +25,19 @@ import com.google.inject.Inject;
 import org.apache.cxf.management.web.logging.browser.client.event.BrowseEvent;
 import org.apache.cxf.management.web.logging.browser.client.event.SignOutEvent;
 import org.apache.cxf.management.web.logging.browser.client.helper.EventBus;
-import org.apache.cxf.management.web.logging.browser.client.model.Subscription;
 import org.apache.cxf.management.web.logging.browser.client.settings.SettingsManager;
+import org.apache.cxf.management.web.logging.browser.client.settings.Subscription;
 import org.apache.cxf.management.web.logging.browser.client.view.SettingsView;
 
 public class SettingsPresenter extends BasePresenter implements SettingsView.Presenter {
     private final SettingsView view;
-    private final SettingsManager settings;
+    private final SettingsManager settingsManager;
 
     @Inject
-    public SettingsPresenter(EventBus eventBus, SettingsView view, SettingsManager settings) {
+    public SettingsPresenter(EventBus eventBus, SettingsView view, SettingsManager settingsManager) {
         super(eventBus);
         this.view = view;
-        this.settings = settings;
+        this.settingsManager = settingsManager;
         this.view.setPresenter(this);
 
         updateSubscriptions();
@@ -49,27 +49,25 @@ public class SettingsPresenter extends B
     }
 
     public void unbind() {
-        // TODO Auto-generated method stub
-
     }
 
     public void onEditSubscription(Subscription subscription) {
-        settings.updateSubscription(subscription);
+        settingsManager.updateSubscription(subscription);
         updateSubscriptions();
     }
 
     public void onRemoveSubscriptionButtonClicked(Subscription subscription) {
-        settings.removeSubscription(subscription);
+        settingsManager.removeSubscription(subscription);
         updateSubscriptions();
     }
 
     public void onAddSubscription(Subscription subscription) {
-        settings.updateSubscription(subscription);
+        settingsManager.updateSubscription(subscription);
         updateSubscriptions();
     }
 
     private void updateSubscriptions() {
-        view.setSubscriptions(settings.getSubscriptions());
+        view.setSubscriptions(settingsManager.getSubscriptions());
     }
 
     public void onBackHyperlinkClicked() {

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/AccessControl.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/AccessControl.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/AccessControl.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/AccessControl.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/AccessControl.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/AccessControl.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/AccessControl.java Sun Jul 25 12:20:36 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.management.web.logging.browser.client.model;
+package org.apache.cxf.management.web.logging.browser.client.settings;
 
 public enum AccessControl {
     GLOBAL,

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Credentials.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/Credentials.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Credentials.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Credentials.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/Credentials.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/model/Credentials.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/Credentials.java Sun Jul 25 12:20:36 2010
@@ -17,13 +17,9 @@
  * under the License.
  */
 
-package org.apache.cxf.management.web.logging.browser.client.model;
-
-import java.io.Serializable;
-
-public class Credentials implements Serializable {
-    private static final long serialVersionUID = 8374250693769719998L;
+package org.apache.cxf.management.web.logging.browser.client.settings;
 
+public class Credentials {
     private String username;
     private String password;
 

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorageImpl.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorage.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorageImpl.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorageImpl.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorage.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorage.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/LocalStorageImpl.java Sun Jul 25 12:20:36 2010
@@ -1,3 +1,5 @@
+// CHECKSTYLE:OFF
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
@@ -20,23 +22,256 @@
 package org.apache.cxf.management.web.logging.browser.client.settings;
 
 import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArray;
+
+public class LocalStorageImpl implements LocalStorage {
+    private static final String SETTINGS_KEY = "logBrowser.settings";
+
+    private Boolean isAvailable;
+
+    public boolean isAvailable() {
+        if (isAvailable == null) {
+            this.isAvailable = checkIsAvailable();
+        }
+        return this.isAvailable;
+    }
+
+    private native boolean checkIsAvailable() /*-{
+        var key = "isLocalStorageAvailable";
+        $wnd.$.jStorage.set(key, true);
+        return !($wnd.$.jStorage.get(key) == null);
+    }-*/;
+
+    public void saveSettings(final Settings settings) {
+        assert settings != null;
+
+        if (isAvailable()) {
+            set(SETTINGS_KEY, Converter.convertToLocalSettings(settings));
+        }
+    }
+
+    public Settings retrieveSettings() {
+        if (isAvailable()) {
+            LocalSettings localSettings = (LocalSettings) get(SETTINGS_KEY);
+            if (localSettings != null) {
+                return Converter.convertToSettings(localSettings);
+            }
+        }
+        return null;
+    }
+
+    public void flush() {
+        if (isAvailable()) {
+            deleteKey(SETTINGS_KEY);
+        }
+    }
+
+    private native void set(final String key, final JavaScriptObject obj) /*-{
+        $wnd.$.jStorage.set(key, obj);
+    }-*/;
+
+    private native JavaScriptObject get(final String key) /*-{
+        return $wnd.$.jStorage.get(key);
+    }-*/;
+
+    private native void deleteKey(final String key) /*-{
+        $wnd.$.jStorage.deleteKey(key);
+    }-*/;
+
+    private static final class Converter {
+
+        public static Settings convertToSettings(final LocalSettings src) {
+            if (src == null) {
+                return null;
+            }
+
+            Settings dst = new Settings();
+            dst.setCredentials(convertToCredentials(src.getCredentials()));
+            JsArray<LocalSubscription> subscriptions = src.getSubscriptions();
+            for (int i = 0; i < subscriptions.length(); i++) {
+                Subscription subscription = convertToSubscription(subscriptions.get(i));
+                if (subscription != null) {
+                    dst.getSubscriptions().add(subscription);
+                }
+            }
+
+            return dst;
+        }
+
+        private static Credentials convertToCredentials(final LocalCredentials src) {
+            if (src == null) {
+                return null;
+            }
+
+            Credentials dst = new Credentials();
+
+            dst.setUsername(src.getUsername());
+            dst.setPassword(src.getPassword());
+
+            return dst;
+        }
+
+        private static Subscription convertToSubscription(final LocalSubscription src) {
+            if (src == null) {
+                return null;
+            }
+
+            Subscription dst = new Subscription();
+
+            dst.setName(src.getName());
+            dst.setUrl(src.getURL());
+            dst.setCredentials(convertToCredentials(src.getCredentials()));
+
+            if (src.getAccessControl() != null) {
+                dst.setAccessControl(AccessControl.valueOf(src.getAccessControl()));
+            }
+
+            return dst;
+        }
+
+        @SuppressWarnings("unchecked")
+        public static LocalSettings convertToLocalSettings(final Settings src) {
+            if (src == null) {
+                return null;
+            }
+
+            LocalSettings dst = (LocalSettings)JavaScriptObject.createObject();
+
+            dst.setCredentials(convertToLocalCredentials(src.getCredentials()));
+
+            JsArray<LocalSubscription> dstSubscriptions = (JsArray<LocalSubscription>)JavaScriptObject.createArray();
+            for (Subscription subscription : src.getSubscriptions()) {
+                dstSubscriptions.push(convertToLocalSubscription(subscription));
+            }
+            dst.setSubscriptions(dstSubscriptions);
+
+            return dst;
+
+        }
+
+        private static LocalCredentials convertToLocalCredentials(final Credentials src) {
+            if (src == null) {
+                return null;
+            }
+
+            LocalCredentials dst = (LocalCredentials)JavaScriptObject.createObject();
+
+            dst.setUsername(src.getUsername());
+            dst.setPassword(src.getPassword());
+
+            return dst;
+        }
+
+        private static LocalSubscription convertToLocalSubscription(final Subscription src) {
+            if (src == null) {
+                return null;
+            }
+
+            LocalSubscription dst = (LocalSubscription)JavaScriptObject.createObject();
+
+            dst.setName(src.getName());
+            dst.setURL(src.getUrl());
+            dst.setCredentials(convertToLocalCredentials(src.getCredentials()));
+
+            if (src.getAccessControl() != null) {
+                dst.setAccessControl(src.getAccessControl().name());
+            }
+
+            return dst;
+        }
+    }
+
+    public static class LocalSettings extends JavaScriptObject {
+
+        protected LocalSettings() {
+        }
+    
+        public final native void setCredentials(final LocalCredentials credentials) /*-{
+            this.credentials = credentials;
+        }-*/;
+
+        public final native LocalCredentials getCredentials() /*-{
+            return this.credentials;
+        }-*/;
+
+        public final native void setSubscriptions(final JsArray<LocalSubscription> subscriptions) /*-{
+            this.subscriptions = subscriptions;
+        }-*/;
+
+        public final native JsArray<LocalSubscription> getSubscriptions() /*-{
+            if (this.subscriptions != null) {
+                try { //hack
+                    this.subscriptions.concat([]);
+                } catch(err) {
+                    var temp = this.subscriptions;
+                    this.subscriptions = new Array();
+                    this.subscriptions.push(temp);
+                }
+                return this.subscriptions;
+            } else {
+                return [];
+            }
+        }-*/;
+    }
+
+    private static class LocalCredentials extends JavaScriptObject {
+
+        protected LocalCredentials() {
+        }
+
+        public final native void setUsername(final String username) /*-{
+            this.username = username;
+        }-*/;
+
+        public final native String getUsername() /*-{
+            return this.username;
+        }-*/;
+
+        public final native void setPassword(final String password) /*-{
+            this.password = password;
+        }-*/;
+
+        public final native String getPassword() /*-{
+             return this.password;
+        }-*/;
+    }
+
+    private static class LocalSubscription extends JavaScriptObject {
+
+        protected LocalSubscription() {
+        }
+
+        public final native void setName(final String name) /*-{
+            this.name = name;
+        }-*/;
+
+        public final native String getName() /*-{
+            return this.name;
+        }-*/;
+
+        public final native void setURL(final String url) /*-{
+            this.url = url;
+        }-*/;
+
+        public final native String getURL() /*-{
+            return this.url;
+        }-*/;
+
+        public final native void setAccessControl(final String accessControl) /*-{
+            this.accessControl = accessControl;
+        }-*/;
+
+        public final native String getAccessControl() /*-{
+            return this.accessControl;
+        }-*/;
+
+        public final native void setCredentials(final LocalCredentials credentials) /*-{
+            this.credentials = credentials;
+        }-*/;
+
+        public final native LocalCredentials getCredentials() /*-{
+            return this.credentials;
+        }-*/;
+    }
 
-public class LocalStorage {
-    public native boolean isAvailable() /*-{
-                                        var key = "isLocalStorageAvailable";
-                                        $wnd.$.jStorage.set(key, true);
-                                        return !($wnd.$.jStorage.get(key) == null);
-                                        }-*/;
-
-    public native void set(String key, JavaScriptObject obj) /*-{
-                                                             $wnd.$.jStorage.set(key, obj);
-                                                             }-*/;
-
-    public native JavaScriptObject get(String key) /*-{
-                                                   return $wnd.$.jStorage.get(key);
-                                                   }-*/;
-
-    public native void deleteKey(String key) /*-{
-                                             $wnd.$.jStorage.deleteKey(key);
-                                             }-*/;
 }

Copied: cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/RemoteStorage.java (from r959377, cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxy.java)
URL: http://svn.apache.org/viewvc/cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/RemoteStorage.java?p2=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/RemoteStorage.java&p1=cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxy.java&r1=959377&r2=979031&rev=979031&view=diff
==============================================================================
--- cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/BootstrapStorageProxy.java (original)
+++ cxf/sandbox/logbrowser/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/browser/client/settings/RemoteStorage.java Sun Jul 25 12:20:36 2010
@@ -21,10 +21,7 @@ package org.apache.cxf.management.web.lo
 
 import com.google.gwt.http.client.RequestCallback;
 
-import org.apache.cxf.management.web.logging.browser.client.model.Credentials;
-import org.apache.cxf.management.web.logging.browser.client.model.Settings;
-
-public interface BootstrapStorageProxy {
+public interface RemoteStorage {
     void getSettings(Credentials credentials, RequestCallback callback);
 
     void setSettings(Credentials credentials, Settings settings, RequestCallback callback);



Mime
View raw message