ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject svn commit: r1170759 - in /incubator/ace/trunk: ./ ace-server-log-ui/ ace-server-log-ui/src/ ace-server-log-ui/src/main/ ace-server-log-ui/src/main/java/ ace-server-log-ui/src/main/java/org/ ace-server-log-ui/src/main/java/org/apache/ ace-server-log-ui...
Date Wed, 14 Sep 2011 18:32:10 GMT
Author: pauls
Date: Wed Sep 14 18:32:10 2011
New Revision: 1170759

URL: http://svn.apache.org/viewvc?rev=1170759&view=rev
Log:
Provide a simple auditlogviewerextension (ACE-181)

Added:
    incubator/ace/trunk/ace-server-log-ui/
    incubator/ace/trunk/ace-server-log-ui/pom.xml
    incubator/ace/trunk/ace-server-log-ui/src/
    incubator/ace/trunk/ace-server-log-ui/src/main/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/Activator.java
    incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
Modified:
    incubator/ace/trunk/ace-target-devserver/pom.xml
    incubator/ace/trunk/pom.xml
    incubator/ace/trunk/pom/pom.xml

Added: incubator/ace/trunk/ace-server-log-ui/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-server-log-ui/pom.xml?rev=1170759&view=auto
==============================================================================
--- incubator/ace/trunk/ace-server-log-ui/pom.xml (added)
+++ incubator/ace/trunk/ace-server-log-ui/pom.xml Wed Sep 14 18:32:10 2011
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-incubator-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <version>0.8.1-incubator-SNAPSHOT</version>
+    <artifactId>org.apache.ace.server.log.ui</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache ACE :: Server :: Log :: UI</name>
+    <description />
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/ace/trunk/ace-server-log-ui</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/ace/trunk/ace-server-log-ui</developerConnection>
+        <url>http://svn.apache.org/repos/asf/incubator/ace/trunk/ace-server-log-ui</url>
+    </scm>
+
+   <properties>
+        <private.package>
+            org.apache.ace.server.log.ui
+        </private.package>
+        <bundle.activator>
+            org.apache.ace.server.log.ui.Activator
+        </bundle.activator>
+    </properties>
+
+    <dependencies>
+        <dependency>
+             <groupId>org.apache.ace</groupId>
+             <artifactId>org.apache.ace.server.log.store</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.dependencymanager</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.webui.vaadin</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.vaadin</groupId>
+            <artifactId>vaadin</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Added: incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/Activator.java?rev=1170759&view=auto
==============================================================================
--- incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/Activator.java
(added)
+++ incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/Activator.java
Wed Sep 14 18:32:10 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.ace.server.log.ui;
+
+import java.util.Properties;
+
+import org.apache.ace.client.repository.repository.DeploymentVersionRepository;
+import org.apache.ace.server.log.store.LogStore;
+import org.apache.ace.webui.UIExtensionFactory;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends DependencyActivatorBase {
+
+	@Override
+	public void init(BundleContext context, DependencyManager manager)
+			throws Exception {
+		manager.add(createComponent().setInterface(
+                UIExtensionFactory.class.getName(), new Properties() {
+                    {
+                        put(UIExtensionFactory.EXTENSION_POINT_KEY, UIExtensionFactory.EXTENSION_POINT_VALUE_TARGET);
+                    }
+                }).setImplementation(LogViewerExtension.class)
+                .add(createServiceDependency()
+                		.setService(LogStore.class)
+                		.setRequired(true)));
+	}
+
+	@Override
+	public void destroy(BundleContext context, DependencyManager manager)
+			throws Exception {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

Added: incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java?rev=1170759&view=auto
==============================================================================
--- incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
(added)
+++ incubator/ace/trunk/ace-server-log-ui/src/main/java/org/apache/ace/server/log/ui/LogViewerExtension.java
Wed Sep 14 18:32:10 2011
@@ -0,0 +1,122 @@
+/*
+ * 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.ace.server.log.ui;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.object.GatewayObject;
+import org.apache.ace.log.AuditEvent;
+import org.apache.ace.log.LogDescriptor;
+import org.apache.ace.log.LogEvent;
+import org.apache.ace.server.log.store.LogStore;
+import org.apache.ace.webui.NamedObject;
+import org.apache.ace.webui.UIExtensionFactory;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+
+public class LogViewerExtension implements UIExtensionFactory {
+	private volatile LogStore m_store;
+
+	public Component create(Map<String, Object> context) {
+	    RepositoryObject object = getRepositoryObjectFromContext(context);
+			
+	    Table table = new Table();
+	    table.setWidth("100%");
+	    table.setHeight("100%");
+	    table.setCaption("LogViewer");
+        table.addContainerProperty("Time", Date.class, null);
+        table.addContainerProperty("Type", String.class, null);
+        table.addContainerProperty("Properties", TextArea.class, null);
+        table.setColumnExpandRatio("Properties", 1);
+	    try {
+	    	String id = object.getAttribute(GatewayObject.KEY_ID);
+		
+			List<LogDescriptor> desc = m_store.getDescriptors(id);
+			if (desc != null) {
+				for (LogDescriptor log : desc) {
+					for (LogEvent event : m_store.get(log)) {
+						Dictionary props = event.getProperties();
+						Enumeration keys = props.keys();
+						Set<String> keySet = new TreeSet<String>();
+						while (keys.hasMoreElements()) {
+							keySet.add(keys.nextElement().toString());
+						}
+						Iterator<String> keyIter = keySet.iterator();
+						String value = "";
+						String propString = "";
+						String prepend = "";
+						while (keyIter.hasNext()) {
+							String key = keyIter.next();
+							value = props.get(key).toString();
+							propString += prepend + key + ": " + value;
+							prepend = "\n";
+						}
+						TextArea area = new TextArea("", propString);
+						area.setWidth("100%");
+						area.setRows(props.size());
+						area.setWordwrap(false);
+						area.setReadOnly(true);
+						area.setImmediate(true);
+						String type = Integer.toString(event.getType());
+						for (Field f : AuditEvent.class.getFields()) {
+							if (((f.getModifiers() & Modifier.STATIC) == Modifier.STATIC) && (f.getType()
== Integer.TYPE)){
+								if (((Integer) f.get(null)).intValue() == event.getType()) {
+									type = f.getName();
+									break;
+								}
+							}
+						}
+						table.addItem(new Object[] {new Date(event.getTime()), type, area},null);
+					}
+				}
+			}
+			
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		}
+		return table;
+	} 
+	
+	private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context)
{
+        Object contextObject = context.get("object");
+        if (contextObject == null) {
+            throw new IllegalStateException("No context object found");
+        }
+        // It looks like there is some bug (or some other reason that escapes
+        // me)
+        // why ace is using either the object directly or wraps it in a
+        // NamedObject first.
+        // Its unclear when it does which so for now we cater for both.
+        return ((RepositoryObject) (contextObject instanceof NamedObject ? ((NamedObject)
contextObject)
+                .getObject() : contextObject));
+    }
+
+}

Modified: incubator/ace/trunk/ace-target-devserver/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-target-devserver/pom.xml?rev=1170759&r1=1170758&r2=1170759&view=diff
==============================================================================
--- incubator/ace/trunk/ace-target-devserver/pom.xml (original)
+++ incubator/ace/trunk/ace-target-devserver/pom.xml Wed Sep 14 18:32:10 2011
@@ -316,6 +316,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.server.log.ui</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
             <artifactId>org.apache.ace.webui.vaadin</artifactId>
             <scope>runtime</scope>
         </dependency>

Modified: incubator/ace/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/pom.xml?rev=1170759&r1=1170758&r2=1170759&view=diff
==============================================================================
--- incubator/ace/trunk/pom.xml (original)
+++ incubator/ace/trunk/pom.xml Wed Sep 14 18:32:10 2011
@@ -82,6 +82,7 @@
         <module>ace-httplistener</module>
 
         <module>ace-server-log-store</module>
+        <module>ace-server-log-ui</module>
         <module>ace-log-servlet</module>
         <module>ace-log-task</module>
         <module>ace-log-listener</module>

Modified: incubator/ace/trunk/pom/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/pom/pom.xml?rev=1170759&r1=1170758&r2=1170759&view=diff
==============================================================================
--- incubator/ace/trunk/pom/pom.xml (original)
+++ incubator/ace/trunk/pom/pom.xml Wed Sep 14 18:32:10 2011
@@ -600,6 +600,11 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.ace</groupId>
+                <artifactId>org.apache.ace.server.log.ui</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.ace</groupId>
                 <artifactId>org.apache.ace.target.defaults</artifactId>
                 <version>${project.version}</version>
             </dependency>



Mime
View raw message