You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2010/12/23 03:48:11 UTC
svn commit: r1052148 [8/17] - in /oodt/branches/wengine-branch/filemgr: ./
.settings/ src/ src/main/ src/main/assembly/ src/main/bin/ src/main/java/
src/main/java/gov/ src/main/java/gov/nasa/ src/main/java/gov/nasa/jpl/
src/main/java/gov/nasa/jpl/oodt/...
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManager.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManager.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManager.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,292 @@
+/*
+ * 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.filemgr.repository;
+
+//JDK imports
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.ProductType;
+import org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException;
+import org.apache.oodt.cas.filemgr.util.XmlStructFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A {@link RepositoryManager} that manages {@link Product} policy based on an
+ * xml file called <code>product-types.xml</code>.
+ * </p>
+ * </p>
+ *
+ */
+public class XMLRepositoryManager implements RepositoryManager {
+
+ /* URIs pointing to directories containing product-types.xml files */
+ private List<String> productTypeHomeUris = null;
+
+ /* our map of product types that the system knows about */
+ private HashMap<String, ProductType> productTypeMap = new HashMap<String, ProductType>();
+
+ /* our log stream */
+ private static Logger LOG = Logger.getLogger(XMLRepositoryManager.class
+ .getName());
+
+ /**
+ *
+ */
+ public XMLRepositoryManager(List<String> uris) throws InstantiationException {
+ if (uris == null) {
+ throw new InstantiationException(
+ "Attempt to construct XMLRepositoryManager with a NULL list of product type home URIs!");
+ }
+
+ this.productTypeHomeUris = uris;
+ loadProductTypes(productTypeHomeUris);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManager#addProductType(gov.nasa.jpl.oodt.cas.filemgr.structs.ProductType)
+ */
+ public void addProductType(ProductType productType)
+ throws RepositoryManagerException {
+ productTypeMap.put(productType.getProductTypeId(), productType);
+ saveProductTypes();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManager#modifyProductType(gov.nasa.jpl.oodt.cas.filemgr.structs.ProductType)
+ */
+ public void modifyProductType(ProductType productType)
+ throws RepositoryManagerException {
+ productTypeMap.put(productType.getProductTypeId(), productType);
+ saveProductTypes();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManager#removeProductType(gov.nasa.jpl.oodt.cas.filemgr.structs.ProductType)
+ */
+ public void removeProductType(ProductType productType)
+ throws RepositoryManagerException {
+ productTypeMap.remove(productType.getProductTypeId());
+ saveProductTypes();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManager#getProductTypeById(java.lang.String)
+ */
+ public ProductType getProductTypeById(String productTypeId)
+ throws RepositoryManagerException {
+ return (ProductType) productTypeMap.get(productTypeId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManager#getProductTypeByName(java.lang.String)
+ */
+ public ProductType getProductTypeByName(String productTypeName)
+ throws RepositoryManagerException {
+ for (Iterator<String> i = productTypeMap.keySet().iterator(); i.hasNext();) {
+ String typeId = (String) i.next();
+ ProductType type = (ProductType) productTypeMap.get(typeId);
+ if (type.getName().equals(productTypeName)) {
+ return type;
+ }
+ }
+
+ LOG.log(Level.WARNING,
+ "XMLRepositoryManager: Unable to find product type: ["
+ + productTypeName + "], returning null");
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManager#getProductTypes()
+ */
+ public List<ProductType> getProductTypes() throws RepositoryManagerException {
+ return Arrays.asList(productTypeMap.values().toArray(new ProductType[productTypeMap.values().size()]));
+ }
+
+ private void saveProductTypes() {
+ for (Iterator<String> i = productTypeHomeUris.iterator(); i.hasNext();) {
+ String dirUri = i.next();
+ File productTypeDir = null;
+
+ try {
+ productTypeDir = new File(new URI(dirUri));
+
+ if (!productTypeDir.isDirectory()) {
+ LOG
+ .log(
+ Level.WARNING,
+ "Product type directory: "
+ + dirUri
+ + " is not "
+ + "a directory: skipping product type saving to it.");
+ continue;
+ }
+
+ String productTypeDirStr = productTypeDir.getAbsolutePath();
+ if (!productTypeDirStr.endsWith("/")) {
+ productTypeDirStr += "/";
+ }
+
+ String productTypeXmlFile = productTypeDirStr
+ + "product-types.xml";
+ XmlStructFactory.writeProductTypeXmlDocument(Arrays
+ .asList(productTypeMap.values().toArray(new ProductType[productTypeMap.values().size()])),
+ productTypeXmlFile);
+ } catch (URISyntaxException e) {
+ LOG.log(Level.WARNING,
+ "URISyntaxException when saving product "
+ + "type directory URI: " + dirUri
+ + ": Skipping Product Type saving"
+ + "for it: Message: " + e.getMessage());
+ continue;
+ }
+
+ }
+
+ }
+
+ private void loadProductTypes(List<String> dirUris) {
+ for (Iterator<String> i = dirUris.iterator(); i.hasNext();) {
+ File productTypeDir = null;
+ String dirUri = i.next();
+
+ try {
+ productTypeDir = new File(new URI(dirUri));
+
+ if (!productTypeDir.isDirectory()) {
+ LOG
+ .log(
+ Level.WARNING,
+ "Product type directory: "
+ + dirUri
+ + " is not "
+ + "a directory: skipping product type loading from it.");
+ continue;
+ }
+
+ String productTypeDirStr = productTypeDir.getAbsolutePath();
+ if (!productTypeDirStr.endsWith("/")) {
+ productTypeDirStr += "/";
+ }
+
+ String productTypeXmlFile = productTypeDirStr
+ + "product-types.xml";
+ Document productTypeDoc = getDocumentRoot(productTypeXmlFile);
+
+ // now load the product types from it
+ if (productTypeDoc != null) {
+ Element productTypeRoot = productTypeDoc
+ .getDocumentElement();
+
+ NodeList productTypeNodeList = productTypeRoot
+ .getElementsByTagName("type");
+
+ if (productTypeNodeList != null
+ && productTypeNodeList.getLength() > 0) {
+ for (int j = 0; j < productTypeNodeList.getLength(); j++) {
+ Node productTypeNode = productTypeNodeList.item(j);
+ ProductType type = XmlStructFactory
+ .getProductType(productTypeNode);
+ LOG.log(Level.FINE,
+ "XMLRepositoryManager: found product type: ["
+ + type.getName() + "]");
+ productTypeMap.put(type.getProductTypeId(), type);
+ }
+ }
+ }
+ } catch (URISyntaxException e) {
+ LOG.log(Level.WARNING,
+ "URISyntaxException when loading product "
+ + "type directory URI: " + dirUri
+ + ": Skipping Product Type loading"
+ + "for it: Message: " + e.getMessage());
+ continue;
+ }
+ }
+ }
+
+ private Document getDocumentRoot(String xmlFile) {
+ // open up the XML file
+ DocumentBuilderFactory factory = null;
+ DocumentBuilder parser = null;
+ Document document = null;
+ InputSource inputSource = null;
+
+ InputStream xmlInputStream = null;
+
+ try {
+ xmlInputStream = new File(xmlFile).toURL().openStream();
+ } catch (IOException e) {
+ LOG.log(Level.WARNING,
+ "IOException when getting input stream from [" + xmlFile
+ + "]: returning null document root");
+ return null;
+ }
+
+ inputSource = new InputSource(xmlInputStream);
+
+ try {
+ factory = DocumentBuilderFactory.newInstance();
+ parser = factory.newDocumentBuilder();
+ document = parser.parse(inputSource);
+ } catch (Exception e) {
+ LOG.warning("Unable to parse xml file [" + xmlFile + "]."
+ + "Reason is [" + e + "]");
+ return null;
+ }
+
+ return document;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManagerFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManagerFactory.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManagerFactory.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/repository/XMLRepositoryManagerFactory.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.filemgr.repository;
+
+//JDK imports
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.util.PathUtils;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Factory class for creating {@link XMLRepositoryManager} objects.
+ * </p>
+ *
+ */
+public class XMLRepositoryManagerFactory implements RepositoryManagerFactory {
+
+ /* list of dir uris specifying file paths to productType directories */
+ private List<String> productTypeDirList = null;
+
+ /* our log stream */
+ private static Logger LOG = Logger
+ .getLogger(XMLRepositoryManagerFactory.class.getName());
+
+ /**
+ * <p>
+ * Default Constructor
+ * </p>.
+ */
+ public XMLRepositoryManagerFactory() {
+ String productTypeDirUris = System
+ .getProperty("gov.nasa.jpl.oodt.cas.filemgr.repositorymgr.dirs");
+
+ if (productTypeDirUris != null) {
+ productTypeDirUris = PathUtils
+ .replaceEnvVariables(productTypeDirUris);
+ String[] dirUris = productTypeDirUris.split(",");
+ productTypeDirList = Arrays.asList(dirUris);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see gov.nasa.jpl.oodt.cas.filemgr.repository.RepositoryManagerFactory#createRepositoryManager()
+ */
+ public RepositoryManager createRepositoryManager() {
+ if (productTypeDirList != null) {
+ RepositoryManager repositoryManager = null;
+ try {
+ repositoryManager = new XMLRepositoryManager(productTypeDirList);
+ } catch (Exception ignore) {
+ }
+
+ return repositoryManager;
+ } else {
+ LOG
+ .log(
+ Level.WARNING,
+ "Cannot create XML Repository Manager: no product type dir uris specified: value: "
+ + System
+ .getProperty("gov.nasa.jpl.oodt.cas.filemgr.repositorymgr.dirs"));
+ return null;
+ }
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/BooleanQueryCriteria.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,177 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.exceptions.QueryFormulationException;
+
+/**
+ * @author woollard
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Boolean Query Citeria that allows combination of a number of terms into a
+ * query with a boolean operator (AND, OR, NOT). The NOT operator can only be
+ * applied to one term.
+ * </p>
+ *
+ */
+
+public class BooleanQueryCriteria extends QueryCriteria {
+
+ /**
+ * Constants
+ */
+ public static final int AND = 0;
+
+ public static final int OR = 1;
+
+ public static final int NOT = 2;
+
+ private static final long serialVersionUID = 4718948237682772671L;
+
+ private int operator;
+
+ private List<QueryCriteria> terms;
+
+ /**
+ * Default constructor. Uses the AND operator.
+ */
+ public BooleanQueryCriteria() {
+ operator = AND;
+ terms = new Vector<QueryCriteria>();
+ }
+
+ /**
+ * Boolean query constructor. This query is a boolean combination of term,
+ * range, and other boolean queries. The supported operators are AND, OR and
+ * NOT. Note that the NOT operator can only be used with one (1) term. This
+ * method throws the QueryFormulationException if more than one term is used
+ * with NOT.
+ *
+ * @param terms
+ * The criteria onto which to apply the boolean operator
+ * @param op
+ * The boolean operator to be applied
+ */
+ public BooleanQueryCriteria(List<QueryCriteria> terms, int op)
+ throws QueryFormulationException {
+ operator = op;
+ if (op == NOT && terms.size() > 1) {
+ throw new QueryFormulationException(
+ "BooleanQueryCriteria: NOT operator "
+ + "cannot be applied to multiple terms");
+ } else {
+ this.terms = terms;
+ }
+ }
+
+ /**
+ * Method to add a term to the boolean query. Note that a NOT operator can
+ * only be applied to one term. Method throws the QueryFormulationException
+ * if this rule is violated.
+ *
+ * @param t
+ * Term to be added to the query
+ */
+ public void addTerm(QueryCriteria t) throws QueryFormulationException {
+ if (operator == NOT && !terms.isEmpty()) {
+ throw new QueryFormulationException(
+ "BooleanQueryCriteria: NOT operator "
+ + "cannot be applied to multiple terms");
+ } else {
+ terms.add(t);
+ }
+ }
+
+ /**
+ * Accessor method for the list of terms in the query.
+ *
+ * @return The list of terms
+ */
+ public List<QueryCriteria> getTerms() {
+ return terms;
+ }
+
+ /**
+ * Mutator method for the boolean operator. Note that this method throws the
+ * QueryFormulationException if the operator is set to NOT and multiple
+ * terms are already defined.
+ *
+ * @param op
+ * Boolean operator
+ */
+ public void setOperator(int op) throws QueryFormulationException {
+ if (op == NOT && terms.size() > 1) {
+ throw new QueryFormulationException(
+ "BooleanQueryCriteria: NOT operator "
+ + "cannot be applied to multiple terms");
+ } else {
+ operator = op;
+ }
+ }
+
+ /**
+ * Accessor method for the boolean operator.
+ *
+ * @return the boolean operator
+ */
+ public int getOperator() {
+ return operator;
+ }
+
+ /**
+ * Method is not used in this class...
+ */
+ public String getElementName() {
+ return null;
+ }
+
+ /**
+ * Method is not used in this class...
+ */
+ public void setElementName(String elementName) {
+ }
+
+ /**
+ * Method to convert the query to a string.
+ *
+ * @return string equivement of the query
+ */
+ public String toString() {
+ String query = new String();
+ if (operator == AND)
+ query += "AND(";
+ else if (operator == OR)
+ query += "OR(";
+ else
+ query += "NOT(";
+
+ for (int i = 0; i < terms.size(); i++) {
+ query += ((QueryCriteria) terms.get(i)).toString();
+ if (i < (terms.size() - 1))
+ query += ", ";
+ }
+ query += ")";
+ return query;
+ }
+}
\ No newline at end of file
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Element.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Element.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Element.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Element.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,141 @@
+/*
+ * 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.filemgr.structs;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ *
+ * <p>
+ * A metadata element.
+ * </p>
+ *
+ */
+public class Element {
+
+ /* the element id */
+ private String elementId = null;
+
+ /* the element name */
+ private String elementName = null;
+
+ /* the corresponding DC element for this CAS element */
+ private String dcElement = null;
+
+ /* the element's string description. */
+ private String description = null;
+
+ /**
+ * <p>
+ * Default constructor
+ * </p>
+ *
+ */
+ public Element() {
+ }
+
+ /**
+ * <p>
+ * Constructs a new CAS element
+ * </p>
+ *
+ * @param elementId
+ * The element's Id from the database.
+ * @param elementName
+ * The element name.
+ * @param element
+ * The DC element that corresponds to this archive element.
+ *
+ * @param desc
+ * The element's description.
+ *
+ */
+ public Element(String elementId, String elementName,
+ String elemMetadataColumn, String element,
+ String desc) {
+ this.elementId = elementId;
+ this.elementName = elementName;
+ this.dcElement = element;
+ this.description = desc;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.elementId.hashCode();
+ }
+
+ /**
+ * @return Returns the dcElement.
+ */
+ public String getDCElement() {
+ return dcElement;
+ }
+
+ /**
+ * @param element
+ * The dcElement to set.
+ */
+ public void setDCElement(String element) {
+ dcElement = element;
+ }
+
+ /**
+ * @return Returns the elementId.
+ */
+ public String getElementId() {
+ return elementId;
+ }
+
+ /**
+ * @param elementId
+ * The elementId to set.
+ */
+ public void setElementId(String elementId) {
+ this.elementId = elementId;
+ }
+
+ /**
+ * @return Returns the elementName.
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+ /**
+ * @param elementName
+ * The elementName to set.
+ */
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description
+ * The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ExtractorSpec.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ExtractorSpec.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ExtractorSpec.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ExtractorSpec.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,81 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.util.Properties;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ *
+ * <p>
+ * A specification class showing how to constract
+ * a {@link FilemgrMetExtractor}.
+ * </p>.
+ */
+public class ExtractorSpec {
+
+ private String className;
+
+ private Properties configuration;
+
+ public ExtractorSpec() {
+
+ }
+
+ /**
+ * @param className
+ * @param configuration
+ */
+ public ExtractorSpec(String className, Properties configuration) {
+ super();
+ this.className = className;
+ this.configuration = configuration;
+ }
+
+ /**
+ * @return the className
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * @param className
+ * the className to set
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ /**
+ * @return the configuration
+ */
+ public Properties getConfiguration() {
+ return configuration;
+ }
+
+ /**
+ * @param configuration
+ * the configuration to set
+ */
+ public void setConfiguration(Properties configuration) {
+ this.configuration = configuration;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FileTransferStatus.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FileTransferStatus.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FileTransferStatus.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FileTransferStatus.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,118 @@
+/*
+ * 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.filemgr.structs;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ *
+ * <p>
+ * A class to represent the status of a transfer for a file reference belonging
+ * to a {@link Product}.
+ * </p>
+ *
+ */
+public class FileTransferStatus {
+
+ /* the file reference that is being transferred */
+ private Reference fileRef = null;
+
+ /* the amount of bytes transferred so far */
+ private long bytesTransferred = 0L;
+
+ /* the associated Product */
+ private Product parentProduct = null;
+
+ /**
+ * <p>
+ * Default Constructor
+ * </p>.
+ */
+ public FileTransferStatus() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param fileRef
+ * The file reference being transferred.
+ * @param bytesTransferred
+ * The number of bytes transferred so far for this file.
+ * @param parentProduct
+ * The parent Product that this file reference belongs to.
+ */
+ public FileTransferStatus(Reference fileRef, long fileSize,
+ long bytesTransferred, Product parentProduct) {
+ this.fileRef = fileRef;
+ this.bytesTransferred = bytesTransferred;
+ this.parentProduct = parentProduct;
+ }
+
+ /**
+ * @return Returns the bytesTransferred.
+ */
+ public long getBytesTransferred() {
+ return bytesTransferred;
+ }
+
+ /**
+ * @param bytesTransferred
+ * The bytesTransferred to set.
+ */
+ public void setBytesTransferred(long bytesTransferred) {
+ this.bytesTransferred = bytesTransferred;
+ }
+
+ /**
+ * @return Returns the fileRef.
+ */
+ public Reference getFileRef() {
+ return fileRef;
+ }
+
+ /**
+ * @param fileRef
+ * The fileRef to set.
+ */
+ public void setFileRef(Reference fileRef) {
+ this.fileRef = fileRef;
+ }
+
+ /**
+ * @return Returns the parentProduct.
+ */
+ public Product getParentProduct() {
+ return parentProduct;
+ }
+
+ /**
+ * @param parentProduct
+ * The parentProduct to set.
+ */
+ public void setParentProduct(Product parentProduct) {
+ this.parentProduct = parentProduct;
+ }
+
+ /**
+ *
+ * @return The percentage of the file that has been transferred so far.
+ */
+ public double computePctTransferred() {
+ return ((double) (bytesTransferred * 1.0) / (fileRef.getFileSize() * 1.0));
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/FreeTextQueryCriteria.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,174 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * @author woollard
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Free Text Criteria element for a Query to the Catalog.
+ * </p>
+ *
+ */
+public class FreeTextQueryCriteria extends QueryCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String elementName;
+
+ private List<String> values;
+
+ private static final String[] noiseWords = { "a", "all", "am", "an", "and",
+ "any", "are", "as", "at", "be", "but", "can", "did", "do", "does",
+ "for", "from", "had", "has", "have", "here", "how", "i", "if",
+ "in", "is", "it", "no", "not", "of", "on", "or", "so", "that",
+ "the", "then", "there", "this", "to", "too", "up", "use", "what",
+ "when", "where", "who", "why", "you" };
+
+ private static HashSet<String> noiseWordHash;
+
+ /**
+ * Default constructor.
+ */
+ public FreeTextQueryCriteria() {
+ elementName = new String();
+ values = new ArrayList<String>();
+
+ noiseWordHash = new HashSet<String>();
+ for (int i = 0; i < noiseWords.length; i++)
+ noiseWordHash.add(noiseWords[i]);
+ }
+
+ /**
+ * Constructor for the FreeTextQueryECriteria Class.
+ *
+ * @param elementId
+ * The name of the element to search on.
+ * @param v
+ * A List of terms to search for.
+ */
+ public FreeTextQueryCriteria(String elementName, List<String> v) {
+ this.elementName = elementName;
+ values = v;
+
+ noiseWordHash = new HashSet<String>();
+ for (int i = 0; i < noiseWords.length; i++)
+ noiseWordHash.add(noiseWords[i]);
+ }
+
+ /**
+ * Accessor method for the values of the element to search on.
+ *
+ * @return The values of the element to search on as a List of Strings.
+ */
+ public List<String> getValues() {
+ return values;
+ }
+
+ /**
+ * Mutator method for the values of the element to search on. This method
+ * should be used when keywords have been parsed out of user-entered free
+ * text. The query will JOIN on all of these values. In order to add
+ * unparsed free text to a Query, see the addFreeText method of this class.
+ *
+ * @param value
+ * The values of the element to search on as a List of Strings.
+ */
+ public void setValue(List<String> v) {
+ this.values = v;
+ }
+
+ /**
+ * A method for adding a value to search on to the list of values.
+ *
+ * @param v
+ * The value to be added to the search as a String.
+ */
+ public void addValue(String v) {
+ values.add(v);
+ }
+
+ /**
+ * A method for adding unparsed free text to the FreeTextCriteria. Free text
+ * entered as a string is tokenized and punctuation and common words are
+ * dropped before the values are added to the query. In order to query for
+ * pre-parsed keywords, see the setValues method of this class.
+ *
+ * @param text
+ * The free text to be parsed and searched on.
+ */
+ public void addFreeText(String text) {
+ // remove punctuation from the text
+ text = text.replaceAll("\\p{Punct}+", "");
+
+ // tokenize string using default delimiters
+ StringTokenizer tok = new StringTokenizer(text);
+ String token = null;
+
+ // filter noise words and add to values vector
+ while (tok.hasMoreElements()) {
+ token = tok.nextToken();
+ if (!noiseWordHash.contains(token))
+ values.add(token);
+ }
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * accessing the element ID to search on.
+ *
+ * @return The element ID to search on as a String.
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * mutating the element ID to search on.
+ *
+ * @param elementId
+ * The element ID to search on as a String.
+ */
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * generating a human-parsable string version of the query criteria. Note
+ * that the returned String follows the Lucene query language.
+ *
+ * @return The query as a String.
+ */
+ public String toString() {
+ String serial = elementName + ":(";
+ for (int i = 0; i < values.size(); i++)
+ serial += "+" + (String) values.get(i);
+ serial += ")";
+ return serial;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Product.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,357 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.catalog.Catalog;
+import org.apache.oodt.commons.xml.XMLUtils;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Product is a set of files, or a heirarchical, directory structure that
+ * should be ingested into the {@link Catalog}.
+ * </p>
+ *
+ */
+public class Product {
+
+ /* our product id */
+ private String productId = null;
+
+ /* our product name */
+ private String productName = null;
+
+ /* our product type */
+ private ProductType productType = null;
+
+ /* our product structure: can be Heirarchical, or Flat */
+ private String productStructure = null;
+
+ /* a set of {@link References} to the items that make up this product */
+ private List<Reference> references = null;
+
+ /*
+ * the transfer status of this product: is it TRANSFERING, has it been
+ * RECEIVED?
+ */
+ private String transferStatus = null;
+
+ /*
+ * the root reference for this product: if it's a dir, it's the root of the
+ * dir tree if the product is flat, it's the first (and possibly) only ref.
+ */
+ private Reference rootRef;
+
+ /* a couple of static final Strings to represent the TransferStatus */
+ public static final String STATUS_TRANSFER = "TRANSFERING";
+
+ public static final String STATUS_RECEIVED = "RECEIVED";
+
+ /* a couple of static final Strings to represent the productStructure */
+ public static final String STRUCTURE_FLAT = "Flat";
+
+ public static final String STRUCTURE_HIERARCHICAL = "Hierarchical";
+
+ /* our log stream */
+ private static final Logger LOG = Logger.getLogger(Product.class.getName());
+
+ /**
+ * <p>
+ * Default Constructor
+ * </p>
+ *
+ */
+ public Product() {
+ references = new Vector<Reference>();
+ this.productStructure = Product.STRUCTURE_FLAT;
+ }
+
+ public Product(InputStream is) throws InstantiationException {
+ if (is == null) {
+ throw new InstantiationException(
+ "Unable to parse product stream: stream not set!");
+ }
+
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder parser = factory.newDocumentBuilder();
+ references = new Vector<Reference>();
+ parse(parser.parse(new InputSource(is)));
+ } catch (Exception e) {
+ throw new InstantiationException(
+ "Unable to parse metadata stream.[" + e.getMessage() + "]");
+ }
+ }
+
+ /**
+ * <p>
+ * Constructs a new Product with the specified parameters.
+ * </p>
+ *
+ * @param name
+ * The Product's name.
+ * @param pType
+ * The Product's {@link ProductType}.
+ * @param structure
+ * The structure of the product: either Hierarchical, or Flat.
+ * @param transferStatus
+ * The status of this product's transfer to the DataStore:
+ * TRANSFERING, or RECEIVED would work
+ * @param refs
+ * A {@link List} of {@link Reference}s pointing to the items
+ * that make up this product.
+ */
+ public Product(String name, ProductType pType, String structure,
+ String transferStatus, List<Reference> refs) {
+ productName = name;
+ productType = pType;
+ productStructure = structure;
+ references = refs;
+ }
+
+ /**
+ * @return Returns the productType.
+ */
+ public ProductType getProductType() {
+ return productType;
+ }
+
+ /**
+ * @param productType
+ * The productType to set.
+ */
+ public void setProductType(ProductType productType) {
+ this.productType = productType;
+ }
+
+ /**
+ * @return Returns the productStructure.
+ */
+ public String getProductStructure() {
+ return productStructure;
+ }
+
+ /**
+ * @param productStructure
+ * The productStructure to set.
+ */
+ public void setProductStructure(String productStructure) {
+ this.productStructure = productStructure;
+ }
+
+ /**
+ * @return Returns the references.
+ */
+ public List<Reference> getProductReferences() {
+ return references;
+ }
+
+ /**
+ * @param references
+ * The references to set.
+ */
+ public void setProductReferences(List<Reference> references) {
+ this.references = references;
+ }
+
+ /**
+ * @return Returns the productName.
+ */
+ public String getProductName() {
+ return productName;
+ }
+
+ /**
+ * @param productName
+ * The productName to set.
+ */
+ public void setProductName(String productName) {
+ this.productName = productName;
+ }
+
+ /**
+ * @return Returns the productId.
+ */
+ public String getProductId() {
+ return productId;
+ }
+
+ /**
+ * @param productId
+ * The productId to set.
+ */
+ public void setProductId(String productId) {
+ this.productId = productId;
+ }
+
+ /**
+ * @return Returns the transferStatus.
+ */
+ public String getTransferStatus() {
+ return transferStatus;
+ }
+
+ /**
+ * @param transferStatus
+ * The transferStatus to set.
+ */
+ public void setTransferStatus(String transferStatus) {
+ this.transferStatus = transferStatus;
+ }
+
+ /**
+ * @return the rootRef
+ */
+ public Reference getRootRef() {
+ return rootRef;
+ }
+
+ /**
+ * @param rootRef
+ * the rootRef to set
+ */
+ public void setRootRef(Reference rootRef) {
+ this.rootRef = rootRef;
+ }
+
+ public static final Product getDefaultFlatProduct(String name,
+ String defaultProductTypeId) {
+ Product defaultProduct = new Product();
+ defaultProduct.setProductName(name);
+ defaultProduct.setProductReferences(new Vector<Reference>());
+ defaultProduct.setProductStructure(Product.STRUCTURE_FLAT);
+ ProductType pType = new ProductType();
+ pType.setProductTypeId(defaultProductTypeId);
+ defaultProduct.setProductType(pType);
+ defaultProduct.setTransferStatus(Product.STATUS_TRANSFER);
+ return defaultProduct;
+ }
+
+ public Document toXML() throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ Document doc = null;
+
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ doc = builder.newDocument();
+
+ Element root = (Element) doc.createElement("cas:product");
+ XMLUtils.addAttribute(doc, root, "xmlns:cas",
+ "http://oodt.jpl.nasa.gov/1.0/cas");
+ XMLUtils.addAttribute(doc, root, "id", this.productId);
+ XMLUtils.addAttribute(doc, root, "name", URLEncoder.encode(
+ this.productName, "UTF-8"));
+ doc.appendChild(root);
+
+ XMLUtils.addNode(doc, root, "structure", this.productStructure);
+ XMLUtils.addNode(doc, root, "transferStatus", this.transferStatus);
+ XMLUtils.addNode(doc, root, "type",
+ this.productType != null ? this.productType.getName() : "");
+
+ if (this.getProductReferences() != null
+ && this.getProductReferences().size() > 0) {
+ Element refsElem = XMLUtils.addNode(doc, root, "references");
+ for (Iterator<Reference> i = this.getProductReferences().iterator(); i
+ .hasNext();) {
+ Reference r = i.next();
+ Element refElem = XMLUtils.addNode(doc, refsElem,
+ "reference");
+ XMLUtils.addAttribute(doc, refElem, "orig", r
+ .getOrigReference());
+ XMLUtils.addAttribute(doc, refElem, "dataStore", r
+ .getDataStoreReference());
+ XMLUtils.addAttribute(doc, refElem, "size", String
+ .valueOf(r.getFileSize()));
+
+ }
+ }
+
+ } catch (ParserConfigurationException pce) {
+ LOG.log(Level.WARNING, "Error generating product xml file!: "
+ + pce.getMessage());
+ throw new Exception("Error generating product xml file!: "
+ + pce.getMessage());
+ }
+
+ return doc;
+ }
+
+ private void parse(Document doc) {
+ Element root = doc.getDocumentElement();
+
+ this.productId = root.getAttribute("id");
+ try {
+ this.productName = URLDecoder.decode(root.getAttribute("name"),
+ "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ LOG.log(Level.WARNING,
+ "Unable to set product name: error decoding encoded string: Message: "
+ + e.getMessage());
+
+ }
+
+ this.productStructure = XMLUtils.getElementText("structure", root);
+ this.productType = new ProductType();
+ this.productType.setName(XMLUtils.getElementText("type", root));
+ this.transferStatus = XMLUtils.getElementText("transferStatus", root);
+
+ Element refsElem = XMLUtils.getFirstElement("references", root);
+
+ if (refsElem != null) {
+ NodeList refNodeList = refsElem.getElementsByTagName("reference");
+
+ if (refNodeList != null && refNodeList.getLength() > 0) {
+ for (int i = 0; i < refNodeList.getLength(); i++) {
+ Element refElem = (Element) refNodeList.item(i);
+ Reference r = new Reference();
+ r.setOrigReference(refElem.getAttribute("orig"));
+ r.setDataStoreReference(refElem.getAttribute("dataStore"));
+ r.setFileSize(Long.valueOf(refElem.getAttribute("size"))
+ .longValue());
+ this.references.add(r);
+ }
+ }
+ }
+
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductPage.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductPage.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductPage.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductPage.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,169 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Page of {@link Product}s returned from the <code>File Manager</code>.
+ * </p>
+ *
+ */
+public class ProductPage {
+
+ /* the number of this page */
+ private int pageNum = -1;
+
+ /* the size of the number of products on this page */
+ private int pageSize = -1;
+
+ private int numOfHits = -1;
+
+ /* the list of produdcts associated with this page */
+ private List<Product> pageProducts = null;
+
+ /**
+ * <p>
+ * Default Constructor
+ * </p>.
+ */
+ public ProductPage() {
+ pageProducts = new Vector<Product>();
+ }
+
+ /**
+ * @param pageNum
+ * The number of this page.
+ * @param totalPages
+ * The total number of pages in the set.
+ * @param pageSize
+ * The size of this page.
+ * @param pageProducts
+ * The products associated with this page.
+ */
+ public ProductPage(int pageNum, int pageSize, int numOfHits,
+ List<Product> pageProducts) {
+ this.pageNum = pageNum;
+ this.numOfHits = numOfHits;
+ this.pageSize = pageSize;
+ this.pageProducts = pageProducts;
+ }
+
+ /**
+ * @return Returns the pageNum.
+ */
+ public int getPageNum() {
+ return pageNum;
+ }
+
+ /**
+ * @param pageNum
+ * The pageNum to set.
+ */
+ public void setPageNum(int pageNum) {
+ this.pageNum = pageNum;
+ }
+
+ public void setNumOfHits(int numOfHits) {
+ this.numOfHits = numOfHits;
+ }
+
+ public int getNumOfHits() {
+ return this.numOfHits;
+ }
+
+ /**
+ * @return Returns the pageProducts.
+ */
+ public List<Product> getPageProducts() {
+ return pageProducts;
+ }
+
+ /**
+ * @param pageProducts
+ * The pageProducts to set.
+ */
+ public void setPageProducts(List<Product> pageProducts) {
+ this.pageProducts = pageProducts;
+ }
+
+ /**
+ * @return Returns the pageSize.
+ */
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ /**
+ * @param pageSize
+ * The pageSize to set.
+ */
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * @return Returns the totalPages.
+ */
+ public int getTotalPages() {
+ return (int) Math.ceil((double) this.numOfHits / (double) this.pageSize);
+ }
+//
+// /**
+// * @param totalPages
+// * The totalPages to set.
+// */
+// public void setTotalPages(int totalPages) {
+// this.totalPages = totalPages;
+// }
+
+ /**
+ *
+ * @return True if this is the last page in the set, false otherwise.
+ */
+ public boolean isLastPage() {
+ return pageNum == this.getTotalPages();
+ }
+
+ /**
+ *
+ * @return True if this is the fist page of the set, false otherwise.
+ */
+ public boolean isFirstPage() {
+ return pageNum == 1;
+ }
+
+ /**
+ *
+ * @return A blank, unpopulated {@link ProductPage}.
+ */
+ public static ProductPage blankPage() {
+ ProductPage blank = new ProductPage();
+ blank.setPageNum(0);
+ blank.setPageSize(0);
+ blank.setNumOfHits(0);
+ return blank;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/ProductType.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,203 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.type.TypeHandler;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A ProductType is a type of content that will be ingested into the data store
+ * element of the CAS File Manager. The {@link MetadataStore} also needs to know
+ * about the ProductType, because {@link Element}s are associated with them to
+ * define how the metadata is stored for a particular product.
+ * </p>
+ *
+ */
+public class ProductType {
+
+ /* the unique ID representing this product type */
+ private String productTypeId = null;
+
+ /* the name of this product type */
+ private String name = null;
+
+ /* a description of this product type */
+ private String description = null;
+
+ /* the path to the repository for this product type */
+ private String productRepositoryPath = null;
+
+ /*
+ * the name of the class that implements the versioning scheme for this
+ * product type
+ */
+ private String versioner = null;
+
+ /* metadata describing the product type */
+ private Metadata typeMetadata = null;
+
+ /* list of {@link ExtractorSpec}s associated with this product type */
+ private List<ExtractorSpec> extractors = null;
+
+ private List<TypeHandler> handlers = null;
+
+ public ProductType() {
+ typeMetadata = new Metadata();
+ extractors = new Vector<ExtractorSpec>();
+ }
+
+ public ProductType(String id, String name, String description,
+ String repository, String versioner) {
+ productTypeId = id;
+ this.name = name;
+ this.description = description;
+ productRepositoryPath = repository;
+ this.versioner = versioner;
+ typeMetadata = new Metadata();
+ }
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description
+ * The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the productTypeId.
+ */
+ public String getProductTypeId() {
+ return productTypeId;
+ }
+
+ /**
+ * @param productTypeId
+ * The productTypeId to set.
+ */
+ public void setProductTypeId(String productTypeId) {
+ this.productTypeId = productTypeId;
+ }
+
+ /**
+ * @return Returns the productRepositoryPath.
+ */
+ public String getProductRepositoryPath() {
+ return productRepositoryPath;
+ }
+
+ /**
+ * @param productRepositoryPath
+ * The productRepositoryPath to set.
+ */
+ public void setProductRepositoryPath(String productRepositoryPath) {
+ this.productRepositoryPath = productRepositoryPath;
+ }
+
+ /**
+ * @return Returns the versioner.
+ */
+ public String getVersioner() {
+ return versioner;
+ }
+
+ /**
+ * @param versioner
+ * The versioner to set.
+ */
+ public void setVersioner(String versioner) {
+ this.versioner = versioner;
+ }
+
+ /**
+ * @return the typeMetadata
+ */
+ public Metadata getTypeMetadata() {
+ return typeMetadata;
+ }
+
+ /**
+ * @param typeMetadata
+ * the typeMetadata to set
+ */
+ public void setTypeMetadata(Metadata typeMetadata) {
+ this.typeMetadata = typeMetadata;
+ }
+
+ /**
+ * @return the extractors
+ */
+ public List<ExtractorSpec> getExtractors() {
+ return extractors;
+ }
+
+ /**
+ * @param extractors
+ * the extractors to set
+ */
+ public void setExtractors(List<ExtractorSpec> extractors) {
+ this.extractors = extractors;
+ }
+
+ public List<TypeHandler> getHandlers() {
+ return handlers;
+ }
+
+ public void setHandlers(List<TypeHandler> handlers) {
+ this.handlers = handlers;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.name;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Query.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,96 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Query is a {@link List} of {@link QueryCriteria}.
+ * </p>
+ *
+ */
+public class Query {
+
+ /* the set of {@link QueryCriteria} for this Query */
+ private List<QueryCriteria> criteria = null;
+
+ /**
+ * <p>
+ * Default Constructor
+ * </p>.
+ */
+ public Query() {
+ criteria = new Vector<QueryCriteria>();
+ }
+
+ /**
+ * @param criteria
+ */
+ public Query(List<QueryCriteria> criteria) {
+ if (criteria == null)
+ this.criteria = new Vector<QueryCriteria>();
+ else
+ this.criteria = criteria;
+ }
+
+ /**
+ * @return Returns the criteria.
+ */
+ public List<QueryCriteria> getCriteria() {
+ return criteria;
+ }
+
+ /**
+ * @param criteria
+ * The criteria to set.
+ */
+ public void setCriteria(List<QueryCriteria> criteria) {
+ if (criteria != null)
+ this.criteria = criteria;
+ }
+
+ public void addCriterion(QueryCriteria qc) {
+ criteria.add(qc);
+ }
+
+ /**
+ * @return A String representation of this Query.
+ */
+ public String toString() {
+ StringBuffer rStr = new StringBuffer();
+
+ rStr.append("q=");
+
+ int numCriteria = criteria.size();
+ for (int i = 0; i < numCriteria; i++) {
+ QueryCriteria c = (QueryCriteria) criteria.get(i);
+ rStr.append(c.toString());
+ if (i != numCriteria - 1)
+ rStr.append(" AND ");
+ }
+
+ return rStr.toString();
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/QueryCriteria.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/QueryCriteria.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/QueryCriteria.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/QueryCriteria.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,59 @@
+/*
+ * 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.filemgr.structs;
+
+/**
+ * @author woollard
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * This is an abstract base class for a number of different criteria searches
+ * such as term search, range search and free text search. Subclasses are added
+ * to Query instances in order to search the Catalog.
+ * </p>
+ *
+ * <ul>
+ * <lh>Known Subclasses:</lh>
+ * <li>FreeTextQueryCriteria
+ * <li>RangeQueryCriteria
+ * <li>TermQueryCriteria
+ * </ul>
+ */
+public abstract class QueryCriteria implements Cloneable {
+
+ /**
+ * Abstract accessor method for the Element name to search on.
+ *
+ * @return The ElementName in the form of a String.
+ */
+ public abstract String getElementName();
+
+ /**
+ * Abstract mutator method for the Elment name to search on.
+ *
+ * @param Element Name
+ */
+ public abstract void setElementName(String elementName);
+
+ /**
+ * Abstract method for converting the QueryCriteria to a human-parsable
+ * String.
+ */
+ public abstract String toString();
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/RangeQueryCriteria.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/RangeQueryCriteria.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/RangeQueryCriteria.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/RangeQueryCriteria.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,181 @@
+/*
+ * 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.filemgr.structs;
+
+/**
+ * @author woollard
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Range Criteria element for a Query to the Catalog.
+ * </p>
+ *
+ */
+public class RangeQueryCriteria extends QueryCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String elementName;
+
+ private String startValue;
+
+ private String endValue;
+
+ private boolean inclusive;
+
+ /**
+ * Default constructor.
+ */
+ public RangeQueryCriteria() {
+ elementName = null;
+ startValue = null;
+ endValue = null;
+ inclusive = true;
+ }
+
+ /**
+ * Constructor for the RangeQuerycriteria class. Note that this default
+ * range is inclusive.
+ *
+ * @param elementName
+ * The name of the element to search on.
+ * @param start
+ * The start value for the range search as a String.
+ * @param end
+ * The end value for the range search as a String.
+ */
+ public RangeQueryCriteria(String elementName, String start, String end) {
+ this.elementName = elementName;
+ startValue = start;
+ endValue = end;
+ inclusive = true;
+ }
+
+ /**
+ * Constructor for the RangeQueryCriteria clas that can be used to specify
+ * both inclusive and exclusive ranges.
+ *
+ * @param elementName
+ * The name of the element to search on.
+ * @param start
+ * The start value for the range search as a String.
+ * @param end
+ * The end value for the range search as a String.
+ * @param inclusive
+ * Boolean: true for inclusive, false for exclusive.
+ */
+ public RangeQueryCriteria(String elementName, String start, String end,
+ boolean inclusive) {
+ this.elementName = elementName;
+ startValue = start;
+ endValue = end;
+ this.inclusive = inclusive;
+ }
+
+ /**
+ * Accessor method for the start value of the element to search on.
+ *
+ * @return The start value of the element to search on as a String.
+ */
+ public String getStartValue() {
+ return startValue;
+ }
+
+ /**
+ * Mutator method for the start value fo the element to search on.
+ *
+ * @param value
+ * The start value of the range as a String.
+ */
+ public void setStartValue(String value) {
+ startValue = value;
+ }
+
+ /**
+ * Accessor method for the end value of the element to search on.
+ *
+ * @return The end value of the element to search on as a String.
+ */
+ public String getEndValue() {
+ return endValue;
+ }
+
+ /**
+ * Mutator method for the end value fo the element to search on.
+ *
+ * @param value
+ * The end value of the range as a String.
+ */
+ public void setEndValue(String value) {
+ endValue = value;
+ }
+
+ /**
+ * Accessor method for the inclusive setting for the range.
+ *
+ * @return The boolean inclusive/exclusive flag.
+ */
+ public boolean getInclusive() {
+ return inclusive;
+ }
+
+ /**
+ * Mutator method for the inclusive setting for the range. Note that flag
+ * should be set to true for inclusive, false for exclusive.
+ *
+ * @param inclusive
+ * The boolean inclusive/exclusive flag.
+ */
+ public void setInclusive(boolean flag) {
+ inclusive = flag;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * accessing the element name to search on.
+ *
+ * @return The element name to search on as a String.
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * mutating the element name to search on.
+ *
+ * @param elementName
+ * The element name to search on as a String.
+ */
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * generating a human-parsable string version of the query criteria. Note
+ * that the returned String follows the Lucene query language.
+ *
+ * @return The query as a String.
+ */
+ public String toString() {
+ String serial = elementName + ":[" + startValue + " TO " + endValue + "]";
+ return serial;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/Reference.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,235 @@
+/*
+ * 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.filemgr.structs;
+
+//JDK imports
+import java.net.MalformedURLException;
+import java.net.URL;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.mime.MimeType;
+import org.apache.oodt.cas.filemgr.structs.mime.MimeTypes;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A reference stores the original item reference, and also the item's data
+ * store reference, which describes its location within the data store.
+ * </p>
+ *
+ */
+public class Reference {
+
+ /* the item's original location */
+ private String origReference = null;
+
+ /* the location of the item within the data store */
+ private String dataStoreReference = null;
+
+ /* the size of the file that this reference refers to */
+ private long fileSize = 0L;
+
+ /* the mime-type of the file that this reference refers to */
+ private MimeType mimeType = null;
+
+ private static MimeTypes mimeTypeRepository;
+
+ /* the static reference to the Mime-Type repository */
+ static {
+ mimeTypeRepository = MimeTypes.buildRepository(PathUtils
+ .replaceEnvVariables(System.getProperty(
+ "gov.nasa.jpl.oodt.cas.filemgr.mime.type.repository",
+ "mime-types.xml")));
+ }
+
+ /**
+ * <p>
+ * Copy Constructor
+ * </p>
+ *
+ * @param r
+ * The Reference object to copy
+ */
+ public Reference(Reference r) {
+ this(r.getOrigReference(), r.getDataStoreReference(), r.getFileSize(),
+ r.getMimeType());
+ }
+
+ /**
+ * <p>
+ * Default constructor
+ * </p>
+ */
+ public Reference() {
+ super();
+ this.setMimeType(MimeTypes.DEFAULT);
+ }
+
+ /**
+ * <p>
+ * Constructs a new Reference with the specified parameters.
+ * </p>
+ *
+ * @param origRef
+ * The item's original location.
+ * @param dataRef
+ * The item's location within the data store.
+ * @param size
+ * The size of the file that this reference refers to.
+ */
+ public Reference(String origRef, String dataRef, long size) {
+ origReference = origRef;
+ dataStoreReference = dataRef;
+ fileSize = size;
+ // TODO: since no mimetype was specified, do the dirty work
+ // ourselves to determine the which MimeType class to associate
+ // with this reference.
+ try {
+ this.setMimeType(mimeTypeRepository
+ .getMimeType(new URL(origRef)));
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * <p>
+ * Constructs a new Reference with the specified parameters. In particular,
+ * a MimeType object is explicitly supplied. This object represents the
+ * mime-type of the item this reference refers to
+ * </p>
+ *
+ * @param origRef
+ * The item's original location.
+ * @param dataRef
+ * The item's location within the data store.
+ * @param size
+ * The size of the file that this reference refers to.
+ * @param mime
+ * A MimeType object representing the mime-type of the item
+ */
+ public Reference(String origRef, String dataRef, long size, MimeType mime) {
+ origReference = origRef;
+ dataStoreReference = dataRef;
+ fileSize = size;
+ mimeType = mime;
+ }
+
+ /**
+ * @return Returns the dataStoreReference.
+ */
+ public String getDataStoreReference() {
+ return dataStoreReference;
+ }
+
+ /**
+ * @param dataStoreReference
+ * The dataStoreReference to set.
+ */
+ public void setDataStoreReference(String dataStoreReference) {
+ this.dataStoreReference = dataStoreReference;
+ }
+
+ /**
+ * @return Returns the origReference.
+ */
+ public String getOrigReference() {
+ return origReference;
+ }
+
+ /**
+ * @param origReference
+ * The origReference to set.
+ */
+ public void setOrigReference(String origReference) {
+ this.origReference = origReference;
+ }
+
+ /**
+ * @return Returns the fileSize.
+ */
+ public long getFileSize() {
+ return fileSize;
+ }
+
+ /**
+ * @param fileSize
+ * The fileSize to set.
+ */
+ public void setFileSize(long fileSize) {
+ this.fileSize = fileSize;
+ }
+
+ /**
+ * @return returns a MimeType obj representing the mime-type of this
+ * reference
+ */
+ public MimeType getMimeType() {
+ return mimeType;
+ }
+
+ /**
+ * @param mime
+ * the MimeType object to set for this reference
+ */
+ public void setMimeType(MimeType mime) {
+ if (mime != null)
+ this.mimeType = mime;
+ }
+
+ /**
+ * @param name
+ * the String name of the mimetype of this reference
+ */
+ public void setMimeType(String name) {
+ if (name != null && !name.equals("")) {
+ this.mimeType = mimeTypeRepository.forName(name);
+ if (this.mimeType == null) {
+ try {
+ this.mimeType = new MimeType(name);
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("[orig=");
+ buf.append(this.origReference);
+ buf.append(",dest=");
+ buf.append(this.dataStoreReference);
+ buf.append(",size=");
+ buf.append(this.fileSize);
+ buf.append(",mime=");
+ buf.append(this.mimeType != null ? this.mimeType.toString() : "N/A");
+ buf.append("]");
+ return buf.toString();
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/TermQueryCriteria.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/TermQueryCriteria.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/TermQueryCriteria.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/TermQueryCriteria.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,110 @@
+/*
+ * 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.filemgr.structs;
+
+/**
+ * @author woollard
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * A Term Criteria element for a Query to the Catalog.
+ * </p>
+ *
+ */
+public class TermQueryCriteria extends QueryCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String elementName;
+
+ private String value;
+
+ /**
+ * Default constructor.
+ */
+ public TermQueryCriteria() {
+ elementName = null;
+ value = null;
+ }
+
+ /**
+ * Constructor for the TermQueryECriteria Class.
+ *
+ * @param elementName
+ * The name of the element to search on.
+ * @param v
+ * The value of the term.
+ */
+ public TermQueryCriteria(String elementName, String v) {
+ this.elementName = elementName;
+ value = v;
+ }
+
+ /**
+ * Accessor method for the value of the element to search on.
+ *
+ * @return The value of the element to search on as a String.
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Mutator method for the value of the element to search on
+ *
+ * @param value
+ * The value of the element to search on as a String.
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * accessing the element name to search on.
+ *
+ * @return The element name to search on as a String.
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * mutating the element name to search on.
+ *
+ * @param elementName
+ * The element name to search on as a String.
+ */
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ /**
+ * Implementation of the abstract method inherited from QueryCriteria for
+ * generating a human-parsable string version of the query criteria. Note
+ * that the returned String follows the Lucene query language.
+ *
+ * @return The query as a String.
+ */
+ public String toString() {
+ String serial = this.elementName + ":" + value;
+ return serial;
+ }
+
+}
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CacheException.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CacheException.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CacheException.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CacheException.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.filemgr.structs.exceptions;
+
+/**
+ *
+ * @author bfoster
+ *
+ */
+public class CacheException extends Exception {
+
+ private static final long serialVersionUID = 2154843096944174319L;
+
+ public CacheException() {
+ super();
+ }
+
+ public CacheException(String msg) {
+ super(msg);
+ }
+
+ public CacheException(String message, Throwable t) {
+ super(message, t);
+ }
+
+}
\ No newline at end of file
Added: oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CatalogException.java
URL: http://svn.apache.org/viewvc/oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CatalogException.java?rev=1052148&view=auto
==============================================================================
--- oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CatalogException.java (added)
+++ oodt/branches/wengine-branch/filemgr/src/main/java/org/apache/oodt/cas/filemgr/structs/exceptions/CatalogException.java Thu Dec 23 02:48:02 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.filemgr.structs.exceptions;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ *
+ * <p>A generic exception that occured when dealing with the
+ * Catalog.</p>
+ *
+ */
+public class CatalogException extends Exception {
+
+ private static final long serialVersionUID = 3690753990686029110L;
+
+ /**
+ * <p>Default Constructor</p>
+ */
+ public CatalogException() {
+ super();
+ }
+
+ /**
+ * @param message The message for this exception.
+ */
+ public CatalogException(String message) {
+ super(message);
+ }
+
+ public CatalogException(String message, Throwable t) {
+ super(message, t);
+ }
+
+}