Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--features/org.eclipse.osee.orcs.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.x.core.feature/feature.xml7
-rw-r--r--plugins/org.eclipse.osee.activity.api/.classpath7
-rw-r--r--plugins/org.eclipse.osee.activity.api/.project28
-rw-r--r--plugins/org.eclipse.osee.activity.api/META-INF/MANIFEST.MF11
-rw-r--r--plugins/org.eclipse.osee.activity.api/build.properties4
-rw-r--r--plugins/org.eclipse.osee.activity.api/pom.xml16
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/Activity.java55
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntry.java107
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntryId.java67
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLog.java70
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLogEndpoint.java116
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityType.java26
-rw-r--r--plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/DefaultActivityType.java67
-rw-r--r--plugins/org.eclipse.osee.activity/.classpath7
-rw-r--r--plugins/org.eclipse.osee.activity/.project33
-rw-r--r--plugins/org.eclipse.osee.activity/META-INF/MANIFEST.MF23
-rw-r--r--plugins/org.eclipse.osee.activity/OSEE-INF/activity.json14
-rw-r--r--plugins/org.eclipse.osee.activity/OSGI-INF/activity.database.storage.xml8
-rw-r--r--plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.application.xml8
-rw-r--r--plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.filter.provider.xml11
-rw-r--r--plugins/org.eclipse.osee.activity/OSGI-INF/activity.log.impl.xml13
-rw-r--r--plugins/org.eclipse.osee.activity/OSGI-INF/activity.schema.resource.xml7
-rw-r--r--plugins/org.eclipse.osee.activity/build.properties6
-rw-r--r--plugins/org.eclipse.osee.activity/pom.xml16
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityConstants.java45
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java36
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java336
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitor.java26
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitorImpl.java50
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivitySchemaResource.java58
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityUtil.java48
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java139
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogApplication.java48
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogFilter.java106
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogResource.java151
-rw-r--r--plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/schema/ACTIVITY.DS.SCHEMA.xml42
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zipbin57638 -> 58784 bytes
-rw-r--r--plugins/org.eclipse.osee.orcs.parent/pom.xml2
-rw-r--r--plugins/org.eclipse.osee.x.core.parent/pom.xml16
-rw-r--r--plugins/org.eclipse.osee.x.server.p2/demo/hsql.zipbin115717 -> 118430 bytes
41 files changed, 1830 insertions, 7 deletions
diff --git a/features/org.eclipse.osee.orcs.feature/feature.xml b/features/org.eclipse.osee.orcs.feature/feature.xml
index 19441c7f497..6fbe572f045 100644
--- a/features/org.eclipse.osee.orcs.feature/feature.xml
+++ b/features/org.eclipse.osee.orcs.feature/feature.xml
@@ -122,4 +122,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.activity"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/features/org.eclipse.osee.x.core.feature/feature.xml b/features/org.eclipse.osee.x.core.feature/feature.xml
index 2a1ec1be1b1..d0c4322026c 100644
--- a/features/org.eclipse.osee.x.core.feature/feature.xml
+++ b/features/org.eclipse.osee.x.core.feature/feature.xml
@@ -211,4 +211,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.activity.api"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/plugins/org.eclipse.osee.activity.api/.classpath b/plugins/org.eclipse.osee.activity.api/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.activity.api/.project b/plugins/org.eclipse.osee.activity.api/.project
new file mode 100644
index 00000000000..1a4b1f1fd6d
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.activity.api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.activity.api/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.activity.api/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..130e51bd5a3
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Activity Logging and Monitoring API (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.activity.api
+Bundle-Version: 0.18.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.osee.activity.api
+Import-Package: javax.ws.rs;version="2.0.0",
+ javax.ws.rs.core;version="2.0.0",
+ org.eclipse.osee.framework.jdk.core.type
+Bundle-Vendor: Eclipse Open System Engineering Environment
diff --git a/plugins/org.eclipse.osee.activity.api/build.properties b/plugins/org.eclipse.osee.activity.api/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.activity.api/pom.xml b/plugins/org.eclipse.osee.activity.api/pom.xml
new file mode 100644
index 00000000000..564c572410c
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/pom.xml
@@ -0,0 +1,16 @@
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.x.core.parent</artifactId>
+ <version>0.18.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.core.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.activity.api</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>Activity Logging and Monitoring API (Incubation)</name>
+</project>
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/Activity.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/Activity.java
new file mode 100644
index 00000000000..0a429b33167
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/Activity.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+import java.util.logging.Level;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public enum Activity implements ActivityType {
+ JAXRS_METHOD_CALL(880479734L, INFO, "org.eclipse.osee.activity.jaxrs"),
+ JAXRS_METHOD_CALL_FILTER_ERROR(23133964208285L, SEVERE, "org.eclipse.osee.activity.jaxrs"),
+ SRS_TRACE(80349535402L, INFO, "org.eclipse.osee.define.report.SrsTraceReport"),
+ MSG_CONTINUATION(29566294587L, INFO, "org.eclipse.osee.activity");
+
+ private final Long typeId;
+ private final Long logLevel;
+ private final String module;
+
+ Activity(Long typeId, Level logLevel, String module) {
+ this.typeId = typeId;
+ this.logLevel = new Long(logLevel.intValue());
+ this.module = module;
+ }
+
+ @Override
+ public Long getTypeId() {
+ return typeId;
+ }
+
+ @Override
+ public Long getLogLevel() {
+ return logLevel;
+ }
+
+ @Override
+ public String getModule() {
+ return module;
+ }
+
+ @Override
+ public String getMessageFormat() {
+ return "";
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntry.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntry.java
new file mode 100644
index 00000000000..2014a53dfef
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntry.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@XmlRootElement
+public class ActivityEntry extends ActivityEntryId {
+ private Long parentId;
+ private Long typeId;
+ private Long accountId;
+ private Long serverId;
+ private Long clientId;
+ private Long startTime;
+ private Long duration;
+ private Integer status;
+ private String messageArgs;
+
+ public Long getParentId() {
+ return parentId;
+ }
+
+ public Long getTypeId() {
+ return typeId;
+ }
+
+ public Long getAccountId() {
+ return accountId;
+ }
+
+ public Long getServerId() {
+ return serverId;
+ }
+
+ public Long getClientId() {
+ return clientId;
+ }
+
+ public Long getStartTime() {
+ return startTime;
+ }
+
+ public Long getDuration() {
+ return duration;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public String getMessageArgs() {
+ return messageArgs;
+ }
+
+ public void setParentId(Long parentId) {
+ this.parentId = parentId;
+ }
+
+ public void setTypeId(Long typeId) {
+ this.typeId = typeId;
+ }
+
+ public void setAccountId(Long accountId) {
+ this.accountId = accountId;
+ }
+
+ public void setServerId(Long serverId) {
+ this.serverId = serverId;
+ }
+
+ public void setClientId(Long clientId) {
+ this.clientId = clientId;
+ }
+
+ public void setStartTime(Long startTime) {
+ this.startTime = startTime;
+ }
+
+ public void setDuration(Long duration) {
+ this.duration = duration;
+ }
+
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+
+ public void setMessageArgs(String messageArgs) {
+ this.messageArgs = messageArgs;
+ }
+
+ @Override
+ public String toString() {
+ return "ActivityEntry [" + super.getGuid() + ", parentId=" + parentId + ", typeId=" + typeId + ", accountId=" + accountId + ", serverId=" + serverId + ", clientId=" + clientId + ", startTime=" + startTime + ", duration=" + duration + ", status=" + status + ", messageArgs=" + messageArgs + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntryId.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntryId.java
new file mode 100644
index 00000000000..b6f30578296
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityEntryId.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.jdk.core.type.Identity;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@XmlRootElement
+public class ActivityEntryId implements Identity<Long> {
+
+ private Long id;
+
+ public void setGuid(long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getGuid() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return getGuid().hashCode();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof Identity) {
+ Identity<Long> identity = (Identity<Long>) obj;
+ if (getGuid() == identity.getGuid()) {
+ equal = true;
+ } else if (getGuid() != null) {
+ equal = getGuid().equals(identity.getGuid());
+ }
+ }
+ return equal;
+ }
+
+ @Override
+ public boolean matches(Identity<?>... identities) {
+ for (Identity<?> identity : identities) {
+ if (equals(identity)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "ActivityEntryId [id=" + id + "]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLog.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLog.java
new file mode 100644
index 00000000000..711320774e8
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLog.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface ActivityLog {
+
+ public static interface ActivityDataHandler {
+ void onData(Long entryId, Long parentId, Long typeId, Long accountId, Long serverId, Long clientId, Long startTime, Long duration, Integer status, String messageArgs);
+ }
+
+ public static interface ActivityTypeDataHandler {
+ void onData(Long typeId, Long logLevel, String module, String messageFormat);
+ }
+
+ Integer INITIAL_STATUS = 100;
+ Integer COMPLETE_STATUS = 100;
+ Integer ABNORMALLY_ENDED_STATUS = 500;
+
+ void queryEntry(Long entryId, ActivityDataHandler handler);
+
+ Long createEntry(Long typeId, Integer status, String... messageArgs);
+
+ Long createEntry(Long typeId, Long parentId, Integer status, String... messageArgs);
+
+ Long createUpdateableEntry(ActivityType type, String... messageArgs);
+
+ Long createEntry(ActivityType type, String... messageArgs);
+
+ Long createEntry(ActivityType type, Long parentId, Integer status, String... messageArgs);
+
+ Long createThrowableEntry(ActivityType type, Throwable throwable);
+
+ boolean updateEntry(Long entryId, Integer status);
+
+ /**
+ * Set the status of log entry corresponding to entryId to 100% complete
+ */
+ void completeEntry(Long entryId);
+
+ /**
+ * Set the status of log entry corresponding to entryId to abnormally ended
+ */
+ void endEntryAbnormally(Long entryId);
+
+ void endEntryAbnormally(Long entryId, Integer status);
+
+ Long createActivityThread(ActivityType type, Long accountId, Long serverId, Long clientId, String... messageArgs);
+
+ Long createActivityThread(Long parentId, ActivityType type, Long accountId, Long serverId, Long clientId, String... messageArgs);
+
+ void createActivityTypes(ActivityType... types);
+
+ void queryActivityTypes(ActivityTypeDataHandler handler);
+
+ void queryActivityType(Long typeId, ActivityTypeDataHandler handler);
+
+ boolean activityTypeExists(Long typeId);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLogEndpoint.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLogEndpoint.java
new file mode 100644
index 00000000000..a18f63fb0d2
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityLogEndpoint.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@Path("activity-log")
+public interface ActivityLogEndpoint {
+
+ /**
+ * Get activity entry data
+ *
+ * @param entryId activity entry id
+ * @return JSON stream containing activity entry data
+ */
+ @Path("/entry/{entry-id}")
+ @GET
+ @Produces({MediaType.APPLICATION_JSON})
+ ActivityEntry getEntry(@PathParam("entry-id") Long entryId);
+
+ /**
+ * Create a new activity entry
+ *
+ * @param typeId activity type id
+ * @param parentId of the parent activity
+ * @param status of the activity
+ * @param message to log for the activity
+ * @return entryId
+ */
+ @Path("/entry")
+ @POST
+ @Produces({MediaType.APPLICATION_JSON})
+ ActivityEntryId createEntry(@QueryParam("typeId") Long typeId, @QueryParam("parentId") Long parentId, @QueryParam("status") Integer status, @QueryParam("message") String message);
+
+ /**
+ * Modify an entries status
+ *
+ * @param entryId entry to modify
+ * @param statusId to set entry status to
+ * @return response whether entry was modified
+ * @response.representation.200.doc entry status modified
+ * @response.representation.304.doc entry status not modified
+ */
+ @Path("/entry/{entry-id}/status/{status-id}")
+ @PUT
+ Response updateEntry(@PathParam("entry-id") Long entryId, @PathParam("status-id") Integer statusId);
+
+ /**
+ * Get all activity types
+ *
+ * @param typeId activity typeId id
+ * @return activityType
+ */
+ @Path("/type")
+ @GET
+ @Produces({MediaType.APPLICATION_JSON})
+ DefaultActivityType[] getActivityTypes();
+
+ /**
+ * Get activity type data
+ *
+ * @param typeId activity typeId id
+ * @return activityType
+ */
+ @Path("/type/{type-id}")
+ @GET
+ @Produces({MediaType.APPLICATION_JSON})
+ DefaultActivityType getActivityType(@PathParam("type-id") Long typeId);
+
+ /**
+ * Create a new activity type
+ *
+ * @param typeId activity type id to use
+ * @param logLevel of activity type
+ * @param module this activity comes from
+ * @param messageFormat for activity type
+ * @return activityType
+ */
+ @Path("/type/{type-id}")
+ @POST
+ @Produces({MediaType.APPLICATION_JSON})
+ DefaultActivityType createActivityType(@PathParam("type-id") Long typeId, @QueryParam("level") Long logLevel, @QueryParam("module") String module, @QueryParam("messageFormat") String messageFormat);
+
+ /**
+ * Create a new activity type (will generate a new type id)
+ *
+ * @param logLevel of activity type
+ * @param module this activity comes from
+ * @param messageFormat for activity type
+ * @return activityType
+ */
+ @Path("/type")
+ @POST
+ @Produces({MediaType.APPLICATION_JSON})
+ DefaultActivityType createActivityType(@QueryParam("level") Long logLevel, @QueryParam("module") String module, @QueryParam("messageFormat") String messageFormat);
+
+}
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityType.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityType.java
new file mode 100644
index 00000000000..5e8b8aac59a
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/ActivityType.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface ActivityType {
+
+ Long getTypeId();
+
+ Long getLogLevel();
+
+ String getModule();
+
+ String getMessageFormat();
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/DefaultActivityType.java b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/DefaultActivityType.java
new file mode 100644
index 00000000000..e123293110e
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity.api/src/org/eclipse/osee/activity/api/DefaultActivityType.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.api;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@XmlRootElement
+public class DefaultActivityType implements ActivityType {
+
+ private Long typeId;
+ private Long logLevel;
+ private String module;
+ private String messageFormat;
+
+ @Override
+ public Long getTypeId() {
+ return typeId;
+ }
+
+ @Override
+ public Long getLogLevel() {
+ return logLevel;
+ }
+
+ @Override
+ public String getModule() {
+ return module;
+ }
+
+ @Override
+ public String getMessageFormat() {
+ return messageFormat;
+ }
+
+ public void setTypeId(Long typeId) {
+ this.typeId = typeId;
+ }
+
+ public void setLogLevel(Long logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public void setMessageFormat(String messageFormat) {
+ this.messageFormat = messageFormat;
+ }
+
+ @Override
+ public String toString() {
+ return "DefaultActivityType [typeId=" + typeId + ", logLevel=" + logLevel + ", module=" + module + ", messageFormat=" + messageFormat + "]";
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/.classpath b/plugins/org.eclipse.osee.activity/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.activity/.project b/plugins/org.eclipse.osee.activity/.project
new file mode 100644
index 00000000000..c24080c8c81
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.activity</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.activity/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.activity/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..afaf04da77f
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Activity Logging and Monitoring Impl (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.activity
+Bundle-Version: 0.18.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Service-Component: OSGI-INF/*.xml
+Osee-Data: OSEE-INF/*
+Import-Package: javax.ws.rs;version="2.0.0",
+ javax.ws.rs.container;version="2.0.0",
+ javax.ws.rs.core;version="2.0.0",
+ javax.ws.rs.ext;version="2.0.0",
+ org.eclipse.osee.activity.api,
+ org.eclipse.osee.database.schema,
+ org.eclipse.osee.executor.admin,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.database,
+ org.eclipse.osee.framework.database.core,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.logger
+Export-Package: org.eclipse.osee.activity
diff --git a/plugins/org.eclipse.osee.activity/OSEE-INF/activity.json b/plugins/org.eclipse.osee.activity/OSEE-INF/activity.json
new file mode 100644
index 00000000000..340b842a81b
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/OSEE-INF/activity.json
@@ -0,0 +1,14 @@
+{
+"activityTypes": [
+ "org.eclipse.osee.activity.api.Activity",
+ ""
+],
+"artifacts": [
+ "",
+ ""
+],
+"restCalls": [
+ "",
+ ""
+]
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/OSGI-INF/activity.database.storage.xml b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.database.storage.xml
new file mode 100644
index 00000000000..fb7ae8a9fff
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.database.storage.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" >
+ <implementation class="org.eclipse.osee.activity.internal.DatabaseActivityStorage"/>
+ <service>
+ <provide interface="org.eclipse.osee.activity.ActivityStorage"/>
+ </service>
+ <reference bind="setDatabaseService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.application.xml b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.application.xml
new file mode 100644
index 00000000000..ad7b1b57759
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.application.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
+ <implementation class="org.eclipse.osee.activity.internal.jaxrs.ActivityLogApplication"/>
+ <service>
+ <provide interface="javax.ws.rs.core.Application"/>
+ </service>
+ <reference bind="setActivityLogger" cardinality="1..1" interface="org.eclipse.osee.activity.api.ActivityLog" name="ActivityLog" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.filter.provider.xml b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.filter.provider.xml
new file mode 100644
index 00000000000..e50f35583c4
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.jaxrs.filter.provider.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <implementation class="org.eclipse.osee.activity.internal.jaxrs.ActivityLogFilter"/>
+ <service>
+ <provide interface="java.lang.Object"/>
+ <provide interface="javax.ws.rs.container.ContainerRequestFilter"/>
+ <provide interface="javax.ws.rs.container.ContainerResponseFilter"/>
+ </service>
+ <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
+ <reference bind="setActivityLogger" cardinality="1..1" interface="org.eclipse.osee.activity.api.ActivityLog" name="ActivityLog" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.activity/OSGI-INF/activity.log.impl.xml b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.log.impl.xml
new file mode 100644
index 00000000000..4f8bd11cc95
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.log.impl.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" configuration-policy="optional" deactivate="stop" modified="update">
+ <implementation class="org.eclipse.osee.activity.internal.ActivityLogImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.activity.api.ActivityLog"/>
+ </service>
+ <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
+ <reference bind="setExecutorAdmin" cardinality="1..1" interface="org.eclipse.osee.executor.admin.ExecutorAdmin" name="ExecutorAdmin" policy="static"/>
+ <reference bind="setActivityStorage" cardinality="1..1" interface="org.eclipse.osee.activity.ActivityStorage" name="ActivityStorage" policy="static"/>
+ <property name="osee.activity.log.executor.pool.size" type="Integer" value="1"/>
+ <property name="osee.activity.log.stacktrace.line.count" type="Integer" value="5"/>
+ <property name="osee.activity.log.write.rate.millis" type="Long" value="3000"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.activity/OSGI-INF/activity.schema.resource.xml b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.schema.resource.xml
new file mode 100644
index 00000000000..8127bd945c3
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/OSGI-INF/activity.schema.resource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" >
+ <implementation class="org.eclipse.osee.activity.internal.ActivitySchemaResource" />
+ <service>
+ <provide interface="org.eclipse.osee.database.schema.SchemaResource"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.activity/build.properties b/plugins/org.eclipse.osee.activity/build.properties
new file mode 100644
index 00000000000..f6362c7e7c6
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ OSEE-INF/
diff --git a/plugins/org.eclipse.osee.activity/pom.xml b/plugins/org.eclipse.osee.activity/pom.xml
new file mode 100644
index 00000000000..28081d0ea64
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/pom.xml
@@ -0,0 +1,16 @@
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.orcs.parent</artifactId>
+ <version>0.18.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.activity</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>Activity Logging and Monitoring Impl (Incubation)</name>
+</project>
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityConstants.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityConstants.java
new file mode 100644
index 00000000000..d309ce34bf4
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityConstants.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class ActivityConstants {
+
+ private ActivityConstants() {
+ // Utility class
+ }
+
+ public static final String NAMESPACE = "osee.activity.log";
+
+ private static String qualify(String value) {
+ return String.format("%s.%s", NAMESPACE, value);
+ }
+
+ public static String ACTIVITY_LOGGER__EXECUTOR_ID = qualify("executor");
+
+ public static String ACTIVITY_LOGGER__WRITE_RATE_IN_MILLIS = qualify("write.rate.millis");
+ public static String ACTIVITY_LOGGER__STACKTRACE_LINE_COUNT = qualify("stacktrace.line.count");
+ public static String ACTIVITY_LOGGER__EXECUTOR_POOL_SIZE = qualify("executor.pool.size");
+
+ public static long DEFAULT_ACTIVITY_LOGGER__WRITE_RATE_IN_MILLIS = 3000L;
+ public static int DEFAULT_ACTIVITY_LOGGER__STACKTRACE_LINE_COUNT = 5;
+ public static int DEFAULT_ACTIVITY_LOGGER__EXECUTOR_POOL_SIZE = 1;
+
+ public static final String HTTP_HEADER__ACTIVITY_ENTRY_ID = "X-osee-activity-log-entryId";
+ public static final String ERROR_MSG__MISSING_ACTIVITY_HEADER =
+ "Error [" + ActivityConstants.HTTP_HEADER__ACTIVITY_ENTRY_ID + "] was missing from request http header";
+
+ public static final Long DEFAULT_ACCOUNT_ID = 1896L; // Guest Account Id
+ public static final Long DEFAULT_SERVER_ID = 777L;
+ public static final Long DEFAULT_CLIENT_ID = 111L;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java
new file mode 100644
index 00000000000..26da8cc848b
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/ActivityStorage.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity;
+
+import org.eclipse.osee.activity.api.ActivityLog.ActivityDataHandler;
+import org.eclipse.osee.activity.api.ActivityLog.ActivityTypeDataHandler;
+import org.eclipse.osee.activity.api.ActivityType;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface ActivityStorage {
+
+ void selectEntry(Long entryId, ActivityDataHandler handler);
+
+ int addEntries(Iterable<Object[]> newEntries);
+
+ int updateEntries(Iterable<Object[]> updatedEntries);
+
+ void addActivityTypes(ActivityType... types);
+
+ void selectTypes(ActivityTypeDataHandler handler);
+
+ void selectType(Long typeId, ActivityTypeDataHandler handler);
+
+ boolean typeExists(Long typeId);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java
new file mode 100644
index 00000000000..696702c9a03
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityLogImpl.java
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal;
+
+import static org.eclipse.osee.activity.ActivityConstants.ACTIVITY_LOGGER__EXECUTOR_ID;
+import static org.eclipse.osee.activity.ActivityConstants.ACTIVITY_LOGGER__EXECUTOR_POOL_SIZE;
+import static org.eclipse.osee.activity.ActivityConstants.ACTIVITY_LOGGER__STACKTRACE_LINE_COUNT;
+import static org.eclipse.osee.activity.ActivityConstants.ACTIVITY_LOGGER__WRITE_RATE_IN_MILLIS;
+import static org.eclipse.osee.activity.ActivityConstants.DEFAULT_ACTIVITY_LOGGER__EXECUTOR_POOL_SIZE;
+import static org.eclipse.osee.activity.ActivityConstants.DEFAULT_ACTIVITY_LOGGER__STACKTRACE_LINE_COUNT;
+import static org.eclipse.osee.activity.ActivityConstants.DEFAULT_ACTIVITY_LOGGER__WRITE_RATE_IN_MILLIS;
+import static org.eclipse.osee.activity.internal.ActivityUtil.captureStackTrace;
+import static org.eclipse.osee.activity.internal.ActivityUtil.get;
+import static org.eclipse.osee.framework.database.IOseeDatabaseService.MAX_VARCHAR_LENGTH;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import org.eclipse.osee.activity.ActivityStorage;
+import org.eclipse.osee.activity.api.Activity;
+import org.eclipse.osee.activity.api.ActivityLog;
+import org.eclipse.osee.activity.api.ActivityType;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
+import org.eclipse.osee.framework.jdk.core.type.DrainingIterator;
+import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.logger.Log;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ActivityLogImpl implements ActivityLog, Callable<Void> {
+
+ public static enum LogEntry {
+ ENTRY_ID,
+ PARENT_ID,
+ TYPE_ID,
+ ACCOUNT_ID,
+ SERVER_ID,
+ CLIENT_ID,
+ START_TIME,
+ DURATION,
+ STATUS,
+ MESSAGE_ARGS;
+
+ Long from(Object[] entry) {
+ Object obj = entry[ordinal()];
+ if (obj instanceof Long) {
+ return (Long) entry[ordinal()];
+ }
+ throw new OseeArgumentException("LogEntryIndex.from may only be used with values of type Long");
+ }
+ };
+
+ private final ConcurrentHashMap<Long, Object[]> newEntities = new ConcurrentHashMap<Long, Object[]>();
+ private final ConcurrentHashMap<Long, Object[]> updatedEntities = new ConcurrentHashMap<Long, Object[]>();
+
+ private Log logger;
+ private ExecutorAdmin executorAdmin;
+ private ActivityStorage storage;
+
+ private ActivityMonitorImpl activityMonitor;
+ private volatile long freshnessMillis;
+ private volatile int exceptionLineCount;
+ private volatile int executorPoolSize;
+ private volatile long lastFlushTime;
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ public void setActivityStorage(ActivityStorage storage) {
+ this.storage = storage;
+ }
+
+ public void setExecutorAdmin(ExecutorAdmin executorAdmin) {
+ this.executorAdmin = executorAdmin;
+ }
+
+ public void start(Map<String, Object> properties) throws Exception {
+ activityMonitor = new ActivityMonitorImpl();
+ update(properties);
+ }
+
+ public void stop() {
+ flush(true);
+ try {
+ executorAdmin.shutdown(ACTIVITY_LOGGER__EXECUTOR_ID);
+ } catch (Throwable th) {
+ logger.error(th, "Error shutting down executor [%s]", ACTIVITY_LOGGER__EXECUTOR_ID);
+ }
+ }
+
+ @Override
+ public void queryEntry(Long entryId, ActivityDataHandler handler) {
+ storage.selectEntry(entryId, handler);
+ }
+
+ public void update(Map<String, Object> properties) {
+ //@formatter:off
+ freshnessMillis = get(properties, ACTIVITY_LOGGER__WRITE_RATE_IN_MILLIS, DEFAULT_ACTIVITY_LOGGER__WRITE_RATE_IN_MILLIS);
+ exceptionLineCount = get(properties, ACTIVITY_LOGGER__STACKTRACE_LINE_COUNT, DEFAULT_ACTIVITY_LOGGER__STACKTRACE_LINE_COUNT);
+ int newExecutorPoolSize = get(properties, ACTIVITY_LOGGER__EXECUTOR_POOL_SIZE, DEFAULT_ACTIVITY_LOGGER__EXECUTOR_POOL_SIZE);
+ //@formatter:on
+
+ if (newExecutorPoolSize != executorPoolSize) {
+ executorPoolSize = newExecutorPoolSize;
+ try {
+ executorAdmin.shutdown(ACTIVITY_LOGGER__EXECUTOR_ID);
+ } catch (Throwable th) {
+ logger.error(th, "Error shutting down executor [%s]", ACTIVITY_LOGGER__EXECUTOR_ID);
+ } finally {
+ try {
+ executorAdmin.createFixedPoolExecutor(ACTIVITY_LOGGER__EXECUTOR_ID, executorPoolSize);
+ } catch (Throwable th) {
+ logger.error(th, "Error creating new executor for [%s]", ACTIVITY_LOGGER__EXECUTOR_ID);
+ }
+ }
+ }
+ }
+
+ @Override
+ public Long createEntry(ActivityType type, String... messageArgs) {
+ return createEntry(type.getTypeId(), COMPLETE_STATUS, messageArgs);
+ }
+
+ @Override
+ public Long createUpdateableEntry(ActivityType type, String... messageArgs) {
+ return createEntry(type.getTypeId(), INITIAL_STATUS, messageArgs);
+ }
+
+ @Override
+ public Long createEntry(ActivityType type, Long parentId, Integer status, String... messageArgs) {
+ return createEntry(type.getTypeId(), parentId, status, messageArgs);
+ }
+
+ @Override
+ public Long createEntry(Long typeId, Integer status, String... messageArgs) {
+ Object[] threadRootEntry = activityMonitor.getThreadRootEntry();
+ Long entryId = LogEntry.ENTRY_ID.from(threadRootEntry);
+ return createEntry(typeId, entryId, status, messageArgs);
+ }
+
+ @Override
+ public Long createEntry(Long typeId, Long parentId, Integer status, String... messageArgs) {
+ Object[] rootEntry = activityMonitor.getThreadRootEntry();
+ Long accountId = LogEntry.ACCOUNT_ID.from(rootEntry);
+ Long serverId = LogEntry.SERVER_ID.from(rootEntry);
+ Long clientId = LogEntry.CLIENT_ID.from(rootEntry);
+ Object[] entry =
+ createEntry(parentId, typeId, accountId, serverId, clientId, computeDuration(), status, messageArgs);
+ return LogEntry.ENTRY_ID.from(entry);
+ }
+
+ private Object[] createEntry(Long parentId, Long typeId, Long accountId, Long serverId, Long clientId, Long duration, Integer status, String... messageArgs) {
+ Long entryId = Lib.generateUuid();
+ Long startTime = System.currentTimeMillis();
+ String fullMsg = Collections.toString("\n", (Object[]) messageArgs);
+
+ String msg = fullMsg.substring(0, Math.min(fullMsg.length(), MAX_VARCHAR_LENGTH));
+ // this is the parent entry so it must be inserted first (because the entry writing is asynchronous
+ Object[] entry =
+ new Object[] {entryId, parentId, typeId, accountId, serverId, clientId, startTime, duration, status, msg};
+ newEntities.put(entryId, entry);
+
+ if (fullMsg.length() > MAX_VARCHAR_LENGTH) {
+ Long parentCursor = entryId;
+ for (int i = MAX_VARCHAR_LENGTH; i < fullMsg.length(); i += MAX_VARCHAR_LENGTH) {
+ Long continueEntryId = Lib.generateUuid();
+ Object[] continueEntry =
+ new Object[] {
+ continueEntryId,
+ parentCursor,
+ Activity.MSG_CONTINUATION.getTypeId(),
+ accountId,
+ serverId,
+ clientId,
+ startTime,
+ duration,
+ status,
+ fullMsg.substring(i, Math.min(fullMsg.length(), i + MAX_VARCHAR_LENGTH))};
+ newEntities.put(continueEntryId, continueEntry);
+ parentCursor = continueEntryId;
+ }
+ }
+ flush(false);
+ return entry;
+ }
+
+ @Override
+ public Long createThrowableEntry(ActivityType type, Throwable throwable) {
+ Long entryId = -1L;
+ try {
+ String message = captureStackTrace(throwable, exceptionLineCount);
+ entryId = createEntry(type.getTypeId(), ABNORMALLY_ENDED_STATUS, message);
+ } catch (Throwable th) {
+ logger.error(th, "logging failed in ActivityLogImpl.createThrowableEntry");
+ }
+ return entryId;
+ }
+
+ @Override
+ public boolean updateEntry(Long entryId, Integer status) {
+ boolean modified = false;
+ if (!updateIfNew(entryId, status)) {
+ Object[] data = updatedEntities.get(entryId);
+ if (data == null) {
+ addUpdatedEntryToMap(entryId, status);
+ } else {
+ data[LogEntry.STATUS.ordinal()] = status;
+ if (!updatedEntities.containsKey(entryId)) {
+ addUpdatedEntryToMap(entryId, status);
+ }
+ }
+ modified = true;
+ }
+ return modified;
+ }
+
+ private void addUpdatedEntryToMap(Long entryId, Integer status) {
+ updatedEntities.put(entryId, new Object[] {status, computeDuration(), entryId});
+ }
+
+ private Long computeDuration() {
+ long timeOfUpdate = System.currentTimeMillis();
+ Object[] rootEntry = activityMonitor.getThreadRootEntry();
+ LogEntry.START_TIME.from(rootEntry);
+ return timeOfUpdate - LogEntry.START_TIME.from(rootEntry);
+ }
+
+ /**
+ * If the status has changed for an entry that has not yet been written to the datastore, update in memory and return
+ * true if it has not yet been drained and written to the datastore
+ */
+ private boolean updateIfNew(Long entryId, Integer status) {
+ Object[] data = newEntities.get(entryId);
+ if (data == null) {
+ return false;
+ } else {
+ data[LogEntry.STATUS.ordinal()] = status;
+ data[LogEntry.DURATION.ordinal()] = computeDuration();
+ return newEntities.containsKey(entryId);
+ }
+ }
+
+ @Override
+ public Void call() {
+ if (!newEntities.isEmpty()) {
+ try {
+ storage.addEntries(new DrainingIterator<Object[]>(newEntities.values().iterator()));
+ } catch (Throwable ex) {
+ logger.error(ex, "Exception while storing updates to the activity log");
+ }
+ }
+ if (!updatedEntities.isEmpty()) {
+ try {
+ storage.updateEntries(new DrainingIterator<Object[]>(updatedEntities.values().iterator()));
+ } catch (Throwable ex) {
+ logger.error(ex, "Exception while storing updates to the activity log");
+ }
+ }
+ return null;
+ }
+
+ private void flush(boolean force) {
+ long currentTime = System.currentTimeMillis();
+ if (force || currentTime - lastFlushTime > freshnessMillis) {
+ try {
+ executorAdmin.schedule(ACTIVITY_LOGGER__EXECUTOR_ID, this);
+ } catch (Exception ex) {
+ logger.error(ex, "Error scheduling activity log callable");
+ } finally {
+ lastFlushTime = currentTime;
+ }
+ }
+ }
+
+ @Override
+ public void completeEntry(Long entryId) {
+ updateEntry(entryId, COMPLETE_STATUS);
+ }
+
+ @Override
+ public void endEntryAbnormally(Long entryId) {
+ updateEntry(entryId, ABNORMALLY_ENDED_STATUS);
+ }
+
+ @Override
+ public void endEntryAbnormally(Long entryId, Integer status) {
+ if (status > COMPLETE_STATUS) {
+ updateEntry(entryId, status);
+ } else {
+ endEntryAbnormally(entryId);
+ }
+ }
+
+ @Override
+ public Long createActivityThread(ActivityType type, Long accountId, Long serverId, Long clientId, String... messageArgs) {
+ return createActivityThread(-1L, type, accountId, serverId, clientId, messageArgs);
+ }
+
+ @Override
+ public Long createActivityThread(Long parentId, ActivityType type, Long accountId, Long serverId, Long clientId, String... messageArgs) {
+ Object[] entry = createEntry(parentId, type.getTypeId(), accountId, serverId, clientId, 0L, 0, messageArgs);
+ activityMonitor.addActivityThread(entry);
+ return LogEntry.ENTRY_ID.from(entry);
+ }
+
+ @Override
+ public void createActivityTypes(ActivityType... types) {
+ storage.addActivityTypes(types);
+ }
+
+ @Override
+ public void queryActivityType(Long typeId, ActivityTypeDataHandler handler) {
+ storage.selectType(typeId, handler);
+ }
+
+ @Override
+ public boolean activityTypeExists(Long typeId) {
+ return storage.typeExists(typeId);
+ }
+
+ @Override
+ public void queryActivityTypes(ActivityTypeDataHandler handler) {
+ storage.selectTypes(handler);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitor.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitor.java
new file mode 100644
index 00000000000..5c0f14fca3b
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitor.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface ActivityMonitor {
+
+ Object[] getThreadRootEntry();
+
+ Iterable<Thread> getActiveThreads();
+
+ void addActivityThread(Object[] activityEntry);
+
+ void removeActivityThread();
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitorImpl.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitorImpl.java
new file mode 100644
index 00000000000..68cb015b1e8
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityMonitorImpl.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class ActivityMonitorImpl implements ActivityMonitor {
+
+ private final ConcurrentHashMap<Thread, Object[]> threadToUser = new ConcurrentHashMap<Thread, Object[]>();
+
+ @Override
+ public Object[] getThreadRootEntry() {
+ return threadToUser.get(Thread.currentThread());
+ }
+
+ @Override
+ public synchronized Iterable<Thread> getActiveThreads() {
+ Set<Thread> threads = threadToUser.keySet();
+ Iterator<Thread> threadIter = threads.iterator();
+ while (threadIter.hasNext()) {
+ if (!threadIter.next().isAlive()) {
+ threadIter.remove();
+ }
+ }
+ return threads;
+ }
+
+ @Override
+ public void addActivityThread(Object[] activityEntry) {
+ threadToUser.put(Thread.currentThread(), activityEntry);
+ }
+
+ @Override
+ public void removeActivityThread() {
+ threadToUser.remove(Thread.currentThread());
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivitySchemaResource.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivitySchemaResource.java
new file mode 100644
index 00000000000..4c8cf7631b0
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivitySchemaResource.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal;
+
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import org.eclipse.osee.database.schema.SchemaResource;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class ActivitySchemaResource implements SchemaResource {
+
+ private static final String SCHEMA_PATH = "schema/ACTIVITY.DS.SCHEMA.xml";
+
+ @Override
+ public InputStream getContent() throws OseeCoreException {
+ InputStream inputStream = null;
+ try {
+ URL url = getResourceURL();
+ inputStream = new BufferedInputStream(url.openStream());
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return inputStream;
+ }
+
+ @Override
+ public boolean isApplicable() {
+ return true;
+ }
+
+ @Override
+ public URI getLocation() throws OseeCoreException {
+ try {
+ return getResourceURL().toURI();
+ } catch (URISyntaxException ex) {
+ throw new OseeCoreException(ex, "Error finding [%s] schema resource", SCHEMA_PATH);
+ }
+ }
+
+ private URL getResourceURL() {
+ return getClass().getResource(SCHEMA_PATH);
+ }
+}
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityUtil.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityUtil.java
new file mode 100644
index 00000000000..daaef790b64
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/ActivityUtil.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal;
+
+import java.util.Map;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class ActivityUtil {
+
+ private ActivityUtil() {
+ // Utility class
+ }
+
+ public static String captureStackTrace(Throwable ex, int linesToCapture) {
+ Throwable cause = ex;
+
+ while (cause.getCause() != null) {
+ cause = cause.getCause();
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(cause.toString() + "\n");
+ StackTraceElement stackElements[] = cause.getStackTrace();
+ for (int i = 0; i < linesToCapture; i++) {
+ sb.append(stackElements[i] + "\n");
+ }
+ return sb.toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> T get(Map<String, Object> properties, String key, T defaultValue) {
+ T value = properties != null ? (T) properties.get(key) : null;
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java
new file mode 100644
index 00000000000..5057e7c9a05
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/DatabaseActivityStorage.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal;
+
+import org.eclipse.osee.activity.ActivityStorage;
+import org.eclipse.osee.activity.api.ActivityLog.ActivityDataHandler;
+import org.eclipse.osee.activity.api.ActivityLog.ActivityTypeDataHandler;
+import org.eclipse.osee.activity.api.ActivityType;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IQueryProcessor;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class DatabaseActivityStorage implements ActivityStorage {
+
+ private static final String SELECT_ENTRY = "SELECT * FROM osee_activity WHERE entry_id = ?";
+
+ private static final String INSERT_ENTRIES =
+ "INSERT INTO osee_activity (entry_id, parent_id, type_id, account_id, server_id, client_id, start_time, duration, status, msg_args) VALUES (?,?,?,?,?,?,?,?,?,?)";
+
+ private static final String UPDATE_ENTRIES = "UPDATE osee_activity set status = ?, duration = ? where entry_id = ?";
+
+ private static final String SELECT_ALL_TYPES = "SELECT * FROM osee_activity_type";
+
+ private static final String SELECT_TYPE = "SELECT * FROM osee_activity_type WHERE type_id = ?";
+
+ private static final String INSERT_TYPE =
+ "INSERT INTO osee_activity_type (type_id, log_level, module, msg_format) VALUES (?,?,?,?)";
+
+ private static final String COUNT_TYPE = "SELECT count(1) FROM osee_activity_type WHERE type_id = ?";
+
+ private static class ActivityEntryProcessor implements IQueryProcessor {
+
+ private final ActivityDataHandler handler;
+
+ public ActivityEntryProcessor(ActivityDataHandler handler) {
+ super();
+ this.handler = handler;
+ }
+
+ @Override
+ public void processNext(IOseeStatement chStmt) {
+ Long entryId = chStmt.getLong("entry_id");
+ Long parentId = chStmt.getLong("parent_id");
+ Long typeId = chStmt.getLong("type_id");
+ Long accountId = chStmt.getLong("account_id");
+ Long serverId = chStmt.getLong("server_id");
+ Long clientId = chStmt.getLong("client_id");
+ Long startTime = chStmt.getLong("start_time");
+ Long duration = chStmt.getLong("duration");
+ Integer status = chStmt.getInt("status");
+ String messageArgs = chStmt.getString("msg_args");
+ handler.onData(entryId, parentId, typeId, accountId, serverId, clientId, startTime, duration, status,
+ messageArgs);
+ }
+ }
+
+ private static class ActivityTypeProcessor implements IQueryProcessor {
+
+ private final ActivityTypeDataHandler handler;
+
+ public ActivityTypeProcessor(ActivityTypeDataHandler handler) {
+ super();
+ this.handler = handler;
+ }
+
+ @Override
+ public void processNext(IOseeStatement chStmt) {
+ Long typeId = chStmt.getLong("type_id");
+ Long logLevel = chStmt.getLong("log_level");
+ String module = chStmt.getString("module");
+ String messageFormat = chStmt.getString("msg_format");
+ handler.onData(typeId, logLevel, module, messageFormat);
+ }
+ }
+
+ private IOseeDatabaseService dbService;
+
+ public void setDatabaseService(IOseeDatabaseService dbService) {
+ this.dbService = dbService;
+ }
+
+ @Override
+ public void selectEntry(Long entryId, final ActivityDataHandler handler) {
+ dbService.runQuery(new ActivityEntryProcessor(handler), SELECT_ENTRY, entryId);
+ }
+
+ @Override
+ public int addEntries(Iterable<Object[]> newEntries) {
+ return dbService.runBatchUpdate(INSERT_ENTRIES, newEntries);
+ }
+
+ @Override
+ public int updateEntries(Iterable<Object[]> updatedEntries) {
+ return dbService.runBatchUpdate(UPDATE_ENTRIES, updatedEntries);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void addLogType(ActivityType type) {
+ Long typeId = type.getTypeId();
+ Long logLevel = type.getLogLevel();
+ String module = type.getModule();
+ String messageFormat = type.getMessageFormat();
+ dbService.runPreparedUpdate(INSERT_TYPE, typeId, logLevel, module, messageFormat);
+ }
+
+ @Override
+ public void addActivityTypes(ActivityType... types) {
+ for (ActivityType type : types) {
+ addLogType(type);
+ }
+ }
+
+ @Override
+ public void selectTypes(final ActivityTypeDataHandler handler) {
+ dbService.runQuery(new ActivityTypeProcessor(handler), SELECT_ALL_TYPES);
+ }
+
+ @Override
+ public void selectType(Long typeId, final ActivityTypeDataHandler handler) {
+ dbService.runQuery(new ActivityTypeProcessor(handler), SELECT_TYPE, typeId);
+ }
+
+ @Override
+ public boolean typeExists(Long typeId) {
+ return dbService.runPreparedQueryFetchObject(-1L, COUNT_TYPE, typeId) > 0;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogApplication.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogApplication.java
new file mode 100644
index 00000000000..0e527d14be0
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogApplication.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal.jaxrs;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import org.eclipse.osee.activity.api.ActivityLog;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@ApplicationPath("/")
+public final class ActivityLogApplication extends Application {
+
+ private Set<Object> singletons;
+
+ private ActivityLog activityLog;
+
+ public void setActivityLogger(ActivityLog activityLog) {
+ this.activityLog = activityLog;
+ }
+
+ public void start() {
+ singletons = new HashSet<Object>();
+ singletons.add(new ActivityLogResource(activityLog));
+ }
+
+ public void stop() {
+ singletons.clear();
+ singletons = null;
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return singletons;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogFilter.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogFilter.java
new file mode 100644
index 00000000000..7453ce18c88
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogFilter.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal.jaxrs;
+
+import static org.eclipse.osee.activity.ActivityConstants.ERROR_MSG__MISSING_ACTIVITY_HEADER;
+import static org.eclipse.osee.activity.ActivityConstants.HTTP_HEADER__ACTIVITY_ENTRY_ID;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response.StatusType;
+import javax.ws.rs.ext.Provider;
+import org.eclipse.osee.activity.ActivityConstants;
+import org.eclipse.osee.activity.api.Activity;
+import org.eclipse.osee.activity.api.ActivityLog;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.logger.Log;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@Provider
+public class ActivityLogFilter implements ContainerRequestFilter, ContainerResponseFilter {
+
+ private Log logger;
+ private ActivityLog activityLog;
+
+ public void setActivityLogger(ActivityLog activityLog) {
+ this.activityLog = activityLog;
+ }
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ /**
+ * Called before a resource method is executed
+ */
+ @Override
+ public void filter(ContainerRequestContext context) {
+ try {
+ String message = String.format("%s %s", context.getMethod(), context.getUriInfo().getRequestUri());
+
+ Long serverId = getServerId(context);
+ Long clientId = getClientId(context);
+ Long accountId = getAccountId(context);
+
+ Long entryId =
+ activityLog.createActivityThread(Activity.JAXRS_METHOD_CALL, accountId, serverId, clientId, message);
+
+ context.getHeaders().addFirst(ActivityConstants.HTTP_HEADER__ACTIVITY_ENTRY_ID, String.valueOf(entryId));
+ } catch (Throwable th) {
+ logger.error(th, "Error during ActivityContainerRequestFilter");
+ }
+ }
+
+ /**
+ * Called after a resource method is executed
+ */
+ @Override
+ public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
+ try {
+ String activityHeader = requestContext.getHeaders().getFirst(HTTP_HEADER__ACTIVITY_ENTRY_ID);
+ if (!Strings.isValid(activityHeader)) {
+ activityLog.createUpdateableEntry(Activity.JAXRS_METHOD_CALL_FILTER_ERROR,
+ ERROR_MSG__MISSING_ACTIVITY_HEADER);
+ } else {
+ Long entryId = Long.parseLong(activityHeader);
+
+ StatusType statusType = responseContext.getStatusInfo();
+ if (statusType.getFamily() == Status.Family.SUCCESSFUL) {
+ activityLog.completeEntry(entryId);
+ } else {
+ activityLog.endEntryAbnormally(entryId, responseContext.getStatus());
+ }
+ }
+ } catch (Throwable th) {
+ logger.error(th, "Error during ActivityContainerResponseFilter");
+ }
+ }
+
+ private Long getServerId(ContainerRequestContext context) {
+ Long toReturn = ActivityConstants.DEFAULT_SERVER_ID;
+ return toReturn;
+ }
+
+ private Long getClientId(ContainerRequestContext context) {
+ Long toReturn = ActivityConstants.DEFAULT_CLIENT_ID;
+ return toReturn;
+ }
+
+ private Long getAccountId(ContainerRequestContext context) {
+ Long toReturn = ActivityConstants.DEFAULT_ACCOUNT_ID;
+ return toReturn;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogResource.java b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogResource.java
new file mode 100644
index 00000000000..83204122248
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/jaxrs/ActivityLogResource.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.activity.internal.jaxrs;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.eclipse.osee.activity.api.ActivityEntry;
+import org.eclipse.osee.activity.api.ActivityEntryId;
+import org.eclipse.osee.activity.api.ActivityLog;
+import org.eclipse.osee.activity.api.ActivityLog.ActivityDataHandler;
+import org.eclipse.osee.activity.api.ActivityLog.ActivityTypeDataHandler;
+import org.eclipse.osee.activity.api.ActivityLogEndpoint;
+import org.eclipse.osee.activity.api.DefaultActivityType;
+import org.eclipse.osee.framework.jdk.core.type.MutableBoolean;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class ActivityLogResource implements ActivityLogEndpoint {
+
+ private final ActivityLog activityLog;
+
+ public ActivityLogResource(ActivityLog activityLog) {
+ this.activityLog = activityLog;
+ }
+
+ @Override
+ public ActivityEntry getEntry(Long entryId) {
+ Conditions.checkNotNull(entryId, "activity entry id");
+ final ActivityEntry entry = new ActivityEntry();
+ final MutableBoolean found = new MutableBoolean(false);
+ activityLog.queryEntry(entryId, new ActivityDataHandler() {
+
+ @Override
+ public void onData(Long entryId, Long parentId, Long typeId, Long accountId, Long serverId, Long clientId, Long startTime, Long duration, Integer status, String messageArgs) {
+ found.setValue(true);
+ entry.setAccountId(accountId);
+ entry.setClientId(clientId);
+ entry.setDuration(duration);
+ entry.setGuid(entryId);
+ entry.setMessageArgs(messageArgs);
+ entry.setParentId(parentId);
+ entry.setServerId(serverId);
+ entry.setStartTime(startTime);
+ entry.setStatus(status);
+ entry.setTypeId(typeId);
+ }
+ });
+ if (!found.getValue()) {
+ throw new NotFoundException("Activity Entry for entry id [" + entryId + "] was not found");
+ }
+ return entry;
+ }
+
+ @Override
+ public ActivityEntryId createEntry(Long typeId, Long parentId, Integer status, String message) {
+ Long entryId = activityLog.createEntry(typeId, parentId, status, message);
+ ActivityEntryId entity = new ActivityEntryId();
+ entity.setGuid(entryId);
+ return entity;
+ }
+
+ @Override
+ public Response updateEntry(Long entryId, Integer statusId) {
+ boolean modified = activityLog.updateEntry(entryId, statusId);
+ ResponseBuilder builder;
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+
+ @Override
+ public DefaultActivityType[] getActivityTypes() {
+ final List<DefaultActivityType> types = new ArrayList<DefaultActivityType>();
+ activityLog.queryActivityTypes(new ActivityTypeDataHandler() {
+
+ @Override
+ public void onData(Long typeId, Long logLevel, String module, String messageFormat) {
+ DefaultActivityType type = new DefaultActivityType();
+ type.setTypeId(typeId);
+ type.setLogLevel(logLevel);
+ type.setModule(module);
+ type.setMessageFormat(messageFormat);
+ types.add(type);
+ }
+ });
+ return types.toArray(new DefaultActivityType[0]);
+ }
+
+ @Override
+ public DefaultActivityType getActivityType(Long typeId) {
+ Conditions.checkNotNull(typeId, "activity type id");
+ final MutableBoolean found = new MutableBoolean(false);
+ final DefaultActivityType type = new DefaultActivityType();
+ activityLog.queryActivityType(typeId, new ActivityTypeDataHandler() {
+
+ @Override
+ public void onData(Long typeId, Long logLevel, String module, String messageFormat) {
+ found.setValue(true);
+ type.setTypeId(typeId);
+ type.setLogLevel(logLevel);
+ type.setModule(module);
+ type.setMessageFormat(messageFormat);
+ }
+ });
+ if (!found.getValue()) {
+ throw new NotFoundException("Activity Type for type id [" + typeId + "] was not found");
+ }
+ return type;
+ }
+
+ @Override
+ public DefaultActivityType createActivityType(Long typeId, Long logLevel, String module, String messageFormat) {
+ Conditions.checkExpressionFailOnTrue(activityLog.activityTypeExists(typeId),
+ "Activity Type Id [%s] already exists", typeId);
+ return newActivityHelper(typeId, logLevel, module, messageFormat);
+ }
+
+ @Override
+ public DefaultActivityType createActivityType(Long logLevel, String module, String messageFormat) {
+ Long typeId = Lib.generateUuid();
+ return newActivityHelper(typeId, logLevel, module, messageFormat);
+ }
+
+ private DefaultActivityType newActivityHelper(Long typeId, Long logLevel, String module, String messageFormat) {
+ DefaultActivityType type = new DefaultActivityType();
+ type.setTypeId(typeId);
+ type.setLogLevel(logLevel);
+ type.setModule(module);
+ type.setMessageFormat(messageFormat);
+ activityLog.createActivityTypes(type);
+ return type;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/schema/ACTIVITY.DS.SCHEMA.xml b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/schema/ACTIVITY.DS.SCHEMA.xml
new file mode 100644
index 00000000000..04fef64fa29
--- /dev/null
+++ b/plugins/org.eclipse.osee.activity/src/org/eclipse/osee/activity/internal/schema/ACTIVITY.DS.SCHEMA.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TableConfig>
+
+ <!-- __________________________________________________________ -->
+ <!-- Logging Tables -->
+ <!-- __________________________________________________________ -->
+ <Table name="OSEE_ACTIVITY" schema="OSEE" tablespace="osee_data">
+ <Column id="ENTRY_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="PARENT_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="TYPE_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="ACCOUNT_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="SERVER_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="CLIENT_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="START_TIME" defaultValue="not null" type="BIGINT" />
+ <Column id="DURATION" defaultValue="not null" type="BIGINT" />
+ <Column id="STATUS" defaultValue="not null" type="INTEGER" />
+ <Column id="MSG_ARGS" limits="4000" type="VARCHAR" />
+ <Constraint schema="OSEE" id="OSEE_ACTIVITY__ENTRY_ID_PK" type="PRIMARY KEY" appliesTo="ENTRY_ID" />
+ <Constraint schema="OSEE" id="OSEE_ACTIVITY__TYPE_ID_FK" type="FOREIGN KEY" appliesTo="TYPE_ID" deferrable="true">
+ <References schema="OSEE" table="OSEE_ACTIVITY_TYPE" column="TYPE_ID" />
+ </Constraint>
+ <Index id="OSEE_ACTIVITY__P_E_IDX" type="UNIQUE" tablespace="osee_index">
+ <AppliesTo id="PARENT_ID" />
+ <AppliesTo id="ENTRY_ID" />
+ </Index>
+ <Index id="OSEE_ACTIVITY__ACCOUNT_IDX" tablespace="osee_index">
+ <AppliesTo id="ACCOUNT_ID" />
+ </Index>
+ <Index id="OSEE_ACTIVITY__TYPE_IDX" tablespace="osee_index">
+ <AppliesTo id="TYPE_ID" />
+ </Index>
+ </Table>
+
+ <Table name="OSEE_ACTIVITY_TYPE" schema="OSEE" tablespace="osee_data">
+ <Column id="TYPE_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="LOG_LEVEL" defaultValue="not null" type="BIGINT" />
+ <Column id="MODULE" limits="4000" type="VARCHAR" />
+ <Column id="MSG_FORMAT" limits="4000" type="VARCHAR" />
+ <Constraint schema="OSEE" id="OSEE_ACTIVITY_TYPE__ID_PK" type="PRIMARY KEY" appliesTo="TYPE_ID" />
+ </Table>
+
+</TableConfig>
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
index a98ecdf4fd1..26c6b3055e8 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
+++ b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
Binary files differ
diff --git a/plugins/org.eclipse.osee.orcs.parent/pom.xml b/plugins/org.eclipse.osee.orcs.parent/pom.xml
index 581296d13e5..ca48bce826e 100644
--- a/plugins/org.eclipse.osee.orcs.parent/pom.xml
+++ b/plugins/org.eclipse.osee.orcs.parent/pom.xml
@@ -31,6 +31,8 @@
<module>../../plugins/org.eclipse.osee.database.schema</module>
+ <module>../../plugins/org.eclipse.osee.activity</module>
+
<module>../../plugins/org.eclipse.osee.orcs</module>
<module>../../plugins/org.eclipse.osee.orcs.core</module>
<module>../../plugins/org.eclipse.osee.orcs.core.test</module>
diff --git a/plugins/org.eclipse.osee.x.core.parent/pom.xml b/plugins/org.eclipse.osee.x.core.parent/pom.xml
index b1289d918bf..3d86a2810c1 100644
--- a/plugins/org.eclipse.osee.x.core.parent/pom.xml
+++ b/plugins/org.eclipse.osee.x.core.parent/pom.xml
@@ -21,6 +21,8 @@
<module>../../plugins/org.eclipse.osee.logger.slf4j</module>
<module>../../plugins/org.eclipse.osee.logback.config</module>
+ <module>../../plugins/org.eclipse.osee.activity.api</module>
+
<module>../../plugins/org.eclipse.osee.event</module>
<module>../../plugins/org.eclipse.osee.event.osgi</module>
@@ -41,13 +43,13 @@
<module>../../plugins/org.eclipse.osee.authentication.admin</module>
<module>../../plugins/org.eclipse.osee.authentication.admin.test</module>
-
+
<module>../../plugins/org.eclipse.osee.authorization.admin</module>
<module>../../plugins/org.eclipse.osee.authorization.admin.test</module>
-
+
<module>../../plugins/org.eclipse.osee.authentication.ldap</module>
<module>../../plugins/org.eclipse.osee.authentication.ldap.test</module>
-
+
<module>../../plugins/org.eclipse.osee.account.admin</module>
<module>../../plugins/org.eclipse.osee.account.admin.test</module>
@@ -66,14 +68,14 @@
<module>../../plugins/org.eclipse.osee.jaxrs.server.test</module>
<module>../../plugins/org.eclipse.osee.jaxrs.client</module>
<module>../../plugins/org.eclipse.osee.jaxrs.client.test</module>
-
+
<module>../../plugins/org.eclipse.osee.account.rest.model</module>
<module>../../plugins/org.eclipse.osee.account.rest</module>
- <module>../../plugins/org.eclipse.osee.account.rest.test</module>
+ <module>../../plugins/org.eclipse.osee.account.rest.test</module>
<module>../../plugins/org.eclipse.osee.account.rest.client</module>
-
+
<module>../../plugins/org.eclipse.osee.web</module>
-
+
<module>../../features/org.eclipse.osee.x.core.external.feature</module>
<module>../../features/org.eclipse.osee.x.core.feature</module>
diff --git a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
index c678c4aa841..cdad955dbc9 100644
--- a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
+++ b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
Binary files differ

Back to the top