diff options
author | Andrew M Finkbeiner | 2013-03-21 21:46:56 +0000 |
---|---|---|
committer | donald.g.dunne | 2013-03-27 19:21:42 +0000 |
commit | efc2a587ad3585880e35a65b446ecafc122955de (patch) | |
tree | 652aeb6e81072aaf5eb5ffa2fce60fcc2f37097d /plugins/org.eclipse.osee.ote.rest | |
parent | 44f4e9a833acf2a2571d96cd856857cf65f0713e (diff) | |
download | org.eclipse.osee-efc2a587ad3585880e35a65b446ecafc122955de.tar.gz org.eclipse.osee-efc2a587ad3585880e35a65b446ecafc122955de.tar.xz org.eclipse.osee-efc2a587ad3585880e35a65b446ecafc122955de.zip |
feature[ats_5Z6FP]: Fix up some of the rest API
Change-Id: Ide9db8324d4d7bcd7b21dbf4ca7f281d17df2f7c
Diffstat (limited to 'plugins/org.eclipse.osee.ote.rest')
6 files changed, 107 insertions, 16 deletions
diff --git a/plugins/org.eclipse.osee.ote.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.rest/META-INF/MANIFEST.MF index 5b693498bd3..56c5cefd65b 100644 --- a/plugins/org.eclipse.osee.ote.rest/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ote.rest/META-INF/MANIFEST.MF @@ -9,14 +9,8 @@ Service-Component: OSGI-INF/*.xml Import-Package: javax.ws.rs, javax.ws.rs.core, javax.ws.rs.ext, - org.eclipse.core.resources, - 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.core.model.cache, - org.eclipse.osee.framework.core.util, org.eclipse.osee.ote, org.eclipse.osee.ote.rest.model -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.osee.framework.jdk.core;bundle-version="0.11.0" +Require-Bundle: org.eclipse.osee.framework.jdk.core;bundle-version="0.11.0", + org.eclipse.core.runtime diff --git a/plugins/org.eclipse.osee.ote.rest/build.properties b/plugins/org.eclipse.osee.ote.rest/build.properties index 9b4616ae0ea..168d2dd5dc5 100644 --- a/plugins/org.eclipse.osee.ote.rest/build.properties +++ b/plugins/org.eclipse.osee.ote.rest/build.properties @@ -5,9 +5,3 @@ bin.includes = META-INF/,\ OSGI-INF/ote.configuration.store.xml,\ OSGI-INF/ote.job.store.xml source.. = src/ -additional.bundles = org.eclipse.osee.orcs,\ - javax.ws.rs,\ - org.eclipse.osee.framework.core.model,\ - org.eclipse.osee.framework.core,\ - org.eclipse.osee.framework.jdk.core,\ - org.eclipse.osee.orcs.rest.model diff --git a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteConfigurationStoreImpl.java b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteConfigurationStoreImpl.java index 9ccf4ebae8e..6d313cc3e29 100644 --- a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteConfigurationStoreImpl.java +++ b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteConfigurationStoreImpl.java @@ -42,7 +42,7 @@ public class OteConfigurationStoreImpl implements OteConfigurationStore { @Override public OteJobStatus setup(OteConfiguration config, UriInfo uriInfo) throws InterruptedException, ExecutionException, MalformedURLException, IllegalArgumentException, UriBuilderException { - OTEConfiguration realConfig = config.translateToOtherConfig(); + OTEConfiguration realConfig = TranslateUtil.translateToOtherConfig(config); ConfigurationJobStatus status = createConfigurationJobStatus(config, uriInfo); OTEFuture<OTEConfigurationStatus> future = ote.loadConfiguration(realConfig, status); status.setFuture(future); @@ -75,7 +75,7 @@ public class OteConfigurationStoreImpl implements OteConfigurationStore { OTEFuture<OTEConfigurationStatus> future = ote.getConfiguration(); status.setFuture(future); if(future.isDone()){ - return new OteConfiguration(future.get().getConfiguration()); + return TranslateUtil.translateConfig(future.get().getConfiguration()); } else { return new OteConfiguration(); } diff --git a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteFilesResource.java b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteFilesResource.java new file mode 100644 index 00000000000..0deb2b777d1 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteFilesResource.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.ote.rest.internal; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Request; +import javax.ws.rs.core.StreamingOutput; +import javax.ws.rs.core.UriInfo; + +import org.eclipse.osee.framework.core.exception.OseeCoreException; + +/** + * @author Andrew M. Finkbeiner + */ +@Path("file") +public class OteFilesResource { + + // Allows to insert contextual objects into the class, + // e.g. ServletContext, Request, Response, UriInfo + @Context + UriInfo uriInfo; + @Context + Request request; + + @GET + @Produces(MediaType.APPLICATION_XML) + public StreamingOutput getFile(@QueryParam("path") String path ) throws OseeCoreException { + final String myPath = path; + return new StreamingOutput() { + public void write(OutputStream output) throws IOException, WebApplicationException { + try { + File file = new File(myPath); + InputStream is = new FileInputStream(file); + byte[] bytes = new byte[2048]; + int numRead = 0; + while((numRead = is.read(bytes)) != -1){ + output.write(bytes, 0, numRead); + } + is.close(); + } catch (Exception e) { + throw new WebApplicationException(e); + } + } + }; + } + +} diff --git a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRestApplication.java b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRestApplication.java index dfb988ca60d..eea60588e9e 100644 --- a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRestApplication.java +++ b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/OteRestApplication.java @@ -40,6 +40,7 @@ public class OteRestApplication extends Application { classes.add(OseeCoreExceptionMapper.class); classes.add(OteConfigurationResource.class); classes.add(OteJobsResource.class); + classes.add(OteFilesResource.class); return classes; } diff --git a/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/TranslateUtil.java b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/TranslateUtil.java new file mode 100644 index 00000000000..58337ae9196 --- /dev/null +++ b/plugins/org.eclipse.osee.ote.rest/src/org/eclipse/osee/ote/rest/internal/TranslateUtil.java @@ -0,0 +1,35 @@ +package org.eclipse.osee.ote.rest.internal; + +import org.eclipse.osee.ote.OTEConfiguration; +import org.eclipse.osee.ote.OTEConfigurationItem; +import org.eclipse.osee.ote.rest.model.OteConfiguration; +import org.eclipse.osee.ote.rest.model.OteConfigurationItem; + +public class TranslateUtil { + + public static OTEConfiguration translateToOtherConfig(OteConfiguration restConfig) { + OTEConfiguration config = new OTEConfiguration(); + for(OteConfigurationItem item:restConfig.getItems()){ + config.addItem(TranslateUtil.translateToOtherConfig(item)); + } + return config; + } + + public static OTEConfigurationItem translateToOtherConfig(OteConfigurationItem restConfigItem) { + return new OTEConfigurationItem(restConfigItem.getLocationUrl(), restConfigItem.getBundleVersion(), restConfigItem.getBundleName(), restConfigItem.getMd5Digest()); + } + + public static OteConfiguration translateConfig(OTEConfiguration config){ + OteConfiguration restConfig = new OteConfiguration(); + for(OTEConfigurationItem item:config.getItems()){ + OteConfigurationItem newitem = new OteConfigurationItem(); + newitem.setBundleName(item.getSymbolicName()); + newitem.setBundleVersion(item.getVersion()); + newitem.setLocationUrl(item.getLocationUrl()); + newitem.setMd5Digest(item.getMd5Digest()); + restConfig.addItem(newitem); + } + return restConfig; + } + +} |