Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-01-10 17:16:08 +0000
committerRyan D. Brooks2014-01-10 17:16:08 +0000
commit1f33e0bf0a642c17b674bbeb791e88ea07c4726a (patch)
treea7f971fdceb0c59a0d174158e191c8442e46f695
parentf7524c42f21c8337830d46775bd438e8a96ea9f3 (diff)
downloadorg.eclipse.osee-1f33e0bf0a642c17b674bbeb791e88ea07c4726a.tar.gz
org.eclipse.osee-1f33e0bf0a642c17b674bbeb791e88ea07c4726a.tar.xz
org.eclipse.osee-1f33e0bf0a642c17b674bbeb791e88ea07c4726a.zip
feature[ats_ATS8933]: Create ORCS Account Admin Implementation
-rw-r--r--features/org.eclipse.osee.orcs.feature/feature.xml7
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/.project28
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/META-INF/MANIFEST.MF24
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/OrcsAccountAdminTestSuite.launch58
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/pom.xml47
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/OrcsAccountTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java269
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsIntegrationRule.java53
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/.classpath7
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/.project33
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/META-INF/MANIFEST.MF27
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.access.schema.resource.xml8
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml10
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/build.properties5
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/pom.xml34
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessDatabaseStore.java186
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessImpl.java121
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessSchemaResource.java58
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessStorage.java32
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java70
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java79
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java90
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java289
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/schema/ACCOUNT.DS.SCHEMA.xml22
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zipbin58491 -> 59562 bytes
-rw-r--r--plugins/org.eclipse.osee.orcs.parent/pom.xml7
-rw-r--r--plugins/org.eclipse.osee.x.server.p2/demo/hsql.zipbin128841 -> 118634 bytes
30 files changed, 1620 insertions, 2 deletions
diff --git a/features/org.eclipse.osee.orcs.feature/feature.xml b/features/org.eclipse.osee.orcs.feature/feature.xml
index adda0248fdc..c578179cbc9 100644
--- a/features/org.eclipse.osee.orcs.feature/feature.xml
+++ b/features/org.eclipse.osee.orcs.feature/feature.xml
@@ -115,4 +115,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.eclipse.osee.orcs.account.admin"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/.classpath b/plugins/org.eclipse.osee.orcs.account.admin.test/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.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.orcs.account.admin.test/.project b/plugins/org.eclipse.osee.orcs.account.admin.test/.project
new file mode 100644
index 00000000000..a6a791d41ed
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.orcs.account.admin.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.orcs.account.admin.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.account.admin.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..37ccf399fba
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE ORCS Account Admin Test (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.orcs.account.admin.test
+Bundle-Version: 0.17.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Fragment-Host: org.eclipse.osee.orcs.account.admin
+Require-Bundle: org.junit,
+ org.mockito;bundle-version="1.9.0",
+ org.hamcrest.core,
+ org.objenesis,
+ org.eclipse.equinox.event,
+ org.eclipse.core.runtime,
+ org.eclipse.osee.event.osgi,
+ org.eclipse.osee.logger,
+ org.eclipse.osee.framework.core,
+ org.eclipse.osee.framework.database,
+ org.eclipse.osee.framework.core.model,
+ org.eclipse.osee.framework.resource.management
+Import-Package: org.eclipse.osee.orcs.db.mock,
+ org.eclipse.osee.event,
+ org.eclipse.osee.executor.admin,
+ org.osgi.service.event
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/OrcsAccountAdminTestSuite.launch b/plugins/org.eclipse.osee.orcs.account.admin.test/OrcsAccountAdminTestSuite.launch
new file mode 100644
index 00000000000..8453c1a69c2
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/OrcsAccountAdminTestSuite.launch
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<setAttribute key="additional_plugins">
+<setEntry value="org.eclipse.equinox.ds:1.4.101.v20130813-1853:default:true"/>
+<setEntry value="org.eclipse.osee.hsqldb:0.17.0.qualifier:default:false"/>
+<setEntry value="org.eclipse.osee.orcs.db.mock:0.17.0.qualifier:default:true"/>
+<setEntry value="org.hsqldb:2.2.9.qualifier:default:false"/>
+<setEntry value="org.mockito:1.9.0.qualifier:default:false"/>
+</setAttribute>
+<booleanAttribute key="append.args" value="true"/>
+<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="false"/>
+<booleanAttribute key="automaticValidate" value="true"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="false"/>
+<booleanAttribute key="default_auto_start" value="true"/>
+<stringAttribute key="featureDefaultLocation" value="workspace"/>
+<stringAttribute key="featurePluginResolution" value="workspace"/>
+<booleanAttribute key="includeOptional" value="false"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/OrcsAccountTestSuite.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.orcs.account.admin.OrcsAccountTestSuite"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.orcs.account.admin.test"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m &#13;&#10;-Dosee.log.default=ALL&#13;&#10;-Dlogback.configurationFile=logback-dev.xml&#13;&#10;-DNosgi.noShutdown=true&#13;&#10;-DNequinox.ds.print=true&#13;&#10;-DNequinox.ds.debug=true"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="lba.ote.outfile.conversion.app.convert"/>
+<booleanAttribute key="run_in_ui_thread" value="false"/>
+<setAttribute key="selected_features">
+<setEntry value="org.eclipse.osee.orcs.feature:default"/>
+<setEntry value="org.eclipse.osee.x.core.external.feature:default"/>
+<setEntry value="org.eclipse.osee.x.core.feature:default"/>
+</setAttribute>
+<booleanAttribute key="show_selected_only" value="true"/>
+<stringAttribute key="timestamp" value="1342653904563"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="true"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="false"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/build.properties b/plugins/org.eclipse.osee.orcs.account.admin.test/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/pom.xml b/plugins/org.eclipse.osee.orcs.account.admin.test/pom.xml
new file mode 100644
index 00000000000..e034e9ef053
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/pom.xml
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.orcs.parent</artifactId>
+ <version>0.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.orcs.account.admin.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>OSEE ORCS Account Admin 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.orcs.account.admin.test</testSuite>
+ <testClass>org.eclipse.osee.orcs.account.admin.OrcsAccountTestSuite</testClass>
+ <dependencies>
+ <dependency>
+ <type>eclipse-feature</type>
+ <artifactId>org.eclipse.osee.x.core.external.feature</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>eclipse-feature</type>
+ <artifactId>org.eclipse.osee.x.core.feature</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>eclipse-feature</type>
+ <artifactId>org.eclipse.osee.orcs.feature</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ </dependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/OrcsAccountTestSuite.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/OrcsAccountTestSuite.java
new file mode 100644
index 00000000000..3e0c0eac99c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/OrcsAccountTestSuite.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.orcs.account.admin;
+
+import org.eclipse.osee.orcs.account.admin.integration.OsgiIntegrationTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({OsgiIntegrationTestSuite.class})
+public class OrcsAccountTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java
new file mode 100644
index 00000000000..d9916db2c8d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsAccountStorageImplTest.java
@@ -0,0 +1,269 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.integration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import java.util.HashMap;
+import java.util.Map;
+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.AccountPreferences;
+import org.eclipse.osee.account.admin.CreateAccountRequest;
+import org.eclipse.osee.account.admin.ds.AccountStorage;
+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.util.Compare;
+import org.eclipse.osee.orcs.account.admin.internal.OrcsAccountStorageImpl;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TestName;
+import org.junit.rules.TestRule;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+
+/**
+ * Test Case for {@link AccountAdmin} using {@link OrcsAccountStorageImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class OrcsAccountStorageImplTest {
+
+ @Rule
+ public TestRule osgi = OrcsIntegrationRule.integrationRule(this, "osee.demo.hsql");
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
+ public TestName testName = new TestName();
+
+ @OsgiService
+ private AccountStorage storage;
+
+ // @formatter:off
+ @Mock private CreateAccountRequest request;
+ @Mock private AccountPreferences preferences;
+ // @formatter:on
+
+ private String name;
+ private String email;
+ private String username;
+ private boolean active;
+ private Map<String, String> prefs;
+
+ private Identifiable<String> newAccount;
+
+ @Before
+ public void testSetup() {
+ initMocks(this);
+
+ String methodName = testName.getMethodName();
+
+ name = String.format("displayName-%s", methodName);
+ email = String.format("%s@email.com", methodName);
+ username = String.format("userName-%s", methodName);
+ active = true;
+
+ prefs = new HashMap<String, String>();
+ prefs.put("a", "1");
+ prefs.put("b", "2");
+ prefs.put("c", "true");
+
+ when(request.getDisplayName()).thenReturn(name);
+ when(request.getEmail()).thenReturn(email);
+ when(request.getUserName()).thenReturn(username);
+ when(request.getPreferences()).thenReturn(prefs);
+ when(request.isActive()).thenReturn(active);
+
+ newAccount = storage.createAccount(request);
+ }
+
+ @Test
+ public void testGetAllAccounts() {
+ ResultSet<Account> result = storage.getAllAccounts();
+ assertEquals(10, result.size());
+ }
+
+ @Test
+ public void testGetById() {
+ ResultSet<Account> result = storage.getAccountByUuid(newAccount.getGuid());
+ Account account1 = result.getExactlyOne();
+ assertAccount(account1, newAccount.getGuid(), name, email, username, active, prefs);
+ }
+
+ @Test
+ public void testGetByUuiId() {
+ ResultSet<Account> result = storage.getAccountByUuid(newAccount.getGuid());
+ Account account1 = result.getExactlyOne();
+ assertAccount(account1, newAccount.getGuid(), name, email, username, active, prefs);
+
+ ResultSet<Account> result2 = storage.getAccountByLocalId(account1.getId());
+ Account account2 = result2.getExactlyOne();
+ assertEquals(account1, account2);
+ assertAccount(account2, newAccount.getGuid(), name, email, username, active, prefs);
+ }
+
+ @Test
+ public void testGetByName() {
+ ResultSet<Account> result = storage.getAccountByName(name);
+ Account account = result.getExactlyOne();
+ assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs);
+ }
+
+ @Test
+ public void testGetByEmail() {
+ ResultSet<Account> result = storage.getAccountByEmail(email);
+ Account account = result.getExactlyOne();
+ assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs);
+ }
+
+ @Test
+ public void testGetByUserName() {
+ ResultSet<Account> result = storage.getAccountByUserName(username);
+ Account account = result.getExactlyOne();
+ assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs);
+ }
+
+ @Test
+ public void testGetAccountPrefsByUuid() {
+ AccountPreferences actual = storage.getAccountPreferencesByUuid(newAccount.getGuid()).getExactlyOne();
+ assertPrefs(actual, newAccount.getGuid(), prefs);
+
+ AccountPreferences actual2 = storage.getAccountPreferencesById(actual.getId()).getExactlyOne();
+ assertPrefs(actual2, newAccount.getGuid(), prefs);
+ }
+
+ @Test
+ public void testGetAccountPrefsByLocalId() {
+ Account account = storage.getAccountByUuid(newAccount.getGuid()).getExactlyOne();
+
+ AccountPreferences actual = storage.getAccountPreferencesById(account.getId()).getExactlyOne();
+ assertPrefs(actual, account.getGuid(), account.getId(), prefs);
+ }
+
+ @Test
+ public void testSetActive() {
+ Account account = storage.getAccountByUuid(newAccount.getGuid()).getExactlyOne();
+ assertAccount(account, newAccount.getGuid(), name, email, username, active, prefs);
+
+ storage.setActive(newAccount, false);
+
+ account = storage.getAccountByUuid(newAccount.getGuid()).getExactlyOne();
+ assertFalse(account.isActive());
+
+ storage.setActive(newAccount, true);
+
+ account = storage.getAccountByUuid(newAccount.getGuid()).getExactlyOne();
+ assertTrue(account.isActive());
+ }
+
+ @Test
+ public void testDeleteAccount() {
+ ResultSet<Account> result = storage.getAccountByUuid(newAccount.getGuid());
+ assertEquals(1, result.size());
+
+ storage.deleteAccount(newAccount);
+
+ result = storage.getAccountByUuid(newAccount.getGuid());
+ assertTrue(result.isEmpty());
+ }
+
+ @Test
+ public void testSetAccountPreferences() {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "x");
+ expected.put("b", "y");
+ expected.put("c", "z");
+ expected.put("d", "false");
+
+ storage.setAccountPreferences(newAccount, expected);
+
+ Account account = storage.getAccountByUuid(newAccount.getGuid()).getExactlyOne();
+ AccountPreferences actual = account.getPreferences();
+ assertPrefs(actual, newAccount.getGuid(), account.getId(), expected);
+ }
+
+ @Test
+ public void testAccountAccess() {
+ String token = "myAccess";
+ String address = "myAddress";
+ String details = "myDetails";
+
+ AccessDetails accessDetails = Mockito.mock(AccessDetails.class);
+ when(accessDetails.getAccessDetails()).thenReturn(details);
+ when(accessDetails.getRemoteAddress()).thenReturn(address);
+
+ Account account = storage.getAccountByUuid(newAccount.getGuid()).getExactlyOne();
+
+ AccountAccess actual = storage.createAccountAccess(token, account, accessDetails);
+ assertEquals(details, actual.getAccessDetails());
+ assertEquals(address, actual.getAccessedFrom());
+ assertEquals(token, actual.getAccessToken());
+ assertEquals(account.getId(), actual.getAccountId());
+ assertNotNull(actual.getCreatedOn());
+ assertNotNull(actual.getLastAccessedOn());
+
+ //
+ ResultSet<AccountAccess> result = storage.getAccountAccessByAccessToken(token);
+ AccountAccess actualAccess = result.getExactlyOne();
+ assertEquals(actual, actualAccess);
+
+ storage.deleteAccountAccessByAccessToken(token);
+ assertEquals(true, storage.getAccountAccessByAccessToken(token).isEmpty());
+ }
+
+ private static void assertPrefs(AccountPreferences expected, String uuid, long accountId, Map<String, String> prefs) {
+ assertEquals(accountId, expected.getId());
+ assertPrefs(expected, uuid, prefs);
+ }
+
+ private static void assertPrefs(AccountPreferences expected, String uuid, Map<String, String> prefs) {
+ assertTrue(expected.getId() > 0L);
+
+ assertEquals(uuid, expected.getGuid());
+
+ Map<String, String> actual = expected.asMap();
+ if (prefs != null) {
+ assertNotNull(actual);
+ assertEquals(prefs.size(), actual.size());
+ assertPrefs(prefs, actual);
+ } else {
+ Assert.assertNull(actual);
+ }
+ }
+
+ private static void assertPrefs(Map<String, String> expected, Map<String, String> actual) {
+ assertEquals(false, Compare.isDifferent(expected, actual));
+ }
+
+ private static void assertAccount(Account account, String uuid, String name, String email, String username, boolean isActive, Map<String, String> prefs) {
+ assertTrue(account.getId() > 0L);
+ assertEquals(uuid, account.getGuid());
+
+ assertEquals(name, account.getName());
+ assertEquals(email, account.getEmail());
+ assertEquals(username, account.getUserName());
+ assertEquals(isActive, account.isActive());
+
+ assertPrefs(account.getPreferences(), uuid, prefs);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsIntegrationRule.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsIntegrationRule.java
new file mode 100644
index 00000000000..faba050ead9
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OrcsIntegrationRule.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.orcs.account.admin.integration;
+
+import org.eclipse.osee.account.admin.AccountAdmin;
+import org.eclipse.osee.event.EventService;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
+import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.db.mock.OseeDatabase;
+import org.eclipse.osee.orcs.db.mock.OsgiRule;
+import org.eclipse.osee.orcs.db.mock.OsgiService;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+import org.osgi.service.event.EventAdmin;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class OrcsIntegrationRule extends OsgiRule {
+
+ private OrcsIntegrationRule() {
+ // Utility
+ }
+
+ public static TestRule integrationRule(Object testObject, String dbId) {
+ return RuleChain.outerRule(new OseeDatabase(dbId)).around(new OsgiRule(new CheckServices(), testObject));
+ }
+
+ public static class CheckServices {
+ // @formatter:off
+ @OsgiService public Log log;
+ @OsgiService public EventAdmin eventAdmin;
+ @OsgiService public EventService eventService;
+ @OsgiService public ExecutorAdmin executorAdmin;
+ @OsgiService public IOseeDatabaseService dbService;
+ @OsgiService public IOseeModelFactoryService modelFactory;
+ @OsgiService public OrcsApi orcsApi;
+ @OsgiService public AccountAdmin accountAdmin;
+ // @formatter:on
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java
new file mode 100644
index 00000000000..76b24c91fad
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin.test/src/org/eclipse/osee/orcs/account/admin/integration/OsgiIntegrationTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.integration;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({OrcsAccountStorageImplTest.class})
+public class OsgiIntegrationTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/.classpath b/plugins/org.eclipse.osee.orcs.account.admin/.classpath
new file mode 100644
index 00000000000..ad32c83a788
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/.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.orcs.account.admin/.project b/plugins/org.eclipse.osee.orcs.account.admin/.project
new file mode 100644
index 00000000000..322c9e73939
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.orcs.account.admin</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.orcs.account.admin/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.account.admin/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a480ba8653e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE ORCS Account Admin (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.orcs.account.admin
+Bundle-Version: 0.17.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Service-Component: OSGI-INF/*.xml
+Import-Package: org.eclipse.osee.account.admin,
+ org.eclipse.osee.account.admin.ds,
+ org.eclipse.osee.database.schema,
+ org.eclipse.osee.executor.admin,
+ org.eclipse.osee.framework.core.data,
+ org.eclipse.osee.framework.core.enums,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.model,
+ org.eclipse.osee.framework.database,
+ org.eclipse.osee.framework.database.core,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.logger,
+ org.eclipse.osee.orcs,
+ org.eclipse.osee.orcs.data,
+ org.eclipse.osee.orcs.search,
+ org.eclipse.osee.orcs.transaction,
+ org.eclipse.osee.orcs.utility
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.access.schema.resource.xml b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.access.schema.resource.xml
new file mode 100644
index 00000000000..79133db1e0c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.access.schema.resource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true">
+ <implementation
+ class="org.eclipse.osee.orcs.account.admin.internal.AccountAccessSchemaResource" />
+ <service>
+ <provide interface="org.eclipse.osee.database.schema.SchemaResource"/>
+ </service>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml
new file mode 100644
index 00000000000..e9623c1bed6
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/OSGI-INF/orcs.account.ds.xml
@@ -0,0 +1,10 @@
+<?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.orcs.account.admin.internal.OrcsAccountStorageImpl"/>
+ <service>
+ <provide interface="org.eclipse.osee.account.admin.ds.AccountStorage"/>
+ </service>
+ <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
+ <reference bind="setOrcsApi" cardinality="1..1" interface="org.eclipse.osee.orcs.OrcsApi" name="OrcsApi" policy="static"/>
+ <reference bind="setDatabaseService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/build.properties b/plugins/org.eclipse.osee.orcs.account.admin/build.properties
new file mode 100644
index 00000000000..6210e849b59
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/build.properties
@@ -0,0 +1,5 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
+source.. = src/
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/pom.xml b/plugins/org.eclipse.osee.orcs.account.admin/pom.xml
new file mode 100644
index 00000000000..f7e22d4d63d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/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.orcs.parent</artifactId>
+ <version>0.17.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.orcs.account.admin</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>OSEE ORCS Account Admin - (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.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessDatabaseStore.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessDatabaseStore.java
new file mode 100644
index 00000000000..492c7521d93
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessDatabaseStore.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import org.eclipse.osee.account.admin.AccountAccess;
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+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.Lib;
+import org.eclipse.osee.logger.Log;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountAccessDatabaseStore implements AccountAccessStorage {
+
+ private static final String SELECT_BY_ACCOUNT_ID = "SELECT * FROM osee_account_access WHERE account_id = ?";
+
+ private static final String SELECT_BY_ACCESS_TOKEN = "SELECT * FROM osee_account_access WHERE access_token = ?";
+
+ private static final String INSERT_ACCOUNT_ACCESS =
+ "INSERT INTO osee_account_access (account_id, access_token, created_on, last_accessed_on, accessed_from, access_details) VALUES (?,?,?,?,?,?)";
+
+ private static final String UPDATE_BY_ACCOUNT_ID =
+ "UPDATE osee_account_access SET last_accessed_on = ?, accessed_from = ?, access_details = ? WHERE account_id = ? ";
+
+ private static final String DELETE_BY_ACCESS_TOKEN = "DELETE FROM osee_account_access WHERE access_token = ?";
+
+ private final Log logger;
+ private final IOseeDatabaseService dbService;
+ private final AccountFactory factory;
+
+ public AccountAccessDatabaseStore(Log logger, IOseeDatabaseService dbService, AccountFactory factory) {
+ this.logger = logger;
+ this.dbService = dbService;
+ this.factory = factory;
+ }
+
+ private Object[] asInsert(AccountAccess access) {
+ return new Object[] {
+ access.getAccountId(),
+ access.getAccessToken(),
+ access.getCreatedOn(),
+ access.getLastAccessedOn(),
+ access.getAccessedFrom(),
+ access.getAccessDetails()};
+ }
+
+ private Object[] asUpdate(AccountAccess access) {
+ return new Object[] {
+ access.getLastAccessedOn(),
+ access.getAccessedFrom(),
+ access.getAccessDetails(),
+ access.getAccountId()};
+ }
+
+ @Override
+ public Callable<ResultSet<AccountAccess>> getAccountAccessByAccountId(long accountId) {
+ return selectAccess(SELECT_BY_ACCOUNT_ID, accountId);
+ }
+
+ @Override
+ public Callable<ResultSet<AccountAccess>> getAccountAccessByAccessToken(String accessToken) {
+ return selectAccess(SELECT_BY_ACCESS_TOKEN, accessToken);
+ }
+
+ private Callable<ResultSet<AccountAccess>> selectAccess(final String query, final Object data) {
+ return new AbstractCallable<Object, ResultSet<AccountAccess>>(data) {
+
+ @Override
+ protected ResultSet<AccountAccess> innerCall() throws Exception {
+ List<AccountAccess> list = new LinkedList<AccountAccess>();
+ IOseeStatement chStmt = dbService.getStatement();
+ try {
+ chStmt.runPreparedQuery(query, data);
+ while (chStmt.next()) {
+ long accountId = chStmt.getLong("account_id");
+ String accessToken = chStmt.getString("access_token");
+ Date createdOn = chStmt.getTimestamp("created_on");
+ Date lastAccessedOn = chStmt.getTimestamp("last_accessed_on");
+ String accessedFrom = chStmt.getString("accessed_from");
+ String accessDetails = chStmt.getString("access_details");
+ AccountAccess access =
+ factory.newAccountAccess(accountId, accessToken, createdOn, lastAccessedOn, accessedFrom,
+ accessDetails);
+ list.add(access);
+ }
+ } finally {
+ chStmt.close();
+ }
+ return ResultSets.newResultSet(list);
+ }
+ };
+ }
+
+ @Override
+ public Callable<Integer> createAccountAccess(final Iterable<AccountAccess> datas) {
+ return new AbstractCallable<Iterable<AccountAccess>, Integer>(datas) {
+
+ @Override
+ protected Integer innerCall() throws Exception {
+ List<Object[]> data = new ArrayList<Object[]>();
+ for (AccountAccess access : datas) {
+ data.add(asInsert(access));
+ }
+ int result = dbService.runBatchUpdate(INSERT_ACCOUNT_ACCESS, data);
+ return result;
+ }
+ };
+ }
+
+ @Override
+ public Callable<Integer> updateAccountAccess(final Iterable<AccountAccess> datas) {
+ return new AbstractCallable<Iterable<AccountAccess>, Integer>(datas) {
+
+ @Override
+ protected Integer innerCall() throws Exception {
+ List<Object[]> data = new ArrayList<Object[]>();
+ for (AccountAccess access : datas) {
+ data.add(asUpdate(access));
+ }
+ int result = dbService.runBatchUpdate(UPDATE_BY_ACCOUNT_ID, data);
+ return result;
+ }
+ };
+ }
+
+ @Override
+ public Callable<Integer> deleteAccountAccessByAccessToken(final String token) {
+ return new AbstractCallable<String, Integer>(token) {
+
+ @Override
+ protected Integer innerCall() throws Exception {
+ return dbService.runPreparedUpdate(DELETE_BY_ACCESS_TOKEN, token);
+ }
+ };
+ }
+
+ private abstract class AbstractCallable<I, O> extends CancellableCallable<O> {
+
+ private final I data;
+
+ public AbstractCallable(I data) {
+ super();
+ this.data = data;
+ }
+
+ @Override
+ public final O call() throws Exception {
+ long startTime = System.currentTimeMillis();
+ long endTime = startTime;
+ O result = null;
+ try {
+ if (logger.isTraceEnabled()) {
+ logger.trace("%s [start] - [%s]", getClass().getSimpleName(), data);
+ }
+ result = innerCall();
+ } finally {
+ endTime = System.currentTimeMillis() - startTime;
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("%s [%s] - completed [%s]", getClass().getSimpleName(), Lib.asTimeString(endTime), data);
+ }
+ return result;
+ }
+
+ protected abstract O innerCall() throws Exception;
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessImpl.java
new file mode 100644
index 00000000000..6b8a6a6ea26
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessImpl.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.util.Date;
+import org.eclipse.osee.account.admin.AccountAccess;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountAccessImpl implements AccountAccess {
+
+ private long accountId;
+ private String accessToken;
+ private Date createdOn;
+ private Date lastAccessedOn;
+ private String accessedFrom;
+ private String accessDetails;
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ @Override
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ @Override
+ public Date getCreatedOn() {
+ return createdOn;
+ }
+
+ @Override
+ public Date getLastAccessedOn() {
+ return lastAccessedOn;
+ }
+
+ @Override
+ public String getAccessedFrom() {
+ return accessedFrom;
+ }
+
+ @Override
+ public String getAccessDetails() {
+ return accessDetails;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public void setCreatedOn(Date createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ public void setLastAccessedOn(Date lastUpdated) {
+ this.lastAccessedOn = lastUpdated;
+ }
+
+ public void setAccessedFrom(String accessedFrom) {
+ this.accessedFrom = accessedFrom;
+ }
+
+ public void setAccessDetails(String accessDetails) {
+ this.accessDetails = accessDetails;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((accessToken == null) ? 0 : accessToken.hashCode());
+ result = prime * result + (int) (accountId ^ (accountId >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AccountAccessImpl other = (AccountAccessImpl) obj;
+ if (accessToken == null) {
+ if (other.accessToken != null) {
+ return false;
+ }
+ } else if (!accessToken.equals(other.accessToken)) {
+ return false;
+ }
+ if (accountId != other.accountId) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "AccountSessionImpl [accountId=" + accountId + ", accessToken=" + accessToken + ", createdOn=" + createdOn + ", lastAccessedOn=" + lastAccessedOn + ", accessedFrom=" + accessedFrom + ", accessDetails=" + accessDetails + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessSchemaResource.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessSchemaResource.java
new file mode 100644
index 00000000000..f260f13e11e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessSchemaResource.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import org.eclipse.osee.database.schema.SchemaResource;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountAccessSchemaResource implements SchemaResource {
+
+ private static final String SCHEMA_PATH = "schema/ACCOUNT.DS.SCHEMA.xml";
+
+ @Override
+ public InputStream getContent() throws OseeCoreException {
+ InputStream inputStream = null;
+ try {
+ URL url = getResourceURL();
+ inputStream = new BufferedInputStream(url.openStream());
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return inputStream;
+ }
+
+ @Override
+ public boolean isApplicable() {
+ return true;
+ }
+
+ @Override
+ public URI getLocation() throws OseeCoreException {
+ try {
+ return getResourceURL().toURI();
+ } catch (URISyntaxException ex) {
+ throw new OseeCoreException(ex, "Error finding [%s] schema resource", SCHEMA_PATH);
+ }
+ }
+
+ private URL getResourceURL() {
+ return getClass().getResource(SCHEMA_PATH);
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessStorage.java
new file mode 100644
index 00000000000..4cce4fe3d0f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountAccessStorage.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.util.concurrent.Callable;
+import org.eclipse.osee.account.admin.AccountAccess;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AccountAccessStorage {
+
+ Callable<ResultSet<AccountAccess>> getAccountAccessByAccountId(long accountId);
+
+ Callable<ResultSet<AccountAccess>> getAccountAccessByAccessToken(String accessToken);
+
+ Callable<Integer> createAccountAccess(Iterable<AccountAccess> datas);
+
+ Callable<Integer> updateAccountAccess(Iterable<AccountAccess> datas);
+
+ Callable<Integer> deleteAccountAccessByAccessToken(String accessToken);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java
new file mode 100644
index 00000000000..3f923e4b10d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.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.orcs.account.admin.internal;
+
+import org.eclipse.osee.account.admin.Account;
+import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.jdk.core.type.BaseIdentity;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountArtifact extends BaseIdentity<String> implements Account {
+
+ private static final String NOT_AVAILABLE = "N/A";
+
+ private final ArtifactReadable artifact;
+ private final AccountPreferences preferences;
+
+ public AccountArtifact(String uuid, ArtifactReadable artifact, AccountPreferences preferences) {
+ super(artifact.getGuid());
+ this.artifact = artifact;
+ this.preferences = preferences;
+ }
+
+ @Override
+ public long getId() {
+ return artifact.getLocalId();
+ }
+
+ @Override
+ public boolean isActive() {
+ return artifact.getSoleAttributeValue(CoreAttributeTypes.Active, false);
+ }
+
+ @Override
+ public String getName() {
+ return artifact.getSoleAttributeValue(CoreAttributeTypes.Name, NOT_AVAILABLE);
+ }
+
+ @Override
+ public String getUserName() {
+ return artifact.getSoleAttributeValue(CoreAttributeTypes.UserId, NOT_AVAILABLE);
+ }
+
+ @Override
+ public String getEmail() {
+ return artifact.getSoleAttributeValue(CoreAttributeTypes.Email, NOT_AVAILABLE);
+ }
+
+ @Override
+ public AccountPreferences getPreferences() {
+ return preferences;
+ }
+
+ @Override
+ public String toString() {
+ return "AccountArtifact [artifact=" + artifact + ", preferences=" + preferences + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java
new file mode 100644
index 00000000000..9bfa0cba4b9
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.util.Date;
+import org.eclipse.osee.account.admin.Account;
+import org.eclipse.osee.account.admin.AccountAccess;
+import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.framework.jdk.core.type.ResultSetTransform.Function;
+import org.eclipse.osee.framework.jdk.core.type.ResultSets;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountFactory {
+
+ private final Function<String, ArtifactReadable, Account> function1 = new ArtifactToAccount();
+ private final Function<String, ArtifactReadable, AccountPreferences> function2 = new ArtifactToAccountPreferences();
+
+ public ResultSet<Account> newAccountResultSet(ResultSet<ArtifactReadable> results) {
+ return ResultSets.transform(results, function1);
+ }
+
+ public ResultSet<AccountPreferences> newAccountPreferencesResultSet(ResultSet<ArtifactReadable> results) {
+ return ResultSets.transform(results, function2);
+ }
+
+ public Account newAccount(ArtifactReadable artifact) {
+ AccountPreferences preferences = newAccountPreferences(artifact);
+ return new AccountArtifact(artifact.getGuid(), artifact, preferences);
+ }
+
+ public AccountPreferences newAccountPreferences(ArtifactReadable artifact) {
+ String id = artifact.getGuid();
+ return new AccountPreferencesArtifact(id, artifact);
+ }
+
+ private class ArtifactToAccount implements Function<String, ArtifactReadable, Account> {
+
+ @Override
+ public Account apply(ArtifactReadable source) {
+ return newAccount(source);
+ }
+ }
+
+ private class ArtifactToAccountPreferences implements Function<String, ArtifactReadable, AccountPreferences> {
+
+ @Override
+ public AccountPreferences apply(ArtifactReadable source) {
+ return newAccountPreferences(source);
+ }
+ }
+
+ public AccountAccess newAccountAccess(long accountId, String accessToken, String accessedFrom, String accessDetails) {
+ Date currentDate = new Date();
+ return newAccountAccess(accountId, accessToken, currentDate, currentDate, accessedFrom, accessDetails);
+ }
+
+ public AccountAccess newAccountAccess(long accountId, String accessToken, Date createdOn, Date lastAccessedOn, String accessedFrom, String accessDetails) {
+ AccountAccessImpl session = new AccountAccessImpl();
+ session.setAccountId(accountId);
+ session.setAccessToken(accessToken);
+ session.setCreatedOn(createdOn);
+ session.setLastAccessedOn(lastAccessedOn);
+ session.setAccessDetails(accessDetails);
+ session.setAccessedFrom(accessedFrom);
+ return session;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java
new file mode 100644
index 00000000000..543c6f2f552
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.eclipse.osee.account.admin.AccountPreferences;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.jdk.core.type.BaseIdentity;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AccountPreferencesArtifact extends BaseIdentity<String> implements AccountPreferences {
+
+ private final ArtifactReadable artifact;
+
+ private Map<String, String> data = Collections.emptyMap();
+ private final AtomicBoolean wasLoaded = new AtomicBoolean(false);
+
+ public AccountPreferencesArtifact(String uuid, ArtifactReadable artifact) {
+ super(uuid);
+ this.artifact = artifact;
+ }
+
+ @Override
+ public long getId() {
+ return artifact.getLocalId();
+ }
+
+ @Override
+ public String get(String key) {
+ checkLoaded();
+ return data.get(key);
+ }
+
+ @Override
+ public boolean getBoolean(String key) {
+ checkLoaded();
+ String value = data.get(key);
+ return Boolean.valueOf(value);
+ }
+
+ @Override
+ public Set<String> getKeys() {
+ checkLoaded();
+ return data.keySet();
+ }
+
+ @Override
+ public Map<String, String> asMap() {
+ checkLoaded();
+ return Collections.unmodifiableMap(data);
+ }
+
+ private void checkLoaded() {
+ if (wasLoaded.compareAndSet(false, true)) {
+ String settings = artifact.getSoleAttributeValue(CoreAttributeTypes.UserSettings, null);
+ if (settings != null) {
+ PropertyStore storage = new PropertyStore(artifact.getGuid());
+ try {
+ storage.load(new StringReader(settings));
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+ Map<String, String> map = new HashMap<String, String>();
+ for (String key : storage.keySet()) {
+ map.put(key, storage.get(key));
+ }
+ data = map;
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java
new file mode 100644
index 00000000000..bf19970a857
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorageImpl.java
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * 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.orcs.account.admin.internal;
+
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Map.Entry;
+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.AccountPreferences;
+import org.eclipse.osee.account.admin.CreateAccountRequest;
+import org.eclipse.osee.account.admin.ds.AccountStorage;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.Operator;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.jdk.core.type.Identifiable;
+import org.eclipse.osee.framework.jdk.core.type.Identity;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.ApplicationContext;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.data.ArtifactId;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.eclipse.osee.orcs.search.QueryFactory;
+import org.eclipse.osee.orcs.transaction.TransactionBuilder;
+import org.eclipse.osee.orcs.transaction.TransactionFactory;
+import org.eclipse.osee.orcs.utility.OrcsUtil;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsAccountStorageImpl implements AccountStorage {
+
+ private Log logger;
+ private OrcsApi orcsApi;
+ private IOseeDatabaseService dbService;
+
+ private AccountFactory factory;
+ private IOseeBranch storageBranch;
+ private ApplicationContext context;
+ private AccountAccessStorage accessStore;
+
+ public void setDatabaseService(IOseeDatabaseService dbService) {
+ this.dbService = dbService;
+ }
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ public void setOrcsApi(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ }
+
+ public void start() {
+ logger.trace("Starting OrcsAccountStorageImpl...");
+ factory = new AccountFactory();
+ storageBranch = CoreBranches.COMMON;
+
+ String sessionId = SystemUser.OseeSystem.getGuid();
+ context = newApplicationContext(sessionId);
+
+ accessStore = new AccountAccessDatabaseStore(logger, dbService, factory);
+ }
+
+ public void stop() {
+ logger.trace("Stopping OrcsAccountStorageImpl...");
+ storageBranch = null;
+ factory = null;
+ }
+
+ private ApplicationContext newApplicationContext(final String sessionId) {
+ return new ApplicationContext() {
+
+ @Override
+ public String getSessionId() {
+ return sessionId;
+ }
+ };
+ }
+
+ private IOseeBranch getBranch() {
+ return storageBranch;
+ }
+
+ private QueryBuilder newQuery() {
+ QueryFactory queryFactory = orcsApi.getQueryFactory(context);
+ return queryFactory.fromBranch(getBranch());
+ }
+
+ @SuppressWarnings("unchecked")
+ private ArtifactReadable getSystemUser() {
+ return newQuery().andIds(SystemUser.OseeSystem).getResults().getExactlyOne();
+ }
+
+ @Override
+ public boolean userNameExists(String username) {
+ int count = newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.UserId, username).getCount();
+ return count > 0;
+ }
+
+ @Override
+ public boolean emailExists(String email) {
+ int count = newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.Email, email).getCount();
+ return count > 0;
+ }
+
+ @Override
+ public boolean displayNameExists(String displayName) {
+ int count = newQuery().andIsOfType(CoreArtifactTypes.User).andNameEquals(displayName).getCount();
+ return count > 0;
+ }
+
+ @Override
+ public ResultSet<Account> getAllAccounts() {
+ ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).getResults();
+ return factory.newAccountResultSet(results);
+ }
+
+ @Override
+ public ResultSet<Account> getAccountByUserName(String username) {
+ ResultSet<ArtifactReadable> results =
+ newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.UserId, username).getResults();
+ return factory.newAccountResultSet(results);
+ }
+
+ @Override
+ public ResultSet<Account> getAccountByUuid(String accountUuid) {
+ ResultSet<ArtifactReadable> results =
+ newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(accountUuid).getResults();
+ return factory.newAccountResultSet(results);
+ }
+
+ @Override
+ public ResultSet<Account> getAccountByLocalId(long accountId) {
+ int id = Long.valueOf(accountId).intValue();
+ ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andLocalId(id).getResults();
+ return factory.newAccountResultSet(results);
+ }
+
+ @Override
+ public ResultSet<Account> getAccountByEmail(String email) {
+ ResultSet<ArtifactReadable> results =
+ newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.Email, Operator.EQUAL, email).getResults();
+ return factory.newAccountResultSet(results);
+ }
+
+ @Override
+ public ResultSet<Account> getAccountByName(String name) {
+ ResultSet<ArtifactReadable> results =
+ newQuery().andIsOfType(CoreArtifactTypes.User).andNameEquals(name).getResults();
+ return factory.newAccountResultSet(results);
+ }
+
+ @Override
+ public ResultSet<AccountPreferences> getAccountPreferencesById(long accountId) {
+ int id = Long.valueOf(accountId).intValue();
+ ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andLocalId(id).getResults();
+ return factory.newAccountPreferencesResultSet(results);
+ }
+
+ @Override
+ public ResultSet<AccountPreferences> getAccountPreferencesByUuid(String uuid) {
+ ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(uuid).getResults();
+ return factory.newAccountPreferencesResultSet(results);
+ }
+
+ private TransactionBuilder newTransaction(String comment) {
+ TransactionFactory transactionFactory = orcsApi.getTransactionFactory(context);
+ return transactionFactory.createTransaction(getBranch(), getSystemUser(), comment);
+ }
+
+ @Override
+ public Identifiable<String> createAccount(CreateAccountRequest request) {
+ TransactionBuilder tx = newTransaction("Create Account");
+ ArtifactId artId = tx.createArtifact(CoreArtifactTypes.User, request.getDisplayName());
+ tx.setSoleAttributeFromString(artId, CoreAttributeTypes.Email, request.getEmail());
+ tx.setSoleAttributeFromString(artId, CoreAttributeTypes.UserId, request.getUserName());
+ tx.setSoleAttributeValue(artId, CoreAttributeTypes.Active, request.isActive());
+
+ Map<String, String> preferences = request.getPreferences();
+ if (preferences != null && !preferences.isEmpty()) {
+ String prefValue = asString(artId.getGuid(), preferences);
+ tx.createAttribute(artId, CoreAttributeTypes.UserSettings, prefValue);
+ }
+ tx.commit();
+ return artId;
+ }
+
+ @Override
+ public void setActive(Identifiable<String> account, boolean active) {
+ ArtifactId artId = OrcsUtil.newArtifactId(account.getGuid(), account.getName());
+
+ TransactionBuilder tx = newTransaction("Update Account Active");
+ tx.setSoleAttributeValue(artId, CoreAttributeTypes.Active, active);
+ tx.commit();
+ }
+
+ private String asString(String uuid, Map<String, String> preferences) {
+ PropertyStore settings = new PropertyStore(uuid);
+ for (Entry<String, String> entry : preferences.entrySet()) {
+ settings.put(entry.getKey(), entry.getValue());
+ }
+
+ StringWriter stringWriter = new StringWriter();
+ try {
+ settings.save(stringWriter);
+ return stringWriter.toString();
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+
+ @Override
+ public void setAccountPreferences(Identity<String> account, Map<String, String> preferences) {
+ String prefValue = asString(account.getGuid(), preferences);
+
+ ArtifactId artId = OrcsUtil.newArtifactId(account.getGuid(), "N/A");
+ TransactionBuilder tx = newTransaction("User - Save Settings");
+ tx.setSoleAttributeFromString(artId, CoreAttributeTypes.UserSettings, prefValue);
+ tx.commit();
+ }
+
+ @Override
+ public void deleteAccount(Identifiable<String> account) {
+ ArtifactId artId = OrcsUtil.newArtifactId(account.getGuid(), account.getName());
+
+ TransactionBuilder tx = newTransaction("Delete User");
+ tx.deleteArtifact(artId);
+ tx.commit();
+ }
+
+ @Override
+ public ResultSet<AccountAccess> getAccountAccessById(long accountId) {
+ try {
+ return accessStore.getAccountAccessByAccountId(accountId).call();
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+
+ @Override
+ public ResultSet<AccountAccess> getAccountAccessByAccessToken(String accessToken) {
+ try {
+ return accessStore.getAccountAccessByAccessToken(accessToken).call();
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+
+ @Override
+ public AccountAccess createAccountAccess(String accessToken, Account account, AccessDetails details) {
+ AccountAccess access =
+ factory.newAccountAccess(account.getId(), accessToken, details.getRemoteAddress(), details.getAccessDetails());
+ try {
+ accessStore.createAccountAccess(Collections.singleton(access)).call();
+ return access;
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+
+ @Override
+ public void deleteAccountAccessByAccessToken(String accessToken) {
+ try {
+ accessStore.deleteAccountAccessByAccessToken(accessToken).call();
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/schema/ACCOUNT.DS.SCHEMA.xml b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/schema/ACCOUNT.DS.SCHEMA.xml
new file mode 100644
index 00000000000..a7339983d80
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/schema/ACCOUNT.DS.SCHEMA.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TableConfig>
+
+ <Table name="OSEE_ACCOUNT_ACCESS" schema="OSEE" tablespace="osee_data">
+ <Column id="ACCOUNT_ID" defaultValue="not null" type="BIGINT" />
+ <Column id="ACCESS_TOKEN" defaultValue="not null" type="VARCHAR" limits="100" />
+ <Column id="CREATED_ON" defaultValue="not null" type="TIMESTAMP" />
+ <Column id="LAST_ACCESSED_ON" defaultValue="not null" type="TIMESTAMP" />
+ <Column id="ACCESSED_FROM" defaultValue="not null" type="VARCHAR" limits="100" />
+ <Column id="ACCESS_DETAILS" defaultValue="not null" type="VARCHAR" limits="100" />
+
+ <Constraint schema="OSEE" id="OSEE_ACCOUNT_ACCESS_PK" type="PRIMARY KEY" appliesTo="ACCOUNT_ID, ACCESS_TOKEN" />
+ <Index id="OSEE_ACCOUNT_ACCESS_T_IDX" type="UNIQUE" tablespace="osee_index">
+ <AppliesTo id="ACCESS_TOKEN"/>
+ </Index>
+ </Table>
+
+ <TableDescription referenceTable="OSEE_ACCOUNT_SESSION">
+ <Note purpose="Core table used to store account session tokens" />
+ </TableDescription>
+
+</TableConfig>
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
index 32defe9abfa..6935d11ca16 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
+++ b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
Binary files differ
diff --git a/plugins/org.eclipse.osee.orcs.parent/pom.xml b/plugins/org.eclipse.osee.orcs.parent/pom.xml
index 39b80f38521..5c3d49444ca 100644
--- a/plugins/org.eclipse.osee.orcs.parent/pom.xml
+++ b/plugins/org.eclipse.osee.orcs.parent/pom.xml
@@ -9,7 +9,7 @@
<version>0.17.0-SNAPSHOT</version>
<relativePath>../../plugins/org.eclipse.osee.x.parent</relativePath>
</parent>
-
+
<groupId>org.eclipse.osee</groupId>
<artifactId>org.eclipse.osee.orcs.parent</artifactId>
<packaging>pom</packaging>
@@ -44,11 +44,14 @@
<module>../../plugins/org.eclipse.osee.orcs.db.test</module>
<module>../../plugins/org.eclipse.osee.orcs.test</module>
+ <module>../../plugins/org.eclipse.osee.orcs.account.admin</module>
+ <module>../../plugins/org.eclipse.osee.orcs.account.admin.test</module>
+
<module>../../features/org.eclipse.osee.orcs.feature</module>
<module>../../plugins/org.eclipse.osee.orcs.p2</module>
</modules>
-
+
<profiles>
<profile>
<id>osee-staged</id>
diff --git a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
index 7680d22dc2e..dae9749de56 100644
--- a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
+++ b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
Binary files differ

Back to the top