Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-01-22 02:25:20 +0000
committerRyan D. Brooks2014-01-22 02:25:20 +0000
commit9ea8e0a944e9caee56b35b72a0d913a50394c3e4 (patch)
tree67077a71b076df437c6c87676475e6630dd30f44
parent1f33e0bf0a642c17b674bbeb791e88ea07c4726a (diff)
downloadorg.eclipse.osee-9ea8e0a944e9caee56b35b72a0d913a50394c3e4.tar.gz
org.eclipse.osee-9ea8e0a944e9caee56b35b72a0d913a50394c3e4.tar.xz
org.eclipse.osee-9ea8e0a944e9caee56b35b72a0d913a50394c3e4.zip
feature[ats_ATS8933]: Create Account REST API
-rw-r--r--features/org.eclipse.osee.x.core.feature/feature.xml14
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/.classpath7
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/.project28
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF9
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/build.properties4
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/pom.xml34
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountAccessData.java68
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java85
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountContexts.java38
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountDetailsData.java34
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java113
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInput.java62
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountLoginData.java49
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java45
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesInput.java36
-rw-r--r--plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java74
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/.project28
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/pom.xml32
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/AccountRestTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java96
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountInternalTestSuite.java31
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLoginResourceTest.java89
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLogoutResourceTest.java72
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java436
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java93
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java123
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java56
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java78
-rw-r--r--plugins/org.eclipse.osee.account.rest/.classpath7
-rw-r--r--plugins/org.eclipse.osee.account.rest/.project33
-rw-r--r--plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF19
-rw-r--r--plugins/org.eclipse.osee.account.rest/OSGI-INF/account.rest.application.xml9
-rw-r--r--plugins/org.eclipse.osee.account.rest/REST-INF/.gitignore4
-rw-r--r--plugins/org.eclipse.osee.account.rest/REST-INF/application-doc.xml4
-rw-r--r--plugins/org.eclipse.osee.account.rest/REST-INF/application-grammars.xml4
-rw-r--r--plugins/org.eclipse.osee.account.rest/build.properties6
-rw-r--r--plugins/org.eclipse.osee.account.rest/pom.xml175
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java89
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountApplication.java44
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLoginResource.java55
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLogoutResource.java54
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java209
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java70
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java104
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java46
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java63
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestInfo.java22
-rw-r--r--plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestUtil.java59
-rw-r--r--plugins/org.eclipse.osee.x.core.parent/pom.xml4
52 files changed, 2967 insertions, 0 deletions
diff --git a/features/org.eclipse.osee.x.core.feature/feature.xml b/features/org.eclipse.osee.x.core.feature/feature.xml
index 1ecfc2220d0..893be749086 100644
--- a/features/org.eclipse.osee.x.core.feature/feature.xml
+++ b/features/org.eclipse.osee.x.core.feature/feature.xml
@@ -179,4 +179,18 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.account.rest"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.osee.account.rest.model"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/plugins/org.eclipse.osee.account.rest.model/.classpath b/plugins/org.eclipse.osee.account.rest.model/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/.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.account.rest.model/.project b/plugins/org.eclipse.osee.account.rest.model/.project
new file mode 100644
index 00000000000..ec36c4c7265
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.account.rest.model</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.account.rest.model/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..4a6f6b83233
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Account REST Model (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.account.rest.model
+Bundle-Version: 0.17.0.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.eclipse.osee.account.rest.model
+Import-Package: org.eclipse.osee.framework.jdk.core.type
diff --git a/plugins/org.eclipse.osee.account.rest.model/build.properties b/plugins/org.eclipse.osee.account.rest.model/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.account.rest.model/pom.xml b/plugins/org.eclipse.osee.account.rest.model/pom.xml
new file mode 100644
index 00000000000..2aee7bde9a0
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/pom.xml
@@ -0,0 +1,34 @@
+<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.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.core.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.account.rest.model</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>OSEE Account REST Model - (Incubation)</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountAccessData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountAccessData.java
new file mode 100644
index 00000000000..8d3198945d6
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountAccessData.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import java.util.Date;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountAccessData {
+
+ private long accountId;
+ private Date createdOn;
+ private Date lastAccessedOn;
+ private String accessedFrom;
+ private String accessDetails;
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ public Date getCreatedOn() {
+ return createdOn;
+ }
+
+ public void setCreatedOn(Date createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ public Date getLastAccessedOn() {
+ return lastAccessedOn;
+ }
+
+ public void setLastAccessedOn(Date lastAccessedOn) {
+ this.lastAccessedOn = lastAccessedOn;
+ }
+
+ public String getAccessedFrom() {
+ return accessedFrom;
+ }
+
+ public void setAccessedFrom(String accessedFrom) {
+ this.accessedFrom = accessedFrom;
+ }
+
+ public String getAccessDetails() {
+ return accessDetails;
+ }
+
+ public void setAccessDetails(String accessDetails) {
+ this.accessDetails = accessDetails;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java
new file mode 100644
index 00000000000..204744b0522
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountActiveData.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.jdk.core.type.Identity;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountActiveData implements Identity<String> {
+
+ private long accountId;
+ private boolean isActive;
+ private String uuid;
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ public boolean isActive() {
+ return isActive;
+ }
+
+ public void setActive(boolean isActive) {
+ this.isActive = isActive;
+ }
+
+ @Override
+ public String getGuid() {
+ return uuid;
+ }
+
+ public void setGuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public int hashCode() {
+ return getGuid().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof Identity) {
+ @SuppressWarnings("unchecked")
+ Identity<String> identity = (Identity<String>) obj;
+ if (getGuid() == identity.getGuid()) {
+ equal = true;
+ } else if (getGuid() != null) {
+ equal = getGuid().equals(identity.getGuid());
+ }
+ }
+ return equal;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(getGuid());
+ }
+
+ @Override
+ public boolean matches(Identity<?>... identities) {
+ for (Identity<?> identity : identities) {
+ if (equals(identity)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountContexts.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountContexts.java
new file mode 100644
index 00000000000..e97a0e31962
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountContexts.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class AccountContexts {
+
+ private AccountContexts() {
+ // Constants Class
+ }
+
+ public static final String ACCOUNTS_BASE = "oseex";
+ public static final String ACCOUNTS = "accounts";
+ public static final String ACCOUNT_PREFERENCES = "preferences";
+ public static final String ACCOUNT_ACTIVE = "active";
+
+ public static final String ACCOUNT_ID_PARAM = "account-id";
+ public static final String ACCOUNT_ID_TEMPLATE = "{" + ACCOUNT_ID_PARAM + "}";
+
+ public static final String ACCOUNT_USERNAME = "username";
+ public static final String ACCOUNT_USERNAME_TEMPLATE = "{" + ACCOUNT_USERNAME + "}";
+
+ public static final String ACCOUNT_LOGIN = "login";
+ public static final String ACCOUNT_SESSSIONS = "sessions";
+
+ public static final String ACCOUNT_LOGOUT = "logout";
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountDetailsData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountDetailsData.java
new file mode 100644
index 00000000000..814ed30021a
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountDetailsData.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountDetailsData extends AccountInfoData {
+
+ private AccountPreferencesData preferences;
+
+ public void setPreferences(AccountPreferencesData preferences) {
+ this.preferences = preferences;
+ }
+
+ public AccountPreferencesData getPreferences() {
+ if (preferences == null) {
+ preferences = new AccountPreferencesData();
+ }
+ return preferences;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java
new file mode 100644
index 00000000000..072b3688125
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInfoData.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.jdk.core.type.Identity;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountInfoData implements Identity<String> {
+
+ private String name;
+ private String userName;
+ private String email;
+ private String uuid;
+ private long accountId;
+ private boolean isActive;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ public boolean isActive() {
+ return isActive;
+ }
+
+ public void setActive(boolean isActive) {
+ this.isActive = isActive;
+ }
+
+ @Override
+ public String getGuid() {
+ return uuid;
+ }
+
+ public void setGuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public int hashCode() {
+ return getGuid().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof Identity) {
+ @SuppressWarnings("unchecked")
+ Identity<String> identity = (Identity<String>) obj;
+ if (getGuid() == identity.getGuid()) {
+ equal = true;
+ } else if (getGuid() != null) {
+ equal = getGuid().equals(identity.getGuid());
+ }
+ }
+ return equal;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(getGuid());
+ }
+
+ @Override
+ public boolean matches(Identity<?>... identities) {
+ for (Identity<?> identity : identities) {
+ if (equals(identity)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInput.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInput.java
new file mode 100644
index 00000000000..604df783997
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountInput.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountInput {
+
+ private String name;
+ private String email;
+ private boolean active;
+ private Map<String, String> preferences;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public Map<String, String> getPreferences() {
+ if (preferences == null) {
+ preferences = new HashMap<String, String>();
+ }
+ return preferences;
+ }
+
+ public void setPreferences(Map<String, String> preferences) {
+ this.preferences = preferences;
+ }
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountLoginData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountLoginData.java
new file mode 100644
index 00000000000..93d9bd5760a
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountLoginData.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountLoginData {
+
+ private String username;
+ private String password;
+ private String scheme;
+
+ public String getScheme() {
+ return scheme;
+ }
+
+ public void setScheme(String scheme) {
+ this.scheme = scheme;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java
new file mode 100644
index 00000000000..f8c4c5db943
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesData.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountPreferencesData {
+
+ private long id;
+ private Map<String, String> preferences;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Map<String, String> getMap() {
+ if (preferences == null) {
+ preferences = new HashMap<String, String>();
+ }
+ return preferences;
+ }
+
+ public void setMap(Map<String, String> preferences) {
+ this.preferences = preferences;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesInput.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesInput.java
new file mode 100644
index 00000000000..442cd5977b1
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountPreferencesInput.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountPreferencesInput {
+
+ private Map<String, String> preferences;
+
+ public Map<String, String> getMap() {
+ if (preferences == null) {
+ preferences = new HashMap<String, String>();
+ }
+ return preferences;
+ }
+
+ public void setMap(Map<String, String> preferences) {
+ this.preferences = preferences;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java
new file mode 100644
index 00000000000..43b63c8c90c
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.model/src/org/eclipse/osee/account/rest/model/AccountSessionData.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class AccountSessionData {
+
+ private long accountId;
+ private String token;
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (accountId ^ (accountId >>> 32));
+ result = prime * result + ((token == null) ? 0 : token.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AccountSessionData other = (AccountSessionData) obj;
+ if (accountId != other.accountId) {
+ return false;
+ }
+ if (token == null) {
+ if (other.token != null) {
+ return false;
+ }
+ } else if (!token.equals(other.token)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/.classpath b/plugins/org.eclipse.osee.account.rest.test/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/.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.account.rest.test/.project b/plugins/org.eclipse.osee.account.rest.test/.project
new file mode 100644
index 00000000000..c38c42559ea
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.account.rest.test</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.account.rest.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.rest.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..ac9e913b1ce
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Account REST API Test (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.account.rest.test
+Bundle-Version: 0.17.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Fragment-Host: org.eclipse.osee.account.rest;bundle-version="0.17.0"
+Import-Package: com.sun.ws.rs.ext,
+ org.apache.commons.lang.math,
+ org.hamcrest.core,
+ org.junit,
+ org.junit.rules,
+ org.junit.runner,
+ org.junit.runners,
+ org.junit.runners.model,
+ org.mockito,
+ org.mockito.stubbing
diff --git a/plugins/org.eclipse.osee.account.rest.test/build.properties b/plugins/org.eclipse.osee.account.rest.test/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.account.rest.test/pom.xml b/plugins/org.eclipse.osee.account.rest.test/pom.xml
new file mode 100644
index 00000000000..83ea40e454e
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/pom.xml
@@ -0,0 +1,32 @@
+<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.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.core.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.account.rest.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>OSEE Account REST API Test (Incubation)</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <testSuite>org.eclipse.osee.account.rest.test</testSuite>
+ <testClass>org.eclipse.osee.account.rest.AccountRestTestSuite</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/AccountRestTestSuite.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/AccountRestTestSuite.java
new file mode 100644
index 00000000000..130443febff
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/AccountRestTestSuite.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest;
+
+import org.eclipse.osee.account.rest.internal.AccountInternalTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({AccountInternalTestSuite.class})
+public class AccountRestTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java
new file mode 100644
index 00000000000..0aabcf535e6
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountActiveResourceTest.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.eclipse.osee.account.rest.model.AccountActiveData;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AccountActiveResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountActiveResourceTest {
+
+ //@formatter:off
+ @Mock private AccountOps ops;
+ @Mock private AccountActiveData activeData;
+ //@formatter:on
+
+ private String accountId;
+ private AccountActiveResource resource;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+
+ resource = new AccountActiveResource(ops, accountId);
+ }
+
+ @Test
+ public void testIsActive() {
+ when(ops.isActive(accountId)).thenReturn(activeData);
+
+ AccountActiveData actual = resource.isActive();
+ assertEquals(activeData, actual);
+
+ verify(ops).isActive(accountId);
+ }
+
+ @Test
+ public void testSetActiveOk() {
+ when(ops.setAccountActive(accountId, true)).thenReturn(true);
+
+ Response response = resource.setActive();
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ verify(ops).setAccountActive(accountId, true);
+ }
+
+ @Test
+ public void testSetActiveNotModified() {
+ when(ops.setAccountActive(accountId, true)).thenReturn(false);
+
+ Response response = resource.setActive();
+ assertEquals(Status.NOT_MODIFIED.getStatusCode(), response.getStatus());
+
+ verify(ops).setAccountActive(accountId, true);
+ }
+
+ @Test
+ public void testSetInactiveOk() {
+ when(ops.setAccountActive(accountId, false)).thenReturn(true);
+
+ Response response = resource.setInactive();
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ verify(ops).setAccountActive(accountId, false);
+ }
+
+ @Test
+ public void testSetInactiveMotModified() {
+ when(ops.setAccountActive(accountId, false)).thenReturn(false);
+
+ Response response = resource.setInactive();
+ assertEquals(Status.NOT_MODIFIED.getStatusCode(), response.getStatus());
+
+ verify(ops).setAccountActive(accountId, false);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountInternalTestSuite.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountInternalTestSuite.java
new file mode 100644
index 00000000000..1a9dd21f22c
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountInternalTestSuite.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AccountActiveResourceTest.class,
+ AccountLoginResourceTest.class,
+ AccountLogoutResourceTest.class,
+ AccountOpsTest.class,
+ AccountPreferencesResourceTest.class,
+ AccountResourceTest.class,
+ AccountSessionsResourceTest.class,
+ AccountsResourceTest.class})
+public class AccountInternalTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLoginResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLoginResourceTest.java
new file mode 100644
index 00000000000..cf85cbe3974
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLoginResourceTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.net.URI;
+import java.net.URISyntaxException;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.account.rest.model.AccountLoginData;
+import org.eclipse.osee.account.rest.model.AccountSessionData;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link AccountLoginResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountLoginResourceTest {
+
+ private static final long ACCOUNT_ID = 123413241244L;
+ private static final String ACCOUNT_BASE = "accounts";
+
+ //@formatter:off
+ @Mock private AccountOps ops;
+ @Mock private HttpServletRequest request;
+ @Mock private UriInfo uriInfo;
+ @Mock private AccountLoginData data;
+ @Mock private RequestInfo reqInfo;
+ @Mock private AccountSessionData session;
+ @Captor private ArgumentCaptor<RequestInfo> reqInfoCaptor;
+ //@formatter:on
+
+ private AccountLoginResource resource;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ resource = new AccountLoginResource(ops);
+ }
+
+ @Test
+ public void testLogin() throws URISyntaxException {
+ when(session.getAccountId()).thenReturn(ACCOUNT_ID);
+
+ when(ops.asRequestInfo(request)).thenReturn(reqInfo);
+ when(ops.doLogin(any(RequestInfo.class), eq(data))).thenReturn(session);
+ when(uriInfo.getBaseUri()).thenReturn(new URI(ACCOUNT_BASE));
+
+ Response response = resource.login(request, uriInfo, data);
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ AccountSessionData actual = (AccountSessionData) response.getEntity();
+ assertEquals(session, actual);
+
+ URI location = (URI) response.getMetadata().getFirst(HttpHeaders.CONTENT_LOCATION);
+ assertNotNull(location);
+ assertEquals(ACCOUNT_BASE + "/" + ACCOUNT_ID, location.toASCIIString());
+
+ verify(ops).asRequestInfo(request);
+ verify(ops).doLogin(reqInfoCaptor.capture(), eq(data));
+ verify(uriInfo).getBaseUri();
+
+ assertEquals(reqInfo, reqInfoCaptor.getValue());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLogoutResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLogoutResourceTest.java
new file mode 100644
index 00000000000..4bb455adb2c
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountLogoutResourceTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.eclipse.osee.account.rest.model.AccountSessionData;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link AccountLogoutResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountLogoutResourceTest {
+
+ //@formatter:off
+ @Mock private AccountOps ops;
+
+ @Mock private AccountSessionData session;
+ //@formatter:on
+
+ private AccountLogoutResource resource;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ resource = new AccountLogoutResource(ops);
+ }
+
+ @Test
+ public void testLogout() {
+ String token = "dsfksa-kfsauiewa";
+
+ when(session.getToken()).thenReturn(token);
+ when(ops.doLogout(token)).thenReturn(true);
+
+ Response response = resource.logout(session);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ verify(ops).doLogout(token);
+ }
+
+ @Test
+ public void testLogoutNotModified() {
+ String token = "dsfksa-kfsauiewa";
+
+ when(session.getToken()).thenReturn(token);
+ when(ops.doLogout(token)).thenReturn(false);
+
+ Response response = resource.logout(session);
+
+ assertEquals(Status.NOT_MODIFIED.getStatusCode(), response.getStatus());
+ verify(ops).doLogout(token);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java
new file mode 100644
index 00000000000..ed3df9a333f
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountOpsTest.java
@@ -0,0 +1,436 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.HttpHeaders;
+import org.apache.commons.lang.math.RandomUtils;
+import org.eclipse.osee.account.admin.AccessDetails;
+import org.eclipse.osee.account.admin.Account;
+import org.eclipse.osee.account.admin.AccountAccess;
+import org.eclipse.osee.account.admin.AccountAdmin;
+import org.eclipse.osee.account.admin.AccountLoginRequest;
+import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.account.admin.CreateAccountRequest;
+import org.eclipse.osee.account.rest.model.AccountAccessData;
+import org.eclipse.osee.account.rest.model.AccountActiveData;
+import org.eclipse.osee.account.rest.model.AccountDetailsData;
+import org.eclipse.osee.account.rest.model.AccountInfoData;
+import org.eclipse.osee.account.rest.model.AccountInput;
+import org.eclipse.osee.account.rest.model.AccountLoginData;
+import org.eclipse.osee.account.rest.model.AccountPreferencesData;
+import org.eclipse.osee.account.rest.model.AccountPreferencesInput;
+import org.eclipse.osee.account.rest.model.AccountSessionData;
+import org.eclipse.osee.framework.jdk.core.type.Identifiable;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.framework.jdk.core.type.ResultSets;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link AccountOps}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountOpsTest {
+
+ private static final String ACCOUNT_UID = "hello@hello.com";
+
+ //@formatter:off
+ @Mock private AccountAdmin accountAdmin;
+ //@formatter:on
+
+ private AccountOps ops;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ ops = new AccountOps(accountAdmin);
+ }
+
+ @Test
+ public void testCreateAccount() {
+ String guid = GUID.create();
+ String username = "aUser";
+
+ String email = "hello@hello.com";
+ String name = "myName";
+ boolean active = true;
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("a", "1");
+ map.put("b", "2");
+ map.put("c", "3");
+
+ AccountInput input = mock(AccountInput.class);
+ when(input.getEmail()).thenReturn(email);
+ when(input.getName()).thenReturn(name);
+ when(input.isActive()).thenReturn(active);
+ when(input.getPreferences()).thenReturn(map);
+
+ ArgumentCaptor<CreateAccountRequest> captor = ArgumentCaptor.forClass(CreateAccountRequest.class);
+
+ @SuppressWarnings("unchecked")
+ Identifiable<String> id = mock(Identifiable.class);
+ when(id.getGuid()).thenReturn(guid);
+
+ when(accountAdmin.createAccount(any(CreateAccountRequest.class))).thenReturn(id);
+
+ long accountId = 1982671L;
+ Account account = mockAccount(accountId, guid, name, email, username, active);
+ ResultSet<Account> result = ResultSets.singleton(account);
+ when(accountAdmin.getAccountByUuid(guid)).thenReturn(result);
+
+ AccountInfoData actual = ops.createAccount(username, input);
+
+ verify(accountAdmin).createAccount(captor.capture());
+ CreateAccountRequest request = captor.getValue();
+ assertNotNull(request);
+ assertAccount(actual, accountId, guid, name, email, username, active);
+ assertEquals(name, request.getDisplayName());
+ assertEquals(email, request.getEmail());
+ assertEquals(username, request.getUserName());
+ assertEquals(active, request.isActive());
+ assertEquals(map, request.getPreferences());
+ }
+
+ @Test
+ public void testDoLogin() {
+ String ipAddress = "192.168.100.199";
+ String userAgent = "my agent";
+
+ String scheme = "myscheme";
+ String username = "myuser";
+ String password = "mypass";
+
+ RequestInfo reqInfo = mock(RequestInfo.class);
+ when(reqInfo.getDetails()).thenReturn(userAgent);
+ when(reqInfo.getRemoteIpAddress()).thenReturn(ipAddress);
+
+ AccountLoginData login = mock(AccountLoginData.class);
+ when(login.getScheme()).thenReturn(scheme);
+ when(login.getUsername()).thenReturn(username);
+ when(login.getPassword()).thenReturn(password);
+
+ Date d1 = newRandomDate();
+ Date d2 = newRandomDate();
+ AccountAccess access = mockAccess(789L, "t3", d1, d2, ipAddress, userAgent);
+ ArgumentCaptor<AccountLoginRequest> captor = ArgumentCaptor.forClass(AccountLoginRequest.class);
+
+ when(accountAdmin.login(any(AccountLoginRequest.class))).thenReturn(access);
+
+ AccountSessionData actual = ops.doLogin(reqInfo, login);
+
+ verify(accountAdmin).login(captor.capture());
+ AccountLoginRequest request = captor.getValue();
+ AccessDetails details = request.getDetails();
+ assertNotNull(details);
+ assertEquals(789L, actual.getAccountId());
+ assertEquals("t3", actual.getToken());
+
+ assertEquals(scheme, request.getScheme());
+ assertEquals(username, request.getUserName());
+ assertEquals(password, request.getPassword());
+
+ assertEquals(userAgent, details.getAccessDetails());
+ assertEquals(ipAddress, details.getRemoteAddress());
+ }
+
+ @Test
+ public void testDoLogout() {
+ String token = "asdasa";
+
+ when(accountAdmin.logout(token)).thenReturn(true);
+
+ boolean actual = ops.doLogout(token);
+
+ assertEquals(true, actual);
+ verify(accountAdmin).logout(token);
+ }
+
+ @Test
+ public void testDeleteAccount() {
+ when(accountAdmin.deleteAccount(ACCOUNT_UID)).thenReturn(true);
+
+ boolean actual = ops.deleteAccount(ACCOUNT_UID);
+
+ assertEquals(true, actual);
+ verify(accountAdmin).deleteAccount(ACCOUNT_UID);
+ }
+
+ @Test
+ public void testAsRequestInfo() {
+ String ipAddress = "192.168.100.199";
+ String userAgent = "my agent";
+
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ when(request.getHeader(HttpHeaders.USER_AGENT)).thenReturn(userAgent);
+ when(request.getHeader("HTTP_X_FORWARDED_FOR")).thenReturn(ipAddress);
+
+ RequestInfo actual = ops.asRequestInfo(request);
+
+ assertEquals(userAgent, actual.getDetails());
+ assertEquals(ipAddress, actual.getRemoteIpAddress());
+ }
+
+ @Test
+ public void testAsAccountAccessData() {
+ Date d1 = newRandomDate();
+ Date d2 = newRandomDate();
+
+ AccountAccess access = mockAccess(789L, "t3", d1, d2, "f3", "d3");
+
+ AccountAccessData actual = ops.asAccountAccessData(access);
+
+ assertAccess(actual, 789L, d1, d2, "f3", "d3");
+ }
+
+ @Test
+ public void testAsSessionData() {
+ Date d1 = newRandomDate();
+ Date d2 = newRandomDate();
+ AccountAccess access = mockAccess(123L, "t1", d1, d2, "f1", "d1");
+
+ AccountSessionData actual = ops.asSessionData(access);
+
+ assertEquals(123L, actual.getAccountId());
+ assertEquals("t1", actual.getToken());
+ }
+
+ @Test
+ public void testGetAccountAccessById() {
+ Date d1 = newRandomDate();
+ Date d2 = newRandomDate();
+ Date d3 = newRandomDate();
+ Date d4 = newRandomDate();
+ Date d5 = newRandomDate();
+ Date d6 = newRandomDate();
+
+ AccountAccess access1 = mockAccess(123L, "t1", d1, d2, "f1", "d1");
+ AccountAccess access2 = mockAccess(456L, "t2", d3, d4, "f2", "d2");
+ AccountAccess access3 = mockAccess(789L, "t3", d5, d6, "f3", "d3");
+
+ ResultSet<AccountAccess> result = ResultSets.newResultSet(access1, access2, access3);
+ when(accountAdmin.getAccountAccessByUniqueField(ACCOUNT_UID)).thenReturn(result);
+
+ List<AccountAccessData> actual = ops.getAccountAccessById(ACCOUNT_UID);
+
+ assertEquals(3, actual.size());
+ Iterator<AccountAccessData> iterator = actual.iterator();
+ assertAccess(iterator.next(), 123L, d1, d2, "f1", "d1");
+ assertAccess(iterator.next(), 456L, d3, d4, "f2", "d2");
+ assertAccess(iterator.next(), 789L, d5, d6, "f3", "d3");
+
+ verify(accountAdmin).getAccountAccessByUniqueField(ACCOUNT_UID);
+ }
+
+ @Test
+ public void testGetAccountData() {
+ Account account = mockAccount(456L, "DEF", "acc2", "acc2@email.com", "u2", true);
+ ResultSet<Account> accounts = ResultSets.singleton(account);
+ when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(accounts);
+
+ AccountInfoData actual = ops.getAccountData(ACCOUNT_UID);
+
+ assertAccount(actual, 456L, "DEF", "acc2", "acc2@email.com", "u2", true);
+ verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID);
+ }
+
+ @Test
+ public void testGetAccountDetailsData() {
+ Account account = mockAccount(789L, "GHI", "acc3", "acc3@email.com", "u3", true);
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("a", "1");
+ map.put("b", "2");
+ map.put("c", "3");
+
+ AccountPreferences preferences = mock(AccountPreferences.class);
+ when(preferences.asMap()).thenReturn(map);
+ when(preferences.getId()).thenReturn(789L);
+ when(account.getPreferences()).thenReturn(preferences);
+
+ ResultSet<Account> accounts = ResultSets.singleton(account);
+ when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(accounts);
+
+ AccountDetailsData actual = ops.getAccountDetailsData(ACCOUNT_UID);
+
+ assertAccount(actual, 789L, "GHI", "acc3", "acc3@email.com", "u3", true);
+ AccountPreferencesData actualPrefs = actual.getPreferences();
+ Map<String, String> actualMap = actualPrefs.getMap();
+
+ assertEquals(789L, actualPrefs.getId());
+ assertEquals(3, actualMap.size());
+ assertEquals("1", actualMap.get("a"));
+ assertEquals("2", actualMap.get("b"));
+ assertEquals("3", actualMap.get("c"));
+
+ verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID);
+ }
+
+ @Test
+ public void testGetAccountPreferencesData() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("a", "1");
+ map.put("b", "2");
+ map.put("c", "3");
+
+ AccountPreferences preferences = mock(AccountPreferences.class);
+ when(preferences.asMap()).thenReturn(map);
+ when(preferences.getId()).thenReturn(123L);
+
+ Account account = mock(Account.class);
+ when(account.getPreferences()).thenReturn(preferences);
+
+ ResultSet<Account> accounts = ResultSets.singleton(account);
+ when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(accounts);
+
+ AccountPreferencesData actual = ops.getAccountPreferencesData(ACCOUNT_UID);
+ assertEquals(123L, actual.getId());
+
+ Map<String, String> actualPrefs = actual.getMap();
+ assertEquals(3, actualPrefs.size());
+ assertEquals("1", actualPrefs.get("a"));
+ assertEquals("2", actualPrefs.get("b"));
+ assertEquals("3", actualPrefs.get("c"));
+
+ verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID);
+ }
+
+ @Test
+ public void testGetAllAccounts() {
+ Account account1 = mockAccount(123L, "ABC", "acc1", "acc1@email.com", "u1", true);
+ Account account2 = mockAccount(456L, "DEF", "acc2", "acc2@email.com", "u2", false);
+ Account account3 = mockAccount(789L, "GHI", "acc3", "acc3@email.com", "u3", true);
+
+ ResultSet<Account> accounts = ResultSets.newResultSet(account1, account2, account3);
+
+ when(accountAdmin.getAllAccounts()).thenReturn(accounts);
+
+ List<AccountInfoData> actual = ops.getAllAccounts();
+
+ assertEquals(3, actual.size());
+ Iterator<AccountInfoData> iterator = actual.iterator();
+
+ assertAccount(iterator.next(), 123L, "ABC", "acc1", "acc1@email.com", "u1", true);
+ assertAccount(iterator.next(), 456L, "DEF", "acc2", "acc2@email.com", "u2", false);
+ assertAccount(iterator.next(), 789L, "GHI", "acc3", "acc3@email.com", "u3", true);
+
+ verify(accountAdmin).getAllAccounts();
+ }
+
+ @Test
+ public void testIsActive() {
+ String guid = GUID.create();
+ long accountId = 23127916023214L;
+
+ Account account = mock(Account.class);
+ ResultSet<Account> result = ResultSets.singleton(account);
+
+ when(account.getGuid()).thenReturn(guid);
+ when(account.getId()).thenReturn(accountId);
+ when(account.isActive()).thenReturn(true);
+ when(accountAdmin.getAccountByUniqueField(ACCOUNT_UID)).thenReturn(result);
+
+ AccountActiveData actual = ops.isActive(ACCOUNT_UID);
+
+ assertEquals(accountId, actual.getAccountId());
+ assertEquals(guid, actual.getGuid());
+ assertEquals(true, actual.isActive());
+ verify(accountAdmin).getAccountByUniqueField(ACCOUNT_UID);
+ }
+
+ @Test
+ public void testSetAccountActive() {
+ when(accountAdmin.setActive(ACCOUNT_UID, true)).thenReturn(true);
+
+ boolean actual = ops.setAccountActive(ACCOUNT_UID, true);
+
+ assertEquals(true, actual);
+ verify(accountAdmin).setActive(ACCOUNT_UID, true);
+ }
+
+ @Test
+ public void testSetAccountPreferences() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("a", "1");
+ map.put("b", "2");
+ map.put("c", "3");
+
+ AccountPreferencesInput input = mock(AccountPreferencesInput.class);
+ when(input.getMap()).thenReturn(map);
+ when(accountAdmin.setAccountPreferences(ACCOUNT_UID, map)).thenReturn(true);
+
+ boolean actual = ops.setAccountPreferences(ACCOUNT_UID, input);
+
+ assertEquals(true, actual);
+ verify(accountAdmin).setAccountPreferences(ACCOUNT_UID, map);
+ }
+
+ private static Date newRandomDate() {
+ return new Date(Math.abs(System.currentTimeMillis() - RandomUtils.nextLong()));
+ }
+
+ private static AccountAccess mockAccess(long id, String token, Date created, Date accessed, String accessFrom, String accessDetails) {
+ AccountAccess access = Mockito.mock(AccountAccess.class);
+ when(access.getAccountId()).thenReturn(id);
+ when(access.getAccessToken()).thenReturn(token);
+ when(access.getCreatedOn()).thenReturn(created);
+ when(access.getLastAccessedOn()).thenReturn(accessed);
+ when(access.getAccessedFrom()).thenReturn(accessFrom);
+ when(access.getAccessDetails()).thenReturn(accessDetails);
+ return access;
+ }
+
+ private static void assertAccess(AccountAccessData actual, long id, Date created, Date accessed, String accessFrom, String accessDetails) {
+ assertEquals(accessDetails, actual.getAccessDetails());
+ assertEquals(accessFrom, actual.getAccessedFrom());
+ assertEquals(id, actual.getAccountId());
+ assertEquals(created, actual.getCreatedOn());
+ assertEquals(accessed, actual.getLastAccessedOn());
+ }
+
+ private static Account mockAccount(long id, String uuid, String name, String email, String username, boolean active) {
+ Account account = Mockito.mock(Account.class);
+ when(account.getId()).thenReturn(id);
+ when(account.getGuid()).thenReturn(uuid);
+ when(account.getName()).thenReturn(name);
+ when(account.getEmail()).thenReturn(email);
+ when(account.getUserName()).thenReturn(username);
+ when(account.isActive()).thenReturn(active);
+ return account;
+ }
+
+ private static void assertAccount(AccountInfoData data, long id, String uuid, String name, String email, String username, boolean active) {
+ assertEquals(id, data.getAccountId());
+ assertEquals(uuid, data.getGuid());
+ assertEquals(name, data.getName());
+ assertEquals(email, data.getEmail());
+ assertEquals(username, data.getUserName());
+ assertEquals(active, data.isActive());
+ }
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java
new file mode 100644
index 00000000000..3e1a7431fcd
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResourceTest.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.eclipse.osee.account.rest.model.AccountPreferencesData;
+import org.eclipse.osee.account.rest.model.AccountPreferencesInput;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AccountPreferencesResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountPreferencesResourceTest {
+
+ private static final String ACCOUNT_ID = "hello@hello.com";
+
+ //@formatter:off
+ @Mock private AccountOps accountOps;
+ @Mock private AccountPreferencesData preferences;
+ @Mock private AccountPreferencesInput input;
+ //@formatter:on
+
+ private AccountPreferencesResource resource;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+
+ resource = new AccountPreferencesResource(accountOps, ACCOUNT_ID);
+ }
+
+ @Test
+ public void testGetAccountPreferences() {
+ when(accountOps.getAccountPreferencesData(ACCOUNT_ID)).thenReturn(preferences);
+
+ AccountPreferencesData actual = resource.getAccountPreferences();
+
+ assertEquals(preferences, actual);
+ verify(accountOps).getAccountPreferencesData(ACCOUNT_ID);
+ }
+
+ @Test
+ public void testSetAccountPreferences() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("a", "1");
+ map.put("b", "2");
+ map.put("c", "3");
+
+ when(input.getMap()).thenReturn(map);
+ when(accountOps.setAccountPreferences(ACCOUNT_ID, input)).thenReturn(true);
+
+ Response actual = resource.setAccountPreferences(input);
+
+ assertEquals(Status.OK.getStatusCode(), actual.getStatus());
+ verify(accountOps).setAccountPreferences(ACCOUNT_ID, input);
+ }
+
+ @Test
+ public void testSetAccountPreferencesNotModified() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("a", "1");
+ map.put("b", "2");
+ map.put("c", "3");
+
+ when(input.getMap()).thenReturn(map);
+ when(accountOps.setAccountPreferences(ACCOUNT_ID, input)).thenReturn(false);
+
+ Response actual = resource.setAccountPreferences(input);
+
+ assertEquals(Status.NOT_MODIFIED.getStatusCode(), actual.getStatus());
+ verify(accountOps).setAccountPreferences(ACCOUNT_ID, input);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java
new file mode 100644
index 00000000000..19cf47bfe43
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountResourceTest.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.eclipse.osee.account.rest.model.AccountDetailsData;
+import org.eclipse.osee.account.rest.model.AccountInfoData;
+import org.eclipse.osee.account.rest.model.AccountInput;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AccountResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountResourceTest {
+
+ private static final String ACCOUNT_ID = "hello@hello.com";
+
+ //@formatter:off
+ @Mock private AccountOps accountOps;
+
+ @Mock private AccountInput accountInput;
+ @Mock private AccountInfoData accountInfoData;
+ @Mock private AccountDetailsData details;
+ //@formatter:on
+
+ private AccountResource resource;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+
+ resource = new AccountResource(accountOps, ACCOUNT_ID);
+ }
+
+ @Test
+ public void testCreateAccount() {
+ when(accountOps.createAccount(ACCOUNT_ID, accountInput)).thenReturn(accountInfoData);
+
+ AccountInfoData actual = resource.createAccount(accountInput);
+ assertEquals(accountInfoData, actual);
+
+ verify(accountOps).createAccount(ACCOUNT_ID, accountInput);
+ }
+
+ @Test
+ public void testDeleteAccount() {
+ when(accountOps.deleteAccount(ACCOUNT_ID)).thenReturn(true);
+
+ Response actual = resource.deleteAccount();
+ assertEquals(Status.OK.getStatusCode(), actual.getStatus());
+
+ verify(accountOps).deleteAccount(ACCOUNT_ID);
+ }
+
+ @Test
+ public void testDeleteAccountNotModified() {
+ when(accountOps.deleteAccount(ACCOUNT_ID)).thenReturn(false);
+
+ Response actual = resource.deleteAccount();
+ assertEquals(Status.NOT_MODIFIED.getStatusCode(), actual.getStatus());
+
+ verify(accountOps).deleteAccount(ACCOUNT_ID);
+ }
+
+ @Test
+ public void testGetAccountDetailsData() {
+ when(accountOps.getAccountDetailsData(ACCOUNT_ID)).thenReturn(details);
+
+ AccountDetailsData actual = resource.getAccountDetailsData();
+ assertEquals(details, actual);
+
+ verify(accountOps).getAccountDetailsData(ACCOUNT_ID);
+ }
+
+ @Test
+ public void testAccountSettingsData() {
+ AccountPreferencesResource actual = resource.getAccountSettingsData();
+ assertNotNull(actual);
+
+ // Ensure resource constructed correctly;
+ actual.getAccountPreferences();
+ verify(accountOps).getAccountPreferencesData(ACCOUNT_ID);
+ }
+
+ @Test
+ public void testActive() {
+ AccountActiveResource actual = resource.active();
+ assertNotNull(actual);
+
+ // Ensure resource constructed correctly;
+ actual.isActive();
+ verify(accountOps).isActive(ACCOUNT_ID);
+ }
+
+ @Test
+ public void testGetSessions() {
+ AccountSessionsResource actual = resource.sessions();
+ assertNotNull(actual);
+
+ // Ensure resource constructed correctly;
+ actual.getAccountSessions();
+ verify(accountOps).getAccountAccessById(ACCOUNT_ID);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java
new file mode 100644
index 00000000000..35706f8c6af
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountSessionsResourceTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.account.rest.model.AccountAccessData;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AccountSessionsResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountSessionsResourceTest {
+
+ private static final String ACCOUNT_ID = "hello@hello.com";
+
+ //@formatter:off
+ @Mock private AccountOps accountOps;
+ //@formatter:on
+
+ private AccountSessionsResource resource;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+
+ resource = new AccountSessionsResource(accountOps, ACCOUNT_ID);
+ }
+
+ @Test
+ public void testGetAccountSessions() {
+ List<AccountAccessData> accesses = new ArrayList<AccountAccessData>();
+ when(accountOps.getAccountAccessById(ACCOUNT_ID)).thenReturn(accesses);
+
+ List<AccountAccessData> actual = resource.getAccountSessions();
+
+ assertEquals(accesses, actual);
+ verify(accountOps).getAccountAccessById(ACCOUNT_ID);
+ }
+}
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java
new file mode 100644
index 00000000000..488c9752a2f
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/AccountsResourceTest.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.account.rest.model.AccountInfoData;
+import org.eclipse.osee.account.rest.model.AccountInput;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+
+/**
+ * Test Case for {@link AccountsResource}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AccountsResourceTest {
+
+ private static final String ACCOUNT_ID = "hello@hello.com";
+
+ //@formatter:off
+ @Mock private AccountOps accountOps;
+
+ @Mock private AccountInfoData account;
+ @Mock private AccountInput input;
+ //@formatter:on
+
+ private AccountsResource resource;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+
+ resource = new AccountsResource(accountOps);
+ }
+
+ @Test
+ public void testGetAccounts() {
+ List<AccountInfoData> accesses = new ArrayList<AccountInfoData>();
+ when(accountOps.getAllAccounts()).thenReturn(accesses);
+
+ List<AccountInfoData> actual = resource.getAccounts();
+
+ assertEquals(accesses, actual);
+ verify(accountOps).getAllAccounts();
+ }
+
+ @Test
+ public void testGetAccount() {
+ AccountResource actual = resource.getAccount(ACCOUNT_ID);
+ assertNotNull(actual);
+
+ // Ensure resource constructed correctly;
+ actual.createAccount(input);
+ verify(accountOps).createAccount(ACCOUNT_ID, input);
+ }
+
+ @Test
+ public void testGetLoginResource() {
+ AccountLoginResource actual = resource.getLoginResource();
+ assertNotNull(actual);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/.classpath b/plugins/org.eclipse.osee.account.rest/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/.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.account.rest/.project b/plugins/org.eclipse.osee.account.rest/.project
new file mode 100644
index 00000000000..1129656acf3
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.account.rest</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.account.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..55880e547aa
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Accounts REST API (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.account.rest
+Bundle-Version: 0.17.0.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Service-Component: OSGI-INF/*.xml
+Import-Package: javax.annotation.security,
+ javax.servlet,
+ javax.servlet.http,
+ javax.ws.rs,
+ javax.ws.rs.core,
+ javax.ws.rs.ext,
+ org.eclipse.osee.account.admin,
+ org.eclipse.osee.account.rest.model,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.osee.account.rest/OSGI-INF/account.rest.application.xml b/plugins/org.eclipse.osee.account.rest/OSGI-INF/account.rest.application.xml
new file mode 100644
index 00000000000..31c6fbfd648
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/OSGI-INF/account.rest.application.xml
@@ -0,0 +1,9 @@
+<?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.account.rest.internal.AccountApplication"/>
+ <service>
+ <provide interface="javax.ws.rs.core.Application"/>
+ </service>
+ <property name="context.name" type="String" value="oseex"/>
+ <reference bind="setAccountAdmin" cardinality="1..1" interface="org.eclipse.osee.account.admin.AccountAdmin" name="AccountAdmin" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.account.rest/REST-INF/.gitignore b/plugins/org.eclipse.osee.account.rest/REST-INF/.gitignore
new file mode 100644
index 00000000000..1c748845156
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/REST-INF/.gitignore
@@ -0,0 +1,4 @@
+/doc
+/application.wadl
+/resourcedoc.xml
+/xsd0.xsd
diff --git a/plugins/org.eclipse.osee.account.rest/REST-INF/application-doc.xml b/plugins/org.eclipse.osee.account.rest/REST-INF/application-doc.xml
new file mode 100644
index 00000000000..d0490a93579
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/REST-INF/application-doc.xml
@@ -0,0 +1,4 @@
+<applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02">
+ <doc xml:lang="en" title="Account Management API">
+ </doc>
+</applicationDocs> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.account.rest/REST-INF/application-grammars.xml b/plugins/org.eclipse.osee.account.rest/REST-INF/application-grammars.xml
new file mode 100644
index 00000000000..aa0a1295583
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/REST-INF/application-grammars.xml
@@ -0,0 +1,4 @@
+<grammars xmlns="http://wadl.dev.java.net/2009/02" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xi="http://www.w3.org/1999/XML/xinclude">
+ <include href="xsd0.xsd" />
+</grammars> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.account.rest/build.properties b/plugins/org.eclipse.osee.account.rest/build.properties
new file mode 100644
index 00000000000..e7543d13f58
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/build.properties
@@ -0,0 +1,6 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ REST-INF/
+source.. = src/
diff --git a/plugins/org.eclipse.osee.account.rest/pom.xml b/plugins/org.eclipse.osee.account.rest/pom.xml
new file mode 100644
index 00000000000..7d701996564
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/pom.xml
@@ -0,0 +1,175 @@
+<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.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.core.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.account.rest</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>OSEE Account REST API - (Incubation)</name>
+
+ <build>
+ <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
+ <resources>
+ <resource>
+ <directory>src</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>${maven-clean-version}</version>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>REST-INF</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>application-doc.xml</exclude>
+ <exclude>application-grammars.xml</exclude>
+ <exclude>.gitignore</exclude>
+ </excludes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc-version}</version>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>resource-doc-accounts</id>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ <phase>compile</phase>
+ <configuration>
+ <debug>false</debug>
+ <encoding>UTF-8</encoding>
+ <verbose>false</verbose>
+ <show>public</show>
+ <sourcepath>${basedir}/src:${basedir}/../org.eclipse.osee.account.rest.model/src</sourcepath>
+ <subpackages>org.eclipse.osee.account.rest.internal:org.eclipse.osee.account.rest.model</subpackages>
+ <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
+ <docletArtifacts>
+ <docletArtifact>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>wadl-resourcedoc-doclet</artifactId>
+ <version>${jersey-wadlgen-version}</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>${jersey-version}</version>
+ </docletArtifact>
+ <docletArtifact>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>${xerces-version}</version>
+ </docletArtifact>
+ </docletArtifacts>
+ <additionalparam>-output
+ ${rest-output-directory}/resourcedoc.xml</additionalparam>
+ <useStandardDocletOptions>false</useStandardDocletOptions>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jaxb-report-orcs</id>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ <phase>compile</phase>
+ <configuration>
+ <inherited>false</inherited>
+ <debug>false</debug>
+ <verbose>false</verbose>
+ <name>JAXB Report</name>
+ <description>All the JAXB models</description>
+ <sourcepath>${basedir}/../org.eclipse.osee.account.rest.model/src</sourcepath>
+ <subpackages>org.eclipse.osee.account.rest.model</subpackages>
+ <reportOutputDirectory>${rest-output-directory}</reportOutputDirectory>
+ <destDir>doc/models</destDir>
+ <doclet>com.lunatech.doclets.jax.jaxb.JAXBDoclet</doclet>
+ <docletArtifacts>
+ <docletArtifact>
+ <groupId>com.lunatech.jax-doclets</groupId>
+ <artifactId>doclets</artifactId>
+ <version>${jaxdoclet-version}</version>
+ </docletArtifact>
+ </docletArtifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>maven-wadl-plugin</artifactId>
+ <version>${jersey-wadlgen-version}</version>
+ <executions>
+ <execution>
+ <id>generate</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <wadlFile>${rest-output-directory}/application.wadl</wadlFile>
+ <formatWadlFile>true</formatWadlFile>
+ <baseUri>oseex</baseUri>
+ <packagesResourceConfig>
+ <param>org.eclipse.osee.account.rest.internal</param>
+ <param>org.eclipse.osee.account.rest.model</param>
+ </packagesResourceConfig>
+ <wadlGenerators>
+ <wadlGeneratorDescription>
+ <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc</className>
+ <properties>
+ <property>
+ <name>applicationDocsFile</name>
+ <value>${rest-output-directory}/application-doc.xml</value>
+ </property>
+ </properties>
+ </wadlGeneratorDescription>
+ <wadlGeneratorDescription>
+ <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport</className>
+ <properties>
+ <property>
+ <name>grammarsFile</name>
+ <value>${rest-output-directory}/application-grammars.xml</value>
+ </property>
+ </properties>
+ </wadlGeneratorDescription>
+ <wadlGeneratorDescription>
+ <className>com.sun.jersey.server.wadl.generators.resourcedoc.WadlGeneratorResourceDocSupport</className>
+ <properties>
+ <property>
+ <name>resourceDocFile</name>
+ <value>${rest-output-directory}/resourcedoc.xml</value>
+ </property>
+ </properties>
+ </wadlGeneratorDescription>
+ </wadlGenerators>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java
new file mode 100644
index 00000000000..36370162bae
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountActiveResource.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.eclipse.osee.account.admin.SystemRoles;
+import org.eclipse.osee.account.rest.model.AccountActiveData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountActiveResource {
+
+ private final AccountOps accountOps;
+ private final String accountId;
+
+ public AccountActiveResource(AccountOps accountOps, String accountId) {
+ this.accountOps = accountOps;
+ this.accountId = accountId;
+ }
+
+ /**
+ * Get account active status
+ *
+ * @return account active information
+ */
+ @GET
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public AccountActiveData isActive() {
+ return accountOps.isActive(accountId);
+ }
+
+ /**
+ * Set account status to active
+ *
+ * @return response
+ * @response.representation.200.doc account status set to active
+ * @response.representation.304.doc account active status not modified
+ */
+ @PUT
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ public Response setActive() {
+ ResponseBuilder builder;
+ boolean modified = accountOps.setAccountActive(accountId, true);
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+
+ /**
+ * Set account status to inactive
+ *
+ * @return response
+ * @response.representation.200.doc account status set to inactive
+ * @response.representation.304.doc account status not modified
+ */
+ @DELETE
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ public Response setInactive() {
+ ResponseBuilder builder;
+ boolean modified = accountOps.setAccountActive(accountId, false);
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountApplication.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountApplication.java
new file mode 100644
index 00000000000..74abccc400a
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountApplication.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.ws.rs.core.Application;
+import org.eclipse.osee.account.admin.AccountAdmin;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountApplication extends Application {
+
+ private final Set<Object> singletons = new HashSet<Object>();
+ private AccountAdmin accountAdmin;
+
+ public void setAccountAdmin(AccountAdmin accountAdmin) {
+ this.accountAdmin = accountAdmin;
+ }
+
+ public void start() {
+ AccountOps ops = new AccountOps(accountAdmin);
+ singletons.add(new AccountsResource(ops));
+ }
+
+ public void stop() {
+ singletons.clear();
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return singletons;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLoginResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLoginResource.java
new file mode 100644
index 00000000000..32da9b1badb
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLoginResource.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import java.net.URI;
+import javax.annotation.security.PermitAll;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.account.rest.model.AccountLoginData;
+import org.eclipse.osee.account.rest.model.AccountSessionData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountLoginResource {
+
+ private final AccountOps accountOps;
+
+ public AccountLoginResource(AccountOps accountOps) {
+ this.accountOps = accountOps;
+ }
+
+ /**
+ * Logs user into account and creates a new account Session
+ *
+ * @param data Login data
+ * @return account session information and URL to account info
+ */
+ @POST
+ @PermitAll
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response login(@Context HttpServletRequest request, @Context UriInfo uriInfo, AccountLoginData data) {
+ RequestInfo remoteInfo = accountOps.asRequestInfo(request);
+
+ AccountSessionData token = accountOps.doLogin(remoteInfo, data);
+ String accountId = String.valueOf(token.getAccountId());
+ URI location = UriBuilder.fromUri(uriInfo.getBaseUri()).path(accountId).build();
+ return Response.ok().entity(token).contentLocation(location).build();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLogoutResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLogoutResource.java
new file mode 100644
index 00000000000..745d551c031
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountLogoutResource.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.eclipse.osee.account.admin.SystemRoles;
+import org.eclipse.osee.account.rest.model.AccountSessionData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountLogoutResource {
+
+ private final AccountOps accountOps;
+
+ public AccountLogoutResource(AccountOps accountOps) {
+ this.accountOps = accountOps;
+ }
+
+ /**
+ * Logs user out of the system
+ *
+ * @return response
+ * @response.representation.200.doc successfully logged out
+ * @response.representation.304.doc session not modified
+ */
+ @POST
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response logout(AccountSessionData data) {
+ ResponseBuilder builder;
+ boolean modified = accountOps.doLogout(data.getToken());
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java
new file mode 100644
index 00000000000..462eb18d8ab
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountOps.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import org.eclipse.osee.account.admin.Account;
+import org.eclipse.osee.account.admin.AccountAccess;
+import org.eclipse.osee.account.admin.AccountAdmin;
+import org.eclipse.osee.account.admin.AccountLoginRequest;
+import org.eclipse.osee.account.admin.AccountLoginRequestBuilder;
+import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.account.admin.CreateAccountRequest;
+import org.eclipse.osee.account.admin.CreateAccountRequestBuilder;
+import org.eclipse.osee.account.rest.model.AccountAccessData;
+import org.eclipse.osee.account.rest.model.AccountActiveData;
+import org.eclipse.osee.account.rest.model.AccountDetailsData;
+import org.eclipse.osee.account.rest.model.AccountInfoData;
+import org.eclipse.osee.account.rest.model.AccountInput;
+import org.eclipse.osee.account.rest.model.AccountLoginData;
+import org.eclipse.osee.account.rest.model.AccountPreferencesData;
+import org.eclipse.osee.account.rest.model.AccountPreferencesInput;
+import org.eclipse.osee.account.rest.model.AccountSessionData;
+import org.eclipse.osee.framework.jdk.core.type.Identifiable;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountOps {
+
+ private final AccountAdmin accountAdmin;
+
+ public AccountOps(AccountAdmin accountAdmin) {
+ super();
+ this.accountAdmin = accountAdmin;
+ }
+
+ public RequestInfo asRequestInfo(HttpServletRequest request) {
+ final String userAgent = RequestUtil.getUserAgent(request);
+ final String remoteAddress = RequestUtil.getClientIpAddrress(request);
+ return new RequestInfo() {
+
+ @Override
+ public String getDetails() {
+ return userAgent;
+ }
+
+ @Override
+ public String getRemoteIpAddress() {
+ return remoteAddress;
+ }
+
+ };
+ }
+
+ public List<AccountAccessData> getAccountAccessById(String accountId) {
+ ResultSet<AccountAccess> result = accountAdmin.getAccountAccessByUniqueField(accountId);
+ List<AccountAccessData> toReturn = new ArrayList<AccountAccessData>();
+ for (AccountAccess access : result) {
+ toReturn.add(asAccountAccessData(access));
+ }
+ return toReturn;
+ }
+
+ public AccountAccessData asAccountAccessData(AccountAccess access) {
+ AccountAccessData data = new AccountAccessData();
+ data.setAccountId(access.getAccountId());
+ data.setAccessDetails(access.getAccessDetails());
+ data.setAccessedFrom(access.getAccessedFrom());
+ data.setCreatedOn(access.getCreatedOn());
+ data.setLastAccessedOn(access.getLastAccessedOn());
+ return data;
+ }
+
+ public AccountSessionData doLogin(RequestInfo info, AccountLoginData input) {
+ AccountLoginRequestBuilder builder = AccountLoginRequestBuilder.newBuilder();
+ AccountLoginRequest request = builder//
+ .userName(input.getUsername())//
+ .password(input.getPassword())//
+ .scheme(input.getScheme()) //
+ .accessedBy(info.getDetails())//
+ .remoteAddress(info.getRemoteIpAddress()) //
+ .build();
+ AccountAccess session = accountAdmin.login(request);
+ return asSessionData(session);
+ }
+
+ public boolean doLogout(String token) {
+ return accountAdmin.logout(token);
+ }
+
+ public AccountSessionData asSessionData(AccountAccess session) {
+ AccountSessionData data = new AccountSessionData();
+ data.setAccountId(session.getAccountId());
+ data.setToken(session.getAccessToken());
+ return data;
+ }
+
+ public AccountInfoData createAccount(String username, AccountInput input) {
+ CreateAccountRequestBuilder builder = CreateAccountRequestBuilder.newBuilder();
+ CreateAccountRequest request = builder//
+ .userName(username)//
+ .displayName(input.getName())//
+ .email(input.getEmail())//
+ .active(input.isActive()) //
+ .prefs(input.getPreferences()) //
+ .build();
+
+ Identifiable<String> id = accountAdmin.createAccount(request);
+ ResultSet<Account> result = accountAdmin.getAccountByUuid(id.getGuid());
+ Account account = result.getExactlyOne();
+ return asAccountData(account);
+ }
+
+ public boolean deleteAccount(String accountId) {
+ return accountAdmin.deleteAccount(accountId);
+ }
+
+ public boolean setAccountActive(String accountId, boolean active) {
+ return accountAdmin.setActive(accountId, active);
+ }
+
+ public AccountActiveData isActive(String accountId) {
+ ResultSet<Account> result = accountAdmin.getAccountByUniqueField(accountId);
+ Account account = result.getExactlyOne();
+ return asAccountActiveData(account);
+ }
+
+ public List<AccountInfoData> getAllAccounts() {
+ List<AccountInfoData> toReturn = new ArrayList<AccountInfoData>();
+ ResultSet<Account> result = accountAdmin.getAllAccounts();
+ for (Account account : result) {
+ toReturn.add(asAccountData(account));
+ }
+ return toReturn;
+ }
+
+ public AccountDetailsData getAccountDetailsData(String accountId) {
+ ResultSet<Account> result = accountAdmin.getAccountByUniqueField(accountId);
+ Account account = result.getExactlyOne();
+ return asAccountDetailsData(account);
+ }
+
+ public AccountInfoData getAccountData(String value) {
+ ResultSet<Account> result = accountAdmin.getAccountByUniqueField(value);
+ Account account = result.getExactlyOne();
+ return asAccountData(account);
+ }
+
+ public AccountPreferencesData getAccountPreferencesData(String value) {
+ ResultSet<Account> result = accountAdmin.getAccountByUniqueField(value);
+ Account account = result.getExactlyOne();
+ AccountPreferences preferences = account.getPreferences();
+ return asAccountPreferencesData(preferences);
+ }
+
+ private AccountDetailsData asAccountDetailsData(Account account) {
+ AccountDetailsData data = new AccountDetailsData();
+ fillData(account, data);
+ AccountPreferencesData preferences = asAccountPreferencesData(account.getPreferences());
+ data.setPreferences(preferences);
+ return data;
+ }
+
+ private AccountInfoData asAccountData(Account account) {
+ AccountInfoData data = new AccountInfoData();
+ fillData(account, data);
+ return data;
+ }
+
+ private void fillData(Account account, AccountInfoData data) {
+ data.setAccountId(account.getId());
+ data.setGuid(account.getGuid());
+ data.setName(account.getName());
+ data.setEmail(account.getEmail());
+ data.setUserName(account.getUserName());
+ data.setActive(account.isActive());
+ }
+
+ private AccountPreferencesData asAccountPreferencesData(AccountPreferences preferences) {
+ AccountPreferencesData data = new AccountPreferencesData();
+ data.setId(preferences.getId());
+ data.setMap(preferences.asMap());
+ return data;
+ }
+
+ private AccountActiveData asAccountActiveData(Account account) {
+ AccountActiveData data = new AccountActiveData();
+ data.setAccountId(account.getId());
+ data.setGuid(account.getGuid());
+ data.setActive(account.isActive());
+ return data;
+ }
+
+ public boolean setAccountPreferences(String accountId, AccountPreferencesInput input) {
+ return accountAdmin.setAccountPreferences(accountId, input.getMap());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java
new file mode 100644
index 00000000000..14bf266d279
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountPreferencesResource.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.eclipse.osee.account.admin.SystemRoles;
+import org.eclipse.osee.account.rest.model.AccountPreferencesData;
+import org.eclipse.osee.account.rest.model.AccountPreferencesInput;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountPreferencesResource {
+
+ private final AccountOps accountOps;
+ private final String accountId;
+
+ public AccountPreferencesResource(AccountOps accountOps, String accountId) {
+ this.accountOps = accountOps;
+ this.accountId = accountId;
+ }
+
+ /**
+ * Get account preferences
+ *
+ * @return account preferences
+ */
+ @GET
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public AccountPreferencesData getAccountPreferences() {
+ return accountOps.getAccountPreferencesData(accountId);
+ }
+
+ /**
+ * Sets all preferences to match the incoming preferences.
+ *
+ * @return response
+ * @response.representation.200.doc successfully logged out
+ * @response.representation.304.doc session not modified
+ */
+ @PUT
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response setAccountPreferences(AccountPreferencesInput input) {
+ ResponseBuilder builder;
+ boolean modified = accountOps.setAccountPreferences(accountId, input);
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java
new file mode 100644
index 00000000000..d919ee5101a
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountResource.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.eclipse.osee.account.admin.SystemRoles;
+import org.eclipse.osee.account.rest.model.AccountContexts;
+import org.eclipse.osee.account.rest.model.AccountDetailsData;
+import org.eclipse.osee.account.rest.model.AccountInfoData;
+import org.eclipse.osee.account.rest.model.AccountInput;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountResource {
+
+ private final AccountOps accountOps;
+ private final String accountId;
+
+ public AccountResource(AccountOps accountOps, String accountId) {
+ this.accountOps = accountOps;
+ this.accountId = accountId;
+ }
+
+ /**
+ * Creates a new Account - all fields must be unique
+ *
+ * @param accountInput Account data
+ * @return new account info data
+ */
+ @POST
+ @PermitAll
+ @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public AccountInfoData createAccount(AccountInput accountInput) {
+ return accountOps.createAccount(accountId, accountInput);
+ }
+
+ /**
+ * Deletes the account
+ *
+ * @return response
+ * @response.representation.200.doc account status set to active
+ * @response.representation.304.doc account active status not modified
+ */
+ @DELETE
+ @RolesAllowed(SystemRoles.ROLES_ADMINISTRATOR)
+ public Response deleteAccount() {
+ ResponseBuilder builder;
+ boolean modified = accountOps.deleteAccount(accountId);
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+
+ /**
+ * Get account details
+ *
+ * @return account details
+ */
+ @GET
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public AccountDetailsData getAccountDetailsData() {
+ return accountOps.getAccountDetailsData(accountId);
+ }
+
+ @Path(AccountContexts.ACCOUNT_PREFERENCES)
+ public AccountPreferencesResource getAccountSettingsData() {
+ return new AccountPreferencesResource(accountOps, accountId);
+ }
+
+ @Path(AccountContexts.ACCOUNT_ACTIVE)
+ public AccountActiveResource active() {
+ return new AccountActiveResource(accountOps, accountId);
+ }
+
+ @Path(AccountContexts.ACCOUNT_SESSSIONS)
+ public AccountSessionsResource sessions() {
+ return new AccountSessionsResource(accountOps, accountId);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java
new file mode 100644
index 00000000000..1bbb23e697b
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountSessionsResource.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import java.util.List;
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.GET;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.eclipse.osee.account.admin.SystemRoles;
+import org.eclipse.osee.account.rest.model.AccountAccessData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountSessionsResource {
+
+ private final AccountOps accountOps;
+ private final String accountId;
+
+ public AccountSessionsResource(AccountOps accountOps, String accountId) {
+ this.accountOps = accountOps;
+ this.accountId = accountId;
+ }
+
+ /**
+ * Get all accesses for this account
+ *
+ * @return account accesses
+ */
+ @GET
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public List<AccountAccessData> getAccountSessions() {
+ return accountOps.getAccountAccessById(accountId);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java
new file mode 100644
index 00000000000..026e786f0ff
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/AccountsResource.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import java.util.List;
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.eclipse.osee.account.admin.SystemRoles;
+import org.eclipse.osee.account.rest.model.AccountContexts;
+import org.eclipse.osee.account.rest.model.AccountInfoData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@Path(AccountContexts.ACCOUNTS)
+public class AccountsResource {
+
+ private final AccountOps accountOps;
+
+ public AccountsResource(AccountOps accountOps) {
+ this.accountOps = accountOps;
+ }
+
+ /**
+ * Get all Accounts
+ *
+ * @return All accounts
+ */
+ @GET
+ @RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public List<AccountInfoData> getAccounts() {
+ return accountOps.getAllAccounts();
+ }
+
+ @Path(AccountContexts.ACCOUNT_LOGIN)
+ public AccountLoginResource getLoginResource() {
+ return new AccountLoginResource(accountOps);
+ }
+
+ @Path(AccountContexts.ACCOUNT_LOGOUT)
+ public AccountLogoutResource getLogoutResource() {
+ return new AccountLogoutResource(accountOps);
+ }
+
+ @Path(AccountContexts.ACCOUNT_ID_TEMPLATE)
+ public AccountResource getAccount(@PathParam(AccountContexts.ACCOUNT_ID_PARAM) String accountId) {
+ return new AccountResource(accountOps, accountId);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestInfo.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestInfo.java
new file mode 100644
index 00000000000..8c274f11874
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestInfo.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface RequestInfo {
+
+ String getDetails();
+
+ String getRemoteIpAddress();
+
+}
diff --git a/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestUtil.java b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestUtil.java
new file mode 100644
index 00000000000..41a4883bcd9
--- /dev/null
+++ b/plugins/org.eclipse.osee.account.rest/src/org/eclipse/osee/account/rest/internal/RequestUtil.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.account.rest.internal;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.HttpHeaders;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class RequestUtil {
+
+ private static final String X_FORWARDED_FOR = "X-Forwarded-For";
+ private static final String PROXY_CLIENT_IP = "Proxy-Client-IP";
+ private static final String HTTP_X_FORWARDED_FOR = "HTTP_X_FORWARDED_FOR";
+ private static final String WL_PROXY_CLIENT_IP = "WL-Proxy-Client-IP";
+ private static final String HTTP_CLIENT_IP = "HTTP_CLIENT_IP";
+ private static final String UNKNOWN = "unknown";
+
+ private RequestUtil() {
+ // Utility class
+ }
+
+ public static String getUserAgent(HttpServletRequest request) {
+ return request != null ? request.getHeader(HttpHeaders.USER_AGENT) : "";
+ }
+
+ public static String getClientIpAddrress(HttpServletRequest request) {
+ String ip = "";
+ if (request != null) {
+ ip = request.getHeader(X_FORWARDED_FOR);
+ if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
+ ip = request.getHeader(PROXY_CLIENT_IP);
+ }
+ if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
+ ip = request.getHeader(WL_PROXY_CLIENT_IP);
+ }
+ if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
+ ip = request.getHeader(HTTP_CLIENT_IP);
+ }
+ if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
+ ip = request.getHeader(HTTP_X_FORWARDED_FOR);
+ }
+ if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
+ ip = request.getRemoteAddr();
+ }
+ }
+ return ip;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.x.core.parent/pom.xml b/plugins/org.eclipse.osee.x.core.parent/pom.xml
index 32082452b7c..9f18774bc37 100644
--- a/plugins/org.eclipse.osee.x.core.parent/pom.xml
+++ b/plugins/org.eclipse.osee.x.core.parent/pom.xml
@@ -60,6 +60,10 @@
<module>../../plugins/org.eclipse.osee.rest.admin.test</module>
<module>../../plugins/org.eclipse.osee.rest.client</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.model</module>
+
<module>../../features/org.eclipse.osee.x.core.external.feature</module>
<module>../../features/org.eclipse.osee.x.core.feature</module>

Back to the top