Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-03-14 22:30:34 +0000
committerRyan D. Brooks2012-03-14 22:30:34 +0000
commitd4c344381cc661983cb7a07c19f1d8914c870469 (patch)
tree815d3ac2fd313baf113506393b16d2214d65b7fd
parent19e6edbe334305b3fd6c48a7b390cf6dde52f4fe (diff)
downloadorg.eclipse.osee-d4c344381cc661983cb7a07c19f1d8914c870469.tar.gz
org.eclipse.osee-d4c344381cc661983cb7a07c19f1d8914c870469.tar.xz
org.eclipse.osee-d4c344381cc661983cb7a07c19f1d8914c870469.zip
feature[ats_VVMH0]: Implement OrcsMetaData
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java8
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java6
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ConfigurationServlet.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/build.properties3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/SystemPreferences.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreInfo.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/KeyValueDataAccessor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/SystemPreferencesImpl.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/CreateDatastoreCallable.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/FetchDatastoreMetadataCallable.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockSystemPreferences.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessor.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/FetchDatastoreInfoCallable.java147
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/InitializeDatastoreCallable.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/resource/OseeDatastoreSchemaResource.java21
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/DataStoreInfoImpl.java24
-rw-r--r--plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.orcs/build.properties3
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsMetaData.java9
22 files changed, 362 insertions, 41 deletions
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java
index ce18fd91427..c60e2cbf0cb 100644
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java
+++ b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.database.schema;
import java.io.InputStream;
+import java.net.URI;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
/**
@@ -18,7 +19,10 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
*/
public interface SchemaResource {
- public boolean isApplicable();
+ boolean isApplicable();
+
+ InputStream getContent() throws OseeCoreException;
+
+ URI getLocation() throws OseeCoreException;
- public InputStream getContent() throws OseeCoreException;
}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java
index 2afe3556545..2d4da7a8268 100644
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java
+++ b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java
@@ -54,7 +54,11 @@ public class CreateSchemaCallable extends DatabaseTxCallable<Object> {
dbInit.dropTables(schemas, userSchema, dbSchema);
if (dbType == SupportedDatabase.postgresql || dbType == SupportedDatabase.h2) {
- dbInit.dropSchema(schemas);
+ try {
+ dbInit.dropSchema(schemas);
+ } catch (Exception ex) {
+ //
+ }
dbInit.createSchema(schemas);
}
dbInit.addTables(schemas, userSchema);
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ConfigurationServlet.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ConfigurationServlet.java
index f5c776d1e7b..64bc9b1712a 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ConfigurationServlet.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ConfigurationServlet.java
@@ -10,10 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.framework.manager.servlet;
+import java.io.BufferedInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.StringWriter;
+import java.io.Writer;
import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
@@ -23,6 +29,7 @@ import org.eclipse.osee.framework.core.message.DatastoreInitRequest;
import org.eclipse.osee.framework.core.server.UnsecuredOseeHttpServlet;
import org.eclipse.osee.framework.core.translation.IDataTranslationService;
import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsAdmin;
import org.eclipse.osee.orcs.OrcsApi;
@@ -48,16 +55,20 @@ public class ConfigurationServlet extends UnsecuredOseeHttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String servletPath = request.getServletPath();
String urlPath = request.getRequestURI().replace(servletPath, "");
- if (urlPath.startsWith("/datastore/schema")) {
+ if (urlPath.startsWith("/datastore")) {
OrcsAdmin adminOps = orcsApi.getAdminOps(null);
Callable<OrcsMetaData> callable = adminOps.createFetchOrcsMetaData();
-
try {
- OrcsMetaData result = callable.call();
-
+ OrcsMetaData metaData = callable.call();
StringWriter writer = new StringWriter();
- writer.write(result.toString());
+
+ if (urlPath.contains("schema")) {
+ writeConfigResource(writer, metaData);
+ } else {
+ writeDatabaseInfo(writer, metaData);
+ writeConfigResource(writer, metaData);
+ }
sendMessage(response, HttpURLConnection.HTTP_OK, writer.toString(), null);
} catch (Exception ex) {
@@ -88,9 +99,13 @@ public class ConfigurationServlet extends UnsecuredOseeHttpServlet {
Boolean.toString(data.isUseFileSpecifiedSchemas()));
Callable<OrcsMetaData> callable = adminOps.createDatastore(parameters);
- OrcsMetaData result = callable.call();
- String message = "ok"; //result.toString();
- sendMessage(response, HttpURLConnection.HTTP_ACCEPTED, message, null);
+ OrcsMetaData metaData = callable.call();
+
+ StringWriter writer = new StringWriter();
+ writeDatabaseInfo(writer, metaData);
+ writeConfigResource(writer, metaData);
+
+ sendMessage(response, HttpURLConnection.HTTP_ACCEPTED, writer.toString(), null);
} catch (Exception ex) {
String message = String.format("Datastore Initialization: [%s]\n%s", response.toString(), ex.toString());
sendMessage(response, HttpURLConnection.HTTP_INTERNAL_ERROR, message, ex);
@@ -101,6 +116,39 @@ public class ConfigurationServlet extends UnsecuredOseeHttpServlet {
}
}
+ private void writeDatabaseInfo(Writer writer, OrcsMetaData metaData) {
+ Map<String, String> data = metaData.getProperties();
+ List<String> keys = new ArrayList<String>(data.keySet());
+ Collections.sort(keys);
+
+ try {
+ writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ writer.write("<datastore>\n");
+ writer.write("\t<config>\n");
+ for (String key : keys) {
+ writer.write(String.format("\t\t<%s>%s</s>\n", key, data.get(key), key));
+ }
+ writer.write("\t</config>\n");
+ writer.write("</datastore>\n");
+ } catch (Exception ex) {
+ getLogger().error(ex, "Error transferring data store config properties");
+ }
+ }
+
+ private void writeConfigResource(Writer writer, OrcsMetaData metaData) {
+ for (IResource resource : metaData.getConfigurationResources()) {
+ InputStream inputStream = null;
+ try {
+ inputStream = new BufferedInputStream(resource.getContent());
+ writer.write(Lib.inputStreamToString(inputStream));
+ } catch (Exception ex) {
+ getLogger().error(ex, "Error transferring data store config resource");
+ } finally {
+ Lib.close(inputStream);
+ }
+ }
+ }
+
private void sendMessage(HttpServletResponse response, int status, String message, Throwable ex) throws IOException {
response.setStatus(status);
response.setContentType("text/plain");
diff --git a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
index d8c1af0a1d9..dd0fef12557 100644
--- a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Import-Package: com.google.common.collect;version="1.0.0",
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.resource.management,
org.eclipse.osee.logger,
org.eclipse.osee.orcs,
org.eclipse.osee.orcs.data,
diff --git a/plugins/org.eclipse.osee.orcs.core/build.properties b/plugins/org.eclipse.osee.orcs.core/build.properties
index 88f87400214..2b9bf588f0e 100644
--- a/plugins/org.eclipse.osee.orcs.core/build.properties
+++ b/plugins/org.eclipse.osee.orcs.core/build.properties
@@ -11,4 +11,5 @@ additional.bundles = org.eclipse.osee.logger,\
org.eclipse.core.runtime,\
com.google.collect,\
org.eclipse.osee.executor.admin,\
- org.eclipse.osee.console.admin
+ org.eclipse.osee.console.admin,\
+ org.eclipse.osee.framework.resource.management
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/SystemPreferences.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/SystemPreferences.java
index 759d923a3e7..6937385e717 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/SystemPreferences.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/SystemPreferences.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core;
+import java.util.Set;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
/**
@@ -17,6 +18,8 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
*/
public interface SystemPreferences {
+ public Set<String> getKeys() throws OseeCoreException;
+
public String getSystemUuid() throws OseeCoreException;
public String getValue(String key) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreInfo.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreInfo.java
index a21b7de5c31..0e91d799f17 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreInfo.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreInfo.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
+import java.util.List;
import java.util.Map;
+import org.eclipse.osee.framework.resource.management.IResource;
/**
* @author Roberto E. Escobar
@@ -19,4 +21,6 @@ public interface DataStoreInfo {
Map<String, String> getProperties();
+ List<IResource> getConfigurationResources();
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/KeyValueDataAccessor.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/KeyValueDataAccessor.java
index 282b0983769..966514a6db9 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/KeyValueDataAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/KeyValueDataAccessor.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
+import java.util.Set;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
/**
@@ -17,6 +18,8 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
*/
public interface KeyValueDataAccessor {
+ Set<String> getKeys() throws OseeCoreException;
+
String getValue(String key) throws OseeCoreException;
boolean putValue(String key, String value) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/SystemPreferencesImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/SystemPreferencesImpl.java
index c99770ec2df..ade13ee0df0 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/SystemPreferencesImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/SystemPreferencesImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.core.internal;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -100,4 +101,9 @@ public class SystemPreferencesImpl implements SystemPreferences {
cache.put(key, value);
}
+ @Override
+ public Set<String> getKeys() throws OseeCoreException {
+ return accessor.getKeys();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/CreateDatastoreCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/CreateDatastoreCallable.java
index 3ce15995c1d..b56e1ce2b96 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/CreateDatastoreCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/CreateDatastoreCallable.java
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.admin;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsMetaData;
import org.eclipse.osee.orcs.core.ds.DataStoreAdmin;
@@ -36,9 +38,20 @@ public class CreateDatastoreCallable extends AbstractAdminCallable<OrcsMetaData>
protected OrcsMetaData innerCall() throws Exception {
String sessionId = getSessionContext().getSessionId();
Callable<DataStoreInfo> callable = dataStoreAdmin.createDataStore(sessionId, parameters);
- DataStoreInfo dataStoreInfo = callAndCheckForCancel(callable);
+ final DataStoreInfo dataStoreInfo = callAndCheckForCancel(callable);
- OrcsMetaData orcsMetaData = null;
+ OrcsMetaData orcsMetaData = new OrcsMetaData() {
+
+ @Override
+ public Map<String, String> getProperties() {
+ return dataStoreInfo.getProperties();
+ }
+
+ @Override
+ public List<IResource> getConfigurationResources() {
+ return dataStoreInfo.getConfigurationResources();
+ }
+ };
return orcsMetaData;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/FetchDatastoreMetadataCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/FetchDatastoreMetadataCallable.java
index e8091a153e1..87b052f68aa 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/FetchDatastoreMetadataCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/admin/FetchDatastoreMetadataCallable.java
@@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.admin;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.Callable;
+import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsMetaData;
import org.eclipse.osee.orcs.core.ds.DataStoreAdmin;
@@ -33,10 +36,20 @@ public class FetchDatastoreMetadataCallable extends AbstractAdminCallable<OrcsMe
protected OrcsMetaData innerCall() throws Exception {
String sessionId = getSessionContext().getSessionId();
Callable<DataStoreInfo> callable = dataStoreAdmin.getDataStoreInfo(sessionId);
- DataStoreInfo dataStoreInfo = callAndCheckForCancel(callable);
+ final DataStoreInfo dataStoreInfo = callAndCheckForCancel(callable);
- OrcsMetaData orcsMetaData = null;
+ OrcsMetaData orcsMetaData = new OrcsMetaData() {
+ @Override
+ public Map<String, String> getProperties() {
+ return dataStoreInfo.getProperties();
+ }
+
+ @Override
+ public List<IResource> getConfigurationResources() {
+ return dataStoreInfo.getConfigurationResources();
+ }
+ };
return orcsMetaData;
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java
index 2c00397e6de..b280f8c20da 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessorTest.java
@@ -146,4 +146,14 @@ public class OseeInfoDataAccessorTest {
System.setProperty(DataStoreConstants.DATASTORE_INDEX_ON_START_UP, original);
}
}
+
+ @org.junit.Test
+ public void testGetKeys() throws OseeCoreException {
+ IOseeDatabaseService dbService = OsgiUtil.getService(IOseeDatabaseService.class);
+ OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
+ accessor.setLogger(new MockLog());
+ accessor.setDatabaseService(dbService);
+ Assert.assertTrue(!accessor.getKeys().isEmpty());
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockSystemPreferences.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockSystemPreferences.java
index 98727d4db58..3421025a724 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockSystemPreferences.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockSystemPreferences.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.mocks;
+import java.util.Set;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.SystemPreferences;
@@ -64,4 +65,9 @@ public class MockSystemPreferences implements SystemPreferences {
//
}
+ @Override
+ public Set<String> getKeys() throws OseeCoreException {
+ return null;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java
index 7ce03ac5844..2b0fcf0f9c4 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java
@@ -22,6 +22,7 @@ import org.eclipse.osee.orcs.core.SystemPreferences;
import org.eclipse.osee.orcs.core.ds.BranchDataStore;
import org.eclipse.osee.orcs.core.ds.DataStoreAdmin;
import org.eclipse.osee.orcs.core.ds.DataStoreInfo;
+import org.eclipse.osee.orcs.db.internal.callable.FetchDatastoreInfoCallable;
import org.eclipse.osee.orcs.db.internal.callable.InitializeDatastoreCallable;
import org.eclipse.osee.orcs.db.internal.util.DynamicSchemaResourceProvider;
@@ -72,18 +73,8 @@ public class DataStoreAdminImpl implements DataStoreAdmin {
@Override
public Callable<DataStoreInfo> getDataStoreInfo(String sessionId) {
- DataStoreInfo dataStoreInfo = null;
- // StringWriter writer = new StringWriter();
- // IOseeSchemaProvider schemaProvider = new OseeSchemaProvider();
- // for (IOseeSchemaResource resource : schemaProvider.getSchemaResources()) {
- // InputStream inputStream = null;
- // try {
- // inputStream = new BufferedInputStream(resource.getContent());
- // writer.write(Lib.inputStreamToString(inputStream));
- //
- // }
-
- return null;
+ SchemaResourceProvider schemaProvider = new DynamicSchemaResourceProvider(logger);
+ return new FetchDatastoreInfoCallable(logger, dbService, schemaProvider, preferences);
}
private boolean getOption(Map<String, String> parameters, String key, boolean defaultValue) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessor.java
index 67a51649dac..8e6fe8739f0 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/OseeInfoDataAccessor.java
@@ -12,10 +12,12 @@ package org.eclipse.osee.orcs.db.internal.accessor;
import java.io.File;
import java.sql.DatabaseMetaData;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.database.core.SupportedDatabase;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -25,14 +27,12 @@ import org.eclipse.osee.orcs.core.ds.KeyValueDataAccessor;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.resource.ResourceConstants;
-/**
- * @author Roberto E. Escobar
- */
public class OseeInfoDataAccessor implements KeyValueDataAccessor {
private static final String GET_VALUE_SQL = "SELECT osee_value FROM osee_info WHERE OSEE_KEY = ?";
private static final String INSERT_KEY_VALUE_SQL = "INSERT INTO osee_info (OSEE_KEY, OSEE_VALUE) VALUES (?, ?)";
private static final String DELETE_KEY_SQL = "DELETE FROM osee_info WHERE OSEE_KEY = ?";
+ private static final String GET_KEYS_SQL = "SELECT osee_key FROM osee_info";
private Log logger;
private IOseeDatabaseService dbService;
@@ -88,8 +88,8 @@ public class OseeInfoDataAccessor implements KeyValueDataAccessor {
"Unsupported modification - attempt to modify index start-up flag. This is an launch time setting.",
DataStoreConstants.DATASTORE_INDEX_ON_START_UP);
} else {
- ConnectionHandler.runPreparedUpdate(DELETE_KEY_SQL, key);
- int updated = ConnectionHandler.runPreparedUpdate(INSERT_KEY_VALUE_SQL, key, value);
+ dbService.runPreparedUpdate(DELETE_KEY_SQL, key);
+ int updated = dbService.runPreparedUpdate(INSERT_KEY_VALUE_SQL, key, value);
wasUpdated = updated == 1;
}
return wasUpdated;
@@ -147,4 +147,19 @@ public class OseeInfoDataAccessor implements KeyValueDataAccessor {
}
return areHintsSupported;
}
+
+ @Override
+ public Set<String> getKeys() throws OseeCoreException {
+ Set<String> keys = new HashSet<String>();
+ IOseeStatement chStmt = dbService.getStatement();
+ try {
+ chStmt.runPreparedQuery(GET_KEYS_SQL);
+ while (chStmt.next()) {
+ keys.add(chStmt.getString("osee_key"));
+ }
+ } finally {
+ chStmt.close();
+ }
+ return keys;
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/FetchDatastoreInfoCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/FetchDatastoreInfoCallable.java
new file mode 100644
index 00000000000..0af21a6c7fb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/FetchDatastoreInfoCallable.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.db.internal.callable;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.database.schema.DatabaseCallable;
+import org.eclipse.osee.database.schema.SchemaResource;
+import org.eclipse.osee.database.schema.SchemaResourceProvider;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.SystemPreferences;
+import org.eclipse.osee.orcs.core.ds.DataStoreConstants;
+import org.eclipse.osee.orcs.core.ds.DataStoreInfo;
+import org.eclipse.osee.orcs.db.internal.resource.ResourceConstants;
+import org.eclipse.osee.orcs.db.internal.util.DataStoreInfoImpl;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FetchDatastoreInfoCallable extends DatabaseCallable<DataStoreInfo> {
+
+ private final SchemaResourceProvider schemaProvider;
+ private final SystemPreferences preferences;
+
+ public FetchDatastoreInfoCallable(Log logger, IOseeDatabaseService dbService, SchemaResourceProvider schemaProvider, SystemPreferences preferences) {
+ super(logger, dbService);
+ this.schemaProvider = schemaProvider;
+ this.preferences = preferences;
+ }
+
+ @Override
+ public DataStoreInfo call() throws Exception {
+ DataStoreInfoImpl dataStoreInfo = new DataStoreInfoImpl();
+
+ Map<String, String> props = new HashMap<String, String>();
+ addInfoProperties(props);
+ addDbMetaData(props);
+
+ dataStoreInfo.setProperties(props);
+
+ List<IResource> configResources = new ArrayList<IResource>();
+ dataStoreInfo.setConfigurationResources(configResources);
+
+ for (SchemaResource resource : schemaProvider.getSchemaResources()) {
+ configResources.add(asResource(resource));
+ }
+ return dataStoreInfo;
+ }
+
+ private void addInfoProperties(Map<String, String> props) throws OseeCoreException {
+ for (String key : preferences.getKeys()) {
+ String value = preferences.getValue(key);
+ if (!Strings.isValid(value)) {
+ value = "";
+ }
+ props.put(key, value);
+ }
+ props.put(DataStoreConstants.DATASTORE_ID_KEY, preferences.getSystemUuid());
+ props.put("ds.binary.data.path", ResourceConstants.getBinaryDataPath(preferences));
+ props.put("ds.attribute.data.path", ResourceConstants.getAttributeDataPath(preferences));
+ props.put("ds.exchange.data.path", ResourceConstants.getExchangeDataPath(preferences));
+ }
+
+ private void addDbMetaData(Map<String, String> props) throws OseeCoreException {
+ OseeConnection connection = getDatabaseService().getConnection();
+ try {
+ DatabaseMetaData meta = connection.getMetaData();
+ props.put("db.connection.url", meta.getURL());
+ props.put("db.connection.username", meta.getUserName());
+
+ props.put("db.product.name", meta.getDatabaseProductName());
+ props.put("db.product.version", meta.getDatabaseProductVersion());
+
+ props.put("db.driver.name", meta.getDriverName());
+ props.put("db.driver.version", meta.getDriverVersion());
+
+ } catch (SQLException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ } finally {
+ connection.close();
+ }
+ }
+
+ private IResource asResource(SchemaResource resource) {
+ return new SchemaResourceAdaptor(getLogger(), resource);
+ }
+
+ private static final class SchemaResourceAdaptor implements IResource {
+
+ private final Log logger;
+ private final SchemaResource resource;
+
+ public SchemaResourceAdaptor(Log logger, SchemaResource resource) {
+ super();
+ this.logger = logger;
+ this.resource = resource;
+ }
+
+ @Override
+ public InputStream getContent() throws OseeCoreException {
+ return resource.getContent();
+ }
+
+ @Override
+ public URI getLocation() {
+ URI toReturn = null;
+ try {
+ toReturn = resource.getLocation();
+ } catch (OseeCoreException ex) {
+ logger.error(ex, "Error finding resource");
+ }
+ return toReturn;
+ }
+
+ @Override
+ public String getName() {
+ return resource.getClass().getSimpleName();
+ }
+
+ @Override
+ public boolean isCompressed() {
+ return false;
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/InitializeDatastoreCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/InitializeDatastoreCallable.java
index 149a1e68f50..55bdee3f0a0 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/InitializeDatastoreCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/InitializeDatastoreCallable.java
@@ -88,7 +88,11 @@ public class InitializeDatastoreCallable extends DatabaseCallable<DataStoreInfo>
Callable<Branch> createSystemRoot = branchStore.createBranch("sessionId", systemRootData);
Branch systemRoot = callAndCheckForCancel(createSystemRoot);
- DataStoreInfo dataStoreInfo = null;
+ Conditions.checkNotNull(systemRoot, "System Root Branch");
+
+ Callable<DataStoreInfo> fetchCallable =
+ new FetchDatastoreInfoCallable(getLogger(), getDatabaseService(), schemaProvider, preferences);
+ DataStoreInfo dataStoreInfo = callAndCheckForCancel(fetchCallable);
return dataStoreInfo;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/resource/OseeDatastoreSchemaResource.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/resource/OseeDatastoreSchemaResource.java
index ea253966f23..12126c10677 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/resource/OseeDatastoreSchemaResource.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/resource/OseeDatastoreSchemaResource.java
@@ -12,6 +12,8 @@ package org.eclipse.osee.orcs.db.internal.resource;
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.OseeCoreException;
@@ -21,12 +23,13 @@ import org.osgi.framework.FrameworkUtil;
public class OseeDatastoreSchemaResource implements SchemaResource {
+ private static final String FILE_PATH = "schema/SKYNET.VERSIONING.SCHEMA.xml";
+
@Override
public InputStream getContent() throws OseeCoreException {
InputStream inputStream = null;
try {
- Bundle bundle = FrameworkUtil.getBundle(this.getClass());
- URL url = bundle.getEntry("schema/SKYNET.VERSIONING.SCHEMA.xml");
+ URL url = getURL();
inputStream = new BufferedInputStream(url.openStream());
} catch (Exception ex) {
OseeExceptions.wrapAndThrow(ex);
@@ -38,4 +41,18 @@ public class OseeDatastoreSchemaResource implements SchemaResource {
public boolean isApplicable() {
return true;
}
+
+ @Override
+ public URI getLocation() throws OseeCoreException {
+ try {
+ return getURL().toURI();
+ } catch (URISyntaxException ex) {
+ throw new OseeCoreException(ex, "Error finding [%s] schema resource", FILE_PATH);
+ }
+ }
+
+ private URL getURL() {
+ Bundle bundle = FrameworkUtil.getBundle(this.getClass());
+ return bundle.getEntry(FILE_PATH);
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/DataStoreInfoImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/DataStoreInfoImpl.java
index c4343144148..774ffef1dfb 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/DataStoreInfoImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/DataStoreInfoImpl.java
@@ -10,14 +10,36 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.util;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.orcs.core.ds.DataStoreInfo;
+/**
+ * @author Roberto E. Escobar
+ */
public class DataStoreInfoImpl implements DataStoreInfo {
+ private Map<String, String> configProperties = new HashMap<String, String>();
+ private List<IResource> configResources;
+
@Override
public Map<String, String> getProperties() {
- return null;
+ return configProperties;
+ }
+
+ public void setProperties(Map<String, String> configProperties) {
+ this.configProperties = configProperties;
}
+ @Override
+ public List<IResource> getConfigurationResources() {
+ return configResources != null ? configResources : Collections.<IResource> emptyList();
+ }
+
+ public void setConfigurationResources(List<IResource> configResources) {
+ this.configResources = configResources;
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
index 5da29f17204..e9a50f867f7 100644
--- a/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Import-Package: org.eclipse.osee.executor.admin,
org.eclipse.osee.framework.core.model.change,
org.eclipse.osee.framework.core.model.type,
org.eclipse.osee.framework.jdk.core.type,
- org.eclipse.osee.framework.jdk.core.util
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.resource.management
Export-Package: org.eclipse.osee.orcs,
org.eclipse.osee.orcs.data,
org.eclipse.osee.orcs.search,
diff --git a/plugins/org.eclipse.osee.orcs/build.properties b/plugins/org.eclipse.osee.orcs/build.properties
index 19899692e76..863b838b927 100644
--- a/plugins/org.eclipse.osee.orcs/build.properties
+++ b/plugins/org.eclipse.osee.orcs/build.properties
@@ -6,4 +6,5 @@ additional.bundles = org.eclipse.osee.framework.core,\
org.eclipse.osee.framework.jdk.core,\
org.eclipse.core.runtime,\
org.eclipse.osee.framework.core.model,\
- org.eclipse.osee.executor.admin
+ org.eclipse.osee.executor.admin,\
+ org.eclipse.osee.framework.resource.management
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsMetaData.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsMetaData.java
index 2d2487340f7..49b64acfcb0 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsMetaData.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsMetaData.java
@@ -10,9 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.orcs;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.resource.management.IResource;
+
/**
* @author Roberto E. Escobar
*/
public interface OrcsMetaData {
- //
+
+ Map<String, String> getProperties();
+
+ List<IResource> getConfigurationResources();
}

Back to the top