diff options
23 files changed, 269 insertions, 300 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java index 1a0a812bbe8..5e9a7f6c691 100644 --- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java +++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.message.test.mocks; -import org.eclipse.osee.framework.core.message.DatastoreInitRequest; import org.eclipse.osee.framework.core.model.AbstractOseeType; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.IBasicArtifact; @@ -147,10 +146,4 @@ public final class DataAsserts { Assert.assertFalse(Compare.isDifferent(expected.getRows(), actual.getRows())); } - public static void assertEquals(DatastoreInitRequest expected, DatastoreInitRequest actual) { - Assert.assertEquals(expected.getIndexDataSpace(), actual.getIndexDataSpace()); - Assert.assertEquals(expected.getTableDataSpace(), actual.getTableDataSpace()); - Assert.assertEquals(expected.isUseFileSpecifiedSchemas(), actual.isUseFileSpecifiedSchemas()); - } - } diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java index 1c8e24e2360..c18aad2c185 100644 --- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java +++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java @@ -13,7 +13,6 @@ package org.eclipse.osee.framework.core.message.test.translation; import org.eclipse.osee.framework.core.enums.CoreTranslatorId; import org.eclipse.osee.framework.core.message.internal.DataTranslationService; import org.eclipse.osee.framework.core.message.internal.DataTranslationServiceFactory; -import org.eclipse.osee.framework.core.message.internal.translation.DatastoreInitRequestTranslator; import org.eclipse.osee.framework.core.message.internal.translation.TableDataTranslator; import org.eclipse.osee.framework.core.translation.IDataTranslationService; import org.eclipse.osee.framework.core.translation.ITranslator; @@ -36,8 +35,6 @@ public class DataTranslationServiceFactoryTest { checkExists(srvc, TableDataTranslator.class, CoreTranslatorId.TABLE_DATA); - checkExists(srvc, DatastoreInitRequestTranslator.class, CoreTranslatorId.OSEE_DATASTORE_INIT_REQUEST); - srvc.stop(); } diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DatastoreInitRequestTranslatorTest.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DatastoreInitRequestTranslatorTest.java deleted file mode 100644 index 203bda38ec7..00000000000 --- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DatastoreInitRequestTranslatorTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.framework.core.message.test.translation; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.junit.Assert; -import org.eclipse.osee.framework.core.message.DatastoreInitRequest; -import org.eclipse.osee.framework.core.message.internal.translation.DatastoreInitRequestTranslator; -import org.eclipse.osee.framework.core.message.test.mocks.DataAsserts; -import org.eclipse.osee.framework.core.model.TableData; -import org.eclipse.osee.framework.core.translation.ITranslator; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -/** - * Test Case for {@link TableData} - * - * @author Roberto E. Escobar - */ -@RunWith(Parameterized.class) -public class DatastoreInitRequestTranslatorTest extends BaseTranslatorTest<DatastoreInitRequest> { - - public DatastoreInitRequestTranslatorTest(DatastoreInitRequest data, ITranslator<DatastoreInitRequest> translator) { - super(data, translator); - } - - @Override - protected void checkEquals(DatastoreInitRequest expected, DatastoreInitRequest actual) { - Assert.assertNotSame(expected, actual); - DataAsserts.assertEquals(expected, actual); - } - - @Parameters - public static Collection<Object[]> data() { - ITranslator<DatastoreInitRequest> translator = new DatastoreInitRequestTranslator(); - List<Object[]> data = new ArrayList<Object[]>(); - data.add(new Object[] {new DatastoreInitRequest("tableData", "indexData", true), translator}); - data.add(new Object[] {new DatastoreInitRequest("", "", false), translator}); - return data; - } -} diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java index 9055f3f925f..35cf65227a7 100644 --- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java +++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java @@ -15,7 +15,6 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - DatastoreInitRequestTranslatorTest.class, DataTranslationServiceFactoryTest.class, DataTranslationServiceTest.class, TableDataTranslatorTest.class}) diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java index 5f993c46f2f..133c06f166b 100644 --- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java +++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java @@ -11,7 +11,6 @@ package org.eclipse.osee.framework.core.message.internal; import org.eclipse.osee.framework.core.enums.CoreTranslatorId; -import org.eclipse.osee.framework.core.message.internal.translation.DatastoreInitRequestTranslator; import org.eclipse.osee.framework.core.message.internal.translation.TableDataTranslator; import org.eclipse.osee.framework.core.translation.IDataTranslationService; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -28,7 +27,5 @@ public class DataTranslationServiceFactory { public void configureService(IDataTranslationService service) throws OseeCoreException { service.addTranslator(new TableDataTranslator(), CoreTranslatorId.TABLE_DATA); - - service.addTranslator(new DatastoreInitRequestTranslator(), CoreTranslatorId.OSEE_DATASTORE_INIT_REQUEST); } } diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/DatastoreInitRequestTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/DatastoreInitRequestTranslator.java deleted file mode 100644 index 4c7ee761edf..00000000000 --- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/DatastoreInitRequestTranslator.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 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.framework.core.message.internal.translation; - -import org.eclipse.osee.framework.core.message.DatastoreInitRequest; -import org.eclipse.osee.framework.core.translation.ITranslator; -import org.eclipse.osee.framework.jdk.core.type.PropertyStore; - -public class DatastoreInitRequestTranslator implements ITranslator<DatastoreInitRequest> { - - private static enum Entry { - INDEX_DATA_SPACE, - TABLE_DATA_SPACE, - USE_FILE_SPECIFIED_SCHEMAS; - } - - @Override - public DatastoreInitRequest convert(PropertyStore store) { - String tableDataSpace = store.get(Entry.TABLE_DATA_SPACE.name()); - String indexDataSpace = store.get(Entry.INDEX_DATA_SPACE.name()); - boolean useSchemasSpecified = store.getBoolean(Entry.USE_FILE_SPECIFIED_SCHEMAS.name()); - return new DatastoreInitRequest(tableDataSpace, indexDataSpace, useSchemasSpecified); - } - - @Override - public PropertyStore convert(DatastoreInitRequest object) { - PropertyStore store = new PropertyStore(); - store.put(Entry.INDEX_DATA_SPACE.name(), object.getIndexDataSpace()); - store.put(Entry.TABLE_DATA_SPACE.name(), object.getTableDataSpace()); - store.put(Entry.USE_FILE_SPECIFIED_SCHEMAS.name(), object.isUseFileSpecifiedSchemas()); - return store; - } -} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java index 0b780ce2040..c0f6aa6eeef 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java @@ -23,7 +23,6 @@ public class OseeServerContext { public static final String SESSION_CONTEXT = asAbsoluteContext("session"); public static final String CLIENT_LOOPBACK_CONTEXT = asAbsoluteContext("client/loopback"); public static final String ARTIFACT_CONTEXT = asAbsoluteContext("artifact"); - public static final String OSEE_CONFIGURE_CONTEXT = asAbsoluteContext("configure"); private static final String asAbsoluteContext(String value) { return BASE_CONTEXT + "/" + value; diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreTranslatorId.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreTranslatorId.java index f726fae9ca7..e9bc0a598a8 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreTranslatorId.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreTranslatorId.java @@ -17,8 +17,6 @@ import org.eclipse.osee.framework.core.translation.ITranslatorId; * @author Roberto E. Escobar */ public enum CoreTranslatorId implements ITranslatorId { - OSEE_DATASTORE_INIT_REQUEST, - TABLE_DATA; @Override diff --git a/plugins/org.eclipse.osee.framework.database.init/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.database.init/META-INF/MANIFEST.MF index 641d4cf457c..fd9dcec4718 100644 --- a/plugins/org.eclipse.osee.framework.database.init/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.database.init/META-INF/MANIFEST.MF @@ -37,6 +37,7 @@ Import-Package: org.apache.commons.lang;version="2.4.0", org.eclipse.osee.framework.skynet.core.artifact.search, org.eclipse.osee.framework.skynet.core.attribute, org.eclipse.osee.framework.skynet.core.exportImport, + org.eclipse.osee.framework.skynet.core.httpRequests, org.eclipse.osee.framework.skynet.core.importing, org.eclipse.osee.framework.skynet.core.transaction, org.eclipse.osee.framework.skynet.core.types, diff --git a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/DbBootstrapTask.java b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/DbBootstrapTask.java index 94736208049..f24914c99ec 100644 --- a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/DbBootstrapTask.java +++ b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/DbBootstrapTask.java @@ -11,29 +11,22 @@ package org.eclipse.osee.framework.database.init.internal; -import java.util.HashMap; import java.util.List; import org.eclipse.core.runtime.Platform; import org.eclipse.osee.framework.core.client.BaseCredentialProvider; import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.client.OseeClientProperties; -import org.eclipse.osee.framework.core.client.server.HttpUrlBuilderClient; import org.eclipse.osee.framework.core.data.OseeCredential; -import org.eclipse.osee.framework.core.data.OseeServerContext; -import org.eclipse.osee.framework.core.enums.CoreTranslatorId; import org.eclipse.osee.framework.core.enums.SystemUser; -import org.eclipse.osee.framework.core.message.DatastoreInitRequest; import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.core.services.IOseeCachingService; -import org.eclipse.osee.framework.core.translation.IDataTranslationService; -import org.eclipse.osee.framework.core.util.HttpMessage; -import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult; import org.eclipse.osee.framework.database.init.IDatabaseInitConfiguration; import org.eclipse.osee.framework.database.init.IDbInitializationTask; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.type.OseeStateException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; +import org.eclipse.osee.framework.skynet.core.httpRequests.DatastoreInitializationOperation; import org.eclipse.osee.jdbc.JdbcClient; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; @@ -97,23 +90,12 @@ public class DbBootstrapTask implements IDbInitializationTask { private void createOseeDatastore() throws OseeCoreException { // OseeClientProperties.isOseeImportAllowed(); - String tableDataSpace = OseeClientProperties.getOseeTableDataSpaceForDbInit(); String indexDataSpace = OseeClientProperties.getOseeIndexDataSpaceForDbInit(); boolean useSchemasSpecified = OseeClientProperties.useSchemasSpecifiedInDbConfigFiles(); - DatastoreInitRequest requestData = new DatastoreInitRequest(tableDataSpace, indexDataSpace, useSchemasSpecified); - - String datastoreInitContext = OseeServerContext.OSEE_CONFIGURE_CONTEXT + "/datastore/initialize"; - String urlString = - HttpUrlBuilderClient.getInstance().getOsgiServletServiceUrl(datastoreInitContext, - new HashMap<String, String>()); - - IDataTranslationService service = DatabaseInitActivator.getInstance().getTranslationService(); - AcquireResult updateResponse = - HttpMessage.send(urlString, service, CoreTranslatorId.OSEE_DATASTORE_INIT_REQUEST, requestData, null); - if (!updateResponse.wasSuccessful()) { - throw new OseeStateException("Error during datastore init"); - } + DatastoreInitializationOperation op = + new DatastoreInitializationOperation(tableDataSpace, indexDataSpace, useSchemasSpecified); + Operations.executeWorkAndCheckStatus(op); } } diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.manager.servlet/META-INF/MANIFEST.MF index bb1ff37be43..18292a26787 100644 --- a/plugins/org.eclipse.osee.framework.manager.servlet/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.manager.servlet/META-INF/MANIFEST.MF @@ -10,16 +10,10 @@ Import-Package: com.google.common.collect;version="[11.0.0,15.0.0)", org.eclipse.core.runtime, org.eclipse.core.runtime.jobs, org.eclipse.osee.activity.api, - 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.message, - org.eclipse.osee.framework.core.model, - org.eclipse.osee.framework.core.model.change, - org.eclipse.osee.framework.core.model.type, org.eclipse.osee.framework.core.server, - org.eclipse.osee.framework.core.translation, org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/legacy.servlets.xml b/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/legacy.servlets.xml index 67cee618972..643832bf36c 100644 --- a/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/legacy.servlets.xml +++ b/plugins/org.eclipse.osee.framework.manager.servlet/OSGI-INF/legacy.servlets.xml @@ -6,7 +6,6 @@ <reference bind="setHttpService" cardinality="1..1" interface="org.osgi.service.http.HttpService" name="HttpService" policy="static"/> <reference bind="setSessionManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.ISessionManager" name="ISessionManager" policy="static"/> <reference bind="setAppServerManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IApplicationServerManager" name="IApplicationServerManager" policy="static"/> - <reference bind="setTranslationService" cardinality="1..1" interface="org.eclipse.osee.framework.core.translation.IDataTranslationService" name="IDataTranslationService" policy="static"/> <reference bind="setAuthenticationManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IAuthenticationManager" name="IAuthenticationManager" policy="static"/> <reference bind="setResourceManager" cardinality="1..1" interface="org.eclipse.osee.framework.resource.management.IResourceManager" name="IResourceManager" policy="static"/> <reference bind="setOrcsApi" cardinality="1..1" interface="org.eclipse.osee.orcs.OrcsApi" name="OrcsApi" policy="static"/> 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 deleted file mode 100644 index a91cb535bbc..00000000000 --- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ConfigurationServlet.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * 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.framework.manager.servlet; - -import java.io.IOException; -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; -import javax.servlet.http.HttpServletResponse; -import org.eclipse.osee.framework.core.enums.CoreTranslatorId; -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.logger.Log; -import org.eclipse.osee.orcs.OrcsAdmin; -import org.eclipse.osee.orcs.OrcsApi; -import org.eclipse.osee.orcs.OrcsMetaData; - -/** - * @author Roberto E. Escobar - */ -public class ConfigurationServlet extends UnsecuredOseeHttpServlet { - - private static final long serialVersionUID = -5421308349950133041L; - - private final IDataTranslationService translationService; - private final OrcsApi orcsApi; - - public ConfigurationServlet(Log logger, IDataTranslationService translationService, OrcsApi orcsApi) { - super(logger); - this.translationService = translationService; - this.orcsApi = orcsApi; - } - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - String servletPath = request.getServletPath(); - String urlPath = request.getRequestURI().replace(servletPath, ""); - if (urlPath.startsWith("/datastore")) { - OrcsAdmin adminOps = orcsApi.getAdminOps(null); - - Callable<OrcsMetaData> callable = adminOps.createFetchOrcsMetaData(); - try { - OrcsMetaData metaData = callable.call(); - StringWriter writer = new StringWriter(); - - writeDatabaseInfo(writer, metaData); - sendMessage(response, HttpURLConnection.HTTP_OK, writer.toString(), null); - - } catch (Exception ex) { - String message = String.format("Error Fetching OrcsInfo: [%s]\n%s", response.toString(), ex.toString()); - sendMessage(response, HttpURLConnection.HTTP_INTERNAL_ERROR, message, ex); - } - } else { - String message = String.format("[%s] not found", request.getRequestURI()); - sendMessage(response, HttpURLConnection.HTTP_NOT_FOUND, message, null); - } - } - - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { - String servletPath = request.getServletPath(); - String urlPath = request.getRequestURI().replace(servletPath, ""); - if (urlPath.startsWith("/datastore/initialize")) { - OrcsAdmin adminOps = orcsApi.getAdminOps(null); - - Map<String, String> parameters = new HashMap<String, String>(); - - try { - DatastoreInitRequest data = - translationService.convert(request.getInputStream(), CoreTranslatorId.OSEE_DATASTORE_INIT_REQUEST); - parameters.put("schema.table.data.namespace", data.getTableDataSpace()); - parameters.put("schema.index.data.namespace", data.getIndexDataSpace()); - parameters.put("schema.user.file.specified.schema.names", - Boolean.toString(data.isUseFileSpecifiedSchemas())); - - Callable<OrcsMetaData> callable = adminOps.createDatastore(parameters); - OrcsMetaData metaData = callable.call(); - - StringWriter writer = new StringWriter(); - writeDatabaseInfo(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); - } - } else { - String message = String.format("[%s] not found", request.getRequestURI()); - sendMessage(response, HttpURLConnection.HTTP_NOT_FOUND, message, null); - } - } - - 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 sendMessage(HttpServletResponse response, int status, String message, Throwable ex) throws IOException { - response.setStatus(status); - response.setContentType("text/plain"); - response.getWriter().write(message); - if (ex != null) { - response.getWriter().write(Lib.exceptionToString(ex)); - } - response.getWriter().flush(); - response.getWriter().close(); - } -} diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java index fba014c28a5..64aadc90cbf 100644 --- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java +++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java @@ -18,12 +18,10 @@ import org.eclipse.osee.framework.core.server.IApplicationServerManager; import org.eclipse.osee.framework.core.server.IAuthenticationManager; import org.eclipse.osee.framework.core.server.ISessionManager; import org.eclipse.osee.framework.core.server.OseeHttpServlet; -import org.eclipse.osee.framework.core.translation.IDataTranslationService; import org.eclipse.osee.framework.manager.servlet.AdminServlet; import org.eclipse.osee.framework.manager.servlet.ArtifactFileServlet; import org.eclipse.osee.framework.manager.servlet.AtsServlet; import org.eclipse.osee.framework.manager.servlet.BranchExchangeServlet; -import org.eclipse.osee.framework.manager.servlet.ConfigurationServlet; import org.eclipse.osee.framework.manager.servlet.DataServlet; import org.eclipse.osee.framework.manager.servlet.SessionClientLoopbackServlet; import org.eclipse.osee.framework.manager.servlet.SessionManagementServlet; @@ -45,7 +43,6 @@ public class ServletRegistrationHandler { private Log logger; private ISessionManager sessionManager; private IApplicationServerManager appServerManager; - private IDataTranslationService translationService; private IAuthenticationManager authenticationManager; private IResourceManager resourceManager; private OrcsApi orcsApi; @@ -62,10 +59,6 @@ public class ServletRegistrationHandler { this.appServerManager = appServerManager; } - public void setTranslationService(IDataTranslationService translationService) { - this.translationService = translationService; - } - public void setAuthenticationManager(IAuthenticationManager authenticationManager) { this.authenticationManager = authenticationManager; } @@ -119,7 +112,6 @@ public class ServletRegistrationHandler { register(new SessionClientLoopbackServlet(logger, sessionManager), OseeServerContext.CLIENT_LOOPBACK_CONTEXT); register(new AtsServlet(logger, resourceManager, orcsApi, jdbcClient), "osee/ats"); - register(new ConfigurationServlet(logger, translationService, orcsApi), OseeServerContext.OSEE_CONFIGURE_CONTEXT); register(new DataServlet(logger, resourceManager, orcsApi, jdbcClient), "osee/data"); register(new AdminServlet(logger, context), "osee/console"); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/DatastoreInitializationOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/DatastoreInitializationOperation.java new file mode 100644 index 00000000000..030cdd5d684 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/DatastoreInitializationOperation.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2015 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.framework.skynet.core.httpRequests; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osee.framework.core.operation.AbstractOperation; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.skynet.core.internal.Activator; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; +import org.eclipse.osee.jaxrs.client.JaxRsExceptions; +import org.eclipse.osee.orcs.rest.client.OseeClient; +import org.eclipse.osee.orcs.rest.model.DatastoreEndpoint; +import org.eclipse.osee.orcs.rest.model.DatastoreInitOptions; + +/** + * @author Roberto E. Escobar + */ +public final class DatastoreInitializationOperation extends AbstractOperation { + + private final String tableDataSpace; + private final String indexDataSpace; + private final boolean useSchemasSpecified; + + public DatastoreInitializationOperation(String tableDataSpace, String indexDataSpace, boolean useSchemasSpecified) { + super("Datastore Initialization", Activator.PLUGIN_ID); + this.tableDataSpace = tableDataSpace; + this.indexDataSpace = indexDataSpace; + this.useSchemasSpecified = useSchemasSpecified; + } + + @Override + protected void doWork(IProgressMonitor monitor) throws OseeCoreException { + OseeClient oseeClient = ServiceUtil.getOseeClient(); + DatastoreEndpoint endPoint = oseeClient.getDatastoreEndpoint(); + + DatastoreInitOptions options = new DatastoreInitOptions(); + options.setIndexDataSpace(indexDataSpace); + options.setTableDataSpace(tableDataSpace); + options.setUseFileSpecifiedSchemas(useSchemasSpecified); + + try { + endPoint.initialize(options); + } catch (Exception ex) { + throw JaxRsExceptions.asOseeException(ex); + } + } +} diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java index b1f628046d0..b90b57e3b81 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java @@ -15,6 +15,7 @@ import java.util.Properties; import javax.ws.rs.core.MediaType; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.rest.model.BranchEndpoint; +import org.eclipse.osee.orcs.rest.model.DatastoreEndpoint; import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; import org.eclipse.osee.orcs.rest.model.IndexerEndpoint; import org.eclipse.osee.orcs.rest.model.ResourcesEndpoint; @@ -41,5 +42,7 @@ public interface OseeClient { IdeClientEndpoint getIdeClientEndpoint(); ResourcesEndpoint getResourcesEndpoint(); + + DatastoreEndpoint getDatastoreEndpoint(); } diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java index 8c99730fd8f..4996a8e49b5 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java @@ -35,6 +35,7 @@ import org.eclipse.osee.orcs.rest.client.internal.search.QueryBuilderImpl; import org.eclipse.osee.orcs.rest.client.internal.search.QueryExecutor; import org.eclipse.osee.orcs.rest.client.internal.search.QueryOptions; import org.eclipse.osee.orcs.rest.model.BranchEndpoint; +import org.eclipse.osee.orcs.rest.model.DatastoreEndpoint; import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; import org.eclipse.osee.orcs.rest.model.IndexerEndpoint; import org.eclipse.osee.orcs.rest.model.ResourcesEndpoint; @@ -178,4 +179,10 @@ public class OseeClientImpl implements OseeClient, QueryExecutor { JaxRsClient newClient = JaxRsClient.newBuilder(client.getConfig()).followRedirects(false).build(); return newClient.targetProxy(baseUri, ResourcesEndpoint.class); } + + @Override + public DatastoreEndpoint getDatastoreEndpoint() { + return client.targetProxy(baseUri, DatastoreEndpoint.class); + } + } diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreEndpoint.java new file mode 100644 index 00000000000..8f51ff13ab3 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreEndpoint.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2015 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.rest.model; + +import javax.annotation.security.RolesAllowed; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.eclipse.osee.framework.jdk.core.type.SystemRoles; + +/** + * @author Roberto E. Escobar + */ +@Path("datastore") +@RolesAllowed(SystemRoles.ROLES_AUTHENTICATED) +public interface DatastoreEndpoint { + + @GET + @Path("info") + @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + DatastoreInfo getInfo(); + + @POST + @Path("initialize") + @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + Response initialize(DatastoreInitOptions options); + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreInfo.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreInfo.java new file mode 100644 index 00000000000..9fc583be21a --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreInfo.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2015 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.rest.model; + +import java.util.Collections; +import java.util.Map; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author Roberto E. Escobar + */ +@XmlRootElement +public class DatastoreInfo { + + private Map<String, String> properties; + + public Map<String, String> getProperties() { + return properties != null ? properties : Collections.<String, String> emptyMap(); + } + + public void setProperties(Map<String, String> data) { + this.properties = data; + } + +} diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/DatastoreInitRequest.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreInitOptions.java index 1b2bfc7599e..2d851c214af 100644 --- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/DatastoreInitRequest.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/DatastoreInitOptions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Boeing. + * Copyright (c) 2015 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 @@ -8,20 +8,19 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.core.message; +package org.eclipse.osee.orcs.rest.model; -public class DatastoreInitRequest { +import javax.xml.bind.annotation.XmlRootElement; - private final String tableDataSpace; - private final String indexDataSpace; - private final boolean useFileSpecifiedSchemas; +/** + * @author Roberto E. Escobar + */ +@XmlRootElement +public class DatastoreInitOptions { - public DatastoreInitRequest(String tableDataSpace, String indexDataSpace, boolean useFileSpecifiedSchemas) { - super(); - this.tableDataSpace = tableDataSpace; - this.indexDataSpace = indexDataSpace; - this.useFileSpecifiedSchemas = useFileSpecifiedSchemas; - } + private String tableDataSpace; + private String indexDataSpace; + private boolean useFileSpecifiedSchemas; public String getTableDataSpace() { return tableDataSpace; @@ -34,4 +33,17 @@ public class DatastoreInitRequest { public boolean isUseFileSpecifiedSchemas() { return useFileSpecifiedSchemas; } + + public void setTableDataSpace(String tableDataSpace) { + this.tableDataSpace = tableDataSpace; + } + + public void setIndexDataSpace(String indexDataSpace) { + this.indexDataSpace = indexDataSpace; + } + + public void setUseFileSpecifiedSchemas(boolean useFileSpecifiedSchemas) { + this.useFileSpecifiedSchemas = useFileSpecifiedSchemas; + } + } diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/DatastoreEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/DatastoreEndpointImpl.java new file mode 100644 index 00000000000..6d134b045bf --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/DatastoreEndpointImpl.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2015 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.rest.internal; + +import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.executeCallable; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Callable; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import org.eclipse.osee.orcs.ApplicationContext; +import org.eclipse.osee.orcs.OrcsAdmin; +import org.eclipse.osee.orcs.OrcsApi; +import org.eclipse.osee.orcs.OrcsMetaData; +import org.eclipse.osee.orcs.rest.model.DatastoreEndpoint; +import org.eclipse.osee.orcs.rest.model.DatastoreInfo; +import org.eclipse.osee.orcs.rest.model.DatastoreInitOptions; + +/** + * @author Roberto E. Escobar + */ +public class DatastoreEndpointImpl implements DatastoreEndpoint { + + private final OrcsApi orcsApi; + + @Context + private UriInfo uriInfo; + + public DatastoreEndpointImpl(OrcsApi orcsApi) { + this.orcsApi = orcsApi; + } + + protected void setUriInfo(UriInfo uriInfo) { + this.uriInfo = uriInfo; + } + + protected UriInfo getUriInfo() { + return uriInfo; + } + + private ApplicationContext newContext() { + return new ApplicationContext() { + + @Override + public String getSessionId() { + return null; + } + }; + } + + private OrcsAdmin getOrcsAdmin() { + return orcsApi.getAdminOps(newContext()); + } + + @Override + public DatastoreInfo getInfo() { + OrcsAdmin adminOps = getOrcsAdmin(); + Callable<OrcsMetaData> callable = adminOps.createFetchOrcsMetaData(); + OrcsMetaData metaData = executeCallable(callable); + return asDatastoreInfo(metaData); + } + + @Override + public Response initialize(DatastoreInitOptions options) { + OrcsAdmin adminOps = getOrcsAdmin(); + + Map<String, String> parameters = new HashMap<String, String>(); + parameters.put("schema.table.data.namespace", options.getTableDataSpace()); + parameters.put("schema.index.data.namespace", options.getIndexDataSpace()); + parameters.put("schema.user.file.specified.schema.names", Boolean.toString(options.isUseFileSpecifiedSchemas())); + + Callable<OrcsMetaData> callable = adminOps.createDatastore(parameters); + OrcsMetaData metaData = executeCallable(callable); + + UriInfo uriInfo = getUriInfo(); + URI location = getDatastoreLocation(uriInfo); + return Response.created(location).entity(asDatastoreInfo(metaData)).build(); + } + + private URI getDatastoreLocation(UriInfo uriInfo) { + return uriInfo.getRequestUriBuilder().path("../").path("info").build(); + } + + private DatastoreInfo asDatastoreInfo(OrcsMetaData metaData) { + DatastoreInfo info = new DatastoreInfo(); + info.setProperties(metaData.getProperties()); + return info; + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java index f9ec44e4dc2..7225951287b 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java @@ -57,6 +57,7 @@ public class OrcsApplication extends Application { resources.add(new IndexerEndpointImpl(orcsApi)); resources.add(new ResourcesEndpointImpl(resourceManager)); + resources.add(new DatastoreEndpointImpl(orcsApi)); } public void stop() { diff --git a/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml b/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml index 49fe3520861..f13635336ff 100644 --- a/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml +++ b/plugins/org.eclipse.osee.parent/tools/osee-application-server.xml @@ -102,7 +102,7 @@ </forget> <waitfor maxwait="20" maxwaitunit="second" checkevery="100" checkeveryunit="millisecond"> - <http url="http://127.0.0.1:${xserver-port}/osee/configure/datastore/schema" /> + <http url="http://127.0.0.1:${xserver-port}/orcs/datastore/info" /> </waitfor> </target> |