Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorafinkbein2009-01-14 23:36:16 +0000
committerafinkbein2009-01-14 23:36:16 +0000
commit36fca7df7d259d330e2125e4cac1d97bb2f4f2f6 (patch)
tree6743026ca7ab46e4078f993fb82bb7a08d781749
parentfb447a3fb0045ea8cfc7e03ebf358a47a66a4270 (diff)
downloadorg.eclipse.osee-36fca7df7d259d330e2125e4cac1d97bb2f4f2f6.tar.gz
org.eclipse.osee-36fca7df7d259d330e2125e4cac1d97bb2f4f2f6.tar.xz
org.eclipse.osee-36fca7df7d259d330e2125e4cac1d97bb2f4f2f6.zip
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/.classpath7
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/.project28
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/META-INF/MANIFEST.MF14
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/OSGI-INF/locator.provider.snapshot.xml7
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/build.properties5
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/Activator.java32
-rw-r--r--org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/SnapshotLocatorProvider.java95
8 files changed, 192 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.resource.locator.snapshot/.classpath b/org.eclipse.osee.framework.resource.locator.snapshot/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/.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.locator.snapshot/.project b/org.eclipse.osee.framework.resource.locator.snapshot/.project
new file mode 100644
index 00000000000..8ed1e53b9b7
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.resource.locator.snapshot</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.locator.snapshot/.settings/org.eclipse.pde.core.prefs b/org.eclipse.osee.framework.resource.locator.snapshot/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 00000000000..8760f5abd33
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Tue May 06 18:01:29 MST 2008
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/org.eclipse.osee.framework.resource.locator.snapshot/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.resource.locator.snapshot/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..16bf98ad90c
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Snapshot Locator Plug-in
+Bundle-SymbolicName: org.eclipse.osee.framework.resource.locator.snapshot;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.osee.framework.resource.locator.snapshot.Activator
+Import-Package: org.eclipse.osee.framework.resource.management,
+ org.eclipse.osee.framework.resource.management.exception,
+ org.osgi.framework;version="1.3.0"
+Bundle-ActivationPolicy: lazy
+Service-Component: OSGI-INF/locator.provider.snapshot.xml
+Bundle-Vendor: Boeing
+Export-Package: org.eclipse.osee.framework.resource.locator.snapshot
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/org.eclipse.osee.framework.resource.locator.snapshot/OSGI-INF/locator.provider.snapshot.xml b/org.eclipse.osee.framework.resource.locator.snapshot/OSGI-INF/locator.provider.snapshot.xml
new file mode 100644
index 00000000000..65c265017d4
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/OSGI-INF/locator.provider.snapshot.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="resource.locator.snapshot">
+ <implementation class="org.eclipse.osee.framework.resource.locator.snapshot.SnapshotLocatorProvider"/>
+ <service>
+ <provide interface="org.eclipse.osee.framework.resource.management.IResourceLocatorProvider"/>
+ </service>
+</component> \ No newline at end of file
diff --git a/org.eclipse.osee.framework.resource.locator.snapshot/build.properties b/org.eclipse.osee.framework.resource.locator.snapshot/build.properties
new file mode 100644
index 00000000000..a65755cb2a8
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
diff --git a/org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/Activator.java b/org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/Activator.java
new file mode 100644
index 00000000000..5c1a56274b8
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/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.locator.snapshot;
+
+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.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/SnapshotLocatorProvider.java b/org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/SnapshotLocatorProvider.java
new file mode 100644
index 00000000000..973e200f699
--- /dev/null
+++ b/org.eclipse.osee.framework.resource.locator.snapshot/src/org/eclipse/osee/framework/resource/locator/snapshot/SnapshotLocatorProvider.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.locator.snapshot;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URI;
+import org.eclipse.osee.framework.resource.management.IResourceLocator;
+import org.eclipse.osee.framework.resource.management.IResourceLocatorProvider;
+import org.eclipse.osee.framework.resource.management.ResourceLocator;
+import org.eclipse.osee.framework.resource.management.exception.MalformedLocatorException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class SnapshotLocatorProvider implements IResourceLocatorProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceLocatorProvider#generateResourceLocator(java.lang.String)
+ */
+ @Override
+ public IResourceLocator generateResourceLocator(String seed, String name) throws MalformedLocatorException {
+ URI uri = null;
+ try {
+ uri = new URI(generatePath(seed, name));
+ } catch (Exception ex) {
+ throw new MalformedLocatorException(ex);
+ }
+ return new ResourceLocator(uri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceLocatorProvider#getResourceLocator(java.lang.String)
+ */
+ @Override
+ public IResourceLocator getResourceLocator(String path) throws MalformedLocatorException {
+ URI uri = null;
+ if (isPathValid(path) != false) {
+ try {
+ uri = new URI(path);
+ } catch (Exception ex) {
+ throw new MalformedLocatorException(ex);
+ }
+ } else {
+ throw new MalformedLocatorException(String.format("Invalid path hint: [%s]", path));
+ }
+ return new ResourceLocator(uri);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.resource.management.IResourceLocatorProvider#isValid(java.lang.String)
+ */
+ @Override
+ public boolean isValid(String protocol) {
+ return isArgValid(protocol) != false && protocol.startsWith("snapshot") != false;
+ }
+
+ private boolean isArgValid(String value) {
+ return value != null && value.length() > 0;
+ }
+
+ private boolean isPathValid(String value) {
+ return isArgValid(value) && value.startsWith("snapshot://");
+ }
+
+ private String generatePath(String seed, String name) throws MalformedLocatorException {
+ StringBuilder builder = new StringBuilder("snapshot://");
+ if (isArgValid(seed) != false && isArgValid(name) != false) {
+ try {
+ char[] buffer = new char[3];
+ int cnt = -1;
+ Reader in = new StringReader(seed);
+ while ((cnt = in.read(buffer)) != -1) {
+ builder.append(buffer, 0, cnt);
+ builder.append("/");
+ }
+ } catch (IOException ex) {
+ throw new MalformedLocatorException(ex);
+ }
+ builder.append(name);
+ } else {
+ throw new MalformedLocatorException("Invalid arguments during locator generation.");
+ }
+ return builder.toString();
+ }
+}

Back to the top