diff --git a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar
deleted file mode 100755
index 0722287c..00000000
Binary files a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar and /dev/null differ
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar.md5
deleted file mode 100644
index 908bdffc..00000000
--- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-ff8e2614780c280e7c14f53eeb0d448e
\ No newline at end of file
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar.sha1
deleted file mode 100644
index 324bb736..00000000
--- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-1516c8f09af1d321bc867387e7d7e97fe6333a37
\ No newline at end of file
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom
deleted file mode 100644
index cd520e7c..00000000
--- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
+ * A Product's Ingest Status
+ *
+ * The core interface for a cache of {@link Product}s (identified by a particular
+ *
+ * A Factory class for creating {@link Cache}s
+ *
+ * A Catalog is the front end object interface for a back end peristance layer for storing
+ * product references and metadata. Classes implementing this interface implement methods
+ * to retrieve and store product references and metadata from a particular backend
+ * repository.
+ *
+ * Ingests {@link Metadata} into the metadata store, and associates it with the given
+ *
+ * Removes {@link Metadata} from the metadata store, and disassociates it from the given
+ *
+ * Adds a Product to the Catalog.
+ *
+ * Modifies an existing Product within the Catalog.
+ *
+ * Removes a {@link Product} from the Catalog.
+ *
+ * Persists the
+ * Adds the specified {@link List} of {@link Reference}s to the {@link Catalog}, and associates
+ * them with this {@link Product} specified by its
+ * Gets a {@link Product}, with the specified
+ * Gets a {@link Product} with the specified
+ * Gets the {@link Reference}s associated with this Product.
+ *
+ * Gets all the {@link Product}s in the {@link Catalog}.
+ *
+ * Gets the {@link Product}s associated with the specified ProductType in the {@link Catalog}.
+ *
+ * Gets the Metadata for a given Product.
+ * uniqueElement
) from a File Manager.
+ * productName
+ * exists.
+ *
+ * @param productName The name of the {@link Product} to check for in the Cache.
+ * @return True if the {@link Product} is foudn in the Cache, False, otherwise.
+ */
+ boolean contains(String productName);
+
+ /**
+ * Specifies the {@link URL} to the File Manager to connect this Cache to.
+ *
+ * @param fmUrl The {@link URL} of the File Manager to cache {@link Product}s from.
+ */
+ void setFileManager(URL fmUrl);
+
+ /**
+ *
+ * @return The size of the current {@link Product} cache.
+ */
+ int size();
+
+ /**
+ * Synchronizes this Cache with the File Manager specified by the {@link #setFileManager(URL)}
+ * method.
+ *
+ * @param uniqueElementProductTypeNames The {@link List} {@link ProductType}s to cache
+ * {@link Product}s from.
+ * @throws CacheException If there is any error.
+ */
+ void sync(ListproductId
.
+ * productId
.
+ * transferStatus
attribute of the given {@link Product} to the Catalog.
+ *
+ * @param product The Product whose transfer status will be persisted. The caller should make sure
+ * that the product ID field is set.
+ * @throws CatalogException
+ */
+ void setProductTransferStatus(Product product) throws CatalogException;
+
+ /**
+ * productId
.
+ * productId
.
+ * productName
.
+ * productId
.
+ *
+ * Gets a reduced set of metadata for a give Product. + *
+ * + * @param product The {@link Product} to obtain the Metadata for. + * @param elements The set of metadata elements of interest. + * @return The reduced {@link Metadata} for the givenproductId
.
+ * @throws CatalogException If any error occurs.
+ */
+ Metadata getReducedMetadata(Product product, List+ * Queries the Catalog with the specified {@link Query} + *
+ * . + * + * @param query The set of criteria by which to query the Catalog. + * @param type The {@link ProductType} that should be queried. + * @return A {@link List} of String product IDs that can be used to retrieve products that match + * the query. + * @throws CatalogException If any error occurs. + */ + List+ * Performs a query against the underlying {@link Catalog}, and then properly formulates a page of + * results to send back to the user. This method is useful when you would like to conserve memory + * and not send back the entire list of results, nor load them into memory. Of course, this method + * assumes that queries are deterministic, i.e., the same query issued 2x within a paginating + * session will produce the same set of results to paginate. + *
+ * + * @param query The query to perform against the underlying Catalog. + * @param type The {@link ProductType} that you are querying for. + * @param pageNum The number of the {@link ProductPage} to return back to the user. + * @return The requested {@link ProductPage} of results. + * @throws CatalogException If any error occurs. + */ + ProductPage pagedQuery(Query query, ProductType type, int pageNum) throws CatalogException; + + /** + *
+ * Gets the top N
most recent products that have been cataloged.
+ *
+ * Gets the top N
most recent products that have been cataloged for the given
+ * {@link ProductType}.
+ *
+ * A Factory interface for creating {@link Catalog}s. + *
+ * + */ +public interface CatalogFactory { + + /** + * @return A new {@link Catalog} object implementation. + */ + Catalog createCatalog(); +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CrawlerActionPhases.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CrawlerActionPhases.java new file mode 100644 index 00000000..5ad21b61 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CrawlerActionPhases.java @@ -0,0 +1,46 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.filemgr; + +/** + * Supported Crawler Phases. + * + * @author mattmann (Chris Mattmann) + * @author bfoster (Brian Foster) + */ +public enum CrawlerActionPhases { + PRE_INGEST("preIngest"), POST_INGEST_SUCCESS("postIngestSuccess"), POST_INGEST_FAILURE( + "postIngestFailure"); + + private String name; + + CrawlerActionPhases(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static CrawlerActionPhases getPhaseByName(String name) { + for (CrawlerActionPhases phase : CrawlerActionPhases.values()) { + if (phase.getName().equals(name)) { + return phase; + } + } + return null; + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/DataTransfer.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/DataTransfer.java new file mode 100644 index 00000000..0514f0b9 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/DataTransfer.java @@ -0,0 +1,65 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.filemgr; + +// JDK imports +import java.io.File; +import java.io.IOException; +import java.net.URL; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.DataTransferException; +import gov.nasa.pds.harvest.search.oodt.structs.Product; + +/** + * @author mattmann + * @version $Revision$ + * + *+ * Objects implementing this interface define how to transfer products to the + * {@link DataStore} repository. + *
+ * + */ +public interface DataTransfer { + /* extension point ID */ + String X_POINT_ID = DataTransfer.class.getName(); + + /** + * + * @param url The URL to the File Manager that this transferer will be transferring Products to. + */ + void setFileManagerUrl(URL url); + + /** + * + * @param product The product that is being transferred. The product should have both its + * origFileLocation, as well as its dataStoreRefs filled in to perform the transfer. + * @throws DataTransferException If a general error occurs during the transfer. + * @throws IOException If there is an IO eerror when performing the transfer. + */ + void transferProduct(Product product) throws DataTransferException, IOException; + + /** + * Requires that the data store reference be set, nothing else is used + * + * @param product The product whose data store reference will be copied + * @param directory The directory where the data store reference will be copied to + * @throws DataTransferException If a general error occurs during the transfer. + * @throws IOException If there is an IO eerror when performing the transfer. + */ + void retrieveProduct(Product product, File directory) throws DataTransferException, IOException; + + void deleteProduct(Product product) throws DataTransferException, IOException; +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/DataTransferFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/DataTransferFactory.java new file mode 100644 index 00000000..c519ee88 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/DataTransferFactory.java @@ -0,0 +1,33 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.filemgr; + +/** + * @author mattmann + * @version $Revision$ + * + *+ * A Factory for creating {@link DataTransfer} implementation objects. + *
+ * + */ +public interface DataTransferFactory { + + /** + * @return A new {@link DataTransfer} implementation. + */ + DataTransfer createDataTransfer(); +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/FilemgrMetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/FilemgrMetExtractor.java new file mode 100644 index 00000000..99702004 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/FilemgrMetExtractor.java @@ -0,0 +1,51 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.filemgr; + +// JDK imports +import java.util.Properties; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.MetExtractionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; +import gov.nasa.pds.harvest.search.oodt.structs.Product; + +/** + * @author mattmann + * @version $Revision$ + * + *+ * The core interface for {@link Metadata} extraction on the File Manager server side. + *
+ * . + */ +public interface FilemgrMetExtractor { + + /** + * Extracts {@link Metadata} from the given {@link Product}. + * + * @param product The given {@link Product}. + * @param met The original {@link Metadata} provided during ingestion. + * @return Extracted {@link Metadata} derived from the existing {@link Metadata} and + * {@link Product} provided. + */ + Metadata extractMetadata(Product product, Metadata met) throws MetExtractionException; + + /** + * Sets the configuration for this Metadata extractor. + * + * @param props The {@link Properties} object to configure this Metadata extractor with. + */ + void configure(Properties props); +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/GenericFileManagerObjectFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/GenericFileManagerObjectFactory.java new file mode 100644 index 00000000..a6cbce7f --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/GenericFileManagerObjectFactory.java @@ -0,0 +1,295 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.filemgr; + +import java.util.logging.Level; +import java.util.logging.Logger; +import gov.nasa.pds.harvest.search.oodt.structs.query.FilterAlgor; +import gov.nasa.pds.harvest.search.oodt.structs.query.VersionConverter; +import gov.nasa.pds.harvest.search.oodt.structs.type.TypeHandler; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *+ * Generic object creation utilities for FileManager objects from their interface class + * names. + *
+ * + */ +public final class GenericFileManagerObjectFactory { + + /* our log stream */ + private static final Logger LOG = + Logger.getLogger(GenericFileManagerObjectFactory.class.getName()); + + private GenericFileManagerObjectFactory() throws InstantiationException { + throw new InstantiationException("Don't construct final factory classes!"); + } + + /** + *
+ * Constructs a new {@link DataTransfer} from the specified serviceFactory
.
+ *
+ * Constructs a new {@link RepositoryManager} from the specified serviceFactory
.
+ *
+ * Constructs a new {@link Catalog} from the specified serviceFactory
.
+ *
+ * Creates a {@link ValidationLayer} from the specified serviceFactory
.
+ *
+ * Constructs a new {@link Versioner} from the specified className
.
+ *
+ * An interface for ingesting {@link Product}s + *
+ * . + */ +public interface Ingester { + + /** + * Ingests a {@link Product} to the file manager service object identified by the given + * {@link URL} parameter. The product {@link Metadata} is extracted dynamically using the provided + * {@link MetExtractor} interface. + * + * @param fmUrl The {@link URL} pointer to the file manager service. + * @param prodFile The {@link File} pointer to the product file. + * @param extractor The given {@link MetExtractor} to use to extract {@link Metadata} from the + * {@link Product}. + * @param metConfFile A Config{@link File} for the {@link MetExtractor}. + * @return The ID returned by the file manager for the newly ingested product. + * @throws IngestException If there is an error ingesting the {@link Product} + */ + String ingest(URL fmUrl, File prodFile, MetExtractor extractor, File metConfFile) + throws IngestException; + + /** + * Ingests a {@link Product} to the file manager service object identified by the given + * {@link URL} parameter. The product {@link Metadata} is provided a priori. + * + * @param fmUrl The {@link URL} pointer to the file manager service. + * @param prodFile The {@link File} pointer to the product file. + * @param met The given {@link Metadata} object already extracted from the {@link Product}. + * @return The ID returned by the file manager for the newly ingested product. + * @throws IngestException If there is an error ingesting the {@link Product} + */ + String ingest(URL fmUrl, File prodFile, Metadata met) throws IngestException; + + /** + * + * @param fmUrl The {@link URL} pointer to the file manager service. + * @param prodFiles A {@link List} of {@link String} filePaths pointing to {@link Product} files + * to ingest. + * @param extractor The given {@link MetExtractor} to use to extract {@link Metadata} from the + * {@link Product}s. + * @param metConfFile A Config{@link File} for the {@link MetExtractor}. + * @throws IngestException If there is an error ingesting the {@link Product}s. + */ + void ingest(URL fmUrl, ListFilename
.
+ *
+ * @param prodFile The {@link File} to check for existance of within the file manager at given
+ * {@link URL}.
+ * @url The {@link URL} pointer to the file manager service.
+ * @return
+ */
+ boolean hasProduct(URL fmUrl, File prodFile) throws CatalogException;
+
+ /**
+ * Checks the file manager at the given {@link URL} to see whether or not it knows about the
+ * provided {@link Product} with the given productName
parameter. To do this, it uses
+ * the provided productName
key as the {@link Metadata} key to search for in the
+ * catalog.
+ *
+ * @param fmUrl The {@link URL} pointer to the file manager service.
+ * @param productName The {@link Product} to search for, identified by its (possibly not unique)
+ * name.
+ * @return True if the file manager has the product, false otherwise.
+ */
+ boolean hasProduct(URL fmUrl, String productName) throws CatalogException;
+
+}
diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Pagination.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Pagination.java
new file mode 100644
index 00000000..549ea958
--- /dev/null
+++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Pagination.java
@@ -0,0 +1,62 @@
+/*
+ * 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 gov.nasa.pds.harvest.search.oodt.filemgr;
+
+import gov.nasa.pds.harvest.search.oodt.structs.ProductPage;
+import gov.nasa.pds.harvest.search.oodt.structs.ProductType;
+
+/**
+ * @author mattmann
+ * @version $Revision$
+ *
+ * + * An interface for pagination of {@link org.apache.oodt.cas.filemgr.structs.Product} + * {@link java.util.List}s.. + *
+ * + */ +public interface Pagination { + + /** + * @param type The ProductType to obtain the first {@link ProductPage} for. + * @return The first page of products for a particular {@link ProductType}. + */ + ProductPage getFirstPage(ProductType type); + + /** + * + * @param type The ProductType to obtain the last {@link ProductPage} for. + * @return The last page of products for a particular {@link ProductType}. + */ + ProductPage getLastProductPage(ProductType type); + + /** + * + * @param type The ProductType to obtain the next page for, given thecurrentPage
.
+ * @param currentPage The current page that tells the function what the next page to obtain is.
+ * @return The next page in the ProductType product list, given the currentPage.
+ */
+ ProductPage getNextPage(ProductType type, ProductPage currentPage);
+
+ /**
+ *
+ * @param type The ProductType to obtain the previous page for, given the
+ * currentPage
.
+ * @param currentPage The currentPage that tells the function what the previous page to obtain is.
+ * @return The previous page in the ProductType product list, given the currentPage.
+ */
+ ProductPage getPrevPage(ProductType type, ProductPage currentPage);
+}
diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/QueryResult.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/QueryResult.java
new file mode 100644
index 00000000..5e5d10c4
--- /dev/null
+++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/QueryResult.java
@@ -0,0 +1,137 @@
+/*
+ * 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 gov.nasa.pds.harvest.search.oodt.filemgr;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.util.StringUtils;
+import gov.nasa.pds.harvest.search.oodt.metadata.Metadata;
+import gov.nasa.pds.harvest.search.oodt.structs.Product;
+
+// OODT imports
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * + * A combination of a Product and its Metadata + *
+ */
+public class QueryResult {
+
+ private Product product;
+ private Metadata metadata;
+ private String toStringFormat;
+
+ public QueryResult(Product product, Metadata metadata) {
+ this.metadata = metadata;
+ this.product = product;
+ }
+
+ public Product getProduct() {
+ return this.product;
+ }
+
+ public void setProduct(Product product) {
+ this.product = product;
+ }
+
+ public Metadata getMetadata() {
+ return this.metadata;
+ }
+
+ public void setMetadata(Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ public String getToStringFormat() {
+ return this.toStringFormat;
+ }
+
+ public void setToStringFormat(String toStringFormat) {
+ this.toStringFormat = toStringFormat;
+ }
+
+ public String toString() {
+ return convertMetadataToString(this.metadata, this.toStringFormat);
+ }
+
+ private static String convertMetadataToString(Metadata metadata, String format) {
+ if (format == null) {
+ return concatMetadataIntoString(metadata);
+ }
+ String outputString = format;
+ for (String key : metadata.getAllKeys()) {
+ outputString = outputString.replaceAll("\\$" + key,
+ StringUtils.collectionToCommaDelimitedString(metadata.getAllMetadata(key)));
+ }
+ return outputString;
+ }
+
+ private static String concatMetadataIntoString(Metadata metadata) {
+ List
+// * A Factory for constructing {@link RemoteDataTransferer} objects.
+// *
+// * An implementation of the {@link DataTransfer} interface that transfers files to a remote
+// * file manager over XML-RPC, using the File Manager Client.
+// *
+ * Adds a ProductType to the RepositoryManager. + *
+ * + * @param productType The {@link ProductType} to add. + * @throws RepositoryManagerException + */ + void addProductType(ProductType productType) throws RepositoryManagerException; + + /** + *
+ * Modifies a ProductType in the RepositoryManager with the specified ID field of the
+ * productType
.
+ *
+ * Removes a ProductType from the RepositoryManager + *
+ * . + * + * @param productType The productType to remove. + * @throws RepositoryManagerException If any error occurs during the removal. + */ + void removeProductType(ProductType productType) throws RepositoryManagerException; + + /** + *
+ * Gets a {link ProductType} from the RepositoryManager identified by its
+ * productTypeId
.
+ *
productTypeId
.
+ * @throws RepositoryManagerException If any error occurs.
+ */
+ ProductType getProductTypeById(String productTypeId) throws RepositoryManagerException;
+
+ /**
+ *
+ * Gets a {@link ProductType} specified by its productTypeName
, from the
+ * RepositoryManager.
+ *
+ * Gets all the {@link ProductType}s from the repository. + *
+ * + * @return A {@link List} of {@link ProductType}s from the repository. + * @throws RepositoryManagerException If any error occurs. + */ + List+ * A Factory interface for creating {@link RepositoryManager} objects. + *
+ * + */ +public interface RepositoryManagerFactory { + + RepositoryManager createRepositoryManager(); +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/ValidationLayer.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/ValidationLayer.java new file mode 100644 index 00000000..86fb0ddc --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/ValidationLayer.java @@ -0,0 +1,124 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.filemgr; + +// JDK imports +import java.util.List; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.ValidationLayerException; +import gov.nasa.pds.harvest.search.oodt.structs.Element; +import gov.nasa.pds.harvest.search.oodt.structs.ProductType; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *+ * The Validation Layer for the File Manager, allowing {@link Element}s to be mapped to + * {@link ProductType}s. + *
+ * + */ +public interface ValidationLayer { + + /** + *
+ * Adds the Element
to the ValidationLayer.
+ *
+ * Modifies an existing {@link Element} in the ValidationLayer. + *
+ * + * @param element The new {@link Element} data to update. + * @throws ValidationLayerException If any error occurs. + */ + void modifyElement(Element element) throws ValidationLayerException; + + /** + *+ * Removes a metadata {@link Element} from the ValidationLayer. + * + * @param element The element to remove. + * @throws ValidationLayerException If any error occurs. + */ + void removeElement(Element element) throws ValidationLayerException; + + /** + *
+ * Adds the specified element
to the {@link ProductType} specified by its
+ * productTypeId
.
+ *
+ * @param type The {@link ProductType} to associate the metadata Element with.
+ * @param element The {@link Element} to associate with the ProductType.
+ * @throws ValidationLayerException If any error occurs.
+ */
+ void addElementToProductType(ProductType type, Element element) throws ValidationLayerException;
+
+ /**
+ *
+ * Removes a metadata {@link Element} from the specified productTypeId
.
+ *
element
with.
+ * @param element The element whose association will be removed from the specified ProductType.
+ * @throws ValidationLayerException If any error occurs.
+ */
+ void removeElementFromProductType(ProductType type, Element element)
+ throws ValidationLayerException;
+
+ /**
+ *
+ * Returns a {@link List} of {@link Element}s corresponding to the given ProductType.
+ *
+ * @param type The product type to retrieve the metadata {@link Element}s for.
+ * @return A {@link List} of {@link Element}s corresponding to the given ProductType.
+ * @throws ValidationLayerException If any error occurs.
+ */
+ List
+ * A Factory for creating {@link ValidationLayer}s.
+ *
+ * This interface defines a versioning scheme for generating the DataStore references for
+ * the items in a {@link Product}.
+ *
+ * A factory class for creating File Manager structures suitable for transfer over the
+ * XML-RPC pipe, and for reading objects from the XML-RPC pipe into File Manager structs.
+ *
/path/to/some/file
.
+ *
+ * @param filePath Path to a given file to extract Metadata from.
+ * @return Extracted {@link Metadata} from the given filePath
.
+ * @throws MetExtractionException If any error occurs.
+ */
+ Metadata extractMetadata(String filePath) throws MetExtractionException;
+
+ /**
+ * Extracts {@link Metadata} from a given {@link URL} pointer to a {@link File}.
+ *
+ * @param fileUrl The URL pointer to a File.
+ * @return Extracted {@link Metadata} from the given File {@link URL}.
+ * @throws MetExtractionException If any error occurs.
+ */
+ Metadata extractMetadata(URL fileUrl) throws MetExtractionException;
+
+ /**
+ * Sets the config file for this MetExtractor to the specified {@link File} f
.
+ *
+ * @param f The config file for this MetExtractor.
+ * @throws MetExtractionException
+ */
+ void setConfigFile(File f) throws MetExtractionException;
+
+ /**
+ * Sets the config file for this MetExtractor to the specified {@link File} identified by
+ * filePath
.
+ *
+ * @param filePath The config file path for this MetExtractor.
+ * @throws MetExtractionException
+ */
+ void setConfigFile(String filePath) throws MetExtractionException;
+
+ /**
+ * Sets the MetExtractorConfig for the MetExtractor
+ *
+ * @param config The MetExtractorConfig
+ */
+ void setConfigFile(MetExtractorConfig config);
+
+ /**
+ * Extracts {@link Metadata} from the given {@link File} using the specified config file.
+ *
+ * @param f The File to extract Metadata from.
+ * @param configFile The config file for this MetExtractor.
+ * @return Extracted {@link Metadata} from the given {@link File} using the specified config file.
+ * @throws MetExtractionException If any error occurs.
+ */
+ Metadata extractMetadata(File f, File configFile) throws MetExtractionException;
+
+ /**
+ * Extracts {@link Metadata} from the given {@link File} using the specified config file path.
+ *
+ * @param f The File to extract Metadata from.
+ * @param configFilePath The path to the config file for this MetExtractor.
+ * @return Extracted {@link Metadata} from the given {@link File} using the specified config file
+ * path.
+ * @throws MetExtractionException If any error occurs.
+ */
+ Metadata extractMetadata(File f, String configFilePath) throws MetExtractionException;
+
+ /**
+ * Extracts {@link Metadata} from the given {@link File} using the specified
+ * {@link MetExtractorConfig}.
+ *
+ * @param f The {@link File} from which {@link Metadata} will be extracted from
+ * @param config The config file for the extractor
+ * @return {@link Metadata} extracted from the {@link File}
+ * @throws MetExtractionException If any error occurs
+ */
+ Metadata extractMetadata(File f, MetExtractorConfig config) throws MetExtractionException;
+
+ /**
+ * Extracts {@link Metadata} from the given {@link URL} using the specified
+ * {@link MetExtractorConfig}.
+ *
+ * @param fileUrl The {@link URL} from which {@link Metadata} will be extracted from
+ * @param config The config file for the extractor
+ * @return {@link Metadata} extracted from the {@link URL}
+ * @throws MetExtractionException If any error occurs
+ */
+ Metadata extractMetadata(URL fileUrl, MetExtractorConfig config) throws MetExtractionException;
+}
diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/MetExtractorConfig.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/MetExtractorConfig.java
new file mode 100644
index 00000000..76e9dbc2
--- /dev/null
+++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/MetExtractorConfig.java
@@ -0,0 +1,29 @@
+/*
+ * 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 gov.nasa.pds.harvest.search.oodt.metadata;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * + * A {@link MetExtractor} config + *
+ * . + */ +public interface MetExtractorConfig { +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/Metadata.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/Metadata.java new file mode 100644 index 00000000..9fb0637a --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/Metadata.java @@ -0,0 +1,654 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE.txt 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 gov.nasa.pds.harvest.search.oodt.metadata; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Stack; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; +import gov.nasa.pds.registry.model.ExtrinsicObject; +import gov.nasa.pds.registry.model.Slot; + +/** + * + * Metadata is a {@link Map} ofString
keys mapped to Object values. So, each key can
+ * map to potentially many values, but also can map to null, or to a single value.
+ *
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public class Metadata {
+
+ private static Logger log = Logger.getLogger(Metadata.class.getName());
+
+ private Group root;
+
+ public Metadata() {
+ this.root = this.createNewRoot();
+ }
+
+ public Metadata(Metadata metadata) {
+ this();
+ this.addMetadata(metadata);
+ }
+
+ /**
+ * Adds (Appends if key exists) from given metadata into this metadata
+ *
+ * @param metadata Metadata to add metadata from
+ */
+ public void addMetadata(Metadata metadata) {
+ for (String key : metadata.getAllKeys()) {
+ this.addMetadata(key, metadata.getAllMetadata(key));
+ }
+ }
+
+ public void addMetadata(String group, Metadata metadata) {
+ if (group == null) {
+ this.addMetadata(metadata);
+ } else {
+ for (String key : metadata.getAllKeys()) {
+ this.addMetadata(group + "/" + key, metadata.getAllMetadata(key));
+ }
+ }
+ }
+
+ /**
+ * Adds (Replaces if key exists) from given Metadata into this Metadata
+ *
+ * @param metadata
+ */
+ public void replaceMetadata(Metadata metadata) {
+ for (String key : metadata.getAllKeys()) {
+ this.replaceMetadata(key, metadata.getAllMetadata(key));
+ }
+ }
+
+ public void replaceMetadata(String group, Metadata metadata) {
+ if (group == null) {
+ this.replaceMetadata(metadata);
+ } else {
+ for (String key : metadata.getAllKeys()) {
+ this.replaceMetadata(group + "/" + key, metadata.getAllMetadata(key));
+ }
+ }
+ }
+
+ /**
+ * Adds key (Appends if key exists)
+ *
+ * @param key Key to be added
+ * @param value Value of key to be added
+ */
+ public void addMetadata(String key, String value) {
+ this.getGroup(key).addValue(value);
+ }
+
+ /**
+ * Adds key (Replaces if key exists)
+ *
+ * @param key Key to be added
+ * @param value Value of key to be added
+ */
+ public void replaceMetadata(String key, String value) {
+ this.getGroup(key).setValue(value);
+ }
+
+ /**
+ * Adds key (Appends if key exists)
+ *
+ * @param key Key to be added
+ * @param values Values of key to be added
+ */
+ public void addMetadata(String key, List> values) {
+ for (Object value : values) {
+ if (value instanceof Slot) {
+ Slot slot = (Slot) value;
+ this.addMetadata(key + "/" + slot.getName(), slot.getValues());
+ } else if (value instanceof String) {
+ this.getGroup(key).addValue((String) value);
+ } else if (value instanceof ExtrinsicObject) {
+ this.addMetadata(key, new ArrayList+ * 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. + *
+ * + */ + +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+ * A metadata element. + *
+ * + */ +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; + + /** + *+ * Default constructor + *
+ * + */ + public Element() { + } + + /** + *+ * Constructs a new CAS element + *
+ * + * @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, String typeHandler) { + 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; + } + + public static Element blankElement(){ + Element e = new Element(); + e.setDCElement(""); + e.setDescription("blank"); + e.setElementId(""); + e.setElementName("blank"); + return e; + + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ExtractorSpec.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ExtractorSpec.java new file mode 100644 index 00000000..f300c250 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ExtractorSpec.java @@ -0,0 +1,82 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.structs; + +//JDK imports +import java.util.Properties; + +/** + * @author mattmann + * @version $Revision$ + * + *+ * A specification class showing how to constract + * a {@link FilemgrMetExtractor}. + *
. + */ +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; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/FileTransferStatus.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/FileTransferStatus.java new file mode 100644 index 00000000..6bab5f59 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/FileTransferStatus.java @@ -0,0 +1,119 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.structs; + +/** + * @author mattmann + * @version $Revision$ + * + *+ * A class to represent the status of a transfer for a file reference belonging + * to a {@link Product}. + *
+ * + */ +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; + + /** + *+ * Default Constructor + *
. + */ + 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)); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Product.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Product.java new file mode 100644 index 00000000..9aad80b4 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Product.java @@ -0,0 +1,376 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.structs; + +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +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; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.FileManagerException; +import gov.nasa.pds.harvest.search.oodt.utils.XMLUtils; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *+ * A Product is a set of files, or a heirarchical, directory structure that + * should be ingested into the {@link org.apache.oodt.cas.filemgr.catalog.Catalog}. + *
+ * + */ +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+ * Default Constructor + *
+ * + */ + public Product() { + references = new Vector+ * Constructs a new Product with the specified parameters. + *
+ * + * @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
+ * A Page of {@link Product}s returned from the File Manager
.
+ *
+ * Default Constructor + *
+ * . + */ + public ProductPage() { + pageProducts = new Vector+ * 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. + *
+ * + */ +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+ * A Query is a {@link List} of {@link QueryCriteria}. + *
+ * + */ +public class Query { + + /* the set of {@link QueryCriteria} for this Query */ + private List+ * Default Constructor + *
+ * . + */ + public Query() { + criteria = new Vector+ * 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. + *
+ * + *+ * A Range Criteria element for a Query to the Catalog. + *
+ * + */ +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. + * + */ + 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() { + return elementName + ":[" + startValue + " TO " + endValue + "]"; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Reference.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Reference.java new file mode 100644 index 00000000..c9d6e13f --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Reference.java @@ -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 gov.nasa.pds.harvest.search.oodt.structs; + +import java.io.File; +import java.io.FileInputStream; +import java.util.logging.Level; +import java.util.logging.Logger; +//OODT imports +import org.apache.tika.Tika; +import org.apache.tika.config.TikaConfig; +import org.apache.tika.mime.MimeType; +import org.apache.tika.mime.MimeTypeException; +import org.apache.tika.mime.MimeTypes; +import org.apache.tika.mime.MimeTypesFactory; +import gov.nasa.pds.harvest.search.util.PathUtils; + +//JDK imports + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *+ * A reference stores the original item reference, and also the item's data + * store reference, which describes its location within the data store. + *
+ * + */ +public class Reference { + private static Logger LOG = Logger.getLogger(Reference.class.getName()); + /* 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; + + public static String STREAM_REFERENCE_DELIMITER = "-"; + + /* the static reference to the Mime-Type repository */ + static { + try { + mimeTypeRepository = MimeTypesFactory.create(new FileInputStream(new File(PathUtils + .replaceEnvVariables(System.getProperty( + "org.apache.oodt.cas.filemgr.mime.type.repository", + "mime-types.xml"))))); + } catch (Exception e){ + mimeTypeRepository = TikaConfig.getDefaultConfig().getMimeRepository(); + } + } + + /** + *+ * Copy Constructor + *
+ * + * @param r + * The Reference object to copy + */ + public Reference(Reference r) { + this(r.getOrigReference(), r.getDataStoreReference(), r.getFileSize(), + r.getMimeType()); + } + + /** + *+ * Default constructor + *
+ */ + public Reference() { + super(); + } + + /** + *+ * Constructs a new Reference with the specified parameters. + *
+ * + * @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.mimeType = mimeTypeRepository.forName(new Tika().detect(origRef)); + } catch (MimeTypeException e) { + LOG.log(Level.SEVERE, e.getMessage()); + } + + } + + /** + *+ * 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 + *
+ * + * @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) { + this.mimeType = mime; + } + + /** + * @param name + * the String name of the mimetype of this reference + */ + public void setMimeType(String name) { + if(name == null || (name.equals(""))) { + return; + } + + try { + this.mimeType = mimeTypeRepository.forName(name); + } catch (MimeTypeException e) { + LOG.log(Level.SEVERE, e.getMessage()); + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + public String toString() { + return "[orig=" + this.origReference + ",dest=" + this.dataStoreReference + ",size=" + this.fileSize + ",mime=" + + (this.mimeType != null ? this.mimeType.toString() : "N/A") + "]"; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/TermQueryCriteria.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/TermQueryCriteria.java new file mode 100644 index 00000000..2153deec --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/TermQueryCriteria.java @@ -0,0 +1,104 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.structs; + +/** + * @author woollard + * @author bfoster + * @version $Revision$ + * + *+ * A Term Criteria element for a Query to the Catalog. + *
+ * + */ +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() { + return this.elementName + ":" + value; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/AsciiSortableVersionConverter.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/AsciiSortableVersionConverter.java new file mode 100644 index 00000000..19ed9633 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/AsciiSortableVersionConverter.java @@ -0,0 +1,38 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.structs.query; + +/** + * + * @author bfoster + * @version $Revision$ + * + *+ * Converts a ascii sortable String version into a priority number + *
+ */ +public class AsciiSortableVersionConverter implements VersionConverter { + + public double convertToPriority(String version) { + double priority = 0; + char[] versionCharArray = version.toCharArray(); + for (int i = 0, j = versionCharArray.length - 1; i < versionCharArray.length; i++, j--) { + priority += (((int) versionCharArray[i]) * Math.pow(10, j)); + } + return priority; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/ComplexQuery.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/ComplexQuery.java new file mode 100644 index 00000000..faa76f7d --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/ComplexQuery.java @@ -0,0 +1,97 @@ +/* + * 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 gov.nasa.pds.harvest.search.oodt.structs.query; + +// JDK imports +import java.util.List; +import gov.nasa.pds.harvest.search.oodt.structs.Query; +import gov.nasa.pds.harvest.search.oodt.structs.QueryCriteria; + +/** + * @author bfoster + * @version $Revision$ + * + *
+ * A Complex query allows for querying the filemgr across multiple product-types, reducing + * the metadata queried for, filtering the results, and sorting the results in a single + * query + *
+ */ +public class ComplexQuery extends Query { + + private List+ * An algorithm interface for defining how QueryFilter filters query results + *
+ */
+public abstract class FilterAlgor {
+
+ protected long epsilon;
+
+ public FilterAlgor() {
+ this.epsilon = 0;
+ }
+
+ public void setEpsilon(long epsilon) {
+ this.epsilon = epsilon;
+ }
+
+ public long getEpsilon() {
+ return this.epsilon;
+ }
+
+ public abstract List
+ * A {@link TimeEvent} associated with a particular {@link Object}
+ *
+ * A query filter that allows user to filter results in a complex query
+ *
+ */
+public class QueryFilter {
+
+ private String startDateTimeMetKey, endDateTimeMetKey, priorityMetKey;
+ private FilterAlgor filterAlgor;
+ private VersionConverter converter;
+
+ public QueryFilter(String startDateTimeMetKey, String endDateTimeMetKey, String priorityMetKey,
+ FilterAlgor filterAlgor) {
+ this.startDateTimeMetKey = startDateTimeMetKey;
+ this.endDateTimeMetKey = endDateTimeMetKey;
+ this.priorityMetKey = priorityMetKey;
+ this.filterAlgor = filterAlgor;
+ this.converter = new AsciiSortableVersionConverter();
+ }
+
+ public String getStartDateTimeMetKey() {
+ return startDateTimeMetKey;
+ }
+
+ public void setStartDateTimeMetKey(String startDateTimeMetKey) {
+ this.startDateTimeMetKey = startDateTimeMetKey;
+ }
+
+ public String getEndDateTimeMetKey() {
+ return endDateTimeMetKey;
+ }
+
+ public void setEndDateTimeMetKey(String endDateTimeMetKey) {
+ this.endDateTimeMetKey = endDateTimeMetKey;
+ }
+
+ public String getPriorityMetKey() {
+ return priorityMetKey;
+ }
+
+ public void setPriorityMetKey(String priorityMetKey) {
+ this.priorityMetKey = priorityMetKey;
+ }
+
+ public FilterAlgor getFilterAlgor() {
+ return filterAlgor;
+ }
+
+ public void setFilterAlgor(FilterAlgor filterAlgor) {
+ if (filterAlgor != null) {
+ this.filterAlgor = filterAlgor;
+ }
+ }
+
+ public VersionConverter getConverter() {
+ return converter;
+ }
+
+ public void setConverter(VersionConverter converter) {
+ if (converter != null) {
+ this.converter = converter;
+ }
+ }
+
+}
diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/TimeEvent.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/TimeEvent.java
new file mode 100644
index 00000000..74eeb24b
--- /dev/null
+++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/TimeEvent.java
@@ -0,0 +1,97 @@
+/*
+ * 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 gov.nasa.pds.harvest.search.oodt.structs.query;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ *
+ * A basis for time-based queries results over a start/end datetime with a duration
+ *
+ * An interface for converting a String version into a priority number
+ *
+ */
+public interface VersionConverter {
+
+ double convertToPriority(String version) throws Exception;
+
+}
diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/type/TypeHandler.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/type/TypeHandler.java
new file mode 100644
index 00000000..9ee48d57
--- /dev/null
+++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/type/TypeHandler.java
@@ -0,0 +1,139 @@
+package gov.nasa.pds.harvest.search.oodt.structs.type;
+
+/*
+ * 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.
+ */
+
+// JDK imports
+import java.util.LinkedList;
+import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.QueryFormulationException;
+import gov.nasa.pds.harvest.search.oodt.metadata.Metadata;
+import gov.nasa.pds.harvest.search.oodt.structs.BooleanQueryCriteria;
+import gov.nasa.pds.harvest.search.oodt.structs.Query;
+import gov.nasa.pds.harvest.search.oodt.structs.QueryCriteria;
+import gov.nasa.pds.harvest.search.oodt.structs.RangeQueryCriteria;
+import gov.nasa.pds.harvest.search.oodt.structs.TermQueryCriteria;
+
+/**
+ * A Metadata modification class that intercepts all Metadata flowing in and out of the Catalog.
+ * Allows the Catalog to contain additional Metadata or modified Metadata while keeping it invisible
+ * to the user. The purpose it to create String queriable Metadata so that the Catalog can be
+ * queries accurately and without extra knowledge required on the user end.
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ */
+public abstract class TypeHandler {
+
+ protected String elementName;
+
+ /**
+ * Sets the Element name that this TypeHandler is responsible for handling
+ *
+ * @param elementName The Element name for this TypeHandler
+ */
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ /**
+ * Get the Element name that this TypeHandler is responsible for handling
+ *
+ * @return The Element name for this TypeHandler
+ */
+ public String getElementName() {
+ return this.elementName;
+ }
+
+ /**
+ * Converts this TypeHandler's element in the given Query into a Query with the necessary elements
+ * and values so the Catalog can be queried.
+ *
+ * NOTE: Original Query is modified . . . the argument query becomes equal to the returned query
+ * (return of query is a convenience).
+ *
+ * @param query Query for which the Catalog Query will be returned
+ * @return A Query with Catalog element values
+ * @throws QueryFormulationException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ public Query preQueryHandle(Query query) throws QueryFormulationException {
+ LinkedList
+ * This class was adapted from an O'Reilly site on DOM utilities. It contains a few helper methods
+ * to make extracting out XML text from DOM representations a little easier.
+ *
+ * Method returns the First occurence of Element 'name' in the DOM Node 'element'.
+ *
+ * This function is intended when you have a DOM element with no other DOM elements inside (i.e.
+ *
+ * This function is intended for use when you have merely text between an XML Element (i.e.
+ *
+ * Environment Utilities for reading variables and setting them and such.
+ *
+ * A Utility class containing methods to write and transform XML objects.
+ *
+ * This method writes a DOM document to a file
+ *
+ * A Utility class for replacing environment variables and maniuplating file
+ * path strings.
+ * env
. Unfortunately, this method also uses {@link Process#waitFor()}, which seems
+ * to hang when folks have weird environment variables and such.
+ *
+ * A more appropriate method to call is {@link #getEnv()} because it uses the {@link ExecHelper}
+ * class, which seems to handle process termination a bit more elegantly.
+ *
+ * @deprecated
+ * @return A {@link Properites} object containing the user's current environment variables.
+ */
+ public static Properties getEnvUsingWaitFor() {
+ String commandLine = "env";
+
+ Process p = null;
+ Properties envProps = null;
+
+ try {
+ p = Runtime.getRuntime().exec(commandLine);
+ int retVal = p.waitFor();
+ envProps = new Properties();
+ envProps.load(preProcessInputStream(p.getInputStream()));
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, e.getMessage());
+ LOG.log(Level.WARNING, "Error executing env command: Message: " + e.getMessage());
+ } finally {
+ try {
+ if (p.getErrorStream() != null) {
+ p.getErrorStream().close();
+ }
+ } catch (Exception ignored) {
+ }
+ try {
+ if (p.getInputStream() != null) {
+ p.getInputStream().close();
+ }
+ } catch (Exception ignored) {
+ }
+ try {
+ if (p.getOutputStream() != null) {
+ p.getOutputStream().close();
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ return envProps;
+ }
+
+ /**
+ * This method turns an {@link InputStream} into a String. Method taken from:
+ *
+ * http://snippets.dzone.com/posts/show/555.
+ *
+ * @param in The {@link InputStream} to Stringify.
+ * @return A String constructed from the given {@link InputStream}.
+ * @throws IOException If any error occurs.
+ */
+ public static String slurp(InputStream in) throws IOException {
+ StringBuilder out = new StringBuilder();
+ byte[] b = new byte[INT];
+ for (int n; (n = in.read(b)) != -1;) {
+ out.append(new String(b, 0, n));
+ }
+ return out.toString();
+ }
+
+ protected static InputStream preProcessInputStream(InputStream is) throws IOException {
+ // basically read this sucker into a BufferedReader
+ // line by line, and replaceAll on \ with \\
+ // so \\\\ with \\\\\\\\
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String line;
+ StringBuilder buf = new StringBuilder();
+
+ while ((line = reader.readLine()) != null) {
+ // fix the line
+ line = line.replaceAll("\\\\", "\\\\\\\\");
+ buf.append(line).append("\n");
+ }
+
+ try {
+ reader.close();
+ } catch (Exception ignore) {
+ }
+
+ return new ByteArrayInputStream(buf.toString().getBytes());
+ }
+
+}
diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/XMLUtils.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/XMLUtils.java
new file mode 100644
index 00000000..7e1cc7fb
--- /dev/null
+++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/XMLUtils.java
@@ -0,0 +1,224 @@
+/*
+ * 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 gov.nasa.pds.harvest.search.oodt.utils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+import java.util.List;
+import java.util.Map;
+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.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+// JDK imports
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+
+/**
+ * @author mattmann
+ * @author bfoster
+ * @version $Revision$
+ *
+ *
+ *
)]
+ * example: [DATE_ADD(2009-12-31, yyyy-MM-dd, 1, day)] . . . output will be: 2010-01-01
+ * - dynamic replacement is allowed for the