You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by rl...@apache.org on 2013/10/18 01:06:11 UTC
svn commit: r1533284 [1/3] - in /oodt/trunk: ./ webapp/fmprod/
webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/
webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/
webapp/fmprod/src/main/java/org/apache/oodt/cas/...
Author: rlaidlaw
Date: Thu Oct 17 23:06:09 2013
New Revision: 1533284
URL: http://svn.apache.org/r1533284
Log:
OODT-612, OODT-613: JAX-RS package using Apache CXF, GSoC 2013 project. Removed services package (superceded by jaxrs package).
Added:
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RdfConfiguration.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssConfiguration.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssNamespace.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTag.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTagAttribute.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/BadRequestException.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/InternalServerErrorException.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/NotFoundException.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/BackwardsCompatibleInterceptor.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResource.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResource.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResource.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResource.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/CasProductJaxrsService.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/services/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/servlets/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/servlets/CasProductJaxrsServlet.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/servlets/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/DatasetRdfWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/DatasetRssWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/DatasetZipWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/DatasetZipper.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/ProductRssWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/ProductZipWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/ProductZipper.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/RdfWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/ReferenceFileWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/ReferenceRssWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/ReferenceZipWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/RssWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/TransfersRssWriter.java (with props)
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/writers/package-info.java (with props)
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResourceTest.java (with props)
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResourceTest.java (with props)
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResourceTest.java (with props)
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResourceTest.java (with props)
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResourceTest.java (with props)
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResourceTest.java (with props)
Removed:
oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/service/
oodt/trunk/webapp/fmprod/src/test/java/org/apache/oodt/cas/product/service/
oodt/trunk/webapp/fmprod/src/test/resources/filemgr/
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/webapp/fmprod/pom.xml
oodt/trunk/webapp/fmprod/src/main/resources/georss-config.xml
oodt/trunk/webapp/fmprod/src/main/resources/logging.properties
oodt/trunk/webapp/fmprod/src/main/resources/rdfconf.xml
oodt/trunk/webapp/fmprod/src/main/resources/rss-transfer-conf.xml
oodt/trunk/webapp/fmprod/src/main/resources/rssconf.xml
oodt/trunk/webapp/fmprod/src/main/webapp/META-INF/context.xml
oodt/trunk/webapp/fmprod/src/main/webapp/WEB-INF/web.xml
oodt/trunk/webapp/fmprod/src/test/resources/test.logging.properties
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1533284&r1=1533283&r2=1533284&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Thu Oct 17 23:06:09 2013
@@ -3,6 +3,11 @@ Apache OODT Change Log
Release 0.7 - Current Development
---------------------------------
+* OODT-613 CAS Product web application - configurable content writers for RDF
+ and RSS (rlaidlaw)
+
+* OODT-612 CAS Product web application - add content writers for XML, JSON, RDF,
+ RSS (rlaidlaw)
* OODT-652 New TikaCmdLineMetExtractor (riverma)
Modified: oodt/trunk/webapp/fmprod/pom.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/pom.xml?rev=1533284&r1=1533283&r2=1533284&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/pom.xml (original)
+++ oodt/trunk/webapp/fmprod/pom.xml Thu Oct 17 23:06:09 2013
@@ -28,7 +28,7 @@
</parent>
<artifactId>cas-product</artifactId>
<packaging>war</packaging>
- <name>CAS Product Server</name>
+ <name>CAS Product Server Web Application</name>
<description>
This project builds on top of the CAS file management component and exposes
its underlying data delivery capabilities using the OODT ProductServer
@@ -40,8 +40,8 @@
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<plugins>
<!--
- For plugins by Maven we don't need a groupId specification because
- the groupId org.apache.maven.plugins is assumed by default.
+ For plugins by Maven we don't need to specify a groupId because the
+ groupId org.apache.maven.plugins is assumed by default.
-->
<plugin>
<artifactId>maven-war-plugin</artifactId>
@@ -121,6 +121,11 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.2.5</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>0.8</version>
@@ -141,6 +146,16 @@
<version>1.3.1</version>
</dependency>
<dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ <version>2.6.8</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>2.6.8</version>
@@ -163,5 +178,16 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
+ </dependency>
</dependencies>
</project>
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RdfConfiguration.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RdfConfiguration.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RdfConfiguration.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RdfConfiguration.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,188 @@
+package org.apache.oodt.cas.product.jaxrs.configurations;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.oodt.commons.xml.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Class representing custom configurations for RDF XML outputs.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class RdfConfiguration
+{
+ // Constants used to identify items in the configuration file.
+ private static final String RDF_RES_ATTR = "rdf:resource";
+ private static final String NS_OUTER = "namespaces";
+ private static final String NS_INNER = "ns";
+ private static final String NS_KEY = "name";
+ private static final String NS_VALUE = "value";
+ private static final String REWRITE_OUTER = "rewrite";
+ private static final String REWRITE_INNER = "key";
+ private static final String REWRITE_KEY = "from";
+ private static final String REWRITE_VALUE = "to";
+ private static final String RESLINK_OUTER = "resourcelinks";
+ private static final String RESLINK_INNER = "key";
+ private static final String RESLINK_KEY = "name";
+ private static final String RESLINK_VALUE = "link";
+ private static final String KEY_OUTER = "keynsmap";
+ private static final String KEY_INNER = "key";
+ private static final String KEY_KEY = "name";
+ private static final String KEY_VALUE = "ns";
+ private static final String KEY_DEFAULT = "default";
+ private static final String TYPE_OUTER = "typesnsmap";
+ private static final String TYPE_INNER = "type";
+ private static final String TYPE_KEY = "name";
+ private static final String TYPE_VALUE = "ns";
+ private static final String TYPE_DEFAULT = "default";
+
+ private Map<String, String> nsMap = new HashMap<String, String>();
+ private Map<String, String> rewriteMap = new HashMap<String, String>();
+ private Map<String, String> resLinkMap = new HashMap<String, String>();
+ private Map<String, String> keyNsMap = new HashMap<String, String>();
+ private Map<String, String> typesNsMap = new HashMap<String, String>();
+ private String defaultKeyNs = null;
+ private String defaultTypeNs = null;
+
+
+
+ /**
+ * Initializes the parameters in the configuration object using values from
+ * the supplied file.
+ * @param file the configuration file
+ * @throws IOException if the file does not exist and cannot be read
+ */
+ public void initialize(File file) throws IOException
+ {
+ FileInputStream fis = new FileInputStream(file);
+ Document doc = XMLUtils.getDocumentRoot(fis);
+ Element root = doc.getDocumentElement();
+
+ nsMap = readConfiguration(root,
+ NS_OUTER, NS_INNER, NS_KEY, NS_VALUE);
+
+ rewriteMap = readConfiguration(root,
+ REWRITE_OUTER, REWRITE_INNER, REWRITE_KEY, REWRITE_VALUE);
+
+ resLinkMap = readConfiguration(root,
+ RESLINK_OUTER, RESLINK_INNER, RESLINK_KEY, RESLINK_VALUE);
+
+ keyNsMap = readConfiguration(root,
+ KEY_OUTER, KEY_INNER, KEY_KEY, KEY_VALUE);
+
+ typesNsMap = readConfiguration(root,
+ TYPE_OUTER, TYPE_INNER, TYPE_KEY, TYPE_VALUE);
+
+ Element keyNsRoot = XMLUtils.getFirstElement(KEY_OUTER, root);
+ defaultKeyNs = keyNsRoot.getAttribute(KEY_DEFAULT);
+
+ Element typeNsRoot = XMLUtils.getFirstElement(TYPE_OUTER, root);
+ defaultTypeNs = typeNsRoot.getAttribute(TYPE_DEFAULT);
+
+ fis.close();
+ }
+
+
+
+ private Map<String, String> readConfiguration(Element element,
+ String outerTag, String innerTag, String key, String value)
+ {
+ Map<String, String> map = new HashMap<String, String>();
+
+ Element outer = XMLUtils.getFirstElement(outerTag, element);
+ NodeList nodeList = outer.getElementsByTagName(innerTag);
+ if (nodeList != null && nodeList.getLength() > 0)
+ {
+ for (int i = 0; i < nodeList.getLength(); i++)
+ {
+ Element inner = (Element) nodeList.item(i);
+ map.put(inner.getAttribute(key), inner.getAttribute(value));
+ }
+ }
+
+ return map;
+ }
+
+
+
+ /**
+ * Gets the namespace map for the configuration.
+ * @return the namespace map for the configuration
+ */
+ public Map<String, String> getNamespaces()
+ {
+ return nsMap;
+ }
+
+
+
+ /**
+ * Gets the requested value from the key namespace map if it is found,
+ * otherwise gets the default key namespace.
+ * @param key the map key to use for retrieving the namespace
+ * @return the namespace value for the map key if found, otherwise the default
+ * namespace
+ */
+ public String getKeyNamespace(String key)
+ {
+ return keyNsMap.containsKey(key) ? keyNsMap.get(key) : defaultKeyNs;
+ }
+
+
+
+ /**
+ * Gets the requested value from the type namespace map if it is found,
+ * otherwise gets the default type namespace.
+ * @param key the map key to use for retrieving the namespace
+ * @return the namespace value for the map key if found, otherwise the default
+ * namespace
+ */
+ public String getTypeNamespace(String key)
+ {
+ return typesNsMap.containsKey(key) ? typesNsMap.get(key) : defaultTypeNs;
+ }
+
+
+
+ /**
+ * Creates an {@link Element} for a {@link Document}.
+ * @param key a map key used to search this configuration's maps
+ * @param value the value for the element
+ * @param document the document context of the element
+ * @return a new element constructed within the rules and constraints of this
+ * configuration
+ */
+ public Element createElement(String key, String value, Document document)
+ {
+ // Apply the rewrite rules.
+ String tagName = rewriteMap.containsKey(key) ? rewriteMap.get(key) : key;
+
+ // Get the tag's namespace or the default namespace.
+ String namespace = keyNsMap.containsKey(key)
+ ? keyNsMap.get(key) : defaultKeyNs;
+
+ // Create the element.
+ Element element = null;
+ if (resLinkMap.containsKey(key))
+ {
+ element = document.createElement(namespace + ":" + tagName);
+ String linkBase = resLinkMap.get(key);
+ linkBase += linkBase.endsWith("/") ? "" : "/";
+ element.setAttribute(RDF_RES_ATTR, linkBase + value);
+ }
+ else
+ {
+ element = document.createElement(namespace + ":" + tagName);
+ element.appendChild(document.createTextNode(value));
+ }
+
+ return element;
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RdfConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssConfiguration.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssConfiguration.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssConfiguration.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssConfiguration.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,168 @@
+package org.apache.oodt.cas.product.jaxrs.configurations;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Vector;
+
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+import org.apache.oodt.commons.xml.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Class representing custom configurations for RSS XML outputs.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class RssConfiguration
+{
+ private static final String CHANNEL_LINK = "channelLink";
+ private static final String NAMESPACE = "namespace";
+ private static final String NAMESPACE_KEY = "prefix";
+ private static final String NAMESPACE_VALUE = "uri";
+ private static final String TAG = "tag";
+ private static final String TAG_NAME = "name";
+ private static final String TAG_SOURCE = "source";
+ private static final String ATTRIBUTE = "attribute";
+ private static final String ATTRIBUTE_NAME = "name";
+ private static final String ATTRIBUTE_VALUE = "value";
+
+ private List<RssNamespace> namespaceList = new Vector<RssNamespace>();
+ private List<RssTag> tagList = new Vector<RssTag>();
+ private String channelLink = null;
+
+
+
+ /**
+ * Initializes the parameters in the configuration object using values from
+ * the supplied file.
+ * @param file the configuration file
+ * @throws IOException if the file does not exist and cannot be read
+ */
+ public void initialize(File file) throws IOException
+ {
+ FileInputStream fis = new FileInputStream(file);
+ Document document = XMLUtils.getDocumentRoot(fis);
+ Element root = document.getDocumentElement();
+
+ channelLink = root.getAttribute(CHANNEL_LINK);
+ namespaceList = readNamespaces(root);
+ tagList = readTags(root);
+
+ fis.close();
+ }
+
+
+
+ private List<RssNamespace> readNamespaces(Element root)
+ {
+ List<RssNamespace> namespaces = new Vector<RssNamespace>();
+ NodeList nodeList = root.getElementsByTagName(NAMESPACE);
+ if (nodeList != null && nodeList.getLength() > 0)
+ {
+ for (int i = 0; i < nodeList.getLength(); i++)
+ {
+ Element element = (Element) nodeList.item(i);
+ namespaces.add(new RssNamespace(element.getAttribute(NAMESPACE_KEY),
+ element.getAttribute(NAMESPACE_VALUE)));
+ }
+ }
+ return namespaces;
+ }
+
+
+
+ private List<RssTag> readTags(Element root)
+ {
+ List<RssTag> tags = new Vector<RssTag>();
+ NodeList list = root.getElementsByTagName(TAG);
+ if (list != null && list.getLength() > 0)
+ {
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Element element = (Element) list.item(i);
+ tags.add(new RssTag(element.getAttribute(TAG_NAME),
+ element.getAttribute(TAG_SOURCE), readAttributes(element)));
+ }
+ }
+ return tags;
+ }
+
+
+
+ private List<RssTagAttribute> readAttributes(Element element)
+ {
+ List<RssTagAttribute> attributes = new Vector<RssTagAttribute>();
+ NodeList nodeList = element.getElementsByTagName(ATTRIBUTE);
+ if (nodeList != null && nodeList.getLength() > 0)
+ {
+ for (int i = 0; i < nodeList.getLength(); i++)
+ {
+ Element attribute = (Element) nodeList.item(i);
+ attributes.add(new RssTagAttribute(
+ attribute.getAttribute(ATTRIBUTE_NAME),
+ attribute.getAttribute(ATTRIBUTE_VALUE)));
+ }
+ }
+ return attributes;
+ }
+
+
+
+ /**
+ * Gets the list of namespaces.
+ * @return the list of namespaces
+ */
+ public List<RssNamespace> getNamespaceList()
+ {
+ return namespaceList;
+ }
+
+
+
+ /**
+ * Gets the channel link URL string.
+ * @return the channel link URL string
+ */
+ public String getChannelLink()
+ {
+ return channelLink;
+ }
+
+
+
+ /**
+ * Appends elements (tags) defined in a configuration file to a specific
+ * parent element.
+ * @param metadata the metadata for the product
+ * @param document the document to which these elements belong
+ * @param parent the parent element to attach these elements to
+ */
+ public void appendTags(Metadata metadata, Document document,
+ Element parent)
+ {
+ for (RssTag tag : tagList)
+ {
+ // Create a new element for the tag.
+ Element element = XMLUtils.addNode(document, parent, tag.getName());
+
+ // Add a value for the tag from the tag source.
+ if (tag.getSource() != null)
+ {
+ element.appendChild(document.createTextNode(PathUtils
+ .replaceEnvVariables(tag.getSource(), metadata)));
+ }
+
+ // Add attributes to the tag as defined in the configuration.
+ for (RssTagAttribute attribute : tag.getAttributes())
+ {
+ element.setAttribute(attribute.getName(), PathUtils.replaceEnvVariables(
+ attribute.getValue(), metadata));
+ }
+ }
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssNamespace.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssNamespace.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssNamespace.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssNamespace.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,46 @@
+
+package org.apache.oodt.cas.product.jaxrs.configurations;
+
+/**
+ * Represents an XML namespace for RSS XML content.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class RssNamespace
+{
+ private String prefix;
+ private String uriString;
+
+ /**
+ * Creates an RssNamespace object and sets the prefix and uri string.
+ * @param prefix the namespace prefix
+ * @param uriString the namespace URI as a String
+ */
+ public RssNamespace(String prefix, String uriString)
+ {
+ this.prefix = prefix;
+ this.uriString = uriString;
+ }
+
+
+
+ /**
+ * Gets the prefix for the namespace.
+ * @return the prefix for the namespace
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+
+
+ /**
+ * Gets the URI for the namespace as a String
+ * @return the URI for the namespace as a String
+ */
+ public String getUriString()
+ {
+ return uriString;
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTag.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTag.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTag.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTag.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,63 @@
+package org.apache.oodt.cas.product.jaxrs.configurations;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * Represents an RSS XML tag to include in an RSS feed.
+ * @author mattmann
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class RssTag
+{
+ private String name = null;
+ private String source = null;
+ private List<RssTagAttribute> attributes = new Vector<RssTagAttribute>();
+
+ /**
+ * Creates an RssTag object and sets the name, source and attributes.
+ * @param name the name for the tag
+ * @param source the source for the tag
+ * @param attributes the attributes for the tag
+ */
+ public RssTag(String name, String source, List<RssTagAttribute> attributes)
+ {
+ this.name = name;
+ this.source = source;
+ this.attributes = attributes;
+ }
+
+
+
+ /**
+ * Gets the name for the tag.
+ * @return the name for the tag
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+
+ /**
+ * Gets the source for the tag.
+ * @return the source for the tag
+ */
+ public String getSource()
+ {
+ return source;
+ }
+
+
+
+ /**
+ * Gets the attributes for the tag.
+ * @return the attributes for the tag
+ */
+ public List<RssTagAttribute> getAttributes()
+ {
+ return attributes;
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTagAttribute.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTagAttribute.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTagAttribute.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTagAttribute.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,44 @@
+package org.apache.oodt.cas.product.jaxrs.configurations;
+
+/**
+ * Represents an attribute for an RSS XML tag.
+ * @author mattmann
+ * @author rlaidlaw
+ * @version $Revision$
+*/
+public class RssTagAttribute
+{
+ private String name;
+ private String value;
+
+ /**
+ * Creates an RssTagAttribute and sets the name and value.
+ * @param name the name of the attribute
+ * @param value the value for the attribute
+ */
+ public RssTagAttribute(String name, String value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Gets the name of the attribute.
+ * @return the name of the attribute
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+
+ /**
+ * Gets the value of the attribute.
+ * @return the value of the attribute
+ */
+ public String getValue()
+ {
+ return value;
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/RssTagAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/package-info.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/package-info.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/package-info.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/package-info.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * Contains classes that are used to add custom configurations to outputs.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+package org.apache.oodt.cas.product.jaxrs.configurations;
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/configurations/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/BadRequestException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/BadRequestException.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/BadRequestException.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/BadRequestException.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.exceptions;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * This type of exception returns an HTTP 'bad request' response (status code
+ * 400) with an additional message.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class BadRequestException extends WebApplicationException
+{
+ // Auto-generated ID for serialization.
+ private static final long serialVersionUID = -705065311316100022L;
+
+ /**
+ * Constructor that adds a message to the 'bad request' (status code 400)
+ * HTTP response.
+ * @param message the message to add to the response
+ */
+ public BadRequestException(String message)
+ {
+ super(Response.status(Response.Status.BAD_REQUEST).entity(message)
+ .type(MediaType.TEXT_PLAIN).build());
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/BadRequestException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/InternalServerErrorException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/InternalServerErrorException.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/InternalServerErrorException.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/InternalServerErrorException.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.exceptions;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * This type of exception returns an HTTP 'internal server error' response
+ * (status code 500) with an additional message.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class InternalServerErrorException extends WebApplicationException
+{
+ // Auto-generated ID for serialization.
+ private static final long serialVersionUID = -6132240509391531373L;
+
+ /**
+ * Constructor that adds a message to the 'internal server error' (status code
+ * 500) HTTP response.
+ * @param message the message to add to the response
+ */
+ public InternalServerErrorException(String message)
+ {
+ super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message)
+ .type(MediaType.TEXT_PLAIN).build());
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/InternalServerErrorException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/NotFoundException.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/NotFoundException.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/NotFoundException.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/NotFoundException.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.exceptions;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+/**
+ * This type of exception returns an HTTP 'not found' response (status code 404)
+ * with an additional message.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class NotFoundException extends WebApplicationException
+{
+ // Auto-generated ID for serialization.
+ private static final long serialVersionUID = -3835077083758525919L;
+
+ /**
+ * Constructor that adds a message to the 'not found' (status code 404)
+ * HTTP response.
+ * @param message the message to add to the response
+ */
+ public NotFoundException(String message)
+ {
+ super(Response.status(Response.Status.NOT_FOUND).entity(message)
+ .type(MediaType.TEXT_PLAIN).build());
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/NotFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/package-info.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/package-info.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/package-info.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/package-info.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * Contains classes that extend javax.ws.rs.WebApplicationException to provide
+ * specific response status codes and messages.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+package org.apache.oodt.cas.product.jaxrs.exceptions;
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/exceptions/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/BackwardsCompatibleInterceptor.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/BackwardsCompatibleInterceptor.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/BackwardsCompatibleInterceptor.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/BackwardsCompatibleInterceptor.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,119 @@
+package org.apache.oodt.cas.product.jaxrs.filters;
+
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+
+/**
+ * An Apache CXF interceptor for the incoming chain that monitors request URIs
+ * and maps any URIs from the original scheme to the new scheme.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class BackwardsCompatibleInterceptor extends
+ AbstractPhaseInterceptor<Message>
+{
+ /**
+ * Constructor that inserts the interceptor at the USER_STREAM phase of the
+ * incoming interceptor chain.
+ */
+ public BackwardsCompatibleInterceptor()
+ {
+ super(Phase.USER_STREAM);
+ }
+
+ @Override
+ public void handleMessage(Message message) throws Fault
+ {
+ String base = (String) message.get(Message.BASE_PATH);
+ String uri = (String) message.get(Message.REQUEST_URI);
+ String query = (String) message.get(Message.QUERY_STRING);
+
+ base += base.endsWith("/") ? "" : "/";
+ String request = uri.replaceAll("^" + base, "");
+
+ // Parse the query string into a map of parameters.
+ // [Note: this will overwrite multiple parameters that have the same name.]
+ List<NameValuePair> params = URLEncodedUtils.parse(query, Charset.forName("UTF-8"));
+ Map<String, String> map = new HashMap<String, String>();
+ for (NameValuePair pair : params)
+ {
+ map.put(pair.getName(), pair.getValue());
+ }
+
+ // Maps "data?productID=<product ID>" URI to either
+ // "reference.file?productId=<product ID>" or
+ // "product.zip?productId=<product ID>"
+ if(request.equals("data"))
+ {
+ String format = map.get("format");
+ request =
+ "application/x-zip".equals(format) || "application/zip".equals(format)
+ ? "product.zip" : "reference.file";
+
+ query = "productId=" + map.get("productID");
+ query += map.containsKey("refIndex")
+ ? "&refIndex=" + map.get("refIndex") : "";
+ }
+
+ // Maps "dataset?typeID=<product type ID>" to
+ // "dataset.zip?productTypeId=<product type ID>"
+ else if(request.equals("dataset") && map.containsKey("typeID"))
+ {
+ request = "dataset.zip";
+ query = "productTypeId=" + map.get("typeID");
+ }
+
+ // Maps "rdf?type=ALL" or "rdf?id=<product type ID>" to
+ // "dataset.rdf?productTypeId=<ALL or product type ID>"
+ else if (request.equals("rdf"))
+ {
+ request = "dataset.rdf";
+ String type = map.get("type");
+ query = "productTypeId=";
+ query += "ALL".equals(type) ? type : map.get("id");
+ }
+
+ // Maps "rdf/dataset?type=ALL" or "rdf/dataset?typeID=<product type ID>" to
+ // "dataset.rdf?productTypeId=<ALL or product type ID>"
+ else if (request.equals("rdf/dataset"))
+ {
+ request = "dataset.rdf";
+ String type = map.get("type");
+ query = "productTypeId=";
+ query += "ALL".equals(type) ? type : map.get("typeID");
+ query += map.containsKey("filter") ? "&filter=" + map.get("filter") : "";
+ }
+
+ // Maps "viewRecent?channel=ALL" or "viewRecent?id=<product type ID>" to
+ // "dataset.rss?productTypeId=<ALL or product type ID>"
+ else if (request.equals("viewRecent"))
+ {
+ request = "dataset.rss";
+ String channel = map.get("channel");
+ query = "productTypeId=";
+ query += "ALL".equals(channel) ? channel : map.get("id");
+ query += map.containsKey("topn") ? "&limit=" + map.get("topn") : "";
+ }
+
+ // Maps "viewTransfers" to "transfers.rss?productId=ALL"
+ else if (request.equals("viewTransfers"))
+ {
+ request = "transfers.rss";
+ query = "productId=ALL";
+ }
+
+ // Store the new URI and query in the message map.
+ uri = base + request;
+ message.put(Message.REQUEST_URI, uri);
+ message.put(Message.QUERY_STRING, query);
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/BackwardsCompatibleInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/package-info.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/package-info.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/package-info.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/package-info.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * Contains filters for HTTP requests and responses.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+package org.apache.oodt.cas.product.jaxrs.filters;
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/filters/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/package-info.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/package-info.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/package-info.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/package-info.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * Contains sub-packages with classes that implement a JAX-RS service for the
+ * CAS Product web application.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+package org.apache.oodt.cas.product.jaxrs;
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.resources;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * A JAX-RS resource representing a dataset - a set of {@link Product products}
+ * maintained by the file manager.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@XmlRootElement(name="dataset")
+@XmlType(propOrder = {"id", "name", "metadataResource", "productResources"})
+@XmlAccessorType(XmlAccessType.NONE)
+public class DatasetResource
+{
+ private String id;
+ private String name;
+ private MetadataResource metadataResource;
+ private List<ProductResource> productResources =
+ new ArrayList<ProductResource>();
+
+ // The file manager's working directory for this resource, used for example
+ // when creating zip archives.
+ private File workingDir;
+
+
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public DatasetResource()
+ {
+ }
+
+
+
+ /**
+ * Constructor that sets the name, metadata and working directory for the
+ * dataset resource.
+ * @param id the ID of the dataset
+ * @param name the name of the dataset
+ * @param metadata the metadata for the dataset
+ * @param workingDir the working directory for creating temporary files to
+ * attach to responses
+ */
+ public DatasetResource(String id, String name, Metadata metadata,
+ File workingDir)
+ {
+ this.id = id;
+ this.name = name;
+ this.metadataResource = new MetadataResource(metadata);
+ this.workingDir = workingDir;
+ }
+
+
+
+ /**
+ * Adds a {@link ProductResource} to the list of product resources for the
+ * dataset.
+ * @param resource the resource to add to the dataset.
+ */
+ public void addProductResource(ProductResource resource)
+ {
+ productResources.add(resource);
+ }
+
+
+
+ /**
+ * Gets the working directory for the dataset.
+ * @return the working directory
+ */
+ public File getWorkingDir()
+ {
+ return workingDir;
+ }
+
+
+
+ /**
+ * Gets the id of the dataset.
+ * @return the id of the dataset
+ */
+ @XmlElement
+ public String getId()
+ {
+ return id;
+ }
+
+
+
+ /**
+ * Gets the name of the dataset.
+ * @return the name of the dataset
+ */
+ @XmlElement
+ public String getName()
+ {
+ return name;
+ }
+
+
+
+ /**
+ * Gets the product resources for the dataset.
+ * @return the productResources
+ */
+ @XmlElementWrapper(name = "products")
+ @XmlElement(name = "product")
+ public List<ProductResource> getProductResources()
+ {
+ return productResources;
+ }
+
+
+
+ /**
+ * Gets the metadata resource for the dataset.
+ * @return the metadata resource
+ */
+ @XmlElement(name = "metadata")
+ public MetadataResource getMetadataResource()
+ {
+ return metadataResource;
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/DatasetResource.java
------------------------------------------------------------------------------
svn:executable = *
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResource.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResource.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * A JAX-RS resource representing a {@link Metadata} object.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@XmlRootElement(name = "metadata")
+@XmlAccessorType(XmlAccessType.NONE)
+public class MetadataResource
+{
+ private Metadata metadata;
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public MetadataResource()
+ {
+ }
+
+
+
+ /**
+ * Constructor that sets the metadata for the resource.
+ * @param metadata the metadata for the resource
+ */
+ public MetadataResource(Metadata metadata)
+ {
+ this.metadata = metadata;
+ }
+
+
+
+ /**
+ * Gets the metadata.
+ * @return the metadata
+ */
+ public Metadata getMetadata()
+ {
+ return metadata;
+ }
+
+
+
+ /**
+ * Gets a map of metadata keys and values.
+ * @return a map of metadata keys and values
+ */
+ @XmlElement(name = "keyval")
+ public List<MetadataEntry> getMetadataEntries()
+ {
+ List<MetadataEntry> entries = new ArrayList<MetadataEntry>();
+ for (String key : metadata.getAllKeys())
+ {
+ entries.add(new MetadataEntry(key, metadata.getAllMetadata(key)));
+ }
+ return entries;
+ }
+
+
+
+ /**
+ * Represents a metadata keyval entry.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+ @XmlRootElement
+ @XmlType(propOrder = {"key", "values"})
+ @XmlAccessorType(XmlAccessType.NONE)
+ public static class MetadataEntry
+ {
+ private String key;
+ private List<String> values;
+
+
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public MetadataEntry()
+ {
+ }
+
+
+
+ /**
+ * Constructor that creates a metadata entry using the supplied key and list
+ * of values.
+ * @param key the key for the metadata entry
+ * @param values the values for the metadata entry
+ */
+ public MetadataEntry(String key, List<String> values)
+ {
+ this.key = key;
+ this.values = values;
+ }
+
+
+
+ /**
+ * Gets the key for the metadata entry.
+ * @return the key for the metadata entry
+ */
+ @XmlElement(name = "key")
+ public String getKey()
+ {
+ return key;
+ }
+
+
+
+ /**
+ * Gets the value(s) for the metadata entry
+ * @return the value(s) for the metadata entry
+ */
+ @XmlElement(name = "val")
+ public List<String> getValues()
+ {
+ return values;
+ }
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/MetadataResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.resources;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * A JAX-RS resource representing a {@link Product}.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@XmlRootElement(name = "product")
+@XmlType(propOrder = {"productId", "productName", "productStructure",
+ "productTypeName", "transferStatus", "metadataResource",
+ "referenceResources"})
+@XmlAccessorType(XmlAccessType.NONE)
+public class ProductResource
+{
+ private Product product;
+ private MetadataResource metadataResource;
+ private List<ReferenceResource> referenceResources =
+ new ArrayList<ReferenceResource>();
+
+ // The file manager's working directory for this resource, used for example
+ // when creating zip archives.
+ private File workingDir;
+
+
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public ProductResource()
+ {
+ }
+
+
+
+ /**
+ * Constructor that sets the product, metadata, references and
+ * working directory for the resource.
+ * @param product the product associated with the resource
+ * @param metadata the metadata associated with the resource
+ * @param references the references associated with the resource
+ * @param workingDir the working directory for creating temporary files to
+ * attach to responses
+ */
+ public ProductResource(Product product, Metadata metadata,
+ List<Reference> references, File workingDir)
+ {
+ this.product = product;
+ this.metadataResource = new MetadataResource(metadata);
+ for (int index = 0; index < references.size(); index++)
+ {
+ referenceResources.add(new ReferenceResource(product.getProductId(),
+ index, references.get(index), workingDir));
+ }
+ this.workingDir = workingDir;
+ }
+
+
+
+ /**
+ * Gets the working directory for the product.
+ * @return the working directory
+ */
+ public File getWorkingDir()
+ {
+ return workingDir;
+ }
+
+
+
+ /**
+ * Gets the product's ID.
+ * @return the product's ID.
+ */
+ @XmlElement(name = "id")
+ public String getProductId()
+ {
+ return product.getProductId();
+ }
+
+
+
+ /**
+ * Gets the product's name.
+ * @return the product's name
+ */
+ @XmlElement(name = "name")
+ public String getProductName()
+ {
+ return product.getProductName();
+ }
+
+
+
+ /**
+ * Gets the product's structure.
+ * @return a string describing the product's structure
+ */
+ @XmlElement(name = "structure")
+ public String getProductStructure()
+ {
+ return product.getProductStructure();
+ }
+
+
+
+ /**
+ * Gets the name of the product's type.
+ * @return the name of the product's type
+ */
+ @XmlElement(name = "type")
+ public String getProductTypeName()
+ {
+ return product.getProductType().getName();
+ }
+
+
+
+ /**
+ * Gets the transfer status for the product.
+ * @return the transfer status for the product
+ */
+ @XmlElement(name = "transferStatus")
+ public String getTransferStatus()
+ {
+ return product.getTransferStatus();
+ }
+
+
+
+ /**
+ * Gets the metadata resource for the product.
+ * @return the product's metadata resource
+ */
+ @XmlElement(name = "metadata")
+ public MetadataResource getMetadataResource()
+ {
+ return metadataResource;
+ }
+
+
+
+ /**
+ * Gets the reference resources.
+ * @return the reference resources
+ */
+ @XmlElementWrapper(name = "references")
+ @XmlElement(name = "reference")
+ public List<ReferenceResource> getReferenceResources()
+ {
+ return referenceResources;
+ }
+
+
+
+ /**
+ * Gets the product's references.
+ * @return the product's references
+ */
+ public List<Reference> getProductReferences()
+ {
+ return product.getProductReferences();
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ProductResource.java
------------------------------------------------------------------------------
svn:executable = *
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResource.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResource.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.resources;
+
+import java.io.File;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.tika.mime.MimeType;
+
+/**
+ * A JAX-RS resource representing a {@link Reference}.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@XmlRootElement(name = "reference")
+@XmlType(propOrder = {"productId", "refIndex", "dataStoreReference",
+ "origReference", "mimeTypeName", "fileSize"})
+@XmlAccessorType(XmlAccessType.NONE)
+public class ReferenceResource
+{
+ // The reference for this resource.
+ private Reference reference;
+
+ // The ID of the product that the reference belongs to.
+ private String productId;
+
+ // The index of the reference within its product.
+ private int refIndex;
+
+ // The file manager's working directory for this resource, used for example
+ // when creating zip archives.
+ private File workingDir;
+
+
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public ReferenceResource()
+ {
+ }
+
+
+
+ /**
+ * Constructor that sets the reference and working directory for the resource.
+ * @param productId the ID of the product that the reference belongs to
+ * @param refIndex the index of the reference within its product
+ * @param reference the reference for the resource
+ * @param workingDir the working directory for creating temporary files to
+ * attach to responses
+ */
+ public ReferenceResource(String productId, int refIndex, Reference reference,
+ File workingDir)
+ {
+ this.productId = productId;
+ this.refIndex = refIndex;
+ this.reference = reference;
+ this.workingDir = workingDir;
+ }
+
+
+
+ /**
+ * Gets the reference.
+ * @return the reference
+ */
+ public Reference getReference()
+ {
+ return reference;
+ }
+
+
+
+ /**
+ * Gets the working directory for the reference.
+ * @return the working directory
+ */
+ public File getWorkingDir()
+ {
+ return workingDir;
+ }
+
+
+
+ /**
+ * Gets the ID of the product that the reference belongs to.
+ * @return the ID of the product that the reference belongs to
+ */
+ @XmlElement
+ public String getProductId()
+ {
+ return productId;
+ }
+
+
+
+ /**
+ * Gets the index of the reference within its product.
+ * @return the index of the reference within its product
+ */
+ @XmlElement
+ public int getRefIndex()
+ {
+ return refIndex;
+ }
+
+
+
+ /**
+ * Gets the data store reference for the reference.
+ * @return the data store reference for the reference
+ */
+ @XmlElement
+ public String getDataStoreReference()
+ {
+ return reference.getDataStoreReference();
+ }
+
+
+
+ /**
+ * Gets the file size for the reference.
+ * @return the file size for the reference
+ */
+ @XmlElement
+ public long getFileSize()
+ {
+ return reference.getFileSize();
+ }
+
+
+
+ /**
+ * Gets the name of the MIME type for the reference.
+ * @return the name of the MIME type for the reference
+ */
+ @XmlElement(name = "mimeType")
+ public String getMimeTypeName()
+ {
+ MimeType m = reference.getMimeType();
+ if (m != null)
+ {
+ return m.getName();
+ }
+ return null;
+ }
+
+
+
+ /**
+ * Gets the MIME type for the reference.
+ * @return the MIME type for the reference
+ */
+ public MimeType getMimeType()
+ {
+ return reference.getMimeType();
+ }
+
+
+
+ /**
+ * Gets the original reference for the reference.
+ * @return the original reference for the reference
+ */
+ @XmlElement(name = "originalReference")
+ public String getOrigReference()
+ {
+ return reference.getOrigReference();
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/ReferenceResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResource.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResource.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.resources;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.oodt.cas.filemgr.structs.FileTransferStatus;
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * A JAX-RS resource representing a {@link FileTransferStatus}.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@XmlRootElement(name = "transfer")
+@XmlType(propOrder = {"productName", "productId", "productTypeName",
+ "dataStoreReference", "origReference", "mimeTypeName", "fileSize",
+ "totalBytes", "bytesTransferred", "percentComplete", "productReceivedTime"})
+@XmlAccessorType(XmlAccessType.NONE)
+public class TransferResource
+{
+ private Reference reference;
+ private Product product;
+ private Metadata metadata;
+ private FileTransferStatus status;
+
+
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public TransferResource()
+ {
+ }
+
+
+
+ /**
+ * Constructor that sets the {@link FileTransferStatus} for the resource.
+ * @param product the product being transferred
+ * @param metadata the metadata for the product being transferred
+ * @param status the file transfer status for product
+ */
+ public TransferResource(Product product, Metadata metadata,
+ FileTransferStatus status)
+ {
+ this.reference = status.getFileRef();
+ this.product = product;
+ this.metadata = metadata;
+ this.status = status;
+ }
+
+
+
+ /**
+ * Gets the product.
+ * @return the product
+ */
+ public Product getProduct()
+ {
+ return product;
+ }
+
+
+
+ /**
+ * Gets the metadata.
+ * @return the metadata
+ */
+ public Metadata getMetadata()
+ {
+ return metadata;
+ }
+
+
+
+ /**
+ * Gets the ID of the product.
+ * @return the ID of the product
+ */
+ @XmlElement
+ public String getProductId()
+ {
+ return product.getProductId();
+ }
+
+
+
+ /**
+ * Gets the name of the product.
+ * @return the name of the product
+ */
+ @XmlElement
+ public String getProductName()
+ {
+ return product.getProductName();
+ }
+
+
+
+ /**
+ * Gets the product type name for the product.
+ * @return the product type name for the product
+ */
+ @XmlElement
+ public String getProductTypeName()
+ {
+ return product.getProductType().getName();
+ }
+
+
+
+ /**
+ * Gets the data store reference for the reference.
+ * @return the data store reference for the reference
+ */
+ @XmlElement
+ public String getDataStoreReference()
+ {
+ return reference.getDataStoreReference();
+ }
+
+
+
+ /**
+ * Gets the original reference for the reference.
+ * @return the original reference for the reference
+ */
+ @XmlElement
+ public String getOrigReference()
+ {
+ return reference.getOrigReference();
+ }
+
+
+
+ /**
+ * Gets the name of the MIME type for the reference.
+ * @return the name of the MIME type for the reference
+ */
+ @XmlElement(name = "mimeType")
+ public String getMimeTypeName()
+ {
+ return reference.getMimeType().getName();
+ }
+
+
+
+ /**
+ * Gets the file size for the reference.
+ * @return the file size for the reference
+ */
+ @XmlElement
+ public long getFileSize()
+ {
+ return reference.getFileSize();
+ }
+
+
+
+ /**
+ * Gets the total bytes of the file being transferred.
+ * @return the total bytes of the file
+ */
+ @XmlElement
+ public long getTotalBytes()
+ {
+ return status.getFileRef().getFileSize();
+ }
+
+
+
+ /**
+ * Gets the bytes transferred status of the file transfer.
+ * @return the bytes transferred status
+ */
+ @XmlElement
+ public long getBytesTransferred()
+ {
+ return status.getBytesTransferred();
+ }
+
+
+
+ /**
+ * Gets the percentage complete status of the file transfer.
+ * @return the percentage complete status of the file transfer
+ */
+ @XmlElement
+ public double getPercentComplete()
+ {
+ return status.computePctTransferred() * 100;
+ }
+
+
+
+ /**
+ * Gets the metadata value of the product received time.
+ * @return the metadata value of the product received time
+ */
+ @XmlElement
+ public String getProductReceivedTime()
+ {
+ return metadata.getMetadata("CAS.ProductReceivedTime");
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransferResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResource.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResource.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResource.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResource.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.oodt.cas.product.jaxrs.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.oodt.cas.filemgr.structs.FileTransferStatus;
+
+/**
+ * A JAX-RS resource representing currently active {@link FileTransferStatus
+ * file transfers} as {@link TransferResource transfer resources}.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+@XmlRootElement(name = "transfers")
+@XmlAccessorType(XmlAccessType.NONE)
+public class TransfersResource
+{
+ private String productId;
+
+ private List<TransferResource> transferResources =
+ new ArrayList<TransferResource>();
+
+
+
+ /**
+ * Default constructor required by JAXB.
+ */
+ public TransfersResource()
+ {
+ }
+
+
+
+ /**
+ * Constructor that sets the product ID and list of TransferResource
+ * instances related to the product.
+ * @param productId the product ID
+ * @param transferResources the resources representing currently active file
+ * transfers for the product
+ */
+ public TransfersResource(String productId,
+ List<TransferResource> transferResources)
+ {
+ this.productId = productId;
+ this.transferResources = transferResources;
+ }
+
+
+
+ /**
+ * Gets the product ID.
+ * @return the product ID
+ */
+ @XmlAttribute
+ public String getProductId()
+ {
+ return productId;
+ }
+
+
+
+ /**
+ * Gets the transfer resources.
+ * @return the transfer resources
+ */
+ @XmlElement(name = "transfer")
+ public List<TransferResource> getTransferResources()
+ {
+ return transferResources;
+ }
+}
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/TransfersResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/package-info.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/package-info.java?rev=1533284&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/package-info.java (added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/package-info.java Thu Oct 17 23:06:09 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * Contains JAX-RS resource classes that represent file manager entities such
+ * as products, their references and their metadata.
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+package org.apache.oodt.cas.product.jaxrs.resources;
Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/resources/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native