Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorafinkbein2008-12-01 16:54:42 +0000
committerafinkbein2008-12-01 16:54:42 +0000
commitac740cbc79c1ac1ce94cce32e6a6f8e0b6851f6a (patch)
tree4589a45e5919b66108c9c9c026412df057ec71f7
parent6e35d4f22653e5f6baf51999b5fd562fac4e5905 (diff)
downloadorg.eclipse.osee-ac740cbc79c1ac1ce94cce32e6a6f8e0b6851f6a.tar.gz
org.eclipse.osee-ac740cbc79c1ac1ce94cce32e6a6f8e0b6851f6a.tar.xz
org.eclipse.osee-ac740cbc79c1ac1ce94cce32e6a6f8e0b6851f6a.zip
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/.classpath7
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/.project28
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/META-INF/MANIFEST.MF16
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/OSGI-INF/attribute.provider.xml7
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/build.properties5
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/Activator.java32
-rw-r--r--org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/AttributeProvider.java120
8 files changed, 219 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.resource.provider.attribute/.classpath b/org.eclipse.osee.framework.resource.provider.attribute/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/.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/org.eclipse.osee.framework.resource.provider.attribute/.project b/org.eclipse.osee.framework.resource.provider.attribute/.project
new file mode 100644
index 00000000000..1cb44dfe3da
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.resource.provider.attribute</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/org.eclipse.osee.framework.resource.provider.attribute/.settings/org.eclipse.pde.core.prefs b/org.eclipse.osee.framework.resource.provider.attribute/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 00000000000..61a36bc3b0e
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Mon Apr 14 16:13:43 MST 2008
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/org.eclipse.osee.framework.resource.provider.attribute/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.resource.provider.attribute/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..00dcf27fd61
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Attribute Provider Plug-in
+Bundle-SymbolicName: org.eclipse.osee.framework.resource.provider.attribute
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.osee.framework.resource.provider.attribute.Activator
+Bundle-Vendor: Boeing
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.osee.framework.core.server,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.resource.provider.common,
+ org.osgi.framework;version="1.3.0"
+Service-Component: OSGI-INF/attribute.provider.xml
+Export-Package: org.eclipse.osee.framework.resource.provider.attribute
+Require-Bundle: org.eclipse.osee.framework.resource.management
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.osee.framework.resource.provider.attribute/OSGI-INF/attribute.provider.xml b/org.eclipse.osee.framework.resource.provider.attribute/OSGI-INF/attribute.provider.xml
new file mode 100644
index 00000000000..221393fb7d6
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/OSGI-INF/attribute.provider.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="attribute.resource.provider">
+ <implementation class="org.eclipse.osee.framework.resource.provider.attribute.AttributeProvider"/>
+ <service>
+ <provide interface="org.eclipse.osee.framework.resource.management.IResourceProvider"/>
+ </service>
+</component> \ No newline at end of file
diff --git a/org.eclipse.osee.framework.resource.provider.attribute/build.properties b/org.eclipse.osee.framework.resource.provider.attribute/build.properties
new file mode 100644
index 00000000000..a65755cb2a8
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
diff --git a/org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/Activator.java b/org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/Activator.java
new file mode 100644
index 00000000000..58ad48a1862
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/Activator.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.resource.provider.attribute;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
diff --git a/org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/AttributeProvider.java b/org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/AttributeProvider.java
new file mode 100644
index 00000000000..f71933b7846
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.provider.attribute/src/org/eclipse/osee/framework/resource/provider/attribute/AttributeProvider.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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.resource.provider.attribute;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.eclipse.osee.framework.core.server.OseeServerProperties;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.framework.resource.management.IResourceLocator;
+import org.eclipse.osee.framework.resource.management.IResourceManager;
+import org.eclipse.osee.framework.resource.management.IResourceProvider;
+import org.eclipse.osee.framework.resource.management.Options;
+import org.eclipse.osee.framework.resource.provider.common.OptionsProcessor;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeProvider implements IResourceProvider {
+ private static final String SUPPORTED_PROTOCOL = "attr";
+ private static String BASE_PATH = null;
+
+ public AttributeProvider() {
+ BASE_PATH = OseeServerProperties.getOseeApplicationServerData();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceProvider#isValid(org.eclipse.osee.framework.resource.management.IResourceLocator)
+ */
+ public boolean isValid(IResourceLocator locator) {
+ return locator != null && locator.getProtocol().equals(SUPPORTED_PROTOCOL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceProvider#delete(org.eclipse.osee.framework.resource.management.IResourceLocator)
+ */
+ public int delete(IResourceLocator locator) throws Exception {
+ int toReturn = IResourceManager.FAIL;
+ File file = new File(resolve(locator));
+ if (file == null || file.exists() != true) {
+ toReturn = IResourceManager.RESOURCE_NOT_FOUND;
+ } else if (file.exists() == true && file.canWrite() == true) {
+ boolean result = Lib.deleteFileAndEmptyParents(BASE_PATH, file);
+ if (result) {
+ toReturn = IResourceManager.OK;
+ }
+ }
+ return toReturn;
+ }
+
+ private URI resolve(IResourceLocator locator) throws URISyntaxException {
+ StringBuilder builder = new StringBuilder(BASE_PATH + File.separator + SUPPORTED_PROTOCOL + File.separator);
+ builder.append(locator.getRawPath());
+ return new File(builder.toString()).toURI();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceProvider#acquire(org.eclipse.osee.framework.resource.management.IResourceLocator, org.eclipse.osee.framework.resource.management.Options)
+ */
+ @Override
+ public IResource acquire(IResourceLocator locator, Options options) throws Exception {
+ IResource toReturn = null;
+ OptionsProcessor optionsProcessor = new OptionsProcessor(resolve(locator), locator, null, options);
+ toReturn = optionsProcessor.getResourceToServer();
+ return toReturn;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceProvider#save(org.eclipse.osee.framework.resource.management.IResourceLocator, org.eclipse.osee.framework.resource.management.IResource, org.eclipse.osee.framework.resource.management.Options)
+ */
+ @Override
+ public IResourceLocator save(IResourceLocator locator, IResource resource, Options options) throws Exception {
+ IResourceLocator toReturn = null;
+ OptionsProcessor optionsProcessor = new OptionsProcessor(resolve(locator), locator, resource, options);
+ OutputStream outputStream = null;
+ InputStream inputStream = null;
+ try {
+ File storageFile = optionsProcessor.getStorageFile();
+ IResource resourceToStore = optionsProcessor.getResourceToStore();
+
+ outputStream = new FileOutputStream(storageFile);
+ inputStream = resourceToStore.getContent();
+ Lib.inputStreamToOutputStream(inputStream, outputStream);
+ toReturn = optionsProcessor.getActualResouceLocator();
+ } finally {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ if (toReturn == null) {
+ throw new IllegalStateException(String.format("We failed to save resource %s.", locator.getLocation()));
+ }
+ return toReturn;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceProvider#exists(org.eclipse.osee.framework.resource.management.IResourceLocator)
+ */
+ @Override
+ public boolean exists(IResourceLocator locator) throws Exception {
+ URI uri = resolve(locator);
+ File testFile = new File(uri);
+ return testFile.exists();
+ }
+}

Back to the top