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 @@ - - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-commons - Common Utilities - 1.1.1 - jar - Common Utilities Project - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - maven-surefire-plugin - 2.4 - - pertest - false - - - java.util.logging.config.file - ${basedir}/src/testdata/test.logging.properties - - - 0 - true - - **/*Test*.java - - - - - - - - commons-dbcp - commons-dbcp - 1.2.1 - - - commons-collections - commons-collections - 2.1 - - - commons-pool - commons-pool - 1.2 - - - commons-lang - commons-lang - 2.1 - - - commons-logging - commons-logging - 1.0.3 - - - org.springframework - spring-core - 2.5.4 - - - org.springframework - spring-hibernate3 - 2.0.8 - - - junit - junit - 3.8.2 - test - - -
\ 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.md5 b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom.md5 deleted file mode 100644 index faa4a7f8..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -11163d9d713f58528601d561a3c6f6fb \ 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.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom.sha1 deleted file mode 100644 index 376ef5d7..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/cas-commons-1.1.1.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -b87b41da0e2338350d0e10167ca7cc6d8cac21e1 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/maven-metadata.xml.md5 b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/maven-metadata.xml.md5 deleted file mode 100644 index ae978422..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/maven-metadata.xml.md5 +++ /dev/null @@ -1 +0,0 @@ -209839efe4935a21b9379f7688acafdd \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/maven-metadata.xml.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/maven-metadata.xml.sha1 deleted file mode 100644 index f20fba23..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-commons/1.1.1/maven-metadata.xml.sha1 +++ /dev/null @@ -1 +0,0 @@ -99800b6832b5929fadc35d15de4875d36d9cd00c \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar b/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar deleted file mode 100644 index 1de35add..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar.md5 deleted file mode 100755 index 3f060eb4..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -1fde4c2eb2d96ff3bbd6d7cdddb21345 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar.sha1 deleted file mode 100644 index 8a4894e4..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -1bb3f2d065ad5ccc12f37e5b7ad05e525b168473 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom b/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom deleted file mode 100644 index 398ed99b..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom +++ /dev/null @@ -1,163 +0,0 @@ - - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-crawler - Catalog and Archive Crawling Framework - 2.4.1 - The Catalog and Archive Service Crawling Framework. - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - maven-surefire-plugin - 2.4 - - pertest - false - - - java.util.logging.config.file - ${basedir}/src/testdata/test.logging.properties - - - 0 - true - - **/*Test*.java - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2-beta-2 - - - src/main/assembly/assembly.xml - - - - gov.nasa.jpl.oodt.cas.crawl.CrawlerLauncher - - - - - - package - - single - - - - - - - - gov/nasa/jpl/oodt/cas/crawl - ${basedir}/src/main/resources - - **.xml - - - - - - - gov.nasa.jpl.oodt - cas-commons - 1.1.1 - - - gov.nasa.jpl.oodt - cas-metadata - 1.6.1 - - - gov.nasa.jpl.oodt - cas-filemgr - 1.8.0 - - - gov.nasa.jpl.oodt - cas-workflow - 1.5.1 - - - gov.nasa.jpl.oodt - edm-commons - 2.2.11-dev - - - apache - tika - 0.2-fork - - - commons-lang - commons-lang - 2.1 - - - commons-io - commons-io - 1.1 - - - commons-logging - commons-logging - 1.0.3 - - - commons-httpclient - commons-httpclient - 3.0 - - - commons-codec - commons-codec - 1.3 - - - commons-collections - commons-collections - 2.1 - - - xmlrpc - xmlrpc - 2.1-dev - - - org.springframework - spring-core - 2.5.4 - - - org.springframework - spring-hibernate3 - 2.0.8 - - - junit - junit - 3.8.2 - test - - -
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom.md5 b/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom.md5 deleted file mode 100755 index 8f2d2159..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -1d432f418542a380680f8212cac666cc \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom.sha1 deleted file mode 100755 index db93909d..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-crawler/2.4.1/cas-crawler-2.4.1.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -e91269f796ac7e396f0815f4d0904a8d8e23304f \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar b/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar deleted file mode 100644 index 922f6702..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar.md5 deleted file mode 100644 index 30fbfb71..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -fe88eba6b513cfc39704cd7aef56fd62 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar.sha1 deleted file mode 100644 index f0f39ab3..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -93015cb21219dc7b5fa723799a3530e21f9c787e \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom b/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom deleted file mode 100644 index 2d070ef1..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom +++ /dev/null @@ -1,164 +0,0 @@ - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-filemgr - Catalog and Archive File Management Component - 1.8.0 - The file management component of a Catalog and Archive Service. This component - purposefully separates data stores and metadata stores as standard interfaces, and - provides some out of the box backend implementations of them (including one based - on the javax.sql.DataSource interface). This component provides everything that you need - to catalog, archive and manage files, and directories, and their associated metadata. - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - maven-surefire-plugin - 2.4.3 - - pertest - false - - - java.util.logging.config.file - ${basedir}/src/testdata/test.logging.properties - - - 0 - true - - **/*Test*.java - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2-beta-2 - - - src/main/assembly/assembly.xml - - - - gov.nasa.jpl.oodt.cas.filemgr.system.XmlRpcFileManagerClient - - - - - - package - - single - - - - - - - - - gov.nasa.jpl.oodt - cas-commons - 1.1.1 - - - gov.nasa.jpl.oodt - cas-metadata - 1.6.1 - - - gov.nasa.jpl.oodt - edm-commons - 2.2.11-dev - - - commons-logging - commons-logging - 1.0.3 - - - commons-httpclient - commons-httpclient - 3.0 - - - commons-io - commons-io - 1.1 - - - commons-codec - commons-codec - 1.3 - - - commons-dbcp - commons-dbcp - 1.2.1 - - - commons-collections - commons-collections - 2.1 - - - commons-pool - commons-pool - 1.2 - - - org.apache.lucene - lucene-core - 2.0.0 - - - - org.safehaus.jug - jug - 2.0.0 - asl - - - xmlrpc - xmlrpc - 2.1-dev - - - hsqldb - hsqldb - 1.8.0.7 - - - junit - junit - 3.8.2 - test - - - org.python - jython - 2.2-beta1 - runtime - - -
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom.md5 b/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom.md5 deleted file mode 100644 index 230bb96a..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -86836b22a2b80d5ca4ce21a3da6b4ae9 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom.sha1 deleted file mode 100644 index 1f5e18ab..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-filemgr/1.8.0/cas-filemgr-1.8.0.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -9021c7810b5e6f7720ab9d7010e8a9ec1a16ac00 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar deleted file mode 100644 index 946ff8a3..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar.md5 deleted file mode 100644 index 25921e9b..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -473da04c51e18d4052eae09faed7e4ac \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar.sha1 deleted file mode 100644 index 3688f78a..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -6ff00c68f6c41d346bf89aa9503f71331caa59ee \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom deleted file mode 100644 index 4b634ecd..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom +++ /dev/null @@ -1,111 +0,0 @@ - - - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-metadata - Catalog and Archive Service Generic Multi-valued Metadata Container - 1.6.0 - A Multi-valued, generic Metadata container class. The class uses an internal - Map of string keys pointing to vectors of strings. The data - structure looks like the following: - - [std:string key]=>std:vector of std:strings - - The multi-valued nature of the class is handled transparently by this Metadata - container. Since all values are stored internally as string vectors, the difference - between a scalar value and a non-scalar is handled by determing whether the list of - values for a particular key is greater than 1. - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - gov/nasa/jpl/oodt/cas/metadata/preconditions - ${basedir}/src/main/resources - - tika-mimetypes.xml - - - - - - maven-surefire-plugin - - - - java.util.logging.config.file - ${basedir}/src/main/resources/logging.properties - - - never - - **/*Test*.java - - - - - - - - gov.nasa.jpl.oodt - cas-commons - 1.1.0 - - - commons-lang - commons-lang - 2.3 - - - commons-logging - commons-logging - 1.0.3 - - - commons-codec - commons-codec - 1.3 - - - apache - tika - 0.2-fork - - - org.springframework - spring-core - 2.5.4 - - - org.springframework - spring-hibernate3 - 2.0.8 - - - junit - junit - 3.8.2 - test - - -
\ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom.md5 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom.md5 deleted file mode 100644 index e70a3a73..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -5a72a390ea1b29f67de4a9c00a47de4b \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom.sha1 deleted file mode 100644 index 97be59c9..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.0/cas-metadata-1.6.0.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -0e7b6549c94d68d6ad35904c45a8d749203f53c4 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar deleted file mode 100644 index dcdf2dbd..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar.md5 deleted file mode 100644 index 55a90a7e..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -2dce9daf79570d6744e03d51cdcad371 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar.sha1 deleted file mode 100644 index 010a80b5..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e53e6491d4e6120108b5de73cb3d4238a862d9e2 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom deleted file mode 100644 index 8fcff491..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom +++ /dev/null @@ -1,111 +0,0 @@ - - - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-metadata - Catalog and Archive Service Generic Multi-valued Metadata Container - 1.6.1 - A Multi-valued, generic Metadata container class. The class uses an internal - Map of string keys pointing to vectors of strings. The data - structure looks like the following: - - [std:string key]=>std:vector of std:strings - - The multi-valued nature of the class is handled transparently by this Metadata - container. Since all values are stored internally as string vectors, the difference - between a scalar value and a non-scalar is handled by determing whether the list of - values for a particular key is greater than 1. - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - gov/nasa/jpl/oodt/cas/metadata/preconditions - ${basedir}/src/main/resources - - tika-mimetypes.xml - - - - - - maven-surefire-plugin - - - - java.util.logging.config.file - ${basedir}/src/main/resources/logging.properties - - - never - - **/*Test*.java - - - - - - - - gov.nasa.jpl.oodt - cas-commons - 1.1.1 - - - commons-lang - commons-lang - 2.3 - - - commons-logging - commons-logging - 1.0.3 - - - commons-codec - commons-codec - 1.3 - - - apache - tika - 0.2-fork - - - org.springframework - spring-core - 2.5.4 - - - org.springframework - spring-hibernate3 - 2.0.8 - - - junit - junit - 3.8.2 - test - - -
\ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom.md5 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom.md5 deleted file mode 100644 index c1d82d9d..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -42de7f9da90f65a742ed18e073064f12 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom.sha1 deleted file mode 100644 index 6bc3acb7..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-metadata/1.6.1/cas-metadata-1.6.1.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -234c1d886dcea831a71fcb65542662d6c71243e6 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar b/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar deleted file mode 100644 index 29d1a248..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar.md5 deleted file mode 100644 index 149370bb..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -d684d1e5fb3afb151839ab7c44cd28c6 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar.sha1 deleted file mode 100644 index 962d80bd..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d68210a97a18c0922e82d6de130364eecd148038 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom b/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom deleted file mode 100644 index 50268eb2..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom +++ /dev/null @@ -1,144 +0,0 @@ - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-resource - Catalog and Archive Resource Management Component - 1.3.1 - The resource management component of a Catalog and Archive Service. This component - provides job management, and management of the underlying software system hardware - and resources, such as disk space, computational resources, and shared identity. - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - maven-surefire-plugin - 2.4 - - pertest - false - - - java.util.logging.config.file - ${basedir}/src/testdata/test.logging.properties - - - 0 - true - - **/*Test*.java - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2-beta-2 - - - src/main/assembly/assembly.xml - - - - gov.nasa.jpl.oodt.cas.resource.system.XmlRpcResourceManagerClient - - - - - - package - - single - - - - - - - - - gov.nasa.jpl.oodt - cas-commons - 1.1.1 - - - gov.nasa.jpl.oodt - cas-metadata - 1.6.1 - - - gov.nasa.jpl.oodt - edm-commons - 2.2.11-dev - - - commons-logging - commons-logging - 1.0.3 - - - commons-httpclient - commons-httpclient - 3.0 - - - commons-io - commons-io - 1.1 - - - commons-codec - commons-codec - 1.3 - - - commons-dbcp - commons-dbcp - 1.2.1 - - - commons-collections - commons-collections - 2.1 - - - commons-pool - commons-pool - 1.2 - - - lucene - lucene-core - 2.0.0 - - - org.safehaus.jug - jug - 2.0.0 - asl - - - xmlrpc - xmlrpc - 2.1-dev - - - junit - junit - 3.8.2 - test - - -
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom.md5 b/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom.md5 deleted file mode 100644 index eb8a2c42..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -ae0f132a728a61d3c85dc507e2c3f37d \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom.sha1 deleted file mode 100644 index f7752e3c..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-resource/1.3.1/cas-resource-1.3.1.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -a6810c430e09057929b2370ae4a910dccd9892e2 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar b/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar deleted file mode 100644 index 5c2462cf..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar.md5 b/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar.md5 deleted file mode 100644 index a7be9db8..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -4764aba89517c0f904aada0b83660558 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar.sha1 deleted file mode 100644 index 42205ea2..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -506343656e7621c8a0951928df5bca221880ca84 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom b/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom deleted file mode 100644 index 2128da52..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom +++ /dev/null @@ -1,174 +0,0 @@ - - - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - cas-workflow - Catalog and Archive Workflow Management Component - 1.5.1 - The workflow management component of a Catalog and Archive Service. This component - purposefully separates workflow repositories and workflow engines standard interfaces, and - provides some out of the box backend implementations of them (including one based - on the javax.sql.DataSource interface). This component provides everything that you need - to execute workflows, and science processing pipelines. - - - - -
chris.mattmann@jpl.nasa.gov
-
-
-
-
- - - - maven-surefire-plugin - 2.4 - - pertest - false - - - java.util.logging.config.file - ${basedir}/src/testdata/test.logging.properties - - - 0 - true - - **/*Test*.java - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2-beta-2 - - - src/main/assembly/assembly.xml - - - - gov.nasa.jpl.oodt.cas.resource.system.XmlRpcWorkflowManagerClient - - - - - - package - - single - - - - - - - - - gov.nasa.jpl.oodt - cas-commons - 1.1.1 - - - gov.nasa.jpl.oodt - cas-metadata - 1.6.1 - - - gov.nasa.jpl.oodt - cas-resource - 1.3.1 - - - gov.nasa.jpl.oodt - edm-commons - 2.2.11-dev - - - concurrent - concurrent - 1.3.4 - - - commons-lang - commons-lang - 2.3 - - - commons-dbcp - commons-dbcp - 1.2.1 - - - commons-collections - commons-collections - 2.1 - - - commons-httpclient - commons-httpclient - 3.0 - - - commons-logging - commons-logging - 1.0.3 - - - commons-codec - commons-codec - 1.3 - - - commons-pool - commons-pool - 1.2 - - - commons-io - commons-io - 1.1 - - - xmlrpc - xmlrpc - 2.1-dev - - - lucene - lucene-core - 2.0.0 - - - - org.safehaus.jug - jug - 2.0.0 - asl - - - hsqldb - hsqldb - 1.8.0.7 - - - junit - junit - 3.8.2 - test - - -
diff --git a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom.md5 b/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom.md5 deleted file mode 100644 index d92704d1..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -717a6688ae782feb4d998a349078fd5f \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom.sha1 deleted file mode 100644 index 4797a2da..00000000 --- a/build/repo/gov/nasa/jpl/oodt/cas-workflow/1.5.1/cas-workflow-1.5.1.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -8a8438b268bdead4871e2d77749a9ed944a8cdc7 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar b/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar deleted file mode 100644 index 20d07b45..00000000 Binary files a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar and /dev/null differ diff --git a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar.md5 b/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar.md5 deleted file mode 100644 index f0a425a6..00000000 --- a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -2ea0acbcd5f220261a05a97085f05837 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar.sha1 b/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar.sha1 deleted file mode 100644 index c87659a5..00000000 --- a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -42c79f16be944da78374869532ee4207c178b39a \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom b/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom deleted file mode 100644 index cae003ae..00000000 --- a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom +++ /dev/null @@ -1,92 +0,0 @@ - - 4.0.0 - - gov.nasa.jpl.oodt - oodt-core - 2.0 - - edm-commons - Common Components - 2.2.11-dev - jar - Common components for enterprise data management. These - components are used by and required by all other Enterprise Data - Management and Object Oriented Data Technology Components. The - components include those for parsing, serializing, and navigating - XML documents; encoding and decoding base-64 strings; logging - messages and initializing log listeners; managing the classic EDA - configuration file (edarc.xml); and other utilities. - - - - jpl/eda - ${basedir}/src/main/dtd - - Configuration.dtd - - - - ${basedir}/src/main/dtd - - - jpl/eda - ${basedir}/src/main/conf - - Configuration.xml - ExecServerConfig.properties - - - - jpl/eda/util - ${basedir}/src/main/conf - - entities.xml - - - - - - jpl/eda/util - ${basedir}/src/testdata - - test.xml - - - - jpl/eda - ${basedir}/src/testdata - - test-multiserver.xml - - - - - - maven-surefire-plugin - - - jpl/eda/object/jndi/TestContext.java - jpl/eda/activity/HistoryTest.java - - - - - - - - mysql - mysql-connector-java - 3.1.14 - - - junit - junit - 3.8.1 - - - xmlrpc - xmlrpc - 3.0 - - - diff --git a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom.md5 b/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom.md5 deleted file mode 100644 index a822fe4e..00000000 --- a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -878e239ddc0f2f1e3984d4f18c7bc746 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom.sha1 deleted file mode 100644 index 9ed9e220..00000000 --- a/build/repo/gov/nasa/jpl/oodt/edm-commons/2.2.11-dev/edm-commons-2.2.11-dev.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -389e91d6e866c7baa9cba370deb8018b5459f595 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml b/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml deleted file mode 100644 index 9a89ef8e..00000000 --- a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - gov.nasa.jpl.oodt - oodt-m2-skin - 2.0-SNAPSHOT - - - - - \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml.md5 b/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml.md5 deleted file mode 100644 index c9a51cb0..00000000 --- a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml.md5 +++ /dev/null @@ -1 +0,0 @@ -c80c197bcf5700ccdb0eb8d1ccb3b413 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml.sha1 b/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml.sha1 deleted file mode 100644 index 64748c58..00000000 --- a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0-site.xml.sha1 +++ /dev/null @@ -1 +0,0 @@ -0e8fdf266806c345c897846826f7f94a44cd318e \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom b/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom deleted file mode 100644 index ef33753a..00000000 --- a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom +++ /dev/null @@ -1,387 +0,0 @@ - - - - - 4.0.0 - gov.nasa.jpl.oodt - oodt-core - 2.0 - OODT Core - pom - - http://www.jpl.nasa.gov/art/nasa_logo.gif - /images/${pom.artifactId}.jpg - ${pom.version} - true - ${basedir}/src/site/xdoc - - - https://osr.jpl.nasa.gov/${pom.artifactId} - - JIRA - https://osr.jpl.nasa.gov/jira/secure/ViewProject.jspa?pid=10000 - - - - - - -
Sean.Kelly@jpl.nasa.gov
-
-
-
-
- 1999 - - - OODT Developer List - oodt-dev-subscribe@list.jpl.nasa.gov - oodt-dev-unsubscribe@list.jpl.nasa.gov - - - OODT CVS List - oodt-cvs-subscribe@list.jpl.nasa.gov - oodt-cvs-unsubscribe@list.jpl.nasa.gov - - - - - crichton - Daniel Crichton - Dan.Crichton@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Project Manager - - - - shardman - Sean Hardman - Sean.Hardman@jpl.nasa.gov - http://home.earthlink.net/~hardmans/ - NASA Jet Propulsion Laboratory - - System Engineer - - - - jshughes - Steve Hughes - Steve.Hughes@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Information Architect - - - - kelly - Sean Kelly - Sean.Kelly@jpl.nasa.gov - http://seankelly.biz/ - Independent Consultant - - Technologist - - - - woollard - David Woollard - David.M.Woollard@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Advanced Developer - - - - ahart - Andrew Hart - Andrew.F.Hart@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Developer - - - - mattmann - Chris Mattmann - Chris.Mattmann@jpl.nasa.gov - http://www-scf.usc.edu/~mattmann/ - NASA Jet Propulsion Laboratory - - Advanced Developer - - - - pramirez - Paul Ramirez - Paul.Ramirez@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Advanced Developer - - - - thuytran - Thuy Tran - Thuy.Tran@jpl.nasa.gov - Chipton Ross - - Service Data Management CDE - - - - cwong - Cynthia Wong - Cynthia.Wong@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Metadata Management CDE - - - - danyu - Dan Yu - dan.yu@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Developer - - - - bfoster - Brian Foster - brian.m.foster@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Developer - - - - davoodi - Faranak Davoodi - faranak.davoodi@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Developer - - - - cgoodale - Cameron Goodale - Cameron.E.Goodale@jpl.nasa.gov - NASA Jet Propulsion Laboratory - - Developer - - - - - - OODT License - https://osr.jpl.nasa.gov/oodt-site/license.html - manual - - - - scm:svn:http://${user.name}@oodt.jpl.nasa.gov/repo/${pom.artifactId} - https://osr.jpl.nasa.gov/${pom.artifactId} - - - NASA Jet Propulsion Laboratory, California Institute of Technology - http://www.jpl.nasa.gov/ - - - ${basedir}/src/main/java - ${basedir}/src/test - - - maven-compiler-plugin - - 1.5 - 1.5 - - - - maven-jar-plugin - - - true - - - - - maven-surefire-plugin - - - **/*Test*.java - - - - - maven-javadoc-plugin - - - attach-javadocs - package - - javadoc - - - - - - - - - - org.apache.maven.plugins - maven-changes-plugin - 2.0 - - ${user.name} - ${jira.password} - ${jira.component.ids} - 1 - 5,6 - ${jira.fix.version.ids} - - - - - jira-report - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.2 - - true - 1.5 - - - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.1 - - true - - - - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.3 - - - - - org.codehaus.mojo - rat-maven-plugin - 1.0-alpha-3 - - - - - org.codehaus.mojo - findbugs-maven-plugin - 1.0.0 - - Normal - Default - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.1 - - - false - - - - - - org.apache.maven.plugins - maven-site-plugin - 2.0-beta-7 - - UTF-8 - - - - - - - - false - oodt-repo-loc - OODT Repository - scp://oodt.jpl.nasa.gov/usr/local/apache2/htdocs/download/private - default - - - oodt-site-loc - OODT Component Site - scp://oodt.jpl.nasa.gov/usr/local/apache2/htdocs - - -
diff --git a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom.md5 b/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom.md5 deleted file mode 100644 index 5c29086e..00000000 --- a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom.md5 +++ /dev/null @@ -1 +0,0 @@ -50639aa81048e1e2a944403e4b5a3608 \ No newline at end of file diff --git a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom.sha1 b/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom.sha1 deleted file mode 100644 index dcecebb0..00000000 --- a/build/repo/gov/nasa/jpl/oodt/oodt-core/2.0/oodt-core-2.0.pom.sha1 +++ /dev/null @@ -1 +0,0 @@ -a83339890fdf54edfe4e114cd713bebf993098c0 \ No newline at end of file diff --git a/pom.xml b/pom.xml index e76179d7..c7547f9e 100644 --- a/pom.xml +++ b/pom.xml @@ -161,11 +161,16 @@ - + project.local project file:${project.basedir}/build/repo + + snapshots-repo + FuseSource 3rdP + https://repo.fusesource.com/nexus/content/repositories/releases-3rd-party/ + @@ -223,36 +228,6 @@ 1.1.1 compile - - - gov.nasa.jpl.oodt - cas-crawler - 2.4.1 - compile - - - xerces - xercesImpl - - - lucene - lucene-core - - - apache - tika - - - javax.transaction - jta - - - net.sf.saxon Saxon-HE @@ -275,22 +250,6 @@ - - org.apache.oodt - cas-filemgr - ${oodt-version} - compile - - - org.apache.tika - tika-core - - - org.apache.solr - solr-core - - - gov.nasa.pds.2010.search search-core @@ -317,6 +276,12 @@ ${solr.version} jar compile + + + org.apache.logging.log4j + log4j-api + + solr-solrj @@ -340,6 +305,25 @@ tika-core 1.28.5 + + + com.google.common + google-collect + 1.0 + + + + org.springframework + spring-core + 6.1.11 + + + + org.springframework + spring-context + 6.1.11 + + diff --git a/src/main/java/gov/nasa/pds/harvest/search/HarvestSearchLauncher.java b/src/main/java/gov/nasa/pds/harvest/search/HarvestSearchLauncher.java index 7a3891ca..a726ecb4 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/HarvestSearchLauncher.java +++ b/src/main/java/gov/nasa/pds/harvest/search/HarvestSearchLauncher.java @@ -24,7 +24,6 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.ParseException; import org.apache.commons.io.FileUtils; -import org.apache.oodt.cas.filemgr.structs.exceptions.ConnectionException; import gov.nasa.pds.harvest.search.commandline.options.Flag; import gov.nasa.pds.harvest.search.commandline.options.InvalidOptionException; import gov.nasa.pds.harvest.search.constants.Constants; @@ -33,6 +32,7 @@ import gov.nasa.pds.harvest.search.logging.formatter.HarvestFormatter; import gov.nasa.pds.harvest.search.logging.handler.HarvestFileHandler; import gov.nasa.pds.harvest.search.logging.handler.HarvestStreamHandler; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.ConnectionException; import gov.nasa.pds.harvest.search.policy.Directory; import gov.nasa.pds.harvest.search.policy.DirectoryFilter; import gov.nasa.pds.harvest.search.policy.FileFilter; diff --git a/src/main/java/gov/nasa/pds/harvest/search/HarvesterSearch.java b/src/main/java/gov/nasa/pds/harvest/search/HarvesterSearch.java index 8fa3d5d8..a83c279e 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/HarvesterSearch.java +++ b/src/main/java/gov/nasa/pds/harvest/search/HarvesterSearch.java @@ -1,37 +1,29 @@ package gov.nasa.pds.harvest.search; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.pds.harvest.search.policy.Manifest; -import gov.nasa.pds.harvest.search.constants.Constants; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import gov.nasa.pds.harvest.search.crawler.CollectionCrawler; -import gov.nasa.pds.harvest.search.crawler.PDS3FileCrawler; -import gov.nasa.pds.harvest.search.crawler.PDS3ProductCrawler; import gov.nasa.pds.harvest.search.crawler.PDSProductCrawler; import gov.nasa.pds.harvest.search.crawler.actions.CreateAccessUrlsAction; import gov.nasa.pds.harvest.search.crawler.actions.CreateSearchDocAction; import gov.nasa.pds.harvest.search.crawler.actions.FileObjectRegistrationAction; -import gov.nasa.pds.harvest.search.crawler.actions.StorageIngestAction; -import gov.nasa.pds.harvest.search.crawler.daemon.HarvestSolrDaemon; -import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds3MetExtractorConfig; import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds4MetExtractorConfig; import gov.nasa.pds.harvest.search.doc.SearchDocState; import gov.nasa.pds.harvest.search.file.ChecksumManifest; import gov.nasa.pds.harvest.search.ingest.SearchIngester; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.ConnectionException; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.policy.Manifest; import gov.nasa.pds.harvest.search.policy.Policy; import gov.nasa.pds.search.core.exception.SearchCoreException; import gov.nasa.pds.search.core.exception.SearchCoreFatalException; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.oodt.cas.filemgr.structs.exceptions.ConnectionException; - /** * Front end class to the Harvest tool. * @@ -40,205 +32,200 @@ */ public class HarvesterSearch { - /** - * The port number to use for the daemon if running Harvest in continuous mode. - */ - private int daemonPort; - - /** - * The wait interval in seconds in between crawls when running Harvest in - * continuous mode. - */ - private int waitInterval; - - /** CrawlerAction that performs file object registration. */ - private FileObjectRegistrationAction fileObjectRegistrationAction; - - private File configDir; - private File outputDir; - - /** An ingester for the PDS Registry/Search Service. */ - private SearchIngester ingester; - private String searchUrl; - private SearchDocState searchDocState; - - /** - * Constructor. - * - * @param searchUrl The search service location. - * @param configDir Top level directory to the Search Core configuration files. - * @param outputDir Directory location of the generated Solr documents. - * @param resources JSON file used as a lookup table for populating resources. - * - * - */ - public HarvesterSearch(String searchUrl, File configDir, File outputDir, File resources) throws Exception - { - this.daemonPort = -1; - this.waitInterval = -1; - this.fileObjectRegistrationAction = new FileObjectRegistrationAction(); - this.configDir = configDir; - this.outputDir = outputDir; - this.ingester = new SearchIngester(); - this.searchUrl = searchUrl; - this.searchDocState = new SearchDocState(); - } - - /** - * Sets the daemon port. - * - * @param port The port number to use. - */ - public void setDaemonPort(int port) { - this.daemonPort = port; - } - - /** - * Sets the wait interval in seconds in between crawls. - * - * @param interval The wait interval in seconds. - */ - public void setWaitInterval(int interval) { - this.waitInterval = interval; - } - - /** - * Get the default crawler actions. - * - * @return A list of default crawler actions. - * @throws ConnectionException - * @throws MalformedURLException - * @throws SearchCoreFatalException - * @throws SearchCoreException - */ - private List getDefaultCrawlerActions(Policy policy, PDSProductCrawler crawler) - throws MalformedURLException, ConnectionException, SearchCoreException, SearchCoreFatalException { - List ca = new ArrayList(); - List fileObjectRegistrationActions = new ArrayList(); - ca.add(fileObjectRegistrationAction); - if (policy.getStorageIngestion() != null) { - CrawlerAction fmAction = new StorageIngestAction(new URL(policy.getStorageIngestion().getServerUrl())); - ca.add(fmAction); - fileObjectRegistrationActions.add(fmAction); - } - if ((policy.getAccessUrls().isRegisterFileUrls() != false) - || (!policy.getAccessUrls().getAccessUrl().isEmpty())) { - CreateAccessUrlsAction cauAction = new CreateAccessUrlsAction(policy.getAccessUrls().getAccessUrl()); - cauAction.setRegisterFileUrls(policy.getAccessUrls().isRegisterFileUrls()); - ca.add(cauAction); - fileObjectRegistrationActions.add(cauAction); - } - fileObjectRegistrationAction.setActions(fileObjectRegistrationActions); - // Set the flag to generate checksums - fileObjectRegistrationAction.setGenerateChecksums(policy.getChecksums().isGenerate()); - fileObjectRegistrationAction.setFileTypes(policy.getFileTypes()); - // This is the last action that should be performed. -// ca.add(new SaveMetadataAction()); - // Remove the File Object Registration crawler action if this is - // a Product_File_Repository Crawler - if (crawler instanceof PDS3FileCrawler) { - ca.remove(fileObjectRegistrationAction); - } - CreateSearchDocAction createSearchDoc = new CreateSearchDocAction(configDir, outputDir, - this.searchDocState); - if (crawler instanceof CollectionCrawler) { - createSearchDoc.setCacheCollection(true); - } - ca.add(createSearchDoc); - return ca; - } - - /** - * Harvest the products specified in the given policy. - * - * @param policy An object representation of the configuration file that - * specifies what to harvest. - * - * @throws ConnectionException - * @throws IOException - * @throws SearchCoreFatalException - * @throws SearchCoreException - */ - public void harvest(Policy policy) - throws IOException, ConnectionException, SearchCoreException, SearchCoreFatalException - { - boolean doCrawlerPersistance = false; - Map checksums = new HashMap(); - if (policy.getChecksums().getManifest() != null) { - Manifest manifest = policy.getChecksums().getManifest(); - ChecksumManifest cm = new ChecksumManifest(manifest.getBasePath()); - checksums.putAll(cm.read(new File(manifest.getValue()))); - fileObjectRegistrationAction.setChecksumManifest(checksums); - } - if (waitInterval != -1 && daemonPort != -1) { - doCrawlerPersistance = true; - } - Pds4MetExtractorConfig pds4MetExtractorConfig = new Pds4MetExtractorConfig( - policy.getCandidates().getProductMetadata(), policy.getReferences()); - List crawlers = new ArrayList(); - - // Crawl collections - for (String collection : policy.getCollections().getFile()) { - CollectionCrawler cc = new CollectionCrawler(pds4MetExtractorConfig); - cc.setProductPath(collection); - - crawlers.add(cc); - } - // Crawl directories - for (String directory : policy.getDirectories().getPath()) { - PDSProductCrawler pc = new PDSProductCrawler(pds4MetExtractorConfig); - pc.setProductPath(directory); - if (policy.getDirectories().getFileFilter() != null) { - pc.setFileFilter(policy.getDirectories().getFileFilter()); - } - if (policy.getDirectories().getDirectoryFilter() != null) { - pc.setDirectoryFilter(policy.getDirectories().getDirectoryFilter()); - } - crawlers.add(pc); - } - // Crawl a PDS3 directory - for (String directory : policy.getPds3Directories().getPath()) { - PDS3ProductCrawler p3c = new PDS3ProductCrawler(); - // If the objectType attribute was set to "Product_File_Repository", - // then the tool should just register everything as a - // Product_File_Repository product. - String pds3ObjectType = policy.getCandidates().getPds3ProductMetadata().getObjectType(); - if (pds3ObjectType != null && pds3ObjectType.equals(Constants.FILE_OBJECT_PRODUCT_TYPE)) { - PDS3FileCrawler crawler = new PDS3FileCrawler(); - crawler.setChecksumManifest(checksums); - crawler.setGenerateChecksums(policy.getChecksums().isGenerate()); - p3c = crawler; - } - Pds3MetExtractorConfig pds3MetExtractorConfig = new Pds3MetExtractorConfig( - policy.getCandidates().getPds3ProductMetadata()); - p3c.setPDS3MetExtractorConfig(pds3MetExtractorConfig); - p3c.setProductPath(directory); - if (policy.getPds3Directories().getFileFilter() != null) { - p3c.setFileFilter(policy.getPds3Directories().getFileFilter()); - } - if (policy.getPds3Directories().getDirectoryFilter() != null) { - p3c.setDirectoryFilter(policy.getPds3Directories().getDirectoryFilter()); - } - crawlers.add(p3c); - } - // Perform crawl while looping through the crawler list if - // crawler persistance is disabled. - for (PDSProductCrawler crawler : crawlers) { - crawler.addActions(getDefaultCrawlerActions(policy, crawler)); - crawler.setSearchUrl(searchUrl); - crawler.setIngester(ingester); - crawler.setCounter(this.searchDocState); - // crawler.setSearchDocGenerator(new SearchDocGenerator(configDir, outputDir)); - if (!doCrawlerPersistance) { - crawler.crawl(); - } - } - // If crawler persistance is enabled, use the HarvestDaemon object to - // do the crawling - - if (doCrawlerPersistance) { - new HarvestSolrDaemon(waitInterval, crawlers, daemonPort).startCrawling(); - } - - } + /** + * The port number to use for the daemon if running Harvest in continuous mode. + */ + private int daemonPort; + + /** + * The wait interval in seconds in between crawls when running Harvest in continuous mode. + */ + private int waitInterval; + + /** CrawlerAction that performs file object registration. */ + private FileObjectRegistrationAction fileObjectRegistrationAction; + + private File configDir; + private File outputDir; + + /** An ingester for the PDS Registry/Search Service. */ + private SearchIngester ingester; + private String searchUrl; + private SearchDocState searchDocState; + + /** + * Constructor. + * + * @param searchUrl The search service location. + * @param configDir Top level directory to the Search Core configuration files. + * @param outputDir Directory location of the generated Solr documents. + * @param resources JSON file used as a lookup table for populating resources. + * + * + */ + public HarvesterSearch(String searchUrl, File configDir, File outputDir, File resources) + throws Exception { + this.daemonPort = -1; + this.waitInterval = -1; + this.fileObjectRegistrationAction = new FileObjectRegistrationAction(); + this.configDir = configDir; + this.outputDir = outputDir; + this.ingester = new SearchIngester(); + this.searchUrl = searchUrl; + this.searchDocState = new SearchDocState(); + } + + /** + * Sets the daemon port. + * + * @param port The port number to use. + */ + public void setDaemonPort(int port) { + this.daemonPort = port; + } + + /** + * Sets the wait interval in seconds in between crawls. + * + * @param interval The wait interval in seconds. + */ + public void setWaitInterval(int interval) { + this.waitInterval = interval; + } + + /** + * Get the default crawler actions. + * + * @return A list of default crawler actions. + * @throws ConnectionException + * @throws MalformedURLException + * @throws SearchCoreFatalException + * @throws SearchCoreException + */ + private List getDefaultCrawlerActions(Policy policy, PDSProductCrawler crawler) + throws MalformedURLException, ConnectionException, SearchCoreException, + SearchCoreFatalException, CrawlerActionException { + List ca = new ArrayList(); + List fileObjectRegistrationActions = new ArrayList(); + ca.add(fileObjectRegistrationAction); + // if (policy.getStorageIngestion() != null) { + // // I don't think we need to support this anymore, but leaving + // // the code in for now in case it turns out we do + // + // CrawlerAction fmAction = + // new StorageIngestAction(new URL(policy.getStorageIngestion().getServerUrl())); + // ca.add(fmAction); + // fileObjectRegistrationActions.add(fmAction); + // throw new CrawlerActionException("Unsupported Crawler Action"); + // } + if ((policy.getAccessUrls().isRegisterFileUrls() != false) + || (!policy.getAccessUrls().getAccessUrl().isEmpty())) { + CreateAccessUrlsAction cauAction = + new CreateAccessUrlsAction(policy.getAccessUrls().getAccessUrl()); + cauAction.setRegisterFileUrls(policy.getAccessUrls().isRegisterFileUrls()); + ca.add(cauAction); + fileObjectRegistrationActions.add(cauAction); + } + fileObjectRegistrationAction.setActions(fileObjectRegistrationActions); + // Set the flag to generate checksums + fileObjectRegistrationAction.setGenerateChecksums(policy.getChecksums().isGenerate()); + fileObjectRegistrationAction.setFileTypes(policy.getFileTypes()); + + CreateSearchDocAction createSearchDoc = + new CreateSearchDocAction(configDir, outputDir, this.searchDocState); + if (crawler instanceof CollectionCrawler) { + createSearchDoc.setCacheCollection(true); + } + ca.add(createSearchDoc); + return ca; + } + + /** + * Harvest the products specified in the given policy. + * + * @param policy An object representation of the configuration file that specifies what to + * harvest. + * + * @throws ConnectionException + * @throws IOException + * @throws SearchCoreFatalException + * @throws SearchCoreException + * @throws CrawlerActionException + */ + public void harvest(Policy policy) throws IOException, ConnectionException, SearchCoreException, + SearchCoreFatalException, CrawlerActionException { + boolean doCrawlerPersistance = false; + Map checksums = new HashMap(); + if (policy.getChecksums().getManifest() != null) { + Manifest manifest = policy.getChecksums().getManifest(); + ChecksumManifest cm = new ChecksumManifest(manifest.getBasePath()); + checksums.putAll(cm.read(new File(manifest.getValue()))); + fileObjectRegistrationAction.setChecksumManifest(checksums); + } + if (waitInterval != -1 && daemonPort != -1) { + doCrawlerPersistance = true; + } + Pds4MetExtractorConfig pds4MetExtractorConfig = new Pds4MetExtractorConfig( + policy.getCandidates().getProductMetadata(), policy.getReferences()); + List crawlers = new ArrayList(); + + // Crawl collections + for (String collection : policy.getCollections().getFile()) { + CollectionCrawler cc = new CollectionCrawler(pds4MetExtractorConfig); + cc.setProductPath(collection); + + crawlers.add(cc); + } + // Crawl directories + for (String directory : policy.getDirectories().getPath()) { + PDSProductCrawler pc = new PDSProductCrawler(pds4MetExtractorConfig); + pc.setProductPath(directory); + if (policy.getDirectories().getFileFilter() != null) { + pc.setFileFilter(policy.getDirectories().getFileFilter()); + } + if (policy.getDirectories().getDirectoryFilter() != null) { + pc.setDirectoryFilter(policy.getDirectories().getDirectoryFilter()); + } + crawlers.add(pc); + } + // Crawl a PDS3 directory + // for (String directory : policy.getPds3Directories().getPath()) { + // PDS3ProductCrawler p3c = new PDS3ProductCrawler(); + // // If the objectType attribute was set to "Product_File_Repository", + // // then the tool should just register everything as a + // // Product_File_Repository product. + // String pds3ObjectType = policy.getCandidates().getPds3ProductMetadata().getObjectType(); + // if (pds3ObjectType != null && pds3ObjectType.equals(Constants.FILE_OBJECT_PRODUCT_TYPE)) + // { + // PDS3FileCrawler crawler = new PDS3FileCrawler(); + // crawler.setChecksumManifest(checksums); + // crawler.setGenerateChecksums(policy.getChecksums().isGenerate()); + // p3c = crawler; + // } + // Pds3MetExtractorConfig pds3MetExtractorConfig = new Pds3MetExtractorConfig( + // policy.getCandidates().getPds3ProductMetadata()); + // p3c.setPDS3MetExtractorConfig(pds3MetExtractorConfig); + // p3c.setProductPath(directory); + // if (policy.getPds3Directories().getFileFilter() != null) { + // p3c.setFileFilter(policy.getPds3Directories().getFileFilter()); + // } + // if (policy.getPds3Directories().getDirectoryFilter() != null) { + // p3c.setDirectoryFilter(policy.getPds3Directories().getDirectoryFilter()); + // } + // crawlers.add(p3c); + // } + + + // Perform crawl while looping through the crawler list if + // crawler persistance is disabled. + for (PDSProductCrawler crawler : crawlers) { + crawler.addActions(getDefaultCrawlerActions(policy, crawler)); + crawler.setSearchUrl(searchUrl); + crawler.setIngester(ingester); + crawler.setCounter(this.searchDocState); + // crawler.setSearchDocGenerator(new SearchDocGenerator(configDir, outputDir)); + crawler.crawl(); + } + + } } diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/BundleCrawler.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/BundleCrawler.java index ab59ca0c..3d1196b9 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/BundleCrawler.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/BundleCrawler.java @@ -1,6 +1,7 @@ package gov.nasa.pds.harvest.search.crawler; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionRepo; +import java.io.File; +import java.util.logging.Logger; import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds4MetExtractorConfig; import gov.nasa.pds.harvest.search.inventory.InventoryEntry; import gov.nasa.pds.harvest.search.inventory.InventoryReader; @@ -8,9 +9,7 @@ import gov.nasa.pds.harvest.search.inventory.InventoryXMLReader; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; - -import java.io.File; -import java.util.logging.Logger; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerActionRepo; /** * A crawler class for a PDS Bundle file. diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/CollectionCrawler.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/CollectionCrawler.java index 8ffbd3e2..8449b7d1 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/CollectionCrawler.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/CollectionCrawler.java @@ -2,12 +2,11 @@ import java.io.File; import java.util.logging.Logger; - -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionRepo; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds4MetExtractorConfig; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerActionRepo; /** * A crawler class for a PDS Collection file. diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/PDS3FileCrawler.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/PDS3FileCrawler.java deleted file mode 100644 index 26642496..00000000 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/PDS3FileCrawler.java +++ /dev/null @@ -1,136 +0,0 @@ -package gov.nasa.pds.harvest.search.crawler; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.io.filefilter.AndFileFilter; -import org.apache.commons.io.filefilter.FileFilterUtils; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.io.filefilter.NotFileFilter; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; -import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds3FileMetExtractor; -import gov.nasa.pds.harvest.search.logging.ToolsLevel; -import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; -import gov.nasa.pds.harvest.search.policy.FileFilter; -import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; - -/** - * Crawler class intended to be used for registering PDS3 files as - * Product_File_Repository products. - * - * @author mcayanan - * - */ -public class PDS3FileCrawler extends PDS3ProductCrawler { - /** Logger object. */ - private static Logger log = Logger.getLogger( - PDS3FileCrawler.class.getName()); - - /** Flag to enable generation of checksums on the fly. */ - private boolean generateChecksums; - - /** Represents the checksum manifest file. */ - private Map checksumManifest; - - public PDS3FileCrawler() { - generateChecksums = false; - checksumManifest = new HashMap(); - List fileFilters = new ArrayList(); - fileFilters.add(FileFilterUtils.fileFileFilter()); - fileFilters.add(new NotFileFilter(new WildcardOSFilter("*.LBL"))); - FILE_FILTER = new AndFileFilter(fileFilters); - } - - public void setFileFilter(FileFilter filter) { - List filters = new ArrayList(); - filters.add(FileFilterUtils.fileFileFilter()); - if (filter != null && !filter.getInclude().isEmpty()) { - filters.add(new WildcardOSFilter(filter.getInclude())); - } else if (filter != null && !filter.getExclude().isEmpty()) { - filters.add(new NotFileFilter(new WildcardOSFilter( - filter.getExclude()))); - } - filters.add(new NotFileFilter(new WildcardOSFilter("*.LBL"))); - FILE_FILTER = new AndFileFilter(filters); - } - - protected Metadata getMetadataForProduct(File product) { - Pds3FileMetExtractor metExtractor = new Pds3FileMetExtractor( - getPDS3MetExtractorConfig()); - metExtractor.setChecksumManifest(checksumManifest); - metExtractor.setGenerateChecksums(generateChecksums); - try { - return metExtractor.extractMetadata(product); - } catch (MetExtractionException m) { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, - "Error while gathering metadata: " + m.getMessage(), - product)); - return new Metadata(); - } - } - - protected boolean passesPreconditions(File product) { - if (inPersistanceMode) { - if (touchedFiles.containsKey(product)) { - long lastModified = touchedFiles.get(product); - if (product.lastModified() == lastModified) { - return false; - } else { - touchedFiles.put(product, product.lastModified()); - } - } else { - touchedFiles.put(product, product.lastModified()); - } - } - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Begin processing.", - product)); - boolean passFlag = true; - try { - if (!product.canRead()) { - passFlag = false; - ++HarvestSolrStats.numFilesSkipped; - } else { - // Check for associated label file - String labelFileName = FilenameUtils.getBaseName((product.getName())) + ".LBL"; - File label = new File(product.getParent(), labelFileName); - if (label.exists()) { - ++HarvestSolrStats.numFilesSkipped; - log.log(new ToolsLogRecord(ToolsLevel.SKIP, - "An associated label file exists '" + label.toString() + "'", product)); - passFlag = false; - } else { - ++HarvestSolrStats.numGoodFiles; - } - } - } catch (SecurityException se) { - passFlag = false; - ++HarvestSolrStats.numFilesSkipped; - log.log(new ToolsLogRecord(ToolsLevel.SKIP, - se.getMessage(), product)); - } - return passFlag; - } - - /** - * Set the flag for checksum generation. - * - * @param value 'true' to turn on, 'false' to turn off. - */ - public void setGenerateChecksums(boolean value) { - this.generateChecksums = value; - } - - /** - * Set the map to represent the checksum manifest file. - * - * @param manifest A mapping of file objects to checksums. - */ - public void setChecksumManifest(Map manifest) { - this.checksumManifest = manifest; - } -} diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/PDS3ProductCrawler.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/PDS3ProductCrawler.java deleted file mode 100644 index 70985b9a..00000000 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/PDS3ProductCrawler.java +++ /dev/null @@ -1,142 +0,0 @@ -package gov.nasa.pds.harvest.search.crawler; - -import java.io.File; -import java.util.logging.Logger; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; -import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds3MetExtractor; -import gov.nasa.pds.harvest.search.crawler.metadata.extractor.Pds3MetExtractorConfig; -import gov.nasa.pds.harvest.search.logging.ToolsLevel; -import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; -import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; -import gov.nasa.pds.tools.LabelParserException; -import gov.nasa.pds.tools.label.Label; -import gov.nasa.pds.tools.label.ManualPathResolver; -import gov.nasa.pds.tools.label.parser.DefaultLabelParser; -import gov.nasa.pds.tools.util.MessageUtils; - -/** - * Class to crawl PDS3 data products. - * - * @author mcayanan - * - */ -public class PDS3ProductCrawler extends PDSProductCrawler { - /** Logger object. */ - private static Logger log = Logger.getLogger( - PDS3ProductCrawler.class.getName()); - - /** The configuration object for PDS3 product metadata registrations. */ - private Pds3MetExtractorConfig config; - - /** Gets the PDS3 metextractor configuration object. - * - * @return Return the configuration object. - */ - public Pds3MetExtractorConfig getPDS3MetExtractorConfig() { - return this.config; - } - - /** Sets the PDS3 metextractor configuration. - * - * @param config A configuration object. - */ - public void setPDS3MetExtractorConfig(Pds3MetExtractorConfig config) { - this.config = config; - } - - /** - * Extracts metadata from the given product. - * - * @param product A PDS file. - * - * @return A Metadata object, which holds metadata from the product. - * - */ - @Override - protected Metadata getMetadataForProduct(File product) { - Pds3MetExtractor metExtractor = new Pds3MetExtractor(config); - try { - return metExtractor.extractMetadata(product); - } catch (MetExtractionException m) { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, - "Error while gathering metadata: " + m.getMessage(), - product)); - return new Metadata(); - } - } - - /** - * Determines whether the supplied file passes the necessary - * pre-conditions for the file to be registered. - * - * @param product A file. - * - * @return true if the file passes. - */ - @Override - protected boolean passesPreconditions(File product) { - if (inPersistanceMode) { - if (touchedFiles.containsKey(product)) { - long lastModified = touchedFiles.get(product); - if (product.lastModified() == lastModified) { - return false; - } else { - touchedFiles.put(product, product.lastModified()); - } - } else { - touchedFiles.put(product, product.lastModified()); - } - } - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Begin processing.", - product)); - boolean passFlag = true; - ManualPathResolver resolver = new ManualPathResolver(); - resolver.setBaseURI(ManualPathResolver.getBaseURI(product.toURI())); - DefaultLabelParser parser = new DefaultLabelParser(false, false, resolver); - Label label = null; - try { - label = parser.parseLabel(product.toURI().toURL()); - } catch (LabelParserException lp) { - passFlag = false; - ++HarvestSolrStats.numFilesSkipped; - log.log(new ToolsLogRecord(ToolsLevel.SKIP, - MessageUtils.getProblemMessage(lp), product)); - } catch (Exception e) { - passFlag = false; - ++HarvestSolrStats.numFilesSkipped; - log.log(new ToolsLogRecord(ToolsLevel.SKIP, e.getMessage(), product)); - } - if (passFlag == true) { - ++HarvestSolrStats.numGoodFiles; - } - return passFlag; - - - - //TODO: This reports problems in a PDS3 label. Can we suppress this? -/* - if (!label.getProblems().isEmpty()) { - passFlag = false; - for (LabelParserException problem : label.getProblems()) { - report(problem, product); - } - } -*/ - } - - private void report(LabelParserException problem, File product) { - String message = MessageUtils.getProblemMessage(problem); - if ("INFO".equalsIgnoreCase(problem.getType().getSeverity().getName())) { - log.log(new ToolsLogRecord(ToolsLevel.INFO, message, - product.toString(),problem.getLineNumber())); - } else if ("WARNING".equalsIgnoreCase( - problem.getType().getSeverity().getName())) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, message, - product.toString(),problem.getLineNumber())); - } else { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, message, - product.toString(),problem.getLineNumber())); - } - } -} diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/PDSProductCrawler.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/PDSProductCrawler.java index 8f7f152a..b42fdb76 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/PDSProductCrawler.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/PDSProductCrawler.java @@ -13,11 +13,6 @@ import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.NotFileFilter; import org.xml.sax.SAXParseException; -import gov.nasa.jpl.oodt.cas.crawl.ProductCrawler; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionRepo; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.crawler.actions.LidCheckerAction; import gov.nasa.pds.harvest.search.crawler.actions.LogMissingReqMetadataAction; @@ -29,6 +24,11 @@ import gov.nasa.pds.harvest.search.doc.SearchDocState; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerActionRepo; +import gov.nasa.pds.harvest.search.oodt.crawler.ProductCrawler; +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.policy.DirectoryFilter; import gov.nasa.pds.harvest.search.policy.FileFilter; import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; @@ -157,11 +157,11 @@ public void setDirectoryFilter(DirectoryFilter filter) { * @param product The product file. * @param productMetadata The metadata associated with the product. */ - @Override - protected void addKnownMetadata(File product, Metadata productMetadata) { - //The parent class adds FILENAME, FILE_LOCATION, and PRODUCT_NAME - //to the metadata. Not needed at the moment - } + // @Override + // protected void addKnownMetadata(File product, Metadata productMetadata) { + // //The parent class adds FILENAME, FILE_LOCATION, and PRODUCT_NAME + // //to the metadata. Not needed at the moment + // } /** * Crawls the given directory. diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateAccessUrlsAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateAccessUrlsAction.java index 8c9979de..c4aad1f3 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateAccessUrlsAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateAccessUrlsAction.java @@ -11,14 +11,14 @@ import javax.ws.rs.core.UriBuilder; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.exception.ExceptionUtils; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.file.FileObject; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; import gov.nasa.pds.harvest.search.policy.AccessUrl; import gov.nasa.pds.registry.model.Slot; @@ -54,7 +54,7 @@ public CreateAccessUrlsAction(List accessUrls) { super(); this.accessUrls = new ArrayList(); this.accessUrls.addAll(accessUrls); - String []phases = {CrawlerActionPhases.PRE_INGEST}; + String[] phases = {CrawlerActionPhases.PRE_INGEST.getName()}; setPhases(Arrays.asList(phases)); setId(ID); setDescription(DESCRIPTION); diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateSearchDocAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateSearchDocAction.java index 8cf48a07..3f66ca49 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateSearchDocAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/CreateSearchDocAction.java @@ -4,22 +4,19 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; -import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; - +import java.util.logging.Logger; import javax.xml.bind.JAXBException; - -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.doc.SearchDocGenerator; import gov.nasa.pds.harvest.search.doc.SearchDocState; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; import gov.nasa.pds.harvest.search.util.Utility; import gov.nasa.pds.registry.model.ExtrinsicObject; import gov.nasa.pds.registry.model.Slot; @@ -34,6 +31,8 @@ */ public class CreateSearchDocAction extends CrawlerAction { + private static Logger log = Logger.getLogger(CreateSearchDocAction.class.getName()); + /** The crawler action identifier. */ private final static String ID = "CreateSearchDocAction"; @@ -49,8 +48,8 @@ public class CreateSearchDocAction extends CrawlerAction { public CreateSearchDocAction(File configDir, File outputDir, SearchDocState searchDocState) throws SearchCoreException, SearchCoreFatalException { - generator = new SearchDocGenerator(configDir, outputDir); - String []phases = {CrawlerActionPhases.POST_INGEST_SUCCESS}; + this.generator = new SearchDocGenerator(configDir, outputDir); + String[] phases = {CrawlerActionPhases.POST_INGEST_SUCCESS.getName()}; setPhases(Arrays.asList(phases)); setId(ID); setDescription(DESCRIPTION); @@ -63,7 +62,7 @@ public boolean performAction(File product, Metadata productMetadata) throws CrawlerActionException { try { ExtrinsicObject extrinsic = createProduct(productMetadata, product); - generator.generate(extrinsic, productMetadata, this.searchDocState); + this.generator.generate(extrinsic, productMetadata, this.searchDocState); String lidvid = extrinsic.getLid() + "::" + extrinsic.getSlot( Constants.PRODUCT_VERSION).getValues().get(0); LOG.log(new ToolsLogRecord(ToolsLevel.SUCCESS, @@ -90,12 +89,11 @@ public boolean performAction(File product, Metadata productMetadata) private ExtrinsicObject createProduct(Metadata metadata, File prodFile) { ExtrinsicObject product = new ExtrinsicObject(); Set slots = new HashSet(); - Set metSet = metadata.getHashtable().entrySet(); - for (Iterator i = metSet.iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); - String key = entry.getKey().toString(); + List keys = metadata.getAllKeys(); + for (String key : keys) { if (key.equals(Constants.REFERENCES) || key.equals(Constants.INCLUDE_PATHS) + || key.equals(Constants.SLOT_METADATA) || key.equals("file_ref")) { continue; } @@ -111,8 +109,15 @@ private ExtrinsicObject createProduct(Metadata metadata, File prodFile) { Constants.OBJECT_TYPE)); } else if (key.equals(Constants.TITLE)) { product.setName(metadata.getMetadata(Constants.TITLE)); - } else if (key.equals(Constants.SLOT_METADATA)) { - slots.addAll(metadata.getAllMetadata(Constants.SLOT_METADATA)); + } else if (key.startsWith(Constants.SLOT_METADATA)) { + if (key.split("/")[1].equals("instrument_name")) { + for (Object obj : metadata.getAllMetadata(key)) { + log.info("instrument_name: " + (String) obj); + } + } + slots.add(new Slot(key.split("/")[1], metadata.getAllMetadata(key))); + } else if (key.startsWith("file_ref")) { + slots.add(new Slot(key.replace("/", "_"), metadata.getAllMetadata(key))); } else { LOG.log(new ToolsLogRecord(ToolsLevel.WARNING, "Creating unexpected slot: " + key, prodFile)); diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/FileObjectRegistrationAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/FileObjectRegistrationAction.java index 79146305..f276f60a 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/FileObjectRegistrationAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/FileObjectRegistrationAction.java @@ -9,7 +9,6 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -17,17 +16,17 @@ import javax.xml.bind.JAXBException; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.exception.ExceptionUtils; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.file.FileObject; import gov.nasa.pds.harvest.search.file.FileSize; import gov.nasa.pds.harvest.search.file.MD5Checksum; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +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.policy.FileTypeMap; import gov.nasa.pds.harvest.search.policy.FileTypes; import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; @@ -85,7 +84,7 @@ public class FileObjectRegistrationAction extends CrawlerAction { */ public FileObjectRegistrationAction() { super(); - String []phases = {CrawlerActionPhases.PRE_INGEST}; + String[] phases = {CrawlerActionPhases.PRE_INGEST.getName()}; setPhases(Arrays.asList(phases)); setId(ID); setDescription(DESCRIPTION); @@ -132,13 +131,16 @@ public boolean performAction(File product, Metadata metadata) try { // Perform a set of actions before ingesting the file object for (CrawlerAction action : actions) { - if (action instanceof StorageIngestAction) { - StorageIngestAction siAction = - (StorageIngestAction) action; - String productId = siAction.performAction(product, fileObject, - metadata); - fileObject.setStorageServiceProductId(productId); - } else if (action instanceof CreateAccessUrlsAction) { + // Commenting this out for now because I don't think we + // need to support this action anymore + // if (action instanceof StorageIngestAction) { + // StorageIngestAction siAction = + // (StorageIngestAction) action; + // String productId = siAction.performAction(product, fileObject, + // metadata); + // fileObject.setStorageServiceProductId(productId); + // } else + if (action instanceof CreateAccessUrlsAction) { CreateAccessUrlsAction cauAction = (CreateAccessUrlsAction) action; List urls = cauAction.performAction(product, fileObject); fileObject.setAccessUrls(urls); @@ -181,14 +183,11 @@ public void setActions(List actions) { */ private ExtrinsicObject createProduct(Metadata metadata, File prodFile) { ExtrinsicObject product = new ExtrinsicObject(); -// product.setGuid(idGenerator.getGuid()); Set slots = new HashSet(); - Set metSet = metadata.getHashtable().entrySet(); - for (Iterator i = metSet.iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); - String key = entry.getKey().toString(); + List keys = metadata.getAllKeys(); + for (String key : keys) { if (key.equals(Constants.REFERENCES) - || key.equals(Constants.INCLUDE_PATHS)) { + || key.equals(Constants.INCLUDE_PATHS) || key.equals(Constants.SLOT_METADATA)) { continue; } if (key.equals(Constants.LOGICAL_ID)) { @@ -203,8 +202,8 @@ private ExtrinsicObject createProduct(Metadata metadata, File prodFile) { Constants.OBJECT_TYPE)); } else if (key.equals(Constants.TITLE)) { product.setName(metadata.getMetadata(Constants.TITLE)); - } else if (key.equals(Constants.SLOT_METADATA)) { - slots.addAll(metadata.getAllMetadata(Constants.SLOT_METADATA)); + } else if (key.startsWith(Constants.SLOT_METADATA)) { + slots.add(new Slot(key.split("/")[1], metadata.getAllMetadata(key))); } else { log.log(new ToolsLogRecord(ToolsLevel.WARNING, "Creating unexpected slot: " + key, prodFile)); @@ -242,6 +241,7 @@ private ExtrinsicObject createProduct(Metadata metadata, File prodFile) { */ private Metadata createFileObjectMetadata(FileObject fileObject, Metadata sourceMet) { + log.fine("createFileObjectMetadata"); Metadata metadata = new Metadata(); List slots = new ArrayList(); String lid = sourceMet.getMetadata(Constants.LOGICAL_ID); @@ -298,10 +298,11 @@ private Metadata createFileObjectMetadata(FileObject fileObject, if (!fileObject.getAccessUrls().isEmpty()) { slots.add(new Slot(Constants.ACCESS_URLS, fileObject.getAccessUrls())); } - for (Iterator i = sourceMet.getHashtable().entrySet().iterator(); - i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); - String key = entry.getKey().toString(); + // for (Iterator i = sourceMet.getHashTable().entrySet().iterator(); + // i.hasNext();) { + // Map.Entry entry = (Map.Entry) i.next(); + // String key = entry.getKey().toString(); + for (String key : metadata.getKeys()) { if (key.equals("dd_version_id") || key.equals("std_ref_version_id")) { slots.add(new Slot(key, Arrays.asList( @@ -468,11 +469,9 @@ private List getPds4FileObjects(File product) return results; } - private List getPds3FileObjects(File product, - List includePaths) - throws URISyntaxException, MalformedURLException, MetExtractionException { - SimpleDateFormat format = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'"); + private List getPds3FileObjects(File product, List includePaths) + throws URISyntaxException, MalformedURLException, MetExtractionException { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'"); List results = new ArrayList(); // Create a file object of the label file String lastModified = format.format(new Date(product.lastModified())); @@ -480,20 +479,18 @@ private List getPds3FileObjects(File product, log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Capturing file object metadata for " + product.getName(), product)); String checksum = handleChecksum(product, product); - FileObject fileObject = new FileObject(product.getName(), - product.getParent(), new FileSize(product.length(), Constants.BYTE), - lastModified, checksum, "Label"); + FileObject fileObject = new FileObject(product.getName(), product.getParent(), + new FileSize(product.length(), Constants.BYTE), lastModified, checksum, "Label"); results.add(fileObject); } catch (Exception e) { log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "Error " - + "occurred while calculating checksum for " + product.getName() - + ": " + e.getMessage(), product.toString())); + + "occurred while calculating checksum for " + product.getName() + ": " + e.getMessage(), + product.toString())); ++HarvestSolrStats.numAncillaryProductsNotRegistered; } Label label = null; try { - DefaultLabelParser parser = new DefaultLabelParser(false, true, - new ManualPathResolver()); + DefaultLabelParser parser = new DefaultLabelParser(false, true, new ManualPathResolver()); label = parser.parseLabel(product.toURI().toURL()); } catch (LabelParserException lp) { throw new MetExtractionException(MessageUtils.getProblemMessage(lp)); @@ -510,27 +507,24 @@ private List getPds3FileObjects(File product, File file = resolvePath(fileRef.getPath(), basePath, includePaths); try { if (file != null) { - if (!file.getName().equals(product.getName()) - && !uniqueFiles.contains(file)) { + if (!file.getName().equals(product.getName()) && !uniqueFiles.contains(file)) { log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Capturing file object metadata for " + file.getName(), product)); long size = file.length(); - String creationDateTime = format.format(new Date( - file.lastModified())); + String creationDateTime = format.format(new Date(file.lastModified())); String checksum = handleChecksum(product, file); results.add(new FileObject(file.getName(), file.getParent(), - new FileSize(size, Constants.BYTE), - creationDateTime, checksum, "Observation")); + new FileSize(size, Constants.BYTE), creationDateTime, checksum, "Observation")); uniqueFiles.add(file); } } else { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "File object not " - + "found: " + fileRef.getPath(), product.toString())); + log.log(new ToolsLogRecord(ToolsLevel.SEVERE, + "File object not " + "found: " + fileRef.getPath(), product.toString())); ++HarvestSolrStats.numAncillaryProductsNotRegistered; } } catch (Exception e) { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "Error occurred " - + "while calculating checksum for " + file.getName() + ": ", + log.log(new ToolsLogRecord(ToolsLevel.SEVERE, + "Error occurred " + "while calculating checksum for " + file.getName() + ": ", product)); ++HarvestSolrStats.numAncillaryProductsNotRegistered; } diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LidCheckerAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LidCheckerAction.java index 03f580ec..06b4d718 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LidCheckerAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LidCheckerAction.java @@ -3,14 +3,13 @@ import java.io.File; import java.util.Arrays; import java.util.logging.Logger; - -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; /** * Pre-ingest Crawler Action that checks to see if the logical identifier @@ -40,7 +39,7 @@ public class LidCheckerAction extends CrawlerAction { */ public LidCheckerAction() { super(); - String []phases = {CrawlerActionPhases.PRE_INGEST}; + String[] phases = {CrawlerActionPhases.PRE_INGEST.getName()}; setPhases(Arrays.asList(phases)); setId(ID); setDescription(DESCRIPTION); diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LogMissingReqMetadataAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LogMissingReqMetadataAction.java index df3484f3..e34764bf 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LogMissingReqMetadataAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/LogMissingReqMetadataAction.java @@ -5,13 +5,12 @@ import java.util.Arrays; import java.util.List; import java.util.logging.Logger; - -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; /** * Crawler action class that checks to see if the required metadata @@ -31,7 +30,7 @@ public LogMissingReqMetadataAction(List reqMetadata) { super(); this.reqMetadata = new ArrayList(); this.reqMetadata.addAll(reqMetadata); - String []phases = {CrawlerActionPhases.PRE_INGEST}; + String[] phases = {CrawlerActionPhases.PRE_INGEST.getName()}; setPhases(Arrays.asList(phases)); setId(ID); setDescription(DESCRIPTION); @@ -41,7 +40,8 @@ public LogMissingReqMetadataAction(List reqMetadata) { public boolean performAction(File product, Metadata productMetadata) throws CrawlerActionException { boolean passFlag = true; - if (productMetadata.getHashtable().isEmpty()) { + // if (productMetadata.getHashTable().isEmpty()) { + if (productMetadata.getKeys().isEmpty()) { return false; } for (String key : reqMetadata) { diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/StorageIngestAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/StorageIngestAction.java index 6b215ac0..9e48228c 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/StorageIngestAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/StorageIngestAction.java @@ -1,191 +1,185 @@ -package gov.nasa.pds.harvest.search.crawler.actions; - -import java.io.File; -import java.net.URL; -import java.util.Arrays; -import java.util.List; -import java.util.Vector; -import java.util.logging.Logger; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.oodt.cas.filemgr.datatransfer.InPlaceDataTransferFactory; -import org.apache.oodt.cas.filemgr.structs.Product; -import org.apache.oodt.cas.filemgr.structs.exceptions.ConnectionException; -import org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException; -import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient; -import org.apache.oodt.cas.filemgr.util.GenericFileManagerObjectFactory; -import org.apache.oodt.cas.filemgr.versioning.VersioningUtils; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.filemgr.datatransfer.RemoteDataTransferFactory; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.pds.harvest.search.constants.Constants; -import gov.nasa.pds.harvest.search.file.FileObject; -import gov.nasa.pds.harvest.search.logging.ToolsLevel; -import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; - -/** - * Class that will ingest registered products to the PDS Storage - * Service. - * - * @author mcayanan - * - */ -public class StorageIngestAction extends CrawlerAction { - /** Logger object. */ - private static Logger log = Logger.getLogger( - StorageIngestAction.class.getName()); - - /** The Storage Service Client object. */ - private XmlRpcFileManagerClient fmClient; - - /** The crawler action identifier. */ - private final static String ID = "StorageIngestAction"; - - /** The crawler action description. */ - private final static String DESCRIPTION = "Ingests registered products " - + "to the PDS Storage Service."; - - /** The product type name for the Storage Service. */ - private String productTypeName; - - /** - * Constructor. - * - * @param storageServerUrl URL to the PDS storage server. - * - * @throws ConnectionException If there was an error connecting to the - * Storage Service. - */ - public StorageIngestAction(URL storageServerUrl) - throws ConnectionException { - fmClient = new XmlRpcFileManagerClient(storageServerUrl); - fmClient.setDataTransfer(GenericFileManagerObjectFactory - .getDataTransferServiceFromFactory( - InPlaceDataTransferFactory.class.getName())); - String []phases = {CrawlerActionPhases.PRE_INGEST}; - setPhases(Arrays.asList(phases)); - setId(ID); - setDescription(DESCRIPTION); - productTypeName = "ProductFile"; - } - - /** - * Perform the action to ingest a product to the PDS Storage service. - * - * @param product The registered product. - * @param metadata The metadata associated with the given product. - * - * @return true if the ingestion was successful, false otherwise. - */ - public boolean performAction(File product, Metadata metadata) - throws CrawlerActionException { - // create the product - Product prod = new Product(); - String lidvid = metadata.getMetadata(Constants.LOGICAL_ID) + "::" - + metadata.getMetadata(Constants.PRODUCT_VERSION); - prod.setProductName(lidvid); - prod.setProductStructure(Product.STRUCTURE_FLAT); - try { - prod.setProductType(fmClient.getProductTypeByName(productTypeName)); - } catch (RepositoryManagerException r) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - "Unable to obtain product type: [" + productTypeName + "] " - + "from File Manager at: [" + fmClient.getFileManagerUrl() - + "]: Message: " + r.getMessage(), product)); - return false; - } - List references = new Vector(); - references.add(product.toURI().toString()); - // build refs and attach to product - VersioningUtils.addRefsFromUris(prod, references); - org.apache.oodt.cas.metadata.Metadata prodMet = - new org.apache.oodt.cas.metadata.Metadata(); - prodMet.addMetadata("ProductClass", metadata.getMetadata( - Constants.OBJECT_TYPE)); - - // Are we doing a local/remote data transfer of the ingested product? - try { - String productId = fmClient.ingestProduct(prod, prodMet, true); - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Ingested '" + lidvid - + "' to the Storage Service with product ID: " + productId, product) - ); - metadata.addMetadata(Constants.STORAGE_SERVICE_PRODUCT_ID, productId); - } catch (Exception e) { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "Error occurred while " - + "attempting to ingest into the file manager: " - + ExceptionUtils.getRootCauseMessage(e), product)); - return false; - } - return true; - } - - /** - * Perform ingestion of a file object. - * - * @param product The file associated with the given file object. - * @param fileObject The file object to ingest. - * @param metadata The metadata associated with the given file. - * - * @return The storage service product identifier if an ingestion - * was successful. If an error occurred, a null will be returned. - */ - public String performAction(File product, FileObject fileObject, - Metadata metadata) { - Product prod = new Product(); - String lidvid = metadata.getMetadata(Constants.LOGICAL_ID) + ":" - + fileObject.getName() + "::" - + metadata.getMetadata(Constants.PRODUCT_VERSION); - prod.setProductName(lidvid); - prod.setProductStructure(Product.STRUCTURE_FLAT); - try { - prod.setProductType(fmClient.getProductTypeByName(productTypeName)); - } catch (RepositoryManagerException r) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - "Unable to obtain product type: [" + productTypeName + "] " - + "from File Manager at: [" + fmClient.getFileManagerUrl() - + "]: Message: " + r.getMessage(), product)); - return null; - } - List references = new Vector(); - references.add(new File(fileObject.getLocation(), fileObject.getName()) - .toURI().toString()); - VersioningUtils.addRefsFromUris(prod, references); - org.apache.oodt.cas.metadata.Metadata prodMet = - new org.apache.oodt.cas.metadata.Metadata(); - prodMet.addMetadata("ProductClass", "Product_File_Repository"); - - // Are we doing a local/remote data transfer of the ingested product? - String productId = null; - try { - productId = fmClient.ingestProduct(prod, prodMet, true); - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Ingested '" + lidvid - + "' to the Storage Service with product ID: " + productId, product) - ); - } catch (Exception e) { - log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "Error occurred while " - + "attempting to ingest into the file manager: " - + ExceptionUtils.getRootCauseMessage(e), product)); - return null; - } - return productId; - - } - - /** - * Set the data transfer type. - * - * @param dataTransferType Either 'InPlaceProduct' or 'TransferProduct'. - */ - public void setDataTransferType(String dataTransferType) { - if ("TransferProduct".equalsIgnoreCase(dataTransferType)) { - fmClient.setDataTransfer(GenericFileManagerObjectFactory - .getDataTransferServiceFromFactory(RemoteDataTransferFactory.class - .getName())); - } else { - fmClient.setDataTransfer(GenericFileManagerObjectFactory - .getDataTransferServiceFromFactory( - InPlaceDataTransferFactory.class.getName())); - } - } -} +// package gov.nasa.pds.harvest.search.crawler.actions; +// +// import java.io.File; +// import java.net.URL; +// import java.util.Arrays; +// import java.util.List; +// import java.util.Vector; +// import java.util.logging.Logger; +// import org.apache.commons.lang.exception.ExceptionUtils; +// import gov.nasa.pds.harvest.search.constants.Constants; +// import gov.nasa.pds.harvest.search.crawler.metadata.Metadata; +// import gov.nasa.pds.harvest.search.file.FileObject; +// import gov.nasa.pds.harvest.search.logging.ToolsLevel; +// import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +// import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +// import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +// import gov.nasa.pds.harvest.search.oodt.filemgr.GenericFileManagerObjectFactory; +// import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.ConnectionException; +// import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +// import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.RepositoryManagerException; +// +/// ** +// * Class that will ingest registered products to the PDS Storage*Service. +// * +// * @author mcayanan +// * +// */ +// public class StorageIngestAction extends CrawlerAction { +// /* Logger object. */ +// private static Logger log = Logger.getLogger( +// StorageIngestAction.class.getName()); +// +// /* The Storage Service Client object. */ +// // private XmlRpcFileManagerClient fmClient; +// +// /* The crawler action identifier. */ +// private final static String ID = "StorageIngestAction"; +// +// /* The crawler action description. */ +// private final static String DESCRIPTION = "Ingests registered products " +// + "to the PDS Storage Service."; +// +// /* The product type name for the Storage Service. */ +// private String productTypeName; +// +// /** +// * Constructor. +// * +// * @param storageServerUrl URL to the PDS storage server. +// * +// * @throws ConnectionException If there was an error connecting to the +// * Storage Service. +// */ +// public StorageIngestAction(URL storageServerUrl) +// throws ConnectionException { +// fmClient = new XmlRpcFileManagerClient(storageServerUrl); +// fmClient.setDataTransfer(GenericFileManagerObjectFactory +// .getDataTransferServiceFromFactory( +// InPlaceDataTransferFactory.class.getName())); +// String[] phases = {CrawlerActionPhases.PRE_INGEST.getName()}; +// setPhases(Arrays.asList(phases)); +// setId(ID); +// setDescription(DESCRIPTION); +// productTypeName = "ProductFile"; +// } +// +// /** +// * Perform the action to ingest a product to the PDS Storage service. +// * +// * @param product The registered product. +// * @param metadata The metadata associated with the given product. +// * +// * @return true if the ingestion was successful, false otherwise. +// */ +// public boolean performAction(File product, Metadata metadata) +// throws CrawlerActionException { +// // create the product +// Product prod = new Product(); +// String lidvid = metadata.getMetadata(Constants.LOGICAL_ID) + "::" +// + metadata.getMetadata(Constants.PRODUCT_VERSION); +// prod.setProductName(lidvid); +// prod.setProductStructure(Product.STRUCTURE_FLAT); +// try { +// prod.setProductType(fmClient.getProductTypeByName(productTypeName)); +// } catch (RepositoryManagerException r) { +// log.log(new ToolsLogRecord(ToolsLevel.WARNING, +// "Unable to obtain product type: [" + productTypeName + "] " +// + "from File Manager at: [" + fmClient.getFileManagerUrl() +// + "]: Message: " + r.getMessage(), product)); +// return false; +// } +// List references = new Vector(); +// references.add(product.toURI().toString()); +// // build refs and attach to product +// VersioningUtils.addRefsFromUris(prod, references); +// org.apache.oodt.cas.metadata.Metadata prodMet = +// new org.apache.oodt.cas.metadata.Metadata(); +// prodMet.addMetadata("ProductClass", metadata.getMetadata( +// Constants.OBJECT_TYPE)); +// +// // Are we doing a local/remote data transfer of the ingested product? +// try { +// String productId = fmClient.ingestProduct(prod, prodMet, true); +// log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Ingested '" + lidvid +// + "' to the Storage Service with product ID: " + productId, product) +// ); +// metadata.addMetadata(Constants.STORAGE_SERVICE_PRODUCT_ID, productId); +// } catch (Exception e) { +// log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "Error occurred while " +// + "attempting to ingest into the file manager: " +// + ExceptionUtils.getRootCauseMessage(e), product)); +// return false; +// } +// return true; +// } +// +// /** +// * Perform ingestion of a file object. +// * +// * @param product The file associated with the given file object. +// * @param fileObject The file object to ingest. +// * @param metadata The metadata associated with the given file. +// * +// * @return The storage service product identifier if an ingestion +// * was successful. If an error occurred, a null will be returned. +// */ +// public String performAction(File product, FileObject fileObject, +// Metadata metadata) { +// Product prod = new Product(); +// String lidvid = metadata.getMetadata(Constants.LOGICAL_ID) + ":" +// + fileObject.getName() + "::" +// + metadata.getMetadata(Constants.PRODUCT_VERSION); +// prod.setProductName(lidvid); +// prod.setProductStructure(Product.STRUCTURE_FLAT); +// try { +// prod.setProductType(fmClient.getProductTypeByName(productTypeName)); +// } catch (RepositoryManagerException r) { +// log.log(new ToolsLogRecord(ToolsLevel.WARNING, +// "Unable to obtain product type: [" + productTypeName + "] " +// + "from File Manager at: [" + fmClient.getFileManagerUrl() +// + "]: Message: " + r.getMessage(), product)); +// return null; +// } +// List references = new Vector(); +// references.add(new File(fileObject.getLocation(), fileObject.getName()) +// .toURI().toString()); +// VersioningUtils.addRefsFromUris(prod, references); +// org.apache.oodt.cas.metadata.Metadata prodMet = +// new org.apache.oodt.cas.metadata.Metadata(); +// prodMet.addMetadata("ProductClass", "Product_File_Repository"); +// +// // Are we doing a local/remote data transfer of the ingested product? +// String productId = null; +// try { +// productId = fmClient.ingestProduct(prod, prodMet, true); +// log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Ingested '" + lidvid +// + "' to the Storage Service with product ID: " + productId, product) +// ); +// } catch (Exception e) { +// log.log(new ToolsLogRecord(ToolsLevel.SEVERE, "Error occurred while " +// + "attempting to ingest into the file manager: " +// + ExceptionUtils.getRootCauseMessage(e), product)); +// return null; +// } +// return productId; +// +// } +// +// /** +// * Set the data transfer type. +// * +// * @param dataTransferType Either 'InPlaceProduct' or 'TransferProduct'. +// */ +// public void setDataTransferType(String dataTransferType) { +// if ("TransferProduct".equalsIgnoreCase(dataTransferType)) { +// fmClient.setDataTransfer(GenericFileManagerObjectFactory +// .getDataTransferServiceFromFactory(RemoteDataTransferFactory.class +// .getName())); +// } else { +// fmClient.setDataTransfer(GenericFileManagerObjectFactory +// .getDataTransferServiceFromFactory( +// InPlaceDataTransferFactory.class.getName())); +// } +// } +// } diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/TitleLengthCheckerAction.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/TitleLengthCheckerAction.java index 464748ed..d61b1790 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/TitleLengthCheckerAction.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/actions/TitleLengthCheckerAction.java @@ -3,14 +3,13 @@ import java.io.File; import java.util.Arrays; import java.util.logging.Logger; - -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerAction; -import gov.nasa.jpl.oodt.cas.crawl.action.CrawlerActionPhases; -import gov.nasa.jpl.oodt.cas.crawl.structs.exceptions.CrawlerActionException; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.crawler.CrawlerAction; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; /** * Pre-ingest Crawler Action that checks to see that the title value is @@ -37,7 +36,7 @@ public class TitleLengthCheckerAction extends CrawlerAction { */ public TitleLengthCheckerAction() { super(); - String []phases = {CrawlerActionPhases.PRE_INGEST}; + String[] phases = {CrawlerActionPhases.PRE_INGEST.getName()}; setPhases(Arrays.asList(phases)); setId(ID); setDescription(DESCRIPTION); diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/daemon/HarvestSolrDaemon.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/daemon/HarvestSolrDaemon.java deleted file mode 100644 index 5df043c2..00000000 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/daemon/HarvestSolrDaemon.java +++ /dev/null @@ -1,312 +0,0 @@ -package gov.nasa.pds.harvest.search.crawler.daemon; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.logging.Logger; - -import org.apache.xmlrpc.WebServer; - -import gov.nasa.jpl.oodt.cas.crawl.daemon.CrawlDaemon; -import gov.nasa.pds.harvest.search.crawler.PDSProductCrawler; -import gov.nasa.pds.harvest.search.logging.ToolsLevel; -import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; -import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; - -/** - * Class that provides the capability to make the Harvest Tool run - * in persistance mode. - * - * @author mcayanan - * - */ -public class HarvestSolrDaemon extends CrawlDaemon { - /** To log messages. */ - private static Logger log = Logger.getLogger( - HarvestSolrDaemon.class.getName()); - - /** The port number to be used. */ - private int daemonPort; - - /** A list of crawlers. */ - private List crawlers; - - /** Current number of good files. */ - private int numGoodFiles; - - /** Current number of bad files. */ - private int numBadFiles; - - /** Current number of files skipped. */ - private int numFilesSkipped; - - /** Current number of products registered. */ - private int numDocumentsCreated; - - /** Current number of products no registered. */ - private int numDocumentsNotCreated; - - /** Current number of errors. */ - private int numErrors; - - /** Current number of warnings. */ - private int numWarnings; - - /** Current number of generated checksums matching their supplied value. */ - private int numGeneratedChecksumsSameInManifest; - - /** Current number of generated checksums not matching their supplied value. - */ - private int numGeneratedChecksumsDiffInManifest; - - /** Current number of generated checksums not checked. */ - private int numGeneratedChecksumsNotCheckedInManifest; - - /** Current number of generated checksums matching their supplied value. */ - private int numGeneratedChecksumsSameInLabel; - - /** Current number of generated checksums not matching their supplied value. - */ - private int numGeneratedChecksumsDiffInLabel; - - /** Current number of generated checksums not checked. */ - private int numGeneratedChecksumsNotCheckedInLabel; - - /** Current number of generated checksums matching their supplied value. */ - private int numManifestChecksumsSameInLabel; - - /** Current number of generated checksums not matching their supplied value. - */ - private int numManifestChecksumsDiffInLabel; - - /** Current number of generated checksums not checked. */ - private int numManifestChecksumsNotCheckedInLabel; - - /** Mapping of the current count of registered product types. */ - private HashMap registeredProductTypes; - - /** - * Constructor - * - * @param wait The time in seconds to wait in between crawls. - * @param crawlers A list of PDSProductCrawler objects to be used during - * crawler persistance. - * @param port The port nunmber to be used. - */ - public HarvestSolrDaemon(int wait, List crawlers, int port) { - super(wait, null, port); - this.daemonPort = port; - this.crawlers = new ArrayList(); - this.crawlers.addAll(crawlers); - - numBadFiles = 0; - numFilesSkipped = 0; - numGoodFiles = 0; - numDocumentsCreated = 0; - numDocumentsNotCreated = 0; - numErrors = 0; - numWarnings = 0; - numGeneratedChecksumsSameInManifest = 0; - numGeneratedChecksumsDiffInManifest = 0; - numGeneratedChecksumsNotCheckedInManifest = 0; - numGeneratedChecksumsSameInLabel = 0; - numGeneratedChecksumsDiffInLabel = 0; - numGeneratedChecksumsNotCheckedInLabel = 0; - numManifestChecksumsSameInLabel = 0; - numManifestChecksumsDiffInLabel = 0; - numManifestChecksumsNotCheckedInLabel = 0; - registeredProductTypes = new HashMap(); - } - - /** - * Starts the crawling mechanism. - * - */ - public void startCrawling() { - WebServer server = new WebServer(daemonPort); - server.addHandler("crawldaemon", this); - server.start(); - - log.log(new ToolsLogRecord(ToolsLevel.INFO, "Starting crawler daemon.")); - for (PDSProductCrawler crawler : crawlers) { - crawler.setInPersistanceMode(true); - } - - while (isRunning()) { - // okay, time to crawl - for (PDSProductCrawler crawler : crawlers) { - long timeBefore = System.currentTimeMillis(); - crawler.crawl(); - long timeAfter = System.currentTimeMillis(); - setMilisCrawling((long) getMilisCrawling() + (timeAfter - timeBefore)); - setNumCrawls(getNumCrawls() + 1); - } - printSummary(); - - log.log(new ToolsLogRecord(ToolsLevel.INFO, "Sleeping for: [" - + getWaitInterval() + "] seconds")); - - // take a nap - try { - Thread.currentThread().sleep(getWaitInterval() * 1000); - } catch (InterruptedException ignore) { - } - } - for (PDSProductCrawler crawler : crawlers) { - log.log(new ToolsLogRecord(ToolsLevel.INFO, "Crawl Daemon: Shutting " - + "down gracefully", crawler.getProductPath())); - } - log.log(new ToolsLogRecord(ToolsLevel.INFO, "Total num Crawls: [" - + getNumCrawls() + "]")); - log.log(new ToolsLogRecord(ToolsLevel.INFO, "Total time spent crawling: " - + "[" + (getMilisCrawling() / 1000.0) + "] seconds")); - log.log(new ToolsLogRecord(ToolsLevel.INFO, "Average Crawl Time: [" - + (getAverageCrawlTime() / 1000.0) + "] seconds")); - server.shutdown(); - } - - /** - * Prints a summary of the crawl. - * - */ - private void printSummary() { - // Calculate the stats during this particular harvest instance - int newGoodFiles = HarvestSolrStats.numGoodFiles - numGoodFiles; - int newBadFiles = HarvestSolrStats.numBadFiles - numBadFiles; - int newFilesSkipped = HarvestSolrStats.numFilesSkipped - numFilesSkipped; - - int newDocumentsCreated = HarvestSolrStats.numDocumentsCreated - - numDocumentsCreated; - - int newDocumentsNotCreated = HarvestSolrStats.numDocumentsNotCreated - - numDocumentsNotCreated; - - int newErrors = HarvestSolrStats.numErrors - numErrors; - - int newWarnings = HarvestSolrStats.numWarnings - numWarnings; - - int newGeneratedChecksumsSameInManifest = HarvestSolrStats.numGeneratedChecksumsSameInManifest - numGeneratedChecksumsSameInManifest; - - int newGeneratedChecksumsDiffInManifest = HarvestSolrStats.numGeneratedChecksumsDiffInManifest - numGeneratedChecksumsDiffInManifest; - - int newGeneratedChecksumsNotCheckedInManifest = HarvestSolrStats.numGeneratedChecksumsNotCheckedInManifest - numGeneratedChecksumsNotCheckedInManifest; - - int newGeneratedChecksumsSameInLabel = HarvestSolrStats.numGeneratedChecksumsSameInLabel - numGeneratedChecksumsSameInLabel; - - int newGeneratedChecksumsDiffInLabel = HarvestSolrStats.numGeneratedChecksumsDiffInLabel - numGeneratedChecksumsDiffInLabel; - - int newGeneratedChecksumsNotCheckedInLabel = HarvestSolrStats.numGeneratedChecksumsNotCheckedInLabel - numGeneratedChecksumsNotCheckedInLabel; - - int newManifestChecksumsSameInLabel = HarvestSolrStats.numManifestChecksumsSameInLabel - numManifestChecksumsSameInLabel; - - int newManifestChecksumsDiffInLabel = HarvestSolrStats.numManifestChecksumsDiffInLabel - numManifestChecksumsDiffInLabel; - - int newManifestChecksumsNotCheckedInLabel = HarvestSolrStats.numManifestChecksumsNotCheckedInLabel - numManifestChecksumsNotCheckedInLabel; - - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - + (newGoodFiles + newBadFiles + newFilesSkipped) - + " new file(s) found.")); - - if ( (newGoodFiles + newBadFiles + newFilesSkipped) == 0) { - return; - } else { - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - newGoodFiles + " of " - + (newGoodFiles + newBadFiles) + " new file(s) processed, " - + newFilesSkipped + " other file(s) skipped")); - - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - newErrors + " new error(s), " + newWarnings + " new warning(s)" - + "\n")); - - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - newDocumentsCreated + " of " - + (newDocumentsCreated + newDocumentsNotCreated) - + " new documents created.")); - - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - "\nNew Product Types Handled:\n")); - for (String key : HarvestSolrStats.registeredProductTypes.keySet()) { - if (registeredProductTypes.containsKey(key)) { - BigInteger numNewProductTypes = - HarvestSolrStats.registeredProductTypes.get(key).subtract(registeredProductTypes.get(key)); - if (numNewProductTypes.longValue() != 0) { - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - numNewProductTypes + " " + key)); - } - } else { - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - HarvestSolrStats.registeredProductTypes.get(key).toString() + " " - + key)); - } - } - - int totalGeneratedChecksumsVsManifest = - newGeneratedChecksumsSameInManifest - + newGeneratedChecksumsDiffInManifest; - - if ( (totalGeneratedChecksumsVsManifest != 0) - || (newGeneratedChecksumsNotCheckedInManifest != 0) ) { - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - "\n" + newGeneratedChecksumsSameInManifest - + " of " + totalGeneratedChecksumsVsManifest - + " generated checksums matched " - + "their supplied value in the manifest, " - + newGeneratedChecksumsNotCheckedInManifest - + " generated value(s) not checked\n")); - } - - int totalGeneratedChecksumsVsLabel = - newGeneratedChecksumsSameInLabel - + newGeneratedChecksumsDiffInLabel; - - if ( (totalGeneratedChecksumsVsLabel != 0) - || (newGeneratedChecksumsNotCheckedInLabel != 0) ) { - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - "\n" + newGeneratedChecksumsSameInLabel - + " of " + totalGeneratedChecksumsVsLabel - + " generated checksums matched " - + "the supplied value in their product label, " - + newGeneratedChecksumsNotCheckedInLabel - + " generated value(s) not checked\n")); - } - - int totalManifestChecksumsVsLabel = - newManifestChecksumsSameInLabel - + newManifestChecksumsDiffInLabel; - - if ( (totalManifestChecksumsVsLabel != 0) - || (newManifestChecksumsNotCheckedInLabel != 0) ) { - log.log(new ToolsLogRecord(ToolsLevel.NOTIFICATION, - "\n" + newManifestChecksumsSameInLabel - + " of " + totalManifestChecksumsVsLabel - + " checksums in the manifest matched " - + "the supplied value in their product label, " - + newManifestChecksumsNotCheckedInLabel - + " value(s) not checked\n")); - } - - } - - // Save the stats for the next round of calculations - numGoodFiles = HarvestSolrStats.numGoodFiles; - numBadFiles = HarvestSolrStats.numBadFiles; - numFilesSkipped = HarvestSolrStats.numFilesSkipped; - numDocumentsCreated = HarvestSolrStats.numDocumentsCreated; - numDocumentsNotCreated = HarvestSolrStats.numDocumentsNotCreated; - numErrors = HarvestSolrStats.numErrors; - numWarnings = HarvestSolrStats.numWarnings; - numGeneratedChecksumsSameInManifest = HarvestSolrStats.numGeneratedChecksumsSameInManifest; - numGeneratedChecksumsDiffInManifest = HarvestSolrStats.numGeneratedChecksumsDiffInManifest; - numGeneratedChecksumsNotCheckedInManifest = HarvestSolrStats.numGeneratedChecksumsNotCheckedInManifest; - numGeneratedChecksumsSameInLabel = HarvestSolrStats.numGeneratedChecksumsSameInLabel; - numGeneratedChecksumsDiffInLabel = HarvestSolrStats.numGeneratedChecksumsDiffInLabel; - numGeneratedChecksumsNotCheckedInLabel = HarvestSolrStats.numGeneratedChecksumsNotCheckedInLabel; - numManifestChecksumsSameInLabel = HarvestSolrStats.numManifestChecksumsSameInLabel; - numManifestChecksumsDiffInLabel = HarvestSolrStats.numManifestChecksumsDiffInLabel; - numManifestChecksumsNotCheckedInLabel = HarvestSolrStats.numManifestChecksumsNotCheckedInLabel; - registeredProductTypes.clear(); - registeredProductTypes.putAll(HarvestSolrStats.registeredProductTypes); - } -} diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/BundleMetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/BundleMetExtractor.java index 3a120c8c..862a6018 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/BundleMetExtractor.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/BundleMetExtractor.java @@ -6,12 +6,12 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.inventory.ReferenceEntry; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.MetExtractionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; import gov.nasa.pds.registry.model.Slot; import net.sf.saxon.tree.tiny.TinyElementImpl; @@ -98,14 +98,14 @@ public Metadata extractMetadata(File product) for (ReferenceEntry entry : getReferences(references, product)) { String value = ""; if (!entry.hasVersion()) { - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Setting " + log.log(new ToolsLogRecord(ToolsLevel.INFO, "Setting " + "LID-based association, \'" + entry.getLogicalID() + "\', under slot name \'" + entry.getType() + "\'.", product)); value = entry.getLogicalID(); } else { String lidvid = entry.getLogicalID() + "::" + entry.getVersion(); - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Setting " + log.log(new ToolsLogRecord(ToolsLevel.INFO, "Setting " + "LIDVID-based association, \'" + lidvid + "\', under slot name \'" + entry.getType() + "\'.", product)); @@ -122,6 +122,7 @@ public Metadata extractMetadata(File product) } if (!refMap.isEmpty()) { for (Map.Entry> entry : refMap.entrySet()) { + log.info("refMap key-value: " + entry.getKey() + " - " + entry.getValue()); slots.add(new Slot(entry.getKey(), entry.getValue())); } } diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/CollectionMetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/CollectionMetExtractor.java index 66631ea2..8102de5c 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/CollectionMetExtractor.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/CollectionMetExtractor.java @@ -6,8 +6,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.inventory.InventoryEntry; import gov.nasa.pds.harvest.search.inventory.InventoryReaderException; @@ -15,6 +13,8 @@ import gov.nasa.pds.harvest.search.inventory.ReferenceEntry; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +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.util.LidVid; import gov.nasa.pds.registry.model.Slot; import net.sf.saxon.tree.tiny.TinyElementImpl; @@ -92,6 +92,7 @@ public Metadata extractMetadata(File product) metadata.addMetadata(Constants.TITLE, trimmedTitle); } if (!"".equals(objectType)) { + log.info(Constants.OBJECT_TYPE + ":" + objectType); metadata.addMetadata(Constants.OBJECT_TYPE, objectType); } if ("".equals(associationType)) { @@ -164,14 +165,14 @@ public Metadata extractMetadata(File product) for (ReferenceEntry entry : refEntries) { String value = ""; if (!entry.hasVersion()) { - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Setting " + log.log(new ToolsLogRecord(ToolsLevel.INFO, "Setting " + "LID-based association, \'" + entry.getLogicalID() + "\', under slot name \'" + entry.getType() + "\'.", product)); value = entry.getLogicalID(); } else { String lidvid = entry.getLogicalID() + "::" + entry.getVersion(); - log.log(new ToolsLogRecord(ToolsLevel.DEBUG, "Setting " + log.log(new ToolsLogRecord(ToolsLevel.INFO, "Setting " + "LIDVID-based association, \'" + lidvid + "\', under slot name \'" + entry.getType() + "\'.", product)); diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3FileMetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3FileMetExtractor.java deleted file mode 100644 index ae671ab5..00000000 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3FileMetExtractor.java +++ /dev/null @@ -1,282 +0,0 @@ -package gov.nasa.pds.harvest.search.crawler.metadata.extractor; - -import java.io.File; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import org.apache.commons.io.FilenameUtils; - -import gov.nasa.jpl.oodt.cas.metadata.MetExtractor; -import gov.nasa.jpl.oodt.cas.metadata.MetExtractorConfig; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; -import gov.nasa.pds.harvest.search.constants.Constants; -import gov.nasa.pds.harvest.search.file.FileObject; -import gov.nasa.pds.harvest.search.file.FileSize; -import gov.nasa.pds.harvest.search.file.MD5Checksum; -import gov.nasa.pds.harvest.search.logging.ToolsLevel; -import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; -import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; -import gov.nasa.pds.registry.model.Slot; - -/** - * A class to extract metadata information from PDS3 files. - * - * @author mcayanan - * - */ -public class Pds3FileMetExtractor implements MetExtractor { - /** Logger object. */ - private static Logger log = Logger.getLogger( - Pds3FileMetExtractor.class.getName()); - - /** Holds the metadata extractor configuration. */ - private Pds3MetExtractorConfig config; - - /** Flag to enable generation of checksums on the fly. */ - private boolean generateChecksums; - - /** Represents the checksum manifest file. */ - private Map checksumManifest; - - public Pds3FileMetExtractor(Pds3MetExtractorConfig config) { - this.config = config; - } - - @Override - public Metadata extractMetadata(File product) - throws MetExtractionException { - Metadata metadata = new Metadata(); - metadata.addMetadata(Constants.OBJECT_TYPE, Constants.FILE_OBJECT_PRODUCT_TYPE); - String lid = config.getLidContents().getPrefix(); - if (config.getLidContents().isAppendDir()) { - String parent = product.getParent(); - String offset = config.getLidContents().getOffset(); - if (offset != null) { - boolean matchedOffset = false; - if (parent.startsWith(offset)) { - parent = parent.replace(offset, "") - .trim(); - matchedOffset = true; - } - if ( (offset != null) && (!matchedOffset) ) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - "Cannot trim path of product '" + product - + "' as it does not start with the supplied offset: " - + offset, product)); - } - } - if (!parent.isEmpty()) { - parent = parent.replaceAll("[/|\\\\]", ":"); - if (parent.startsWith(":")) { - lid += parent.toLowerCase(); - } else { - lid += ":" + parent.toLowerCase(); - } - } - } - if (config.getLidContents().isAppendFilename()) { - lid += ":" + FilenameUtils.getBaseName(product.toString()); - } - lid += ":" + product.getName(); - lid = lid.toLowerCase(); - metadata.addMetadata(Constants.LOGICAL_ID, lid); - metadata.addMetadata(Constants.PRODUCT_VERSION, "1.0"); - List fileTypes = new ArrayList(); - fileTypes.add("Extra"); - List slots = new ArrayList(); - if (!config.getStaticMetadata().isEmpty()) { - for (gov.nasa.pds.harvest.search.policy.Slot slot : config.getStaticMetadata()) { - if (slot.getName().equals(Constants.PRODUCT_VERSION)) { - metadata.replaceMetadata(Constants.PRODUCT_VERSION, slot.getValue()); - } else if (slot.getName().equals(Constants.FILE_TYPE)) { - fileTypes = slot.getValue(); - } else { - slots.add(new Slot(slot.getName(), slot.getValue())); - } - } - } - try { - FileObject fileObject = createFileObject(product); - metadata.addMetadata(Constants.TITLE, FilenameUtils.getBaseName( - fileObject.getName())); - slots.add(new Slot(Constants.FILE_NAME, - Arrays.asList(new String[]{fileObject.getName()}))); - - slots.add(new Slot(Constants.FILE_LOCATION, - Arrays.asList(new String[]{fileObject.getLocation()}))); - - FileSize fs = fileObject.getSize(); - Slot fsSlot = new Slot(Constants.FILE_SIZE, Arrays.asList( - new String[]{new Long(fs.getSize()).toString()})); - if (fs.hasUnits()) { - fsSlot.setSlotType(fs.getUnits()); - } - slots.add(fsSlot); - - slots.add(new Slot(Constants.MIME_TYPE, - Arrays.asList(new String[]{fileObject.getMimeType()}))); - - if ( (fileObject.getChecksum()) != null - && (!fileObject.getChecksum().isEmpty()) ) { - slots.add(new Slot(Constants.MD5_CHECKSUM, - Arrays.asList(new String[]{fileObject.getChecksum()}))); - } - - slots.add(new Slot(Constants.FILE_TYPE, fileTypes)); - - slots.add(new Slot(Constants.CREATION_DATE_TIME, - Arrays.asList(new String[]{fileObject.getCreationDateTime()}))); - } catch (Exception e) { - throw new MetExtractionException(e.getMessage()); - } - if (!slots.isEmpty()) { - metadata.addMetadata(Constants.SLOT_METADATA, slots); - } - return metadata; - } - - private FileObject createFileObject(File product) throws Exception { - SimpleDateFormat format = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'"); - String lastModified = format.format(new Date(product.lastModified())); - String checksum = handleChecksum(product, product, null); - FileObject fileObject = new FileObject(product.getName(), - product.getParent(), new FileSize(product.length(), Constants.BYTE), - lastModified, checksum, ""); - return fileObject; - } - - /** - * Method to handle checksum processing. - * - * @param product The source (product label). - * @param fileObject The associated file object. - * @param checksumInLabel Supplied checksum in the label. Can pass in - * an empty value. - * - * @return The resulting checksum. This will either be the generated value, - * the value from the manifest file (if supplied), or the value from the - * supplied value in the product label (if provided). - * - * @throws Exception If there was an error generating the checksum - * (if the flag was on) - */ - private String handleChecksum(File product, File fileObject, - String checksumInLabel) - throws Exception { - String result = ""; - if (generateChecksums) { - String generatedChecksum = MD5Checksum.getMD5Checksum( - fileObject.toString()); - if (!checksumManifest.isEmpty()) { - if (checksumManifest.containsKey(fileObject)) { - String suppliedChecksum = checksumManifest.get(fileObject); - if (!suppliedChecksum.equals(generatedChecksum)) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - "Generated checksum '" + generatedChecksum - + "' does not match supplied checksum '" - + suppliedChecksum + "' in the manifest for file object '" - + fileObject.toString() + "'.", product)); - ++HarvestSolrStats.numGeneratedChecksumsDiffInManifest; - } else { - log.log(new ToolsLogRecord(ToolsLevel.INFO, - "Generated checksum '" + generatedChecksum - + "' matches the supplied checksum '" + suppliedChecksum - + "' in the manifest for file object '" + fileObject.toString() - + "'.", product)); - ++HarvestSolrStats.numGeneratedChecksumsSameInManifest; - } - } else { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - "No checksum found in the manifest for file object '" - + fileObject.toString() + "'.", product)); - ++HarvestSolrStats.numGeneratedChecksumsNotCheckedInManifest; - } - } - result = generatedChecksum; - } - return result; - } - - /** - * Set the flag for checksum generation. - * - * @param value 'true' to turn on, 'false' to turn off. - */ - public void setGenerateChecksums(boolean value) { - this.generateChecksums = value; - } - - /** - * Set the map to represent the checksum manifest file. - * - * @param manifest A mapping of file objects to checksums. - */ - public void setChecksumManifest(Map manifest) { - this.checksumManifest = manifest; - } - - @Override - public Metadata extractMetadata(String product) - throws MetExtractionException { - return extractMetadata(new File(product)); - } - - @Override - public Metadata extractMetadata(URL product) throws MetExtractionException { - return extractMetadata(product.toExternalForm()); - } - - @Override - public Metadata extractMetadata(File product, File configFile) - throws MetExtractionException { - // No need to implement at this point - return null; - } - - @Override - public Metadata extractMetadata(File product, String configFile) - throws MetExtractionException { - // No need to implement at this point - return null; - } - - @Override - public Metadata extractMetadata(File product, MetExtractorConfig config) - throws MetExtractionException { - setConfigFile(config); - return extractMetadata(product); - } - - @Override - public Metadata extractMetadata(URL product, MetExtractorConfig config) - throws MetExtractionException { - setConfigFile(config); - return extractMetadata(product); - } - - @Override - public void setConfigFile(File configFile) throws MetExtractionException { - // No need to implement at this point - - } - - @Override - public void setConfigFile(String configFile) throws MetExtractionException { - // No need to implement at this point - - } - - @Override - public void setConfigFile(MetExtractorConfig config) { - this.config = (Pds3MetExtractorConfig) config; - } - -} diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3MetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3MetExtractor.java deleted file mode 100644 index 11499efd..00000000 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3MetExtractor.java +++ /dev/null @@ -1,363 +0,0 @@ -package gov.nasa.pds.harvest.search.crawler.metadata.extractor; - -import gov.nasa.jpl.oodt.cas.metadata.MetExtractor; -import gov.nasa.jpl.oodt.cas.metadata.MetExtractorConfig; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; -import gov.nasa.pds.harvest.search.constants.Constants; -import gov.nasa.pds.harvest.search.logging.ToolsLevel; -import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; -import gov.nasa.pds.harvest.search.policy.ElementName; -import gov.nasa.pds.harvest.search.policy.LidContents; -import gov.nasa.pds.harvest.search.policy.TitleContents; -import gov.nasa.pds.harvest.search.util.StatementFinder; -import gov.nasa.pds.registry.model.Slot; -import gov.nasa.pds.tools.LabelParserException; -import gov.nasa.pds.tools.label.AttributeStatement; -import gov.nasa.pds.tools.label.Label; -import gov.nasa.pds.tools.label.ManualPathResolver; -import gov.nasa.pds.tools.label.Sequence; -import gov.nasa.pds.tools.label.Set; -import gov.nasa.pds.tools.label.Value; -import gov.nasa.pds.tools.label.parser.DefaultLabelParser; -import gov.nasa.pds.tools.util.MessageUtils; - -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.logging.Logger; - -import org.apache.commons.io.FilenameUtils; - -/** - * A class to extract metadata from a PDS3 data product label. - * - * @author mcayanan - * - */ -public class Pds3MetExtractor implements MetExtractor { - /** Logger object. */ - private static Logger log = Logger.getLogger( - Pds3MetExtractor.class.getName()); - - /** Holds the metadata extractor configuration. */ - private Pds3MetExtractorConfig config; - - /** Label parser. */ - private DefaultLabelParser parser; - - /** - * Constructor. - * - * @param config A configuration object for the metadata extractor. - */ - public Pds3MetExtractor(Pds3MetExtractorConfig config) { - this.config = config; - ManualPathResolver resolver = new ManualPathResolver(); - parser = new DefaultLabelParser(false, true, resolver); - } - - /** - * Extract the metadata from the given file. - * - * @param product The PDS3 label file. - * - * @return A metadata object containing the extracted metadata. - */ - public Metadata extractMetadata(File product) - throws MetExtractionException { - Metadata metadata = new Metadata(); - Label label = null; - try { - label = parser.parseLabel(product.toURI().toURL()); - } catch (LabelParserException lp) { - throw new MetExtractionException(MessageUtils.getProblemMessage(lp)); - } catch (Exception e) { - throw new MetExtractionException(e.getMessage()); - } - metadata.addMetadata(Constants.OBJECT_TYPE, "Product_Proxy_PDS3"); - - String lid = createLid(product, label, config.getLidContents()); - metadata.addMetadata(Constants.LOGICAL_ID, lid); - //Get the value of PRODUCT_VERSION or default to 1.0 - try { - String productVersion = - label.getAttribute("PRODUCT_VERSION").getValue().toString(); - metadata.addMetadata(Constants.PRODUCT_VERSION, productVersion); - } catch (NullPointerException n) { - metadata.addMetadata(Constants.PRODUCT_VERSION, "1.0"); - } - //Create a title - String title = createTitle(product, label, config.getTitleContents()); - - //This is a default title. - if (title.trim().isEmpty()) { - title = "PDS3 Data Product"; - } - String trimmedTitle = title.replaceAll("\\s+", " ").trim(); - metadata.addMetadata(Constants.TITLE, trimmedTitle); - - // Capture the include paths for file object processing. - metadata.addMetadata(Constants.INCLUDE_PATHS, config.getIncludePaths()); - - List slots = new ArrayList(); - // Register any static metadata that is specified in the policy config - if (!config.getStaticMetadata().isEmpty()) { - for (gov.nasa.pds.harvest.search.policy.Slot slot : config.getStaticMetadata()) { - slots.add(new Slot(slot.getName(), slot.getValue())); - } - } - - // Register additional metadata (if specified) - if (!config.getAncillaryMetadata().isEmpty()) { - for (ElementName element : config.getAncillaryMetadata()) { - List attributes = StatementFinder - .getStatementsRecursively(label, element.getValue().trim()); - List extractedValues = new ArrayList(); - for (AttributeStatement attribute : attributes) { - Value value = attribute.getValue(); - if (value instanceof Sequence || value instanceof Set) { - List multValues = new ArrayList(); - Collection collection = (Collection) value; - for (Object o : collection) { - multValues.add(o.toString()); - } - extractedValues.addAll(multValues); - } else { - extractedValues.add(value.toString()); - } - } - Slot slot = null; - if (element.getSlotName() != null) { - slot = new Slot(element.getSlotName(), extractedValues); - } else { - slot = new Slot(element.getValue().toLowerCase(), extractedValues); - } - if (element.getSlotType() != null) { - slot.setSlotType(element.getSlotType()); - } - slots.add(slot); - } - } - if (!slots.isEmpty()) { - metadata.addMetadata(Constants.SLOT_METADATA, slots); - } - return metadata; - } - - /** - * Creates the logical identifier for the PDS3 product. - * - * @param product The PDS3 file being registered. - * @param label The object representation of the PDS3 label. - * @param lidContents The user-specified lid contents. - * @return A logical identifier. - * - * @throws MetExtractionException - */ - private String createLid(File product, Label label, - LidContents lidContents) throws MetExtractionException { - log.log(new ToolsLogRecord(ToolsLevel.INFO, - "Creating logical identifier.", product)); - String lid =""; - List elementValues = new ArrayList(); - for (ElementName name : lidContents.getElementName()) { - try { - Value value = label.getAttribute(name.getValue().trim()) - .getValue(); - String val = ""; - // Get only the first value if multiple values are specified for - // an element. - if (value instanceof Sequence || value instanceof Set) { - Collection collection = (Collection) value; - val = collection.iterator().next().toString(); - } else { - val = value.toString(); - } - elementValues.add(val); - } catch (NullPointerException n) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - name.getValue() + " not found.", product)); - } - } - lid = lidContents.getPrefix(); - for (String elementValue : elementValues) { - lid += ":" + elementValue; - } - if (lidContents.isAppendDir()) { - String parent = product.getParent(); - String offset = lidContents.getOffset(); - if (offset != null) { - boolean matchedOffset = false; - if (parent.startsWith(offset)) { - parent = parent.replace(offset, "") - .trim(); - matchedOffset = true; - } - if ( (offset != null) && (!matchedOffset) ) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - "Cannot trim path of product '" + product - + "' as it does not start with the supplied offset: " - + offset, product)); - } - } - if (!parent.isEmpty()) { - parent = parent.replaceAll("[/|\\\\]", ":"); - if (parent.startsWith(":")) { - lid += parent.toLowerCase(); - } else { - lid += ":" + parent.toLowerCase(); - } - } - } - if (lidContents.isAppendFilename()) { - lid += ":" + FilenameUtils.getBaseName(product.toString()); - } - lid = lid.toLowerCase(); - log.log(new ToolsLogRecord(ToolsLevel.INFO, - "Created the following logical identifier: " + lid, product)); - //Product ID or Product Version values may have slash characters - //Replace it with a dash character - String conformingLid = lid.replaceAll(Constants.URN_ILLEGAL_CHARACTERS, "-"); - //Replace whitespaces with an underscore - conformingLid = conformingLid.replaceAll("\\s+", "_"); - if (!conformingLid.equals(lid)) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, "logical identifier " - + "contained URN reserved and/or excluded characters. " - + "Converting logical identifier to the following: " - + conformingLid, product)); - } - return conformingLid; - } - - /** - * Creates the title of the PDS3 Proxy Product. - * - * @param product The product. - * @param label The product label. - * @param titleContents The title contents. - * - * @return The resulting value. - */ - private String createTitle(File product, Label label, - TitleContents titleContents) { - List elementValues = new ArrayList(); - for (ElementName name : titleContents.getElementName()) { - try { - Value value = label.getAttribute(name.getValue().trim()) - .getValue(); - String val = ""; - // Get only the first value if multiple values are specified for - // an element. - if (value instanceof Sequence || value instanceof Set) { - Collection collection = (Collection) value; - val = collection.iterator().next().toString(); - } else { - val = value.toString(); - } - elementValues.add(val); - } catch (NullPointerException n) { - log.log(new ToolsLogRecord(ToolsLevel.WARNING, - name.getValue() + " not found.", product)); - } - } - String title = ""; - for (String elementValue : elementValues) { - title += " " + elementValue; - } - if (titleContents.isAppendFilename()) { - title += " " + FilenameUtils.getBaseName(product.toString()); - } - log.log(new ToolsLogRecord(ToolsLevel.INFO, - "Created title: " + title.trim(), product)); - return title.trim(); - } - - /** - * Extract the metadata. - * - * @param product A PDS4 xml file. - * @return a class representation of the extracted metadata. - * - */ - public Metadata extractMetadata(String product) - throws MetExtractionException { - return extractMetadata(new File(product)); - } - - /** - * Extract the metadata. - * - * @param product A PDS4 xml file. - * @return a class representation of the extracted metadata. - * - */ - public Metadata extractMetadata(URL product) - throws MetExtractionException { - return extractMetadata(product.toExternalForm()); - } - - /** - * No need to be implemented. - * - */ - public Metadata extractMetadata(File product, File configFile) - throws MetExtractionException { - // No need to implement at this point - return null; - } - - /** - * No need to be implemented. - * - */ - public Metadata extractMetadata(File product, String configFile) - throws MetExtractionException { - // No need to implement at this point - return null; - } - - /** - * No need to be implemented. - * - */ - public Metadata extractMetadata(File product, MetExtractorConfig config) - throws MetExtractionException { - setConfigFile(config); - return extractMetadata(product); - } - - /** - * No need to be implemented. - * - */ - public Metadata extractMetadata(URL product, MetExtractorConfig config) - throws MetExtractionException { - setConfigFile(config); - return extractMetadata(product); - } - - /** - * No need to be implemented. - * - */ - public void setConfigFile(File configFile) - throws MetExtractionException { - // No need to implement at this point - } - - /** - * No need to be implemented. - * - */ - public void setConfigFile(String configFile) - throws MetExtractionException { - // No need to implement at this point - } - - public void setConfigFile(MetExtractorConfig config) { - this.config = (Pds3MetExtractorConfig) config; - } -} diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3MetExtractorConfig.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3MetExtractorConfig.java deleted file mode 100644 index fc23736f..00000000 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds3MetExtractorConfig.java +++ /dev/null @@ -1,78 +0,0 @@ -package gov.nasa.pds.harvest.search.crawler.metadata.extractor; - -import java.util.List; - -import gov.nasa.jpl.oodt.cas.metadata.MetExtractorConfig; -import gov.nasa.pds.harvest.search.policy.ElementName; -import gov.nasa.pds.harvest.search.policy.LidContents; -import gov.nasa.pds.harvest.search.policy.Pds3ProductMetadata; -import gov.nasa.pds.harvest.search.policy.Slot; -import gov.nasa.pds.harvest.search.policy.TitleContents; - -public class Pds3MetExtractorConfig implements MetExtractorConfig { - private List staticMetadata; - private LidContents lidContents; - private List ancillaryMetadata; - private List includePaths; - private TitleContents titleContents; - - /** - * Default contstructor. - * - * @param metadata A class that contains what metadata - * to extract from a PDS3 product. - * - */ - public Pds3MetExtractorConfig(Pds3ProductMetadata metadata) { - staticMetadata = metadata.getStaticMetadata().getSlot(); - lidContents = metadata.getLidContents(); - titleContents = metadata.getTitleContents(); - ancillaryMetadata = metadata.getAncillaryMetadata().getElementName(); - includePaths = metadata.getIncludePaths().getPath(); - } - - /** - * Gets the static metadata. - * - * @return The list of static metadata. - */ - public List getStaticMetadata() { - return staticMetadata; - } - - /** - * Gets the lid contents. - * - * @return The lid contents. - */ - public LidContents getLidContents() { - return lidContents; - } - - /** - * Gets the title contents. - * - * @return The title contents. - */ - public TitleContents getTitleContents() { - return titleContents; - } - - /** - * Gets the ancillary metadata. - * - * @return Ancillary metadata. - */ - public List getAncillaryMetadata() { - return ancillaryMetadata; - } - - /** - * Gets include paths. - * - * @return include paths. - */ - public List getIncludePaths() { - return includePaths; - } -} diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractor.java index f534fd3d..ec9eb11e 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractor.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractor.java @@ -9,14 +9,14 @@ import java.util.logging.Logger; import javax.xml.xpath.XPathExpressionException; import org.apache.commons.lang.exception.ExceptionUtils; -import gov.nasa.jpl.oodt.cas.metadata.MetExtractor; -import gov.nasa.jpl.oodt.cas.metadata.MetExtractorConfig; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; -import gov.nasa.jpl.oodt.cas.metadata.exceptions.MetExtractionException; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.inventory.ReferenceEntry; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.MetExtractionException; +import gov.nasa.pds.harvest.search.oodt.metadata.MetExtractor; +import gov.nasa.pds.harvest.search.oodt.metadata.MetExtractorConfig; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; import gov.nasa.pds.harvest.search.policy.XPath; import gov.nasa.pds.harvest.search.util.LidVid; import gov.nasa.pds.harvest.search.util.XMLExtractor; @@ -57,8 +57,7 @@ public Pds4MetExtractor(Pds4MetExtractorConfig config) { * @param product A PDS4 xml file * @return a class representation of the extracted metadata * - * @throws MetExtractionException If an error occured while performing - * metadata extraction. + * @throws MetExtractionException If an error occurred while performing metadata extraction. * */ public Metadata extractMetadata(File product) @@ -151,6 +150,7 @@ public Metadata extractMetadata(File product) } if (!refMap.isEmpty()) { for (Map.Entry> entry : refMap.entrySet()) { + log.info("refMap: " + entry.getKey()); slots.add(new Slot(entry.getKey(), entry.getValue())); } } @@ -158,6 +158,9 @@ public Metadata extractMetadata(File product) throw new MetExtractionException(ExceptionUtils.getRootCauseMessage(e)); } if (!slots.isEmpty()) { + for (Slot slot : slots) { + log.info("Slot Name: " + slot.getName()); + } metadata.addMetadata(Constants.SLOT_METADATA, slots); } return metadata; diff --git a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractorConfig.java b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractorConfig.java index 49c13cdf..5f64aed4 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractorConfig.java +++ b/src/main/java/gov/nasa/pds/harvest/search/crawler/metadata/extractor/Pds4MetExtractorConfig.java @@ -2,8 +2,7 @@ import java.util.ArrayList; import java.util.List; - -import gov.nasa.jpl.oodt.cas.metadata.MetExtractorConfig; +import gov.nasa.pds.harvest.search.oodt.metadata.MetExtractorConfig; import gov.nasa.pds.harvest.search.policy.Pds4ProductMetadata; import gov.nasa.pds.harvest.search.policy.ReferenceTypeMap; import gov.nasa.pds.harvest.search.policy.References; diff --git a/src/main/java/gov/nasa/pds/harvest/search/doc/SearchDocGenerator.java b/src/main/java/gov/nasa/pds/harvest/search/doc/SearchDocGenerator.java index a2db9857..385ca811 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/doc/SearchDocGenerator.java +++ b/src/main/java/gov/nasa/pds/harvest/search/doc/SearchDocGenerator.java @@ -1,8 +1,6 @@ package gov.nasa.pds.harvest.search.doc; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; @@ -10,17 +8,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - +import java.util.logging.Logger; import org.apache.commons.io.FileUtils; - -import com.google.gson.Gson; import com.google.gson.JsonElement; -import com.google.gson.JsonIOException; import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; - -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.constants.Constants; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; import gov.nasa.pds.harvest.search.stats.HarvestSolrStats; import gov.nasa.pds.harvest.search.util.DocWriter; import gov.nasa.pds.harvest.search.util.TransactionManager; @@ -46,6 +39,8 @@ public class SearchDocGenerator { private static final int SOLR_DOC_THRESHOLD = 1000; + private static Logger log = Logger.getLogger(SearchDocGenerator.class.getName()); + private File outputDirectory; private DocWriter writer = null; @@ -337,6 +332,7 @@ private List getValidSlotValues(ExtendedExtrinsicObject searchExt, private List traverseRegistryPath(List pathList, List searchExtrinsicList, Metadata metadata) throws Exception { + log.fine("traverseRegistryPath"); ArrayList newPathList = null; if (pathList.size() > 1 && !searchExtrinsicList.isEmpty()) { newPathList = new ArrayList(); @@ -347,7 +343,7 @@ private List traverseRegistryPath(List pathList, List extrinsics = new ArrayList(); if ("file_ref".equalsIgnoreCase(pathList.get(0))) { if (metadata.containsKey("file_ref")) { - extrinsics.addAll(metadata.getAllMetadata("file_ref")); + extrinsics.addAll(metadata.getAllMetadata(Constants.SLOT_METADATA + "/" + "file_ref")); } } else if ("collection_ref".equalsIgnoreCase(pathList.get(0))) { List refs = searchExtrinsic.getSlotValues("collection_ref"); diff --git a/src/main/java/gov/nasa/pds/harvest/search/ingest/SearchIngester.java b/src/main/java/gov/nasa/pds/harvest/search/ingest/SearchIngester.java index 507a8f8a..86be09c3 100755 --- a/src/main/java/gov/nasa/pds/harvest/search/ingest/SearchIngester.java +++ b/src/main/java/gov/nasa/pds/harvest/search/ingest/SearchIngester.java @@ -4,14 +4,14 @@ import java.net.URL; import java.util.List; import java.util.logging.Logger; -import gov.nasa.jpl.oodt.cas.filemgr.ingest.Ingester; -import gov.nasa.jpl.oodt.cas.filemgr.structs.exceptions.CatalogException; -import gov.nasa.jpl.oodt.cas.filemgr.structs.exceptions.IngestException; -import gov.nasa.jpl.oodt.cas.metadata.MetExtractor; -import gov.nasa.jpl.oodt.cas.metadata.Metadata; import gov.nasa.pds.harvest.search.constants.Constants; import gov.nasa.pds.harvest.search.logging.ToolsLevel; import gov.nasa.pds.harvest.search.logging.ToolsLogRecord; +import gov.nasa.pds.harvest.search.oodt.filemgr.Ingester; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CatalogException; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.IngestException; +import gov.nasa.pds.harvest.search.oodt.metadata.MetExtractor; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; import gov.nasa.pds.harvest.search.registry.MetadataExtractor; import gov.nasa.pds.harvest.search.registry.RegistryDAO; import gov.nasa.pds.harvest.search.registry.RegistryMetadata; @@ -25,7 +25,7 @@ * @author mcayanan * */ -public class SearchIngester implements Ingester +public class SearchIngester implements Ingester { private static Logger log = Logger.getLogger(SearchIngester.class.getName()); @@ -108,6 +108,10 @@ public String ingest(URL searchUrl, File prodFile, Metadata met) throws IngestEx String lid = met.getMetadata(Constants.LOGICAL_ID); String vid = met.getMetadata(Constants.PRODUCT_VERSION); String lidvid = lid + "::" + vid; + + for (String key : met.getAllKeys()) { + log.info("ingest key: " + key); + } try { @@ -152,8 +156,8 @@ public String ingest(URL fmUrl, File prodFile, MetExtractor extractor, File metC * Method not implemented at this time. * */ - public void ingest(URL fmUrl, List prodFiles, MetExtractor extractor, File metConfFile) - throws IngestException { + public void ingest(URL fmUrl, List prodFiles, MetExtractor extractor, + File metConfFile) { // No need for this method at this time } } diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/Crawler.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/Crawler.java new file mode 100755 index 00000000..89fdcb16 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/Crawler.java @@ -0,0 +1,80 @@ +//// Copyright 2006-2017, by the California Institute of Technology. +//// ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged. +//// Any commercial use must be negotiated with the Office of Technology Transfer +//// at the California Institute of Technology. +//// +//// This software is subject to U. S. export control laws and regulations +//// (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software +//// is subject to U.S. export control laws and regulations, the recipient has +//// the responsibility to obtain export licenses or other export authority as +//// may be required before exporting such information to foreign countries or +//// providing access to foreign nationals. +//// +//// $Id$ +// package gov.nasa.pds.harvest.search.crawler; +// +// import java.io.FileFilter; +// import java.io.IOException; +// import java.net.URL; +// import java.util.ArrayList; +// import java.util.List; +// import org.apache.commons.io.filefilter.FileFilterUtils; +// import org.apache.commons.io.filefilter.IOFileFilter; +// +// public abstract class Crawler { +// /** A file filter. */ +// protected IOFileFilter fileFilter; +// +// /** A directory filter. */ +// protected FileFilter directoryFilter; +// +// protected ArrayList ignoreList = new ArrayList<>(); // List of items to be removed from +// // result of +// // crawl() function. +// +// public Crawler() { +// fileFilter = new WildcardOSFilter("*"); +// directoryFilter = FileFilterUtils.directoryFileFilter(); +// } +// +// public void addAllIgnoreItems(ArrayList ignoreList) { +// // Function allow all item named to be removed from the crawl() function. +// this.ignoreList = ignoreList; +// } +// +// public Crawler(IOFileFilter fileFilter) { +// this.fileFilter = fileFilter; +// directoryFilter = FileFilterUtils.directoryFileFilter(); +// } +// +// public void setFileFilter(List fileFilters) { +// this.fileFilter = new WildcardOSFilter(fileFilters); +// } +// +// public void setFileFilter(IOFileFilter fileFilter) { +// this.fileFilter = fileFilter; +// } +// +// public List crawl(URL url) throws IOException { +// return crawl(url, true, this.fileFilter); +// } +// +// public List crawl(URL url, IOFileFilter fileFilter) throws IOException { +// return crawl(url, true, fileFilter); +// } +// +// public List crawl(URL url, boolean getDirectories) throws IOException { +// return crawl(url, getDirectories, this.fileFilter); +// } +// +// public List crawl(URL url, String[] extensions, boolean getDirectories) +// throws IOException { +// return crawl(url, extensions, getDirectories); +// } +// +// public abstract List crawl(URL url, boolean getDirectories, IOFileFilter fileFilter) +// throws IOException; +// +// } + + diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/CrawlerAction.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/CrawlerAction.java new file mode 100644 index 00000000..c8fbc1e7 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/CrawlerAction.java @@ -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 gov.nasa.pds.harvest.search.oodt.crawler; + +// JDK imports +import java.io.File; +import java.util.List; +import java.util.logging.Logger; +// OODT imports +import org.apache.commons.lang.Validate; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CrawlerActionException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; + +/** + * An action taken by the crawler during success or fail of one of its lifecycle states: preIngest, + * postIngestSuccess, or postIngestFail . + * + * @author bfoster (Brian Foster) + * @author mattmann (Chris Mattmann) + */ +public abstract class CrawlerAction { + + public List phases; + + public static Logger LOG = Logger.getLogger(CrawlerAction.class.getName()); + + private String description; + + private String id; + + public CrawlerAction() {} + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setPhases(List phases) { + this.phases = phases; + } + + public List getPhases() { + return this.phases; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof CrawlerAction) { + return ((CrawlerAction) obj).id.equals(id); + } else { + return false; + } + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + public void validate() throws CrawlerActionException { + try { + Validate.notNull(id, "Must specify id"); + Validate.notNull(phases, "Must specify phases"); + } catch (Exception e) { + throw new CrawlerActionException(e); + } + } + + public abstract boolean performAction(File product, Metadata productMetadata) + throws CrawlerActionException; + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/CrawlerActionRepo.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/CrawlerActionRepo.java new file mode 100644 index 00000000..f938eef6 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/CrawlerActionRepo.java @@ -0,0 +1,107 @@ +/* + * 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.crawler; + +// JDK imports +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import org.springframework.context.ApplicationContext; +import com.google.common.collect.Sets; +import gov.nasa.pds.harvest.search.oodt.filemgr.CrawlerActionPhases; + +/** + * A repository and reader for {@link CrawlerAction}s associated with Crawler lifecycle phases: + * preIngest, postIngestSuccess and postIngestFail. + * + * @author bfoster (Brian Foster) + * @author mattmann (Chris Mattmann) + */ +public class CrawlerActionRepo { + + private LinkedList preIngestActions; + private LinkedList postIngestOnFailActions; + private LinkedList postIngestOnSuccessActions; + + public CrawlerActionRepo() { + this.preIngestActions = new LinkedList(); + this.postIngestOnFailActions = new LinkedList(); + this.postIngestOnSuccessActions = new LinkedList(); + } + + public Set getActions() { + Set actions = Sets.newHashSet(); + actions.addAll(preIngestActions); + actions.addAll(postIngestOnFailActions); + actions.addAll(postIngestOnSuccessActions); + return actions; + } + + public List getPreIngestActions() { + return this.preIngestActions; + } + + public List getPostIngestOnFailActions() { + return this.postIngestOnFailActions; + } + + public List getPostIngestOnSuccessActions() { + return this.postIngestOnSuccessActions; + } + + public void loadActions(List crawlerActions) { + for (CrawlerAction action : crawlerActions) { + for (String phase : action.phases) { + switch (CrawlerActionPhases.getPhaseByName(phase)) { + case PRE_INGEST: + preIngestActions.add(action); + break; + case POST_INGEST_SUCCESS: + postIngestOnSuccessActions.add(action); + break; + case POST_INGEST_FAILURE: + postIngestOnFailActions.add(action); + break; + default: + throw new RuntimeException("Phase '" + phase + "' is not supported"); + } + } + } + } + + public void loadActionsFromBeanFactory(ApplicationContext context, List actionIds) { + for (String actionId : actionIds) { + CrawlerAction action = ((CrawlerAction) context.getBean(actionId, CrawlerAction.class)); + List phases = action.getPhases(); + for (String phase : phases) { + switch (CrawlerActionPhases.getPhaseByName(phase)) { + case PRE_INGEST: + preIngestActions.add(action); + break; + case POST_INGEST_SUCCESS: + postIngestOnSuccessActions.add(action); + break; + case POST_INGEST_FAILURE: + postIngestOnFailActions.add(action); + break; + default: + throw new RuntimeException("Phase '" + phase + "' is not supported"); + } + } + } + } +} + diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/IngestStatus.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/IngestStatus.java new file mode 100644 index 00000000..eb1c3fd5 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/IngestStatus.java @@ -0,0 +1,42 @@ +/* + * 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.crawler; + +// JDK imports +import java.io.File; + +/** + * @author bfoster + * @version $Revision$ + * + *

+ * A Product's Ingest Status + *

+ * . + */ +public interface IngestStatus { + + enum Result { + SUCCESS, FAILURE, SKIPPED, PRECONDS_FAILED + } + + File getProduct(); + + Result getResult(); + + String getMessage(); + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/ProductCrawler.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/ProductCrawler.java new file mode 100644 index 00000000..17344d66 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/ProductCrawler.java @@ -0,0 +1,335 @@ +/* + * 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.crawler; + +import java.io.File; +import java.io.FileFilter; +import java.net.URL; +import java.util.Collections; +import java.util.List; +import java.util.Stack; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; +import com.google.common.annotations.VisibleForTesting; +import gov.nasa.pds.harvest.search.oodt.filemgr.Ingester; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; + + +/** + * An abstract base class for Product Crawling. This class provides methods to communicate with the + * file manager and parse met files that show how to ingest a particular Product into the File + * Manager. + * + * @author mattmann (Chris Mattmann) + * @author bfoster (Brian Foster) + */ +public abstract class ProductCrawler extends ProductCrawlerBean { + + /* our log stream */ + protected static Logger LOG = Logger.getLogger(ProductCrawler.class.getName()); + + // filter to only find directories when doing a listFiles + protected static FileFilter DIR_FILTER = new FileFilter() { + public boolean accept(File file) { + return file.isDirectory(); + } + }; + + // filter to only find product files, not met files + protected static FileFilter FILE_FILTER = new FileFilter() { + public boolean accept(File file) { + return file.isFile(); + } + }; + + protected List ingestStatus = new Vector(); + protected CrawlerActionRepo actionRepo; + protected Ingester ingester; + + public void crawl() { + crawl(new File(getProductPath())); + } + + public void crawl(File dirRoot) { + // Reset ingest status. + ingestStatus.clear(); + + // Load actions. + loadAndValidateActions(); + + // Create Ingester. + // setupIngester(); + + // Verify valid crawl directory. + if (dirRoot == null || !dirRoot.exists()) { + throw new IllegalArgumentException("dir root is null or non existant!"); + } + + // Start crawling. + Stack stack = new Stack(); + stack.push(dirRoot.isDirectory() ? dirRoot : dirRoot.getParentFile()); + while (!stack.isEmpty()) { + File dir = (File) stack.pop(); + LOG.log(Level.INFO, "Crawling " + dir); + + File[] productFiles; + productFiles = isCrawlForDirs() ? dir.listFiles(DIR_FILTER) : dir.listFiles(FILE_FILTER); + + if (productFiles != null) { + for (File productFile : productFiles) { + ingestStatus.add(handleFile(productFile)); + } + } + + if (!isNoRecur()) { + File[] subdirs = dir.listFiles(DIR_FILTER); + if (subdirs != null) { + for (File subdir : subdirs) { + stack.push(subdir); + } + } + } + } + } + + public IngestStatus handleFile(File product) { + LOG.log(Level.INFO, "Handling file " + product); + + // Check preconditions. + if (!passesPreconditions(product)) { + LOG.log(Level.WARNING, "Failed to pass preconditions for ingest of product: [" + + product.getAbsolutePath() + "]"); + return createIngestStatus(product, IngestStatus.Result.PRECONDS_FAILED, + "Failed to pass preconditions"); + } + + // Generate Metadata for product. + Metadata productMetadata = new Metadata(); + productMetadata.addMetadata(getGlobalMetadata()); + try { + productMetadata.replaceMetadata(getMetadataForProduct(product)); + } catch (Exception e) { + LOG.log(Level.SEVERE, "Failed to get metadata for product : " + e.getMessage(), e); + performPostIngestOnFailActions(product, productMetadata); + return createIngestStatus(product, IngestStatus.Result.FAILURE, + "Failed to get metadata for product : " + e.getMessage()); + } + + // Set known metadata if not already specified. + // addKnownMetadata(product, productMetadata); + + // Check that metadata contains required metadata. + // if (!containsRequiredMetadata(productMetadata)) { + // LOG.log(Level.SEVERE, "Missing required metadata for product '" + product + "'"); + // performPostIngestOnFailActions(product, productMetadata); + // return createIngestStatus(product, IngestStatus.Result.FAILURE, "Missing required metadata"); + // } + + // Run preIngest actions. + if (!performPreIngestActions(product, productMetadata)) { + performPostIngestOnFailActions(product, productMetadata); + return createIngestStatus(product, IngestStatus.Result.FAILURE, + "PreIngest actions failed to complete"); + } + + // Check if ingest has been turned off. + if (isSkipIngest()) { + LOG.log(Level.INFO, "Skipping ingest of product: [" + product.getAbsolutePath() + "]"); + return createIngestStatus(product, IngestStatus.Result.SKIPPED, "Crawler ingest turned OFF"); + } + + // Ingest product. + boolean ingestSuccess = ingest(product, productMetadata); + + // On Successful Ingest. + if (ingestSuccess) { + LOG.log(Level.INFO, "Successful ingest of product: [" + product.getAbsolutePath() + "]"); + performPostIngestOnSuccessActions(product, productMetadata); + return createIngestStatus(product, IngestStatus.Result.SUCCESS, "Ingest was successful"); + + // On Failed Ingest. + } else { + LOG.log(Level.WARNING, "Failed to ingest product: [" + product.getAbsolutePath() + + "]: performing postIngestFail actions"); + performPostIngestOnFailActions(product, productMetadata); + return createIngestStatus(product, IngestStatus.Result.FAILURE, "Failed to ingest product"); + } + } + + public List getIngestStatus() { + return Collections.unmodifiableList(ingestStatus); + } + + protected abstract boolean passesPreconditions(File product); + + protected abstract Metadata getMetadataForProduct(File product) throws Exception; + + // @VisibleForTesting + // void setupIngester() { + // ingester = new StdIngester(getClientTransferer()); + // } + + @VisibleForTesting + void loadAndValidateActions() { + if (actionRepo == null && getApplicationContext() != null) { + actionRepo = new CrawlerActionRepo(); + actionRepo.loadActionsFromBeanFactory(getApplicationContext(), getActionIds()); + validateActions(); + } + } + + @VisibleForTesting + void validateActions() { + StringBuilder actionErrors = new StringBuilder(""); + for (CrawlerAction action : actionRepo.getActions()) { + try { + action.validate(); + } catch (Exception e) { + actionErrors.append(" ").append(action.getId()).append(": ").append(e.getMessage()) + .append("\n"); + } + } + if (actionErrors.length() > 0) { + throw new RuntimeException("Actions failed validation:\n" + actionErrors); + } + } + + @VisibleForTesting + synchronized boolean containsRequiredMetadata(Metadata productMetadata) { + for (String reqMetKey : getRequiredMetadata()) { + if (!productMetadata.containsKey(reqMetKey)) { + LOG.log(Level.WARNING, "Missing required metadata field " + reqMetKey); + return false; + } + } + return true; + } + + // @VisibleForTesting + // void addKnownMetadata(File product, Metadata productMetadata) { + // // Add ProductName if not specified. + // if (!productMetadata.containsKey(PRODUCT_NAME)) { + // productMetadata.addMetadata(PRODUCT_NAME, product.getName()); + // } + // // Add Filename if not specified. + // if (!productMetadata.containsKey(FILENAME)) { + // productMetadata.addMetadata(FILENAME, product.getName()); + // } + // // Add FileLocation if not specified. + // if (!productMetadata.containsKey(FILE_LOCATION)) { + // productMetadata.addMetadata(FILE_LOCATION, + // product.getAbsoluteFile().getParentFile().getAbsolutePath()); + // } + // // Add FileSize if not specified + // if (!productMetadata.containsKey(FILE_SIZE)) { + // productMetadata.addMetadata(FILE_SIZE, Long.toString(product.length())); + // } + // } + + @VisibleForTesting + IngestStatus createIngestStatus(final File product, final IngestStatus.Result result, + final String message) { + return new IngestStatus() { + public File getProduct() { + return product; + } + + public Result getResult() { + return result; + } + + public String getMessage() { + return message; + } + }; + } + + @VisibleForTesting + boolean ingest(File product, Metadata productMetdata) { + try { +// LOG.log(Level.INFO, "ProductCrawler: Ready to ingest product: [" + product +// + "]: ProductType: [" + productMetdata.getMetadata(PRODUCT_TYPE) + "]"); + String productId = ingester.ingest(new URL(getFilemgrUrl()), product, productMetdata); + LOG.log(Level.INFO, + "Successfully ingested product: [" + product + "]: product id: " + productId); + } catch (Exception e) { + LOG.log(Level.WARNING, "ProductCrawler: Exception ingesting product: [" + product + + "]: Message: " + e.getMessage() + ": attempting to continue crawling", e); + return false; + } + return true; + } + + @VisibleForTesting + boolean performPreIngestActions(File product, Metadata productMetadata) { + if (actionRepo != null) { + return performProductCrawlerActions(actionRepo.getPreIngestActions(), product, + productMetadata); + } else { + return true; + } + } + + @VisibleForTesting + boolean performPostIngestOnSuccessActions(File product, Metadata productMetadata) { + if (actionRepo != null) { + return performProductCrawlerActions(actionRepo.getPostIngestOnSuccessActions(), product, + productMetadata); + } else { + return true; + } + } + + @VisibleForTesting + boolean performPostIngestOnFailActions(File product, Metadata productMetadata) { + if (actionRepo != null) { + return performProductCrawlerActions(actionRepo.getPostIngestOnFailActions(), product, + productMetadata); + } else { + return true; + } + } + + @VisibleForTesting + boolean performProductCrawlerActions(List actions, File product, + Metadata productMetadata) { + boolean allSucceeded = true; + for (CrawlerAction action : actions) { + try { + LOG.fine("Performing action (id = " + action.getId() + " : description = " + + action.getDescription() + ")"); + if (!action.performAction(product, productMetadata)) { + throw new Exception("Action (id = " + action.getId() + " : description = " + + action.getDescription() + ") returned false"); + } + } catch (Exception e) { + allSucceeded = false; + LOG.log(Level.WARNING, "Failed to perform crawler action : " + e.getMessage(), e); + } + } + return allSucceeded; + } + + public void setActionRepo(CrawlerActionRepo repo) { + this.actionRepo = repo; + } + + public void setIngester(Ingester ingester) { + this.ingester = ingester; + } +} + diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/ProductCrawlerBean.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/ProductCrawlerBean.java new file mode 100644 index 00000000..1e75f5aa --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/crawler/ProductCrawlerBean.java @@ -0,0 +1,172 @@ +package gov.nasa.pds.harvest.search.oodt.crawler; +/* + * 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.net.MalformedURLException; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +// Spring imports +import org.springframework.context.ApplicationContext; +import gov.nasa.pds.harvest.search.crawler.metadata.PDSCoreMetKeys; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; + +/** + * Turns a {@link ProductCrawler} into a Spring-configurable entity. + * + * @author bfoster (Brian Foster) + */ +public abstract class ProductCrawlerBean implements PDSCoreMetKeys { + + private HashSet requiredMetadata; + + private List actionIds; + + private String filemgrUrl; + + private String clientTransferer; + + private boolean noRecur, crawlForDirs, skipIngest; + + private int daemonWait, daemonPort; + + private String productPath; + + private ApplicationContext applicationContext; + + private String id; + + private Metadata globalMetadata; + + public ProductCrawlerBean() { + this.actionIds = new LinkedList(); + this.requiredMetadata = new HashSet(); + this.requiredMetadata.add(LOGICAL_ID); + this.requiredMetadata.add(PRODUCT_VERSION); + this.requiredMetadata.add(TITLE); + this.noRecur = false; + this.crawlForDirs = false; + this.skipIngest = false; + this.daemonPort = -1; + this.daemonWait = -1; + this.globalMetadata = new Metadata(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void setApplicationContext(ApplicationContext applicationContext) { + this.applicationContext = applicationContext; + } + + public ApplicationContext getApplicationContext() { + return this.applicationContext; + } + + public void setActionIds(List actionIds) { + this.actionIds = actionIds; + } + + public List getActionIds() { + return this.actionIds; + } + + public void setRequiredMetadata(List requiredMetadata) { + this.requiredMetadata.addAll(requiredMetadata); + } + + public void setFilemgrUrl(String filemgrUrl) throws MalformedURLException { + this.filemgrUrl = filemgrUrl; + } + + public String getFilemgrUrl() { + return this.filemgrUrl; + } + + public List getRequiredMetadata() { + return new LinkedList(this.requiredMetadata); + } + + public void setClientTransferer(String clientTransferer) { + this.clientTransferer = clientTransferer; + } + + public String getClientTransferer() { + return this.clientTransferer; + } + + public void setNoRecur(boolean noRecur) { + this.noRecur = noRecur; + } + + public boolean isNoRecur() { + return this.noRecur; + } + + public void setCrawlForDirs(boolean crawlForDirs) { + this.crawlForDirs = crawlForDirs; + } + + public boolean isCrawlForDirs() { + return this.crawlForDirs; + } + + public void setSkipIngest(boolean skipIngest) { + this.skipIngest = skipIngest; + } + + public boolean isSkipIngest() { + return this.skipIngest; + } + + public void setDaemonWait(int daemonWait) { + this.daemonWait = daemonWait; + } + + public int getDaemonWait() { + return this.daemonWait; + } + + public void setDaemonPort(int daemonPort) { + this.daemonPort = daemonPort; + } + + public int getDaemonPort() { + return this.daemonPort; + } + + public void setProductPath(String productPath) { + this.productPath = productPath; + } + + public String getProductPath() { + return this.productPath; + } + + public Metadata getGlobalMetadata() { + return globalMetadata; + } + + public void setGlobalMetadata(Metadata globalMetadata) { + this.globalMetadata.addMetadata(globalMetadata.getMap()); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Cache.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Cache.java new file mode 100644 index 00000000..2c50cad0 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Cache.java @@ -0,0 +1,123 @@ +/* + * 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.net.URL; +import java.util.List; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CacheException; +import gov.nasa.pds.harvest.search.oodt.structs.ProductType; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * The core interface for a cache of {@link Product}s (identified by a particular + * uniqueElement) from a File Manager. + *

+ * . + */ +public interface Cache { + + String DEFAULT_UNIQUE_MET_KEY = "CAS.ProductName"; + + /** + * Clears the current cache. This should be used before a re- occurs. + * + */ + void clear(); + + /** + * Checks the cache to determine if a {@link Product} with the given 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(List uniqueElementProductTypeNames) throws CacheException; + + /** + * Synchronizes this Cache with the File Manager specified by the {@link #setFileManager(URL)} + * method. + * + * @param uniqueElementName The met key identifier to use for determining {@link Product} + * existance (if different than {@value #DEFAULT_UNIQUE_MET_KEY}). + * @param uniqueElementProductTypeNames The {@link List} of {@link ProductType}s to cache + * {@link Product}s from. + * @throws CacheException If there is any error. + */ + void sync(String uniqueElementName, List uniqueElementProductTypeNames) + throws CacheException; + + /** + * Synchronizes this Cache with the File Manager specified by the {@link #setFileManager(URL)} + * method. This method also assumes that the unique element (identified by + * {@link #setUniqueElementName(String)} and the {@link List} of {@link ProductType}s have also + * been set appropriate (e.g., by using {@link #setUniqueElementProductTypeNames(List)}. + * + * @throws CacheException If any error occurs. + */ + void sync() throws CacheException; + + /** + * Sets the names of the {@link ProductType}s to cache. + * + * @param uniqueElementProductTypeNames A {@link List} of java.util.String names of + * {@link ProductType}s. + */ + void setUniqueElementProductTypeNames(List uniqueElementProductTypeNames); + + /** + * Sets the name of the met element to use as the identifier of a {@link Product} for use in + * determining whether the Product is in the Cache. + * + * @param uniqueElementName The name of the met element used to uniquely identify + * {@link Product}s. + */ + void setUniqueElementName(String uniqueElementName); + + /** + * Gets the {@link URL} of the File Manager that this Cache communicates with. + * + * @return The {@link URL} of the File Manager that this Cache communicates with. + */ + URL getFileManagerUrl(); +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CacheFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CacheFactory.java new file mode 100644 index 00000000..5903d021 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CacheFactory.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.filemgr; + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * A Factory class for creating {@link Cache}s + *

+ * . + */ +public interface CacheFactory { + + /** + * Create a new {@link Cache}. + * + * @return A new {@link Cache}, constructed by the implementing Factory. + * @throws InstantiationException If the the particular {@link Cache} can not be created for some + * reason. + */ + Cache createCache() throws InstantiationException; + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Catalog.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Catalog.java new file mode 100644 index 00000000..562f7077 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Catalog.java @@ -0,0 +1,272 @@ +/* + * 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.CatalogException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; +import gov.nasa.pds.harvest.search.oodt.structs.Product; +import gov.nasa.pds.harvest.search.oodt.structs.ProductPage; +import gov.nasa.pds.harvest.search.oodt.structs.ProductType; +import gov.nasa.pds.harvest.search.oodt.structs.Query; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * 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. + *

+ * + */ +public interface Catalog extends Pagination { + + String X_POINT_ID = Catalog.class.getName(); + + /** + *

+ * Ingests {@link Metadata} into the metadata store, and associates it with the given + * productId. + *

+ * + * @param m The {@link Metadata} to ingest. + * @param product The product to add the metadata for. + * @throws CatalogException If any general error occurs. + */ + void addMetadata(Metadata m, Product product) throws CatalogException; + + /** + *

+ * Removes {@link Metadata} from the metadata store, and disassociates it from the given + * productId. + *

+ * + * @param m The {@link Metadata} to remove. + * @param product The product for which the metadata is to be removed. + * @throws CatalogException If any general error occurs. + */ + void removeMetadata(Metadata m, Product product) throws CatalogException; + + /** + *

+ * Adds a Product to the Catalog. + *

+ * + * @param product The {@link Product} to add. + * @throws CatalogException If any error occurs during the add. + */ + void addProduct(Product product) throws CatalogException; + + /** + *

+ * Modifies an existing Product within the Catalog. + *

+ * + * @param product The new {@link Product} information to modify the existing Product with. + * @throws CatalogException If any error occurs. + */ + void modifyProduct(Product product) throws CatalogException; + + /** + *

+ * Removes a {@link Product} from the Catalog. + *

+ * + * @param product The product to remove. + * @throws CatalogException If any error occurs. + */ + void removeProduct(Product product) throws CatalogException; + + /** + *

+ * Persists the 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; + + /** + *

+ * Adds the specified {@link List} of {@link Reference}s to the {@link Catalog}, and associates + * them with this {@link Product} specified by its productId. + *

+ * + * @param product The product to add references for. The references are read from the Products + * list of References. + * @throws CatalogException If anything goes wrong. + */ + void addProductReferences(Product product) throws CatalogException; + + /** + *

+ * Gets a {@link Product}, with the specified productId. + *

+ * + * @param productId The unique ID of the Product to retrieve. + * @return A {@link Product}, with the given ID. The implementer of this method should ensure that + * the product {@link Reference}s are populated as well. + * @throws CatalogException If any error occurs. + */ + Product getProductById(String productId) throws CatalogException; + + /** + *

+ * Gets a {@link Product} with the specified productName. + *

+ * + * @param productName The name of the Product to retrieve. + * @return A {@link Product} with the given name. The implementer of this method should ensure + * that the product {@link Reference}s are populated as well. + * @throws CatalogException + */ + Product getProductByName(String productName) throws CatalogException; + + /** + *

+ * Gets the {@link Reference}s associated with this Product. + *

+ * + * @param product The {@link Product} to obtain the References for. + * @return A {@link List} of {@link Reference}s, associated with the specified Product. + * @throws CatalogException + */ + List getProductReferences(Product product) throws CatalogException; + + /** + *

+ * Gets all the {@link Product}s in the {@link Catalog}. + *

+ * + * @return A {@link List} of {@link Product}s in the {@link Catalog}. + * @throws CatalogException If any error occurs. + */ + List getProducts() throws CatalogException; + + /** + *

+ * Gets the {@link Product}s associated with the specified ProductType in the {@link Catalog}. + *

+ * + * @param type The {@link ProductType} to obtain the {@link Product}s for. + * @return A {@link List} of {@link Product}s that are associated with the specified productType + * in the {@link Catalog}. + * @throws CatalogException If any error occurs. + */ + List getProductsByProductType(ProductType type) throws CatalogException; + + /** + *

+ * Gets the Metadata for a given Product. + *

+ * + * @param product The {@link Product} to obtain the Metadata for. + * @return The {@link Metadata} for the given productId. + *

+ * @throws CatalogException If any error occurs. + */ + Metadata getMetadata(Product product) throws CatalogException; + + /** + *

+ * 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 given productId. + * @throws CatalogException If any error occurs. + */ + Metadata getReducedMetadata(Product product, List elements) throws CatalogException; + + /** + *

+ * 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 query(Query query, ProductType type) throws CatalogException; + + /** + *

+ * 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. + *

+ * + * @param n The amount of recent products to return. + * @return A {@link List} of {@link Product}s that have been cataloged recently. + * @throws CatalogException If any error occurs. + */ + List getTopNProducts(int n) throws CatalogException; + + /** + *

+ * Gets the top N most recent products that have been cataloged for the given + * {@link ProductType}. + *

+ * + * @param n The amount of recent products to return. + * @param type The ProductType to limit the query to. + * @return A {@link List} of {@link Product}s that have been cataloged recently. + * @throws CatalogException If any error occurs. + */ + List getTopNProducts(int n, ProductType type) throws CatalogException; + + /** + * + * @return The {@link ValidationLayer} that is used by this Catalog. + * @throws CatalogException If any error occurs (e.g., the layer isn't initialized). + */ + ValidationLayer getValidationLayer(); + + /** + * + * @param type The ProductType to count the number of products for. + * @return An integer count of the number of {@link Product}s for the specified + * {@link ProductType}. + * @throws CatalogException If any error occurs. + */ + int getNumProducts(ProductType type) throws CatalogException; + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CatalogFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CatalogFactory.java new file mode 100644 index 00000000..96f9e27f --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/CatalogFactory.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 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. + *

+ * + * @param serviceFactory The Service Factory class name that will be instantiated to provide + * DataTransfer objects. + * @return A newly instantiated {@link DataTransfer} object. + */ + @SuppressWarnings("unchecked") + public static DataTransfer getDataTransferServiceFromFactory(String serviceFactory) { + DataTransferFactory dataTransferFactory; + Class dataTransferFactoryClass; + + try { + dataTransferFactoryClass = (Class) Class.forName(serviceFactory); + dataTransferFactory = dataTransferFactoryClass.newInstance(); + return dataTransferFactory.createDataTransfer(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading data transfer factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading data transfer factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading data transfer factory class " + + serviceFactory + " Message: " + e.getMessage()); + } + + return null; + } + + /** + *

+ * Constructs a new {@link RepositoryManager} from the specified serviceFactory. + *

+ * + * @param serviceFactory The class name of the service factory used to create new + * RepositoryManager objects. + * @return A newly constructed {@link RepositoryManager} object. + */ + @SuppressWarnings("unchecked") + public static RepositoryManager getRepositoryManagerServiceFromFactory(String serviceFactory) { + RepositoryManagerFactory factory; + Class clazz; + + try { + clazz = (Class) Class.forName(serviceFactory); + factory = clazz.newInstance(); + return factory.createRepositoryManager(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading data store factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading data store factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading data store factory class " + + serviceFactory + " Message: " + e.getMessage()); + } + + return null; + } + + /** + *

+ * Constructs a new {@link Catalog} from the specified serviceFactory. + *

+ * + * @param serviceFactory The class name of the service factory used to create new Catalog objects. + * @return A newly constructed {@link Catalog} object. + */ + @SuppressWarnings("unchecked") + public static Catalog getCatalogServiceFromFactory(String serviceFactory) { + CatalogFactory factory; + Class clazz; + + try { + clazz = (Class) Class.forName(serviceFactory); + factory = clazz.newInstance(); + return factory.createCatalog(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading metadata store factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading metadata store factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading metadata store factory class " + + serviceFactory + " Message: " + e.getMessage()); + } + + return null; + } + + /** + *

+ * Creates a {@link ValidationLayer} from the specified serviceFactory. + *

+ * + * @param serviceFactory The classname of the ValidationLayerFactory to use to create the + * ValidationLayer. + * @return A new {@link ValidationLayer}, created from the specified ValidationLayerFactory. + */ + @SuppressWarnings("unchecked") + public static ValidationLayer getValidationLayerFromFactory(String serviceFactory) { + ValidationLayerFactory factory; + Class clazz; + + try { + clazz = (Class) Class.forName(serviceFactory); + factory = clazz.newInstance(); + return factory.createValidationLayer(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading validation layer factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading validation layer factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading validation layer factory class " + + serviceFactory + " Message: " + e.getMessage()); + } + + return null; + } + + @SuppressWarnings("unchecked") + public static Cache getCacheFromFactory(String serviceFactory) { + CacheFactory factory; + Class clazz; + + try { + clazz = (Class) Class.forName(serviceFactory); + factory = clazz.newInstance(); + return factory.createCache(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading cache factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading cache factory class " + + serviceFactory + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading cache factory class " + + serviceFactory + " Message: " + e.getMessage()); + } + + return null; + } + + /** + *

+ * Constructs a new {@link Versioner} from the specified className. + *

+ * + * @param className The class name of the Versioner object to create. + * @return A newly constructed {@link Versioner} object. + */ + public static Versioner getVersionerFromClassName(String className) { + try { + @SuppressWarnings("unchecked") + Class versionerClass = (Class) Class.forName(className); + return versionerClass.newInstance(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading versioner class " + className + + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading versioner class " + className + + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading versioner class " + className + + " Message: " + e.getMessage()); + } + + return null; + } + + public static FilemgrMetExtractor getExtractorFromClassName(String className) { + try { + @SuppressWarnings("unchecked") + Class extractorClass = + (Class) Class.forName(className); + return extractorClass.newInstance(); + } catch (ClassNotFoundException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "ClassNotFoundException when loading extractor class " + className + + " Message: " + e.getMessage()); + } catch (InstantiationException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "InstantiationException when loading extractor class " + className + + " Message: " + e.getMessage()); + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, "IllegalAccessException when loading extractor class " + className + + " Message: " + e.getMessage()); + } + return null; + } + + public static TypeHandler getTypeHandlerFromClassName(String className) { + try { + return (TypeHandler) Class.forName(className).newInstance(); + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, + "Failed to load TypeHandler class '" + className + "' : " + e.getMessage()); + } + return null; + } + + public static FilterAlgor getFilterAlgorFromClassName(String className) { + try { + return (FilterAlgor) Class.forName(className).newInstance(); + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, + "Failed to load TypeHandler class '" + className + "' : " + e.getMessage()); + } + return null; + } + + public static VersionConverter getVersionConverterFromClassName(String className) { + try { + return (VersionConverter) Class.forName(className).newInstance(); + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, + "Failed to load TypeHandler class '" + className + "' : " + e.getMessage()); + } + return null; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Ingester.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Ingester.java new file mode 100644 index 00000000..3b747cf1 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Ingester.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.filemgr; + +// JDK imports +import java.io.File; +import java.net.URL; +import java.util.List; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CatalogException; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.IngestException; +import gov.nasa.pds.harvest.search.oodt.metadata.MetExtractor; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * 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, List prodFiles, MetExtractor extractor, File metConfFile); + + /** + * Checks the file manager at the given {@link URL} to see whether or not it knows about the + * provided {@link Product} {@link File} parameter. To do this, it uses {@link File#getName()} as + * the {@link Metadata} key Filename. + * + * @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 the currentPage. + * @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 outputString = new ArrayList(); + for (String key : metadata.getAllKeys()) { + outputString.add(StringUtils.collectionToCommaDelimitedString(metadata.getAllMetadata(key))); + } + return StringUtils.collectionToCommaDelimitedString(outputString); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + QueryResult other = (QueryResult) obj; + if (metadata == null) { + if (other.metadata != null) { + return false; + } + } else if (!metadata.equals(other.metadata)) { + return false; + } + if (product == null) { + if (other.product != null) { + return false; + } + } else if (!product.equals(other.product)) { + return false; + } + if (toStringFormat == null) { + if (other.toStringFormat != null) { + return false; + } + } else if (!toStringFormat.equals(other.toStringFormat)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = product != null ? product.hashCode() : 0; + result = 31 * result + (metadata != null ? metadata.hashCode() : 0); + result = 31 * result + (toStringFormat != null ? toStringFormat.hashCode() : 0); + return result; + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RemoteDataTransferFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RemoteDataTransferFactory.java new file mode 100644 index 00000000..79687bfb --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RemoteDataTransferFactory.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; +// +//// JDK imports +// import java.util.logging.Level; +// import java.util.logging.Logger; +// +/// ** +// * @author mattmann +// * @version $Revision$ +// * +// *

+// * A Factory for constructing {@link RemoteDataTransferer} objects. +// *

+// * +// */ +// public class RemoteDataTransferFactory implements DataTransferFactory { +// +// /* the chunk size for sending files remotely */ +// private int chunkSize = 0; +// +// /* our log stream */ +// private static final Logger LOG = Logger.getLogger(RemoteDataTransferFactory.class.getName()); +// +// /** +// * +// */ +// public RemoteDataTransferFactory() { +// chunkSize = +// Integer.getInteger("org.apache.oodt.cas.filemgr.datatransfer.remote.chunkSize", 1024); +// +// LOG.log(Level.INFO, "RemoteDataTransfer enabled: using chunk size: [" + chunkSize + "]"); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.oodt.cas.filemgr.datatransfer.DataTransferFactory#createDataTransfer() +// */ +// public DataTransfer createDataTransfer() { +// return new RemoteDataTransferer(chunkSize); +// } +// +// } diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RemoteDataTransferer.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RemoteDataTransferer.java new file mode 100644 index 00000000..7a138d0f --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RemoteDataTransferer.java @@ -0,0 +1,256 @@ +/// * +// * 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.FileInputStream; +// import java.io.FileOutputStream; +// import java.io.IOException; +// import java.net.URI; +// import java.net.URISyntaxException; +// import java.net.URL; +// import java.util.logging.Level; +// import java.util.logging.Logger; +// import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.ConnectionException; +// import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.DataTransferException; +// import gov.nasa.pds.harvest.search.oodt.structs.Product; +// import gov.nasa.pds.harvest.search.oodt.structs.Reference; +// +/// ** +// * @author mattmann +// * @author bfoster +// * @version $Revision$ +// * +// *

+// * An implementation of the {@link DataTransfer} interface that transfers files to a remote +// * file manager over XML-RPC, using the File Manager Client. +// *

+// * +// */ +// public class RemoteDataTransferer implements DataTransfer { +// +// public static final int NUM_BYTES = 1024; +// /* +// * the url pointer to the file manager that we'll remotely transfer the file to +// */ +// private URL fileManagerUrl = null; +// +// /* +// * the size of the chunks that files should be transferred over XML-RPC using +// */ +// private int chunkSize = 1024; +// +// /* our file manager client */ +// private XmlRpcFileManagerClient client = null; +// +// /* our log stream */ +// private static final Logger LOG = Logger.getLogger(RemoteDataTransferer.class.getName()); +// +// /** +// * +// */ +// public RemoteDataTransferer(int chunkSz) { +// this.chunkSize = chunkSz; +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.oodt.cas.filemgr.datatransfer.DataTransfer#setFileManagerUrl (java.net.URL) +// */ +// public void setFileManagerUrl(URL url) { +// try { +// client = new XmlRpcFileManagerClient(url); +// this.fileManagerUrl = url; +// LOG.log(Level.INFO, +// "Remote Data Transfer to: [" + client.getFileManagerUrl().toString() + "] enabled"); +// } catch (ConnectionException e) { +// LOG.log(Level.WARNING, "Connection exception for filemgr: [" + url + "]"); +// } +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.oodt.cas.filemgr.datatransfer.DataTransfer#transferProduct( +// * org.apache.oodt.cas.filemgr.structs.Product) +// */ +// public void transferProduct(Product product) throws DataTransferException, IOException { +// +// if (fileManagerUrl == null) { +// throw new DataTransferException( +// "No file manager url specified for remote data transfer: cannot transfer product: [" +// + product.getProductName() + "]!"); +// } +// +// quietNotifyTransferProduct(product); +// +// // for each file reference, transfer the file to the remote file manager +// for (Reference r : product.getProductReferences()) { +// // test whether or not the reference is a directory or a file +// File refFile; +// try { +// refFile = new File(new URI(r.getOrigReference())); +// } catch (URISyntaxException e) { +// LOG.log(Level.WARNING, "Unable to test if reference: [" + r.getOrigReference() +// + "] is a directory: skipping it"); +// continue; +// } +// +// if (!refFile.isDirectory()) { +// LOG.log(Level.FINE, "Reference: [" + r.getOrigReference() + "] is file: transferring it"); +// +// try { +// remoteTransfer(r, product); +// } catch (URISyntaxException e) { +// LOG.log(Level.WARNING, "Error transferring file: [" + r.getOrigReference() +// + "]: URISyntaxException: " + e.getMessage()); +// } +// } else { +// LOG.log(Level.FINE, "RemoteTransfer: skipping reference: [" + refFile.getAbsolutePath() +// + "] of product: [" + product.getProductName() + "]: ref is a directory"); +// } +// } +// +// quietNotifyProductTransferComplete(product); +// +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.oodt.cas.filemgr.datatransfer.DataTransfer#retrieveProduct(org. +// * apache.oodt.cas.filemgr.structs.Product, java.io.File) +// */ +// public void retrieveProduct(Product product, File directory) +// throws DataTransferException, IOException { +// for (Reference reference : product.getProductReferences()) { +// FileOutputStream fOut = null; +// try { +// File dataStoreFile = new File(new URI(reference.getDataStoreReference())); +// File dest = new File(directory, dataStoreFile.getName()); +// fOut = new FileOutputStream(dest, false); +// LOG.log(Level.INFO, "RemoteDataTransfer: Copying File: " + "fmp:" +// + dataStoreFile.getAbsolutePath() + " to " + "file:" + dest.getAbsolutePath()); +// byte[] fileData; +// int offset = 0; +// while (true) { +// fileData = +// (byte[]) client.retrieveFile(dataStoreFile.getAbsolutePath(), offset, NUM_BYTES); +// if (fileData.length <= 0) { +// break; +// } +// fOut.write(fileData); +// if (fileData.length < NUM_BYTES) { +// break; +// } +// offset += NUM_BYTES; +// } +// } catch (Exception e) { +// throw new DataTransferException("", e); +// } finally { +// try { +// fOut.close(); +// } catch (Exception ignored) { +// } +// } +// } +// } +// +// @Override +// public void deleteProduct(Product product) throws DataTransferException, IOException { +// for (Reference ref : product.getProductReferences()) { +// File dataFile = new File(URI.create(ref.getDataStoreReference()).toURL().getPath()); +// if (!dataFile.delete()) { +// throw new IOException( +// String.format("Failed to delete file %s - delete returned false", dataFile)); +// } +// } +// } +// +// private void remoteTransfer(Reference reference, Product product) throws URISyntaxException { +// // get the file path +// File origFile = new File(new URI(reference.getOrigReference())); +// File destFile = new File(new URI(reference.getDataStoreReference())); +// String origFilePath = origFile.getAbsolutePath(); +// String destFilePath = destFile.getAbsolutePath(); +// +// // read the file in chunk by chunk +// +// byte[] buf = new byte[chunkSize]; +// +// FileInputStream is = null; +// +// try { +// is = new FileInputStream(origFile); +// int offset = 0; +// int numBytes; +// +// // remove the file if it already exists: this operation +// // is an overwrite +// if (!client.removeFile(destFilePath)) { +// LOG.log(Level.WARNING, "RemoteDataTransfer: attempt to perform overwrite of dest file: [" +// + destFilePath + "] failed"); +// } +// +// while ((numBytes = is.read(buf, offset, chunkSize)) != -1) { +// client.transferFile(destFilePath, buf, offset, numBytes); +// } +// } catch (IOException e) { +// LOG.log(Level.WARNING, +// "Error opening input stream to read file to transfer: Message: " + e.getMessage()); +// } catch (DataTransferException e) { +// LOG.log(Level.WARNING, "DataTransferException when transfering file: [" + origFilePath +// + "] to [" + destFilePath + "]: Message: " + e.getMessage()); +// } finally { +// if (is != null) { +// try { +// is.close(); +// } catch (Exception ignore) { +// } +// +// } +// } +// } +// +// private void quietNotifyTransferProduct(Product p) { +// try { +// client.transferringProduct(p); +// } catch (DataTransferException e) { +// LOG.log(Level.SEVERE, e.getMessage()); +// LOG.log(Level.WARNING, +// "Error notifying file manager of product transfer initiation for product: [" +// + p.getProductId() + "]: Message: " + e.getMessage()); +// } +// } +// +// private void quietNotifyProductTransferComplete(Product p) { +// try { +// client.removeProductTransferStatus(p); +// } catch (DataTransferException e) { +// LOG.log(Level.SEVERE, e.getMessage()); +// LOG.log(Level.WARNING, +// "Error notifying file manager of product transfer completion for product: [" +// + p.getProductId() + "]: Message: " + e.getMessage()); +// } +// } +// +// } diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RepositoryManager.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RepositoryManager.java new file mode 100644 index 00000000..dc1fea21 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RepositoryManager.java @@ -0,0 +1,106 @@ +/* + * 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.RepositoryManagerException; +import gov.nasa.pds.harvest.search.oodt.structs.ProductType; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + * A Repository Manager is an extension point that is responsible for managing + * {@link ProductType} information which boils down to policy information about + * {@link org.apache.oodt.cas.filemgr.structs.Product}s that are ingested into the File + * Manager. This includes information such as the root repository path for a product type, + * what type of URI generation scheme to apply, etc. + *

+ * + */ +public interface RepositoryManager { + + /* extension point ID */ + String X_POINT_ID = RepositoryManager.class.getName(); + + /** + *

+ * 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. + *

+ * + * @param productType The new {@link ProductType} information. + * @throws RepositoryManagerException If any error occurs. + */ + void modifyProductType(ProductType productType) throws RepositoryManagerException; + + /** + *

+ * 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. + *

+ * + * @param productTypeId The ID of the ProductType to retrieve. + * @return The {@link ProductType} corresponding to the specified productTypeId. + * @throws RepositoryManagerException If any error occurs. + */ + ProductType getProductTypeById(String productTypeId) throws RepositoryManagerException; + + /** + *

+ * Gets a {@link ProductType} specified by its productTypeName, from the + * RepositoryManager. + *

+ * + * @param productTypeName The name of the ProductType to get. + * @return A {@link ProductType}, with the specified name. + * @throws RepositoryManagerException If any error occurs. + */ + ProductType getProductTypeByName(String productTypeName) throws RepositoryManagerException; + + /** + *

+ * 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 getProductTypes() throws RepositoryManagerException; +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RepositoryManagerFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RepositoryManagerFactory.java new file mode 100644 index 00000000..44fa9f9b --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/RepositoryManagerFactory.java @@ -0,0 +1,30 @@ +/* + * 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 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. + *

+ * + * @param element The element to add. + * @throws ValidationLayerException If any error occurs during the add. + */ + void addElement(Element element) throws ValidationLayerException; + + /** + *

+ * 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. + *

+ * + * @param type The {@link ProductType} to remove the association of the specified + * 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 getElements(ProductType type) throws ValidationLayerException; + + /** + * @return A {@link List} of all the metadata {@link Element}s in the ValidationLayer. + * @throws ValidationLayerException If any error occurs. + */ + List getElements() throws ValidationLayerException; + + /** + * Gets an element by its String identifier. + * + * @param elementId The String identifier of the {@link Element} to get. + * @return An {@link Element} by its String identifier. + * @throws ValidationLayerException If any error occurs. + */ + Element getElementById(String elementId) throws ValidationLayerException; + + /** + * Gets an element by its String name. + * + * @param elementName The String name of the {@link Element} to get. + * @return An {@link Element} by its String name. + * @throws ValidationLayerException If any error occurs. + */ + Element getElementByName(String elementName) throws ValidationLayerException; + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/ValidationLayerFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/ValidationLayerFactory.java new file mode 100644 index 00000000..4c0bed66 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/ValidationLayerFactory.java @@ -0,0 +1,30 @@ +/* + * 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 ValidationLayer}s. + *

+ * + */ +public interface ValidationLayerFactory { + + ValidationLayer createValidationLayer(); +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Versioner.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Versioner.java new file mode 100644 index 00000000..2f914b52 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/Versioner.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.filemgr; + +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.VersioningException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; +import gov.nasa.pds.harvest.search.oodt.structs.Product; + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * This interface defines a versioning scheme for generating the DataStore references for + * the items in a {@link Product}. + *

+ * + */ +public interface Versioner { + + String X_POINT_ID = Versioner.class.getName(); + + void createDataStoreReferences(Product product, Metadata metadata) throws VersioningException; + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/XmlRpcStructFactory.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/XmlRpcStructFactory.java new file mode 100644 index 00000000..ebe2b33e --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/XmlRpcStructFactory.java @@ -0,0 +1,749 @@ +/* + * 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.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; +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.Element; +import gov.nasa.pds.harvest.search.oodt.structs.ExtractorSpec; +import gov.nasa.pds.harvest.search.oodt.structs.FileTransferStatus; +import gov.nasa.pds.harvest.search.oodt.structs.Product; +import gov.nasa.pds.harvest.search.oodt.structs.ProductPage; +import gov.nasa.pds.harvest.search.oodt.structs.ProductType; +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.Reference; +import gov.nasa.pds.harvest.search.oodt.structs.TermQueryCriteria; +import gov.nasa.pds.harvest.search.oodt.structs.query.ComplexQuery; +import gov.nasa.pds.harvest.search.oodt.structs.query.FilterAlgor; +import gov.nasa.pds.harvest.search.oodt.structs.query.QueryFilter; +import gov.nasa.pds.harvest.search.oodt.structs.type.TypeHandler; + + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + *

+ *

+ * 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. + *

+ */ +public final class XmlRpcStructFactory { + + private XmlRpcStructFactory() throws InstantiationException { + throw new InstantiationException("Don't instantiate XmlRpcStructFactories!"); + } + + public static Map getXmlRpcFileTransferStatus(FileTransferStatus status) { + Map statusHash = new Hashtable(); + statusHash.put("bytesTransferred", Long.toString(status.getBytesTransferred())); + statusHash.put("parentProduct", getXmlRpcProduct(status.getParentProduct())); + statusHash.put("fileRef", getXmlRpcReference(status.getFileRef())); + return statusHash; + } + + @SuppressWarnings("unchecked") + public static FileTransferStatus getFileTransferStatusFromXmlRpc(Map statusHash) { + FileTransferStatus status = new FileTransferStatus(); + status.setBytesTransferred(Long.parseLong(statusHash.get("bytesTransferred").toString())); + status.setParentProduct( + getProductFromXmlRpc((Hashtable) statusHash.get("parentProduct"))); + status + .setFileRef(getReferenceFromXmlRpc((Hashtable) statusHash.get("fileRef"))); + return status; + } + + public static Vector> getXmlRpcFileTransferStatuses( + List statuses) { + Vector> statusVector = new Vector>(); + + if (statuses != null && statuses.size() > 0) { + + for (FileTransferStatus status : statuses) { + statusVector.add(getXmlRpcFileTransferStatus(status)); + } + } + + return statusVector; + } + + public static List getFileTransferStatusesFromXmlRpc( + Vector> statusVector) { + List statuses = new Vector(); + + if (statusVector != null && statusVector.size() > 0) { + for (Map statusHash : statusVector) { + FileTransferStatus status = getFileTransferStatusFromXmlRpc(statusHash); + statuses.add(status); + } + } + + return statuses; + } + + public static Map getXmlRpcProductPage(ProductPage page) { + Hashtable productPageHash = new Hashtable(); + productPageHash.put("totalPages", page.getTotalPages()); + productPageHash.put("pageNum", page.getPageNum()); + productPageHash.put("pageSize", page.getPageSize()); + productPageHash.put("pageProducts", getXmlRpcProductList(page.getPageProducts())); + return productPageHash; + } + + @SuppressWarnings("unchecked") + public static ProductPage getProductPageFromXmlRpc(Map productPageHash) { + ProductPage page = new ProductPage(); + page.setPageNum((Integer) productPageHash.get("pageNum")); + page.setPageSize((Integer) productPageHash.get("pageSize")); + page.setTotalPages((Integer) productPageHash.get("totalPages")); + page.setPageProducts(getProductListFromXmlRpc( + (Vector>) productPageHash.get("pageProducts"))); + return page; + } + + public static Map getXmlRpcComplexQuery(ComplexQuery complexQuery) { + Map complexQueryHash = getXmlRpcQuery(complexQuery); + if (complexQuery.getReducedProductTypeNames() != null) { + complexQueryHash.put("reducedProductTypeNames", + new Vector(complexQuery.getReducedProductTypeNames())); + } else { + complexQueryHash.put("reducedProductTypeNames", new Vector()); + } + if (complexQuery.getReducedMetadata() != null) { + complexQueryHash.put("reducedMetadata", + new Vector(complexQuery.getReducedMetadata())); + } else { + complexQueryHash.put("reducedMetadata", new Vector()); + } + if (complexQuery.getSortByMetKey() != null) { + complexQueryHash.put("sortByMetKey", complexQuery.getSortByMetKey()); + } + if (complexQuery.getToStringResultFormat() != null) { + complexQueryHash.put("toStringResultFormat", complexQuery.getToStringResultFormat()); + } + if (complexQuery.getQueryFilter() != null) { + complexQueryHash.put("queryFilter", getXmlRpcQueryFilter(complexQuery.getQueryFilter())); + } + return complexQueryHash; + } + + @SuppressWarnings("unchecked") + public static ComplexQuery getComplexQueryFromXmlRpc(Map complexQueryHash) { + ComplexQuery complexQuery = new ComplexQuery(); + complexQuery.setCriteria(getQueryFromXmlRpc(complexQueryHash).getCriteria()); + if (((Vector) complexQueryHash.get("reducedProductTypeNames")).size() > 0) { + complexQuery.setReducedProductTypeNames( + (Vector) complexQueryHash.get("reducedProductTypeNames")); + } + if (((Vector) complexQueryHash.get("reducedMetadata")).size() > 0) { + complexQuery.setReducedMetadata((Vector) complexQueryHash.get("reducedMetadata")); + } + complexQuery.setSortByMetKey((String) complexQueryHash.get("sortByMetKey")); + complexQuery.setToStringResultFormat((String) complexQueryHash.get("toStringResultFormat")); + if (complexQueryHash.get("queryFilter") != null) { + complexQuery.setQueryFilter( + getQueryFilterFromXmlRpc((Map) complexQueryHash.get("queryFilter"))); + } + return complexQuery; + } + + public static Map getXmlRpcQueryFilter(QueryFilter queryFilter) { + Map queryFilterHash = new ConcurrentHashMap(); + queryFilterHash.put("startDateTimeMetKey", queryFilter.getStartDateTimeMetKey()); + queryFilterHash.put("endDateTimeMetKey", queryFilter.getEndDateTimeMetKey()); + queryFilterHash.put("priorityMetKey", queryFilter.getPriorityMetKey()); + queryFilterHash.put("filterAlgor", getXmlRpcFilterAlgor(queryFilter.getFilterAlgor())); + queryFilterHash.put("versionConverterClass", + queryFilter.getConverter().getClass().getCanonicalName()); + return queryFilterHash; + } + + public static QueryFilter getQueryFilterFromXmlRpc(Map queryFilterHash) { + String startDateTimeMetKey = (String) queryFilterHash.get("startDateTimeMetKey"); + String endDateTimeMetKey = (String) queryFilterHash.get("endDateTimeMetKey"); + String priorityMetKey = (String) queryFilterHash.get("priorityMetKey"); + @SuppressWarnings("unchecked") + FilterAlgor filterAlgor = + getFilterAlgorFromXmlRpc((Map) queryFilterHash.get("filterAlgor")); + QueryFilter queryFilter = + new QueryFilter(startDateTimeMetKey, endDateTimeMetKey, priorityMetKey, filterAlgor); + queryFilter.setConverter(GenericFileManagerObjectFactory + .getVersionConverterFromClassName((String) queryFilterHash.get("versionConverterClass"))); + return queryFilter; + } + + public static Map getXmlRpcFilterAlgor(FilterAlgor filterAlgor) { + Map filterAlgorHash = new ConcurrentHashMap(); + filterAlgorHash.put("class", filterAlgor.getClass().getCanonicalName()); + filterAlgorHash.put("epsilon", Long.toString(filterAlgor.getEpsilon())); + return filterAlgorHash; + } + + public static FilterAlgor getFilterAlgorFromXmlRpc(Map filterAlgorHash) { + FilterAlgor filterAlgor = GenericFileManagerObjectFactory + .getFilterAlgorFromClassName((String) filterAlgorHash.get("class")); + if (filterAlgor != null) { + filterAlgor.setEpsilon(Long.parseLong((String) filterAlgorHash.get("epsilon"))); + } + return filterAlgor; + } + + public static Vector> getXmlRpcQueryResults(List queryResults) { + Vector> queryResultHashVector = new Vector>(); + for (QueryResult queryResult : queryResults) { + queryResultHashVector.add(getXmlRpcQueryResult(queryResult)); + } + return queryResultHashVector; + } + + public static List getQueryResultsFromXmlRpc( + Vector> queryResultHashVector) { + List queryResults = new Vector(); + for (Map queryResultHash : queryResultHashVector) { + queryResults.add(getQueryResultFromXmlRpc(queryResultHash)); + } + return queryResults; + } + + public static Map getXmlRpcQueryResult(QueryResult queryResult) { + Hashtable queryResultHash = new Hashtable(); + if (queryResult.getToStringFormat() != null) { + queryResultHash.put("toStringFormat", queryResult.getToStringFormat()); + } + queryResultHash.put("product", getXmlRpcProduct(queryResult.getProduct())); + queryResultHash.put("metadata", queryResult.getMetadata().getHashTable()); + return queryResultHash; + } + + + @SuppressWarnings("unchecked") + public static QueryResult getQueryResultFromXmlRpc(Map queryResultHash) { + Product product = getProductFromXmlRpc((Map) queryResultHash.get("product")); + Metadata metadata = new Metadata(); + metadata.addMetadata((Map) queryResultHash.get("metadata")); + QueryResult queryResult = new QueryResult(product, metadata); + queryResult.setToStringFormat((String) queryResultHash.get("toStringFormat")); + return queryResult; + } + + public static Map getXmlRpcProduct(Product product) { + Map productHash = new Hashtable(); + if (product.getProductId() != null) { + productHash.put("id", product.getProductId()); + } + if (product.getProductName() != null) { + productHash.put("name", product.getProductName()); + } + if (product.getProductType() != null) { + productHash.put("type", getXmlRpcProductType(product.getProductType())); + } + if (product.getProductStructure() != null) { + productHash.put("structure", product.getProductStructure()); + } + if (product.getTransferStatus() != null) { + productHash.put("transferStatus", product.getTransferStatus()); + } + if (product.getProductReferences() != null) { + productHash.put("references", getXmlRpcReferences(product.getProductReferences())); + } + if (product.getRootRef() != null) { + productHash.put("rootReference", getXmlRpcReference(product.getRootRef())); + } + return productHash; + } + + @SuppressWarnings("unchecked") + public static Product getProductFromXmlRpc(Map productHash) { + Product product = new Product(); + product.setProductId((String) productHash.get("id")); + product.setProductName((String) productHash.get("name")); + if (productHash.get("type") != null) { + product + .setProductType(getProductTypeFromXmlRpc((Map) productHash.get("type"))); + } + product.setProductStructure((String) productHash.get("structure")); + product.setTransferStatus((String) productHash.get("transferStatus")); + if (productHash.get("references") != null) { + product.setProductReferences( + getReferencesFromXmlRpc((Vector>) productHash.get("references"))); + } + if (productHash.get("rootReference") != null) { + product.setRootRef( + getReferenceFromXmlRpc((Map) productHash.get("rootReference"))); + } + return product; + } + + public static List getProductListFromXmlRpc(Vector> productVector) { + List productList = new Vector(); + + for (Map productHash : productVector) { + Product product = getProductFromXmlRpc(productHash); + productList.add(product); + } + + return productList; + } + + + public static Vector> getXmlRpcProductList(List products) { + Vector> productVector = new Vector>(); + + if (products == null) { + return productVector; + } + + for (Product product : products) { + Map productHash = getXmlRpcProduct(product); + productVector.add(productHash); + } + + return productVector; + } + + public static Vector> getXmlRpcProductTypeList( + List productTypes) { + Vector> productTypeVector = new Vector>(); + + if (productTypes == null) { + return productTypeVector; + } + + for (ProductType type : productTypes) { + Map typeHash = getXmlRpcProductType(type); + productTypeVector.add(typeHash); + } + return productTypeVector; + } + + public static List getProductTypeListFromXmlRpc( + Vector> productTypeVector) { + List productTypeList = new Vector(); + for (Map productTypeHash : productTypeVector) { + ProductType type = getProductTypeFromXmlRpc(productTypeHash); + productTypeList.add(type); + } + + return productTypeList; + } + + public static Map getXmlRpcProductType(ProductType type) { + Map productTypeHash = new Hashtable(); + // TODO(bfoster): ProductType ID is currently required by XmlRpcFileManager. + productTypeHash.put("id", type.getProductTypeId()); + if (type.getName() != null) { + productTypeHash.put("name", type.getName()); + } + if (type.getDescription() != null) { + productTypeHash.put("description", type.getDescription()); + } + if (type.getProductRepositoryPath() != null) { + productTypeHash.put("repositoryPath", type.getProductRepositoryPath()); + } + if (type.getVersioner() != null) { + productTypeHash.put("versionerClass", type.getVersioner()); + } + if (type.getTypeMetadata() != null) { + productTypeHash.put("typeMetadata", type.getTypeMetadata().getHashTable()); + } + if (type.getExtractors() != null) { + productTypeHash.put("typeExtractors", getXmlRpcTypeExtractors(type.getExtractors())); + } + if (type.getHandlers() != null) { + productTypeHash.put("typeHandlers", getXmlRpcTypeHandlers(type.getHandlers())); + } + return productTypeHash; + } + + @SuppressWarnings("unchecked") + public static ProductType getProductTypeFromXmlRpc(Map productTypeHash) { + ProductType type = new ProductType(); + type.setDescription((String) productTypeHash.get("description")); + type.setName((String) productTypeHash.get("name")); + type.setProductRepositoryPath((String) productTypeHash.get("repositoryPath")); + type.setProductTypeId((String) productTypeHash.get("id")); + type.setVersioner((String) productTypeHash.get("versionerClass")); + if (productTypeHash.get("typeMetadata") != null) { + Metadata typeMet = new Metadata(); + typeMet.addMetadata((Map) productTypeHash.get("typeMetadata")); + type.setTypeMetadata(typeMet); + } + if (productTypeHash.get("typeExtractors") != null) { + type.setExtractors(getTypeExtractorsFromXmlRpc( + (Vector>) productTypeHash.get("typeExtractors"))); + } + if (productTypeHash.get("typeHandlers") != null) { + type.setHandlers(getTypeHandlersFromXmlRpc( + (Vector>) productTypeHash.get("typeHandlers"))); + } + return type; + } + + public static Vector> getXmlRpcTypeExtractors( + List extractors) { + Vector> extractorsVector = new Vector>(); + + if (extractors != null && extractors.size() > 0) { + for (ExtractorSpec spec : extractors) { + extractorsVector.add(getXmlRpcExtractorSpec(spec)); + } + } + + return extractorsVector; + } + + public static Map getXmlRpcExtractorSpec(ExtractorSpec spec) { + Map extractorHash = new Hashtable(); + extractorHash.put("className", spec.getClassName()); + extractorHash.put("config", getXmlRpcProperties(spec.getConfiguration())); + return extractorHash; + } + + public static Vector> getXmlRpcTypeHandlers(List typeHandlers) { + Vector> handlersVector = new Vector>(); + + if (typeHandlers != null && typeHandlers.size() > 0) { + for (TypeHandler typeHandler : typeHandlers) { + handlersVector.add(getXmlRpcTypeHandler(typeHandler)); + } + } + + return handlersVector; + } + + public static Map getXmlRpcTypeHandler(TypeHandler typeHandler) { + Map handlerHash = new Hashtable(); + handlerHash.put("className", + typeHandler != null ? typeHandler.getClass().getCanonicalName() : ""); + handlerHash.put("elementName", typeHandler != null ? typeHandler.getElementName() : ""); + return handlerHash; + } + + public static List getTypeExtractorsFromXmlRpc( + Vector> extractorsVector) { + List extractors = new Vector(); + + if (extractorsVector != null && extractorsVector.size() > 0) { + for (Map extractorSpecHash : extractorsVector) { + extractors.add(getExtractorSpecFromXmlRpc(extractorSpecHash)); + } + } + + return extractors; + } + + @SuppressWarnings("unchecked") + public static ExtractorSpec getExtractorSpecFromXmlRpc(Map extractorSpecHash) { + ExtractorSpec spec = new ExtractorSpec(); + spec.setClassName((String) extractorSpecHash.get("className")); + spec.setConfiguration( + getPropertiesFromXmlRpc((Map) extractorSpecHash.get("config"))); + return spec; + } + + public static List getTypeHandlersFromXmlRpc( + Vector> handlersVector) { + List handlers = new Vector(); + + if (handlersVector != null && handlersVector.size() > 0) { + for (Map typeHandlerHash : handlersVector) { + handlers.add(getTypeHandlerFromXmlRpc(typeHandlerHash)); + } + } + + return handlers; + } + + public static TypeHandler getTypeHandlerFromXmlRpc(Map typeHandlerHash) { + TypeHandler typeHandler = GenericFileManagerObjectFactory + .getTypeHandlerFromClassName((String) typeHandlerHash.get("className")); + if (typeHandler != null) { + typeHandler.setElementName((String) typeHandlerHash.get("elementName")); + } + return typeHandler; + } + + public static Properties getPropertiesFromXmlRpc(Map propHash) { + Properties props = new Properties(); + + if (propHash != null && propHash.keySet().size() > 0) { + for (Map.Entry propName : propHash.entrySet()) { + String propValue = propName.getValue(); + props.setProperty(propName.getKey(), propValue); + } + } + + return props; + } + + public static Map getXmlRpcProperties(Properties props) { + Map propHash = new Hashtable(); + + if (props != null && props.keySet().size() > 0) { + for (Object o : props.keySet()) { + String propName = (String) o; + String propValue = props.getProperty(propName); + propHash.put(propName, propValue); + } + } + + return propHash; + } + + + public static Vector> getXmlRpcReferences(List references) { + Vector> refVector = new Vector>(); + + if (references == null) { + return refVector; + } + + for (Reference reference : references) { + Map refHash = getXmlRpcReference(reference); + refVector.add(refHash); + } + + return refVector; + } + + public static List getReferencesFromXmlRpc( + Vector> referenceVector) { + List references = new Vector(); + for (Map aReferenceVector : referenceVector) { + Reference r = getReferenceFromXmlRpc(aReferenceVector); + references.add(r); + } + return references; + } + + public static Map getXmlRpcReference(Reference reference) { + Map referenceHash = new Hashtable(); + referenceHash.put("origReference", reference.getOrigReference()); + referenceHash.put("dataStoreReference", + reference.getDataStoreReference() != null ? reference.getDataStoreReference() : ""); + referenceHash.put("fileSize", Long.toString(reference.getFileSize())); + referenceHash.put("mimeType", + (reference.getMimeType() == null) ? "" : reference.getMimeType().getName()); + return referenceHash; + } + + public static Reference getReferenceFromXmlRpc(Map referenceHash) { + Reference reference = new Reference(); + reference.setDataStoreReference((String) referenceHash.get("dataStoreReference")); + reference.setOrigReference((String) referenceHash.get("origReference")); + reference.setFileSize(Long.parseLong(referenceHash.get("fileSize").toString())); + reference.setMimeType((String) referenceHash.get("mimeType")); + return reference; + } + + public static Reference getReferenceFromXmlRpcHashtable(Map referenceHash) { + Reference reference = new Reference(); + reference.setDataStoreReference((String) referenceHash.get("dataStoreReference")); + reference.setOrigReference((String) referenceHash.get("origReference")); + reference.setFileSize(Long.parseLong(referenceHash.get("fileSize").toString())); + reference.setMimeType((String) referenceHash.get("mimeType")); + return reference; + } + + public static Vector> getXmlRpcElementListHashtable( + List elementList) { + Vector> elementVector = new Vector>(elementList.size()); + for (Element element : elementList) { + Map elementHash = getXmlRpcElementHashTable(element); + elementVector.add(elementHash); + } + return elementVector; + } + + public static Vector> getXmlRpcElementList(List elementList) { + Vector> elementVector = new Vector>(elementList.size()); + for (Element element : elementList) { + Map elementHash = getXmlRpcElement(element); + elementVector.add(elementHash); + } + return elementVector; + } + + public static List getElementListFromXmlRpc(Vector> elementVector) { + List elementList = new Vector(elementVector.size()); + for (Map elementHash : elementVector) { + Element element = getElementFromXmlRpc(elementHash); + elementList.add(element); + } + return elementList; + } + + public static Map getXmlRpcElement(Element element) { + Map elementHash = new HashMap(); + + elementHash.put("id", element.getElementId()); + elementHash.put("name", element.getElementName()); + elementHash.put("dcElement", element.getDCElement() != null ? element.getDCElement() : ""); + elementHash.put("description", + element.getDescription() != null ? element.getDescription() : ""); + + return elementHash; + } + + public static Map getXmlRpcElementHashTable(Element element) { + Map elementHash = new Hashtable(); + + elementHash.put("id", element.getElementId()); + elementHash.put("name", element.getElementName()); + elementHash.put("dcElement", element.getDCElement() != null ? element.getDCElement() : ""); + elementHash.put("description", + element.getDescription() != null ? element.getDescription() : ""); + + return elementHash; + } + + public static Element getElementFromXmlRpc(Map elementHash) { + Element element = new Element(); + element.setElementId((String) elementHash.get("id")); + element.setElementName((String) elementHash.get("name")); + element.setDescription((String) elementHash.get("description")); + element.setDCElement((String) elementHash.get("dcElement")); + + return element; + } + + public static Map getXmlRpcQuery(Query query) { + Map queryHash = new Hashtable(); + Vector> criteriaVector = getXmlRpcQueryCriteriaList(query.getCriteria()); + queryHash.put("criteria", criteriaVector); + return queryHash; + } + + public static Query getQueryFromXmlRpc(Map queryHash) { + Query query = new Query(); + @SuppressWarnings("unchecked") + List criteria = + getQueryCriteriaListFromXmlRpc((Vector>) queryHash.get("criteria")); + query.setCriteria(criteria); + return query; + } + + public static Vector> getXmlRpcQueryCriteriaList( + List criteriaList) { + Vector> criteriaVector = + new Vector>(criteriaList.size()); + for (QueryCriteria criteria : criteriaList) { + Map criteriaHash = getXmlRpcQueryCriteria(criteria); + criteriaVector.add(criteriaHash); + } + + return criteriaVector; + } + + public static List getQueryCriteriaListFromXmlRpc( + Vector> criteriaVector) { + + List criteriaList = new Vector(criteriaVector.size()); + for (Map criteriaHash : criteriaVector) { + QueryCriteria criteria = getQueryCriteriaFromXmlRpc(criteriaHash); + criteriaList.add(criteria); + } + return criteriaList; + } + + public static Map getXmlRpcQueryCriteria(QueryCriteria criteria) { + Map criteriaHash = new Hashtable(); + criteriaHash.put("class", criteria.getClass().getCanonicalName()); + + if (criteria instanceof TermQueryCriteria) { + criteriaHash.put("elementName", criteria.getElementName()); + criteriaHash.put("elementValue", ((TermQueryCriteria) criteria).getValue()); + } else if (criteria instanceof RangeQueryCriteria) { + criteriaHash.put("elementName", criteria.getElementName()); + criteriaHash.put("elementStartValue", + ((RangeQueryCriteria) criteria).getStartValue() != null + ? ((RangeQueryCriteria) criteria).getStartValue() + : ""); + criteriaHash.put("elementEndValue", + ((RangeQueryCriteria) criteria).getEndValue() != null + ? ((RangeQueryCriteria) criteria).getEndValue() + : ""); + criteriaHash.put("inclusive", + Boolean.toString(((RangeQueryCriteria) criteria).getInclusive())); + } else if (criteria instanceof BooleanQueryCriteria) { + BooleanQueryCriteria boolQuery = (BooleanQueryCriteria) criteria; + criteriaHash.put("operator", boolQuery.getOperator()); + Vector> termsHash = new Vector>(); + List terms = boolQuery.getTerms(); + + for (QueryCriteria term : terms) { + Map termHash = getXmlRpcQueryCriteria(term); + termsHash.add(termHash); + } + criteriaHash.put("terms", termsHash); + + } + return criteriaHash; + } + + public static QueryCriteria getQueryCriteriaFromXmlRpc(Map criteriaHash) { + QueryCriteria criteria = null; + if (criteriaHash.get("class").equals(TermQueryCriteria.class.getCanonicalName())) { + criteria = new TermQueryCriteria(); + criteria.setElementName((String) criteriaHash.get("elementName")); + ((TermQueryCriteria) criteria).setValue((String) criteriaHash.get("elementValue")); + } else if (criteriaHash.get("class").equals(RangeQueryCriteria.class.getCanonicalName())) { + criteria = new RangeQueryCriteria(); + criteria.setElementName((String) criteriaHash.get("elementName")); + String startVal = criteriaHash.get("elementStartValue").equals("") ? null + : (String) criteriaHash.get("elementStartValue"); + String endVal = criteriaHash.get("elementEndValue").equals("") ? null + : (String) criteriaHash.get("elementEndValue"); + ((RangeQueryCriteria) criteria).setStartValue(startVal); + ((RangeQueryCriteria) criteria).setEndValue(endVal); + ((RangeQueryCriteria) criteria) + .setInclusive(Boolean.parseBoolean((String) criteriaHash.get("inclusive"))); + } else if (criteriaHash.get("class").equals(BooleanQueryCriteria.class.getCanonicalName())) { + criteria = new BooleanQueryCriteria(); + try { + ((BooleanQueryCriteria) criteria).setOperator((Integer) criteriaHash.get("operator")); + } catch (QueryFormulationException e) { + System.out.println("Error generating Boolean Query."); + } + @SuppressWarnings("unchecked") + List> terms = (List>) criteriaHash.get("terms"); + for (Map term : terms) { + QueryCriteria termCriteria = getQueryCriteriaFromXmlRpc(term); + try { + ((BooleanQueryCriteria) criteria).addTerm(termCriteria); + } catch (QueryFormulationException e) { + System.out.println("Error generating Boolean Query."); + } + } + + } + + return criteria; + + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CacheException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CacheException.java new file mode 100644 index 00000000..11ca9390 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CacheException.java @@ -0,0 +1,39 @@ +/* + * 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.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 msg, Throwable t) { + super(msg, t); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CasMetadataException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CasMetadataException.java new file mode 100644 index 00000000..e4f421e1 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CasMetadataException.java @@ -0,0 +1,28 @@ +/** + * 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.exceptions; + +/** + * Cas Metadata Exception for internal Exceptions. + */ +public class CasMetadataException extends Exception { + + private static final long serialVersionUID = -828047859188622964L; + + public CasMetadataException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CatalogException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CatalogException.java new file mode 100644 index 00000000..41aeca72 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CatalogException.java @@ -0,0 +1,38 @@ +// 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.filemgr.exceptions; + +public class CatalogException extends Exception { + + private static final long serialVersionUID = -1690967589460701735L; + + public CatalogException() { + super(); + } + + public CatalogException(String message) { + super(message); + } + + public CatalogException(Throwable t) { + super(t); + + } + + public CatalogException(String message, Throwable t) { + super(message, t); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CommonsException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CommonsException.java new file mode 100644 index 00000000..db616d24 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CommonsException.java @@ -0,0 +1,13 @@ +package gov.nasa.pds.harvest.search.oodt.filemgr.exceptions; + +/** + * Created by bugg on 27/10/15. + */ +public class CommonsException extends Exception { + + private static final long serialVersionUID = -2829459506392240104L; + + public CommonsException(String message) { + super(message); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/ConnectionException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/ConnectionException.java new file mode 100644 index 00000000..5bf907c5 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/ConnectionException.java @@ -0,0 +1,39 @@ +// 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.filemgr.exceptions; + +public class ConnectionException extends Exception { + + private static final long serialVersionUID = 7104067469225299050L; + + /** + *

+ * Default Constructor + *

+ */ + public ConnectionException() { + super(); + } + + /** + * @param message The message for this exception. + */ + public ConnectionException(String message) { + super(message); + } + + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CrawlerActionException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CrawlerActionException.java new file mode 100644 index 00000000..f721e6c7 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/CrawlerActionException.java @@ -0,0 +1,42 @@ +package gov.nasa.pds.harvest.search.oodt.filemgr.exceptions; + +/* + * 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. + */ + +/** + * An Exception thrown by a {@link CrawlerAction}. + * + * @author bfoster (Brian Foster) + */ +public class CrawlerActionException extends Exception { + + private static final long serialVersionUID = -5497368381787942685L; + + public CrawlerActionException() { + super(); + } + + public CrawlerActionException(String msg) { + super(msg); + } + + public CrawlerActionException(Throwable t) { + super(t); + } + + public CrawlerActionException(String msg, Throwable t) { + super(msg, t); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/DataTransferException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/DataTransferException.java new file mode 100644 index 00000000..f126f002 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/DataTransferException.java @@ -0,0 +1,61 @@ +/* + * 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.exceptions; + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * An exception thrown during data transfer. + *

+ * + */ +public class DataTransferException extends Exception { + + private static final long serialVersionUID = 2532419395263364901L; + + /** + * + */ + public DataTransferException() { + super(); + } + + /** + * @param message + */ + public DataTransferException(String message) { + super(message); + } + + /** + * @param cause + */ + public DataTransferException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public DataTransferException(String message, Throwable cause) { + super(message, cause); + } + + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/FileManagerException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/FileManagerException.java new file mode 100644 index 00000000..8343d396 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/FileManagerException.java @@ -0,0 +1,13 @@ +package gov.nasa.pds.harvest.search.oodt.filemgr.exceptions; + +/** + * Created by bugg on 27/10/15. + */ +public class FileManagerException extends Exception { + + private static final long serialVersionUID = -524318947157613316L; + + public FileManagerException(String message) { + super(message); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/IngestException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/IngestException.java new file mode 100644 index 00000000..85a8f7f8 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/IngestException.java @@ -0,0 +1,67 @@ +// 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.filemgr.exceptions; + +public class IngestException extends Exception { + + /** + * IngestException + */ + + private static final long serialVersionUID = -9005072751751947989L; + + /** + * + */ + public IngestException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + */ + public IngestException(String arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + * @param arg1 + */ + public IngestException(String arg0, Throwable arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + */ + public IngestException(Throwable arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/MetExtractionException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/MetExtractionException.java new file mode 100644 index 00000000..07cd6837 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/MetExtractionException.java @@ -0,0 +1,55 @@ +// 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.filemgr.exceptions; + +public class MetExtractionException extends Exception { + + private static final long serialVersionUID = -1895333160395182674L; + + /** + * + */ + public MetExtractionException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + */ + public MetExtractionException(String arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + * @param arg1 + */ + public MetExtractionException(String arg0, Throwable arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + */ + public MetExtractionException(Throwable arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/QueryFormulationException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/QueryFormulationException.java new file mode 100644 index 00000000..6f1f932b --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/QueryFormulationException.java @@ -0,0 +1,48 @@ +/* + * 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.exceptions; + +/** + * @author woollard + * @version $Revision$ + * + *

+ * A generic exception that occured when dealing with the Catalog. + *

+ * + */ +public class QueryFormulationException extends Exception { + + private static final long serialVersionUID = 1641381629886581382L; + + /** + *

+ * Default Constructor + *

+ */ + public QueryFormulationException() { + super(); + } + + /** + * @param message The message for this exception. + */ + public QueryFormulationException(String message) { + super(message); + } + + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/RepositoryManagerException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/RepositoryManagerException.java new file mode 100644 index 00000000..e9434ba0 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/RepositoryManagerException.java @@ -0,0 +1,53 @@ +/* + * 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.exceptions; + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * An exception thrown from the + * {@link org.apache.oodt.cas.filemgr.repository.RepositoryManager} interface. + *

+ * + */ +public class RepositoryManagerException extends Exception { + + private static final long serialVersionUID = 3688502208018920497L; + + /** + * + */ + public RepositoryManagerException() { + super(); + } + + /** + * @param message + */ + public RepositoryManagerException(String message) { + super(message); + } + + public RepositoryManagerException(Throwable t) { + super(t); + } + + public RepositoryManagerException(String message, Throwable t) { + super(message, t); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/ValidationLayerException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/ValidationLayerException.java new file mode 100644 index 00000000..ff6f11d1 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/ValidationLayerException.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.exceptions; + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * An exception thrown by the validation layer. + *

+ * + */ +public class ValidationLayerException extends Exception { + + /* serial version UID */ + private static final long serialVersionUID = -929293299393L; + + /** + * + */ + public ValidationLayerException() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + */ + public ValidationLayerException(String arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + * @param arg1 + */ + public ValidationLayerException(String arg0, Throwable arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + } + + /** + * @param arg0 + */ + public ValidationLayerException(Throwable arg0) { + super(arg0); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/VersioningException.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/VersioningException.java new file mode 100644 index 00000000..3d05bbe0 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/filemgr/exceptions/VersioningException.java @@ -0,0 +1,64 @@ +/* + * 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.exceptions; + +import gov.nasa.pds.harvest.search.oodt.filemgr.Versioner; + + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * An exception thrown during Versioning by a {@link Versioner}. + *

+ * + */ +public class VersioningException extends Exception { + + /* default serial UID */ + private static final long serialVersionUID = 3256999960552615984L; + + /** + * + */ + public VersioningException() { + super(); + } + + /** + * @param message + */ + public VersioningException(String message) { + super(message); + } + + /** + * @param cause + */ + public VersioningException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public VersioningException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/CoreMetKeys.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/CoreMetKeys.java new file mode 100644 index 00000000..616cb618 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/CoreMetKeys.java @@ -0,0 +1,48 @@ +/* + * 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 mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * Describe your class here + *

+ * . + */ +public interface CoreMetKeys { + + String PRODUCT_NAME = "ProductName"; + + String PRODUCT_ID = "ProductId"; + + String PRODUCT_RECEVIED_TIME = "ProductReceivedTime"; + + String FILE_LOCATION = "FileLocation"; + + String FILENAME = "Filename"; + + String FILE_SIZE = "FileSize"; + + String PRODUCT_TYPE = "ProductType"; + + String PRODUCT_STRUCTURE = "ProductStructure"; + + String MIME_TYPE = "MimeType"; + +} \ No newline at end of file diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/MetExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/MetExtractor.java new file mode 100644 index 00000000..b0020ce0 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/metadata/MetExtractor.java @@ -0,0 +1,133 @@ +/* + * 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; + +// JDK imports +import java.io.File; +import java.net.URL; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.MetExtractionException; + +/** + * @author mattmann + * @version $Revision$ + * + *

+ * An interface for {@link Metadata} extraction. This interface expects the definition of + * the following two parameters: + * + *

    + *
  • file - the file to extract {@link Metadata} from.
  • + *
  • config file - a pointer to the config file for this MetExtractor
  • + *
+ *

+ * + */ +public interface MetExtractor { + + /** + * Extracts {@link Metadata} from a given {@link File}. + * + * @param f File object to extract Metadata from. + * @return Extracted {@link Metadata} from the given {@link File}. + * @throws MetExtractionException If any error occurs. + */ + Metadata extractMetadata(File f) throws MetExtractionException; + + /** + * Extracts {@link Metadata} from a given /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} of String 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(((ExtrinsicObject) value).getSlots())); + } + } + + } + + /** + * Adds key (Replaces if key exists) + * + * @param key Key to be added + * @param values Values of key to be added + */ + public void replaceMetadata(String key, List values) { + this.getGroup(key).setValues(values); + } + + /** + * Removes key + * + * @param key Key to remove + */ + public void removeMetadata(String key) { + Group removeGroup = this.getGroup(key, false); + if (removeGroup != null && removeGroup.hasValues()) { + if (removeGroup.getChildren().size() > 0) { + removeGroup.clearValues(); + } else { + removeGroup.getParent().removeChild(removeGroup.getName()); + } + } + } + + /** + * Removes key + * + */ + public void removeMetadataGroup(String group) { + Group removeGroup = this.getGroup(group, false); + if (removeGroup != null && removeGroup.getChildren().size() > 0) { + removeGroup.getParent().removeChild(removeGroup.getName()); + } + } + + /** + * Checks if keys exists + * + * @param key Key to check for + * @return True if key exists, false otherwise + */ + public boolean containsKey(String key) { + Group group = this.getGroup(key, false); + return group != null && group.hasValues(); + } + + /** + * Checks if key has more than one value + * + * @param key Key to check for + * @return True is key exists and has more than one value, false otherwise + */ + public boolean isMultiValued(String key) { + Group group = this.getGroup(key, false); + return group != null && group.getValues().size() > 1; + } + + /** + * Creates a Metadata from the given group + * + * @param group The Group to grab + * @return Metadata containing group and all keys below it + */ + public Metadata getSubMetadata(String group) { + Metadata m = new Metadata(); + Group newRoot = this.getGroup(group, false); + if (newRoot != null) { + m.root.addChildren(newRoot.clone().getChildren()); + } + return m; + } + + /** + * Gets the first value for the given key + * + * @param key The key for which the first value will be returned + * @return First value for given key, or null if key does not exist + */ + public String getMetadata(String key) { + Group group = this.getGroup(key, false); + if (group != null) { + return group.getValue(); + } else { + return null; + } + } + + /** + * Gets all values for give key + * + * @param key The key for which all values will be return + * @return All values for given key, or null if key does not exist + */ + public List getAllMetadata(String key) { + Group group = this.getGroup(key, false); + if (group != null) { + return new Vector(group.getValues()); + } else { + return null; + } + } + + /** + * Gets all values for give key + * + * @param key The key for which all values will be return + * @return All values for given key, or null if key does not exist + */ + public List getAllMetadataAsSlots(String groupKey) { + List slots = new ArrayList(); + Metadata group = this.getSubMetadata(groupKey); + for (String k : group.getKeys()) { + log.info("group key: " + k); + } + for (String value : group.getValues()) { + log.info("group value: " + value); + } + return slots; + } + + /** + * Gets All key in and below given group + * + * @param group The group in question + * @return All keys for the given group and below + */ + public List getKeys(String group) { + Group foundGroup = this.getGroup(group); + if (foundGroup != null) { + return this.getKeys(foundGroup); + } else { + return new Vector(); + } + } + + /** + * Gets all keys in this Metadata + * + * @return All keys in this Metadata + */ + public List getKeys() { + return this.getKeys(this.root); + } + + protected List getKeys(Group group) { + Vector keys = new Vector(); + for (Group child : group.getChildren()) { + if (child.hasValues()) { + keys.add(child.getFullPath()); + } + } + return keys; + } + + /** + * Gets All key in and below given group + * + * @param group The group in question + * @return All keys for the given group and below + */ + public List getAllKeys(String group) { + Group foundGroup = this.getGroup(group); + if (foundGroup != null) { + return this.getAllKeys(foundGroup); + } else { + return new Vector(); + } + } + + /** + * Gets all keys in this Metadata + * + * @return All keys in this Metadata + */ + public List getAllKeys() { + return this.getAllKeys(this.root); + } + + protected List getAllKeys(Group group) { + Vector keys = new Vector(); + for (Group child : group.getChildren()) { + if (child.hasValues()) { + keys.add(child.getFullPath()); + } + keys.addAll(this.getAllKeys(child)); + } + return keys; + } + + /** + * Get all keys whose leaf key name is equal to the given arg + * @param key leaf key name + * @return list of keys with the given leaf key name + */ + public List getAllKeysWithName(String key) { + List keys = new Vector(); + Stack stack = new Stack(); + stack.add(this.root); + while (!stack.empty()) { + Group curGroup = stack.pop(); + if (curGroup.getName().equals(key) && curGroup.hasValues()) { + keys.add(curGroup.getFullPath()); + } + stack.addAll(curGroup.getChildren()); + } + return keys; + } + + /** + * Gets Values in root group + * + * @return All Values in root group + */ + public List getValues() { + Vector values = new Vector(); + for (String key : this.getKeys()) { + values.addAll(this.getAllMetadata(key)); + } + return values; + } + + /** + * Gets values in given group + * + * @param group Group in question + * @return Values in given group + */ + public List getValues(String group) { + Vector values = new Vector(); + for (String key : this.getKeys(group)) { + values.addAll(this.getAllMetadata(key)); + } + return values; + } + + /** + * Gets all values in this Metadata + * + * @return All values in this Metadata + */ + public List getAllValues() { + Vector values = new Vector(); + for (String key : this.getAllKeys()) { + values.addAll(this.getAllMetadata(key)); + } + return values; + } + + /** + * Gets All values in and below given group + * + * @param group Group in question + * @return All values in and below given group + */ + public List getAllValues(String group) { + Vector values = new Vector(); + for (String key : this.getAllKeys(group)) { + values.addAll(this.getAllMetadata(key)); + } + return values; + } + + @Deprecated + public void addMetadata(Hashtable metadata) { + addMetadata(metadata, false); + } + + public void addMetadata(Map metadata) { + addMetadata(metadata, false); + } + + /** + * Takes a Map of String keys and Object values. Values of type List must be a List of Strings; + * all other values will have its toString() method invoked. + * + * @param metadata Map based metadata to add + * @param replace If true, existing keys will be replaced, other values will be combined. + */ + @Deprecated + public void addMetadata(Map metadata, boolean replace) { + // for back compat: the old method allowed us to give it a + // Map and it still worked + for (Map.Entry key : metadata.entrySet()) { + List vals = (key.getValue() instanceof List) ? (List) key.getValue() + : Collections.singletonList(key.getValue().toString()); + if (replace) { + this.replaceMetadata(key.getKey(), vals); + } else { + this.addMetadata(key.getKey(), vals); + } + } + } + + + public void replaceMetadata(Map metadata) { + this.root = this.createNewRoot(); + this.addMetadata(metadata); + } + + public boolean containsGroup(String group) { + return this.getGroup(group, false) != null; + } + + public List getGroups() { + return this.getGroups(this.root); + } + + public List getGroups(String group) { + return this.getGroups(this.getGroup(group)); + } + + protected List getGroups(Group group) { + Vector groupNames = new Vector(); + for (Group child : group.getChildren()) { + groupNames.add(child.getName()); + } + return groupNames; + } + + protected Group getGroup(String key) { + return getGroup(key, true); + } + + protected Group getGroup(String key, boolean create) { + if (key == null) { + return this.root; + } + StringTokenizer tokenizer = new StringTokenizer(key, "/"); + Group curGroup = this.root; + while (tokenizer.hasMoreTokens()) { + String groupName = tokenizer.nextToken(); + Group childGroup = curGroup.getChild(groupName); + if (childGroup == null) { + if (!create) { + return null; + } + childGroup = new Group(groupName); + curGroup.addChild(childGroup); + } + curGroup = childGroup; + } + return curGroup; + } + + protected Group createNewRoot() { + return new Group(Group.ROOT_GROUP_NAME); + } + + protected class Group { + + private static final String ROOT_GROUP_NAME = "root"; + + private String name; + private List values; + private Group parent; + private Map children; + + public Group(String name) { + this.name = name; + this.values = new Vector(); + this.children = new Hashtable(); + } + + /** + * Create Metadata Group. By default we create a group using a Hashtable for XMLRPC support. + * Once this has been superceeded by the Avro Impl we should make the HashMap implementation the + * default. + * + * @param name + * @param legacy + */ + public Group(String name, boolean legacy) { + this.name = name; + this.values = new Vector(); + this.children = + legacy ? new Hashtable() : new ConcurrentHashMap(); + + } + + public String getName() { + return this.name; + } + + public String getFullPath() { + if (this.parent != null && !this.parent.getName().equals(ROOT_GROUP_NAME)) { + return this.parent.getFullPath() + "/" + this.name; + } else { + return this.name; + } + } + + public Group getParent() { + return this.parent; + } + + public void setValue(String value) { + this.values.clear(); + this.values.add(value); + } + + public void setValues(List values) { + this.values.clear(); + this.values.addAll(values); + } + + public void clearValues() { + this.values.clear(); + } + + public void addValue(String value) { + this.values.add(value); + } + + public void addValues(List value) { + this.values.addAll(value); + } + + public boolean hasValues() { + return this.values.size() > 0; + } + + public String getValue() { + if (this.hasValues()) { + return this.values.get(0); + } else { + return null; + } + } + + public List getValues() { + return this.values; + } + + public void addChild(Group child) { + this.children.put(child.getName(), child); + child.parent = this; + } + + public void addChildren(List children) { + for (Group child : children) { + this.addChild(child); + } + } + + public List getChildren() { + return new Vector(this.children.values()); + } + + public void removeChild(String name) { + this.children.remove(name); + } + + public Group getChild(String name) { + return this.children.get(name); + } + + @Override + public Group clone() { + Group clone = new Group(this.name); + clone.setValues(this.values); + for (Group child : this.children.values()) { + clone.addChild(child.clone()); + } + return clone; + } + + @Override + public String toString() { + return this.getFullPath(); + } + + } + + + @Deprecated + public Hashtable getHashTable() { + Hashtable table = new Hashtable(); + for (String key : this.getAllKeys()) { + table.put(key, this.getAllMetadata(key)); + } + return table; + } + + public Map getMap() { + Map table = new ConcurrentHashMap(); + for (String key : this.getAllKeys()) { + table.put(key, this.getAllMetadata(key)); + } + return table; + } + + public boolean equals(Object obj) { + if (obj instanceof Metadata) { + Metadata compMet = (Metadata) obj; + if (this.getKeys().equals(compMet.getKeys())) { + for (String key : this.getKeys()) { + if (!this.getAllMetadata(key).equals(compMet.getAllMetadata(key))) { + return false; + } + } + return true; + } else { + return false; + } + + } else { + return false; + } + } + + @Override + public int hashCode() { + return root != null ? root.hashCode() : 0; + } +} \ No newline at end of file diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/BooleanQueryCriteria.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/BooleanQueryCriteria.java new file mode 100644 index 00000000..c02b4a4f --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/BooleanQueryCriteria.java @@ -0,0 +1,179 @@ +/* + * 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.util.List; +import java.util.Vector; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.QueryFormulationException; + +//OODT imports + +/** + * @author woollard + * @author bfoster + * @version $Revision$ + * + *

+ * 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 terms; + + /** + * Default constructor. Uses the AND operator. + */ + public BooleanQueryCriteria() { + operator = AND; + terms = new Vector(); + } + + /** + * 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 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 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() { + StringBuilder query = new StringBuilder(); + if (operator == AND) { + query.append("AND("); + } else if (operator == OR) { + query.append("OR("); + } else { + query.append("NOT("); + } + + for (int i = 0; i < terms.size(); i++) { + query.append(terms.get(i).toString()); + if (i < (terms.size() - 1)) { + query.append(", "); + } + } + query.append(")"); + return query.toString(); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Element.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Element.java new file mode 100644 index 00000000..7a78f383 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Element.java @@ -0,0 +1,152 @@ +/* + * 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 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 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"; + + public static final String STRUCTURE_STREAM = "Stream"; + + private static String[] VALID_STRUCTURES = new String[]{STRUCTURE_FLAT,STRUCTURE_HIERARCHICAL,STRUCTURE_STREAM}; + + /* our log stream */ + private static final Logger LOG = Logger.getLogger(Product.class.getName()); + + private String productReceivedTime; + /** + *

+ * Default Constructor + *

+ * + */ + public Product() { + references = new Vector(); + + } + + 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(); + parse(parser.parse(new InputSource(is))); + } catch (Exception e) { + throw new InstantiationException( + "Unable to parse metadata stream.[" + e.getMessage() + "]"); + } + } + + /** + *

+ * 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 refs) { + productName = name; + productType = pType; + productStructure = structure; + references = refs; + this.transferStatus = transferStatus; + } + + /** + * @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) { + //Guard clause, according to a unit test null is a valid value + if (!java.util.Arrays.asList(VALID_STRUCTURES).contains(productStructure) && productStructure != null) { + throw new IllegalArgumentException("Undefined product structure: " + productStructure); + } + this.productStructure = productStructure; + } + + /** + * @return Returns the references. + */ + public List getProductReferences() { + return references; + } + + /** + * @param references + * The references to set. + */ + public void setProductReferences(List 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 Product getDefaultFlatProduct(String name, + String defaultProductTypeId) { + Product defaultProduct = new Product(); + defaultProduct.setProductName(name); + defaultProduct.setProductReferences(new Vector()); + 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 UnsupportedEncodingException, FileManagerException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + Document doc; + + 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 (Reference r : this.getProductReferences()) { + 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 FileManagerException("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"))); + this.references.add(r); + } + } + } + + } + /** + * Set time product was ingested. + * @param productReceivedTime + */ + public void setProductRecievedTime(String productReceivedTime) { + this.productReceivedTime = productReceivedTime; + } + + public String getProductReceivedTime() { + return productReceivedTime; + } + + @Override + public String toString() { + return String.format("%s[%s-%s]", this.getProductId(), this.getProductName(), this.getProductType()); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ProductPage.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ProductPage.java new file mode 100644 index 00000000..7bc00e8b --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ProductPage.java @@ -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 gov.nasa.pds.harvest.search.oodt.structs; + +import java.util.Collections; +// JDK imports +import java.util.List; +import java.util.Vector; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * A Page of {@link Product}s returned from the File Manager. + *

+ * + */ +public class ProductPage { + + /* the number of this page */ + private int pageNum = -1; + + /* the total number of pages in the set */ + private int totalPages = -1; + + /* the size of the number of products on this page */ + private int pageSize = -1; + + /* the list of produdcts associated with this page */ + private List pageProducts = null; + + /* the computed number of total hits for the query */ + private long numOfHits; + + + /** + *

+ * Default Constructor + *

+ * . + */ + public ProductPage() { + pageProducts = new Vector(); + } + + /** + * @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 totalPages, int pageSize, List pageProducts) { + this.pageNum = pageNum; + this.totalPages = totalPages; + 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; + } + + /** + * @return Returns the pageProducts. + */ + public List getPageProducts() { + return pageProducts; + } + + /** + * @param pageProducts The pageProducts to set. + */ + public void setPageProducts(List 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 totalPages; + } + + /** + * @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 == totalPages; + } + + /** + * + * @return True if this is the fist page of the set, false otherwise. + */ + public boolean isFirstPage() { + return pageNum == 1; + } + + + /** + * @return the numOfHits + */ + public long getNumOfHits() { + return numOfHits; + } + + /** + * @param numOfHits the numOfHits to set + */ + public void setNumOfHits(long numOfHits) { + this.numOfHits = numOfHits; + } + + /** + * + * @return A blank, unpopulated {@link ProductPage}. + */ + public static ProductPage blankPage() { + ProductPage blank = new ProductPage(); + blank.setPageNum(0); + blank.setTotalPages(0); + blank.setPageSize(0); + blank.setPageProducts(Collections.EMPTY_LIST); + return blank; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ProductType.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ProductType.java new file mode 100644 index 00000000..4efaa480 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/ProductType.java @@ -0,0 +1,217 @@ +/* + * 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.util.Collections; +//JDK imports +import java.util.List; +import java.util.Vector; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; +import gov.nasa.pds.harvest.search.oodt.structs.type.TypeHandler; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * 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 extractors = null; + + private List handlers = null; + + public ProductType() { + typeMetadata = new Metadata(); + extractors = new Vector(); + } + + 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 getExtractors() { + return extractors; + } + + /** + * @param extractors + * the extractors to set + */ + public void setExtractors(List extractors) { + this.extractors = extractors; + } + + public List getHandlers() { + return handlers; + } + + public void setHandlers(List handlers) { + this.handlers = handlers; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() { + return this.name; + } + + public static ProductType blankProductType(){ + ProductType type = new ProductType(); + type.setDescription("blank"); + type.setExtractors(Collections.EMPTY_LIST); + type.setHandlers(Collections.EMPTY_LIST); + type.setName("blank"); + type.setProductRepositoryPath(""); + type.setProductTypeId(""); + type.setTypeMetadata(new Metadata()); + type.setVersioner(""); + return type; + } + + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Query.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Query.java new file mode 100644 index 00000000..3fd95167 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/Query.java @@ -0,0 +1,98 @@ +/* + * 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.List; +import java.util.Vector; + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * A Query is a {@link List} of {@link QueryCriteria}. + *

+ * + */ +public class Query { + + /* the set of {@link QueryCriteria} for this Query */ + private List criteria = null; + + /** + *

+ * Default Constructor + *

+ * . + */ + public Query() { + criteria = new Vector(); + } + + /** + * @param criteria + */ + public Query(List criteria) { + if (criteria == null) { + this.criteria = new Vector(); + } else { + this.criteria = criteria; + } + } + + /** + * @return Returns the criteria. + */ + public List getCriteria() { + return criteria; + } + + /** + * @param criteria The criteria to set. + */ + public void setCriteria(List 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() { + StringBuilder rStr = new StringBuilder(); + + 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(); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/QueryCriteria.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/QueryCriteria.java new file mode 100644 index 00000000..6040d49c --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/QueryCriteria.java @@ -0,0 +1,56 @@ +/* + * 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$ + * + *

+ * 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. + *

+ * + *
    + * Known Subclasses: + *
  • FreeTextQueryCriteria + *
  • RangeQueryCriteria + *
  • TermQueryCriteria + *
+ */ +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. + * + */ + public abstract void setElementName(String elementName); + + /** + * Abstract method for converting the QueryCriteria to a human-parsable String. + */ + public abstract String toString(); + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/RangeQueryCriteria.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/RangeQueryCriteria.java new file mode 100644 index 00000000..30348dae --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/RangeQueryCriteria.java @@ -0,0 +1,165 @@ +/* + * 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 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 reducedProductTypeNames; + private List reducedMetadata; + private QueryFilter queryFilter; + private String sortByMetKey; + private String toStringResultFormat; + + public ComplexQuery() { + super(); + } + + public ComplexQuery(List criteria) { + super(criteria); + } + + public List getReducedProductTypeNames() { + return reducedProductTypeNames; + } + + public void setReducedProductTypeNames(List reducedProductTypeNames) { + this.reducedProductTypeNames = reducedProductTypeNames; + } + + public List getReducedMetadata() { + return reducedMetadata; + } + + public void setReducedMetadata(List reducedMetadata) { + this.reducedMetadata = reducedMetadata; + if (this.sortByMetKey != null && this.reducedMetadata != null + && !this.reducedMetadata.contains(this.sortByMetKey)) { + this.reducedMetadata.add(this.sortByMetKey); + } + } + + public QueryFilter getQueryFilter() { + return queryFilter; + } + + public void setQueryFilter(QueryFilter queryFilter) { + this.queryFilter = queryFilter; + } + + public String getSortByMetKey() { + return sortByMetKey; + } + + public void setSortByMetKey(String sortByMetKey) { + this.sortByMetKey = sortByMetKey; + if (this.reducedMetadata != null && this.sortByMetKey != null + && !this.reducedMetadata.contains(this.sortByMetKey)) { + this.reducedMetadata.add(this.sortByMetKey); + } + } + + public String getToStringResultFormat() { + return this.toStringResultFormat; + } + + public void setToStringResultFormat(String toStringResultFormat) { + this.toStringResultFormat = toStringResultFormat; + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/FilterAlgor.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/FilterAlgor.java new file mode 100644 index 00000000..4a513b0c --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/FilterAlgor.java @@ -0,0 +1,48 @@ +/* + * 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; + +/** + * + * @author bfoster + * @version $Revision$ + * + *

+ * 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 filterEvents(List events); + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/ObjectTimeEvent.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/ObjectTimeEvent.java new file mode 100644 index 00000000..118d44ed --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/ObjectTimeEvent.java @@ -0,0 +1,63 @@ +/* + * 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 {@link TimeEvent} associated with a particular {@link Object} + *

+ * . + */ +public class ObjectTimeEvent extends TimeEvent { + + private objType timeObj; + + public ObjectTimeEvent(long startTime, long endTime, objType timeObj) { + super(startTime, endTime); + this.timeObj = timeObj; + } + + public ObjectTimeEvent(long startTime, long endTime, double priority, objType timeObj) { + super(startTime, endTime, priority); + this.timeObj = timeObj; + } + + public objType getTimeObject() { + return this.timeObj; + } + + public boolean equals(Object obj) { + if (obj instanceof ObjectTimeEvent) { + ObjectTimeEvent ote = (ObjectTimeEvent) obj; + return super.equals(obj) && this.timeObj.equals(ote.timeObj); + } else { + return false; + } + } + + public String toString() { + return super.toString() + " - " + timeObj; + } + + @Override + public int hashCode() { + return timeObj != null ? timeObj.hashCode() : 0; + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/QueryFilter.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/QueryFilter.java new file mode 100644 index 00000000..39a381ee --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/QueryFilter.java @@ -0,0 +1,85 @@ +/* + * 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 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 + *

+ * . + */ +public class TimeEvent implements Comparable { + + protected long startTime, endTime, dur; + + protected double priority; + + public TimeEvent(long startTime, long endTime) { + this(startTime, endTime, 0); + } + + public TimeEvent(long startTime, long endTime, double priority) { + this.startTime = startTime; + this.endTime = endTime; + this.dur = this.endTime - this.startTime; + this.priority = priority; + } + + public void setPriority(double priority) { + this.priority = priority; + } + + public double getPriority() { + return this.priority; + } + + public long getStartTime() { + return this.startTime; + } + + public long getEndTime() { + return this.endTime; + } + + public long getDuration() { + return this.dur; + } + + public boolean equals(Object obj) { + if (obj instanceof TimeEvent) { + TimeEvent te = (TimeEvent) obj; + return te.startTime == this.startTime && te.endTime == this.endTime; + } else { + return false; + } + } + + public String toString() { + return "[" + this.startTime + "," + this.endTime + "] - " + this.priority; + } + + public static boolean happenAtSameTime(TimeEvent te1, TimeEvent te2) { + return te1.getStartTime() == te2.getStartTime() && te1.getEndTime() == te2.getEndTime(); + } + + public int compareTo(TimeEvent te) { + return new Long(this.startTime).compareTo(te.startTime); + } + + @Override + public int hashCode() { + int result; + long temp; + result = (int) (startTime ^ (startTime >>> 32)); + result = 31 * result + (int) (endTime ^ (endTime >>> 32)); + result = 31 * result + (int) (dur ^ (dur >>> 32)); + temp = Double.doubleToLongBits(priority); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + return result; + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/VersionConverter.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/VersionConverter.java new file mode 100644 index 00000000..48177d53 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/structs/query/VersionConverter.java @@ -0,0 +1,31 @@ +/* + * 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$ + * + *

+ * 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 qcList = new LinkedList(); + for (QueryCriteria qc : query.getCriteria()) { + qcList.add(this.handleQueryCriteria(qc)); + } + query.setCriteria(qcList); + return query; + } + + private QueryCriteria handleQueryCriteria(QueryCriteria qc) throws QueryFormulationException { + if (qc instanceof BooleanQueryCriteria) { + LinkedList qcList = new LinkedList(); + for (QueryCriteria criteria : ((BooleanQueryCriteria) qc).getTerms()) { + qcList.add(this.handleQueryCriteria(criteria)); + } + BooleanQueryCriteria bqc = new BooleanQueryCriteria(); + bqc.setOperator(((BooleanQueryCriteria) qc).getOperator()); + bqc.setElementName(qc.getElementName()); + for (QueryCriteria criteria : qcList) { + bqc.addTerm(criteria); + } + return bqc; + } else if (qc.getElementName().equals(elementName) && qc instanceof TermQueryCriteria) { + return this.handleTermQueryCriteria((TermQueryCriteria) qc); + } else if (qc.getElementName().equals(elementName) && qc instanceof RangeQueryCriteria) { + return this.handleRangeQueryCriteria((RangeQueryCriteria) qc); + } else { + return qc; + } + } + + /** + * Handles converting any Catalog metadata element values to their original values. Metadata + * elements can be added, modified, or replaced. + * + * @param metadata The Catalog Metadata + */ + public abstract void postGetMetadataHandle(Metadata metadata); + + /** + * Handles converting any metadata element to Catalog element values. Metadata elements can be + * added, modified, or replaced. + * + * @param metadata The Original Metadata + */ + public abstract void preAddMetadataHandle(Metadata metadata); + + /** + * Converts the given RangeQueryCriteria into a QueryCriteria with the necessary Catalog elements + * and values to perform the query + * + * + * @param qc + * @return + */ + protected abstract QueryCriteria handleRangeQueryCriteria(RangeQueryCriteria qc); + + /** + * Converts the given TermQueryCriteria into a QueryCriteria with the necessary Catalog elements + * and values to perform the query + * + * @param qc + * @return + */ + protected abstract QueryCriteria handleTermQueryCriteria(TermQueryCriteria qc); + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/DOMUtil.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/DOMUtil.java new file mode 100644 index 00000000..431c73bd --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/DOMUtil.java @@ -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 gov.nasa.pds.harvest.search.oodt.utils; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CommonsException; + +/** + * + *

+ * 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. + *

+ * + * @author mattmann + * @version 1.0 + */ +public class DOMUtil { + + /** + * + *

+ * Method returns the First occurence of Element 'name' in the DOM Node 'element'. + *

+ * + * @param element The DOM Element node to traverse. + * @param name The XML name of the Element to return. + * @return Element "element" with Name "name"'s first occurence. + */ + public static Element getFirstElement(Element element, String name) throws CommonsException { + NodeList n1 = element.getElementsByTagName(name); + + if (n1.getLength() < 1) { + throw new CommonsException("Element: " + element + " does not contain: " + name); + } + + return (Element) n1.item(0); + } + + /** + * * + *

+ * This function is intended when you have a DOM element with no other DOM elements inside (i.e. + * here is text) + *

+ * * + * + * @param node The DOM 'SimpleElement' as defined in the Function definition. + * @param name The name of the Text to retreive. + * @return the Text inbetween the simple element tags. + */ + public static String getSimpleElementText(Element node, String name) throws CommonsException { + Element namedElement = getFirstElement(node, name); + return getSimpleElementText(namedElement); + } + + /** + * * + *

+ * This function is intended for use when you have merely text between an XML Element (i.e. + * text here). + *

+ * + * @param node The DOM XML Tag, with text inbetween. + * @return String text inbetween the simple element tag. + */ + public static String getSimpleElementText(Element node) { + StringBuilder sb = new StringBuilder(); + NodeList children = node.getChildNodes(); + + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child instanceof Text) { + sb.append(child.getNodeValue()); + } + } + + return sb.toString(); + } +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/DateUtils.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/DateUtils.java new file mode 100644 index 00000000..023072ad --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/DateUtils.java @@ -0,0 +1,241 @@ +/* + * 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.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.SimpleTimeZone; +import java.util.TimeZone; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CommonsException; + +/** + * + * @author bfoster + * @version $Revision$ + * + */ +public class DateUtils { + + public enum FormatType { + UTC_FORMAT, LOCAL_FORMAT, TAI_FORMAT + } + + public static Calendar tai93epoch = new GregorianCalendar(1993, GregorianCalendar.JANUARY, 1); + + public static Calendar julianEpoch = new GregorianCalendar(1970, GregorianCalendar.JANUARY, 1); + + private static SimpleDateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + private static SimpleDateFormat taiFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); + private static SimpleDateFormat localFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + + static { + utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + taiFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + enum IndexType { + DATE(0), LEAP_SECS(1); + + public int index; + + IndexType(int index) { + this.index = index; + } + } + + // Info taken from ftp://oceans.gsfc.nasa.gov/COMMON/leapsec.dat + static long[][] dateAndLeapSecs = + {{0, 10}, {new GregorianCalendar(1972, GregorianCalendar.JULY, 1).getTimeInMillis(), 11}, + {new GregorianCalendar(1973, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 12}, + {new GregorianCalendar(1974, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 13}, + {new GregorianCalendar(1975, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 14}, + {new GregorianCalendar(1976, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 15}, + {new GregorianCalendar(1977, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 16}, + {new GregorianCalendar(1978, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 17}, + {new GregorianCalendar(1979, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 18}, + {new GregorianCalendar(1980, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 19}, + {new GregorianCalendar(1981, GregorianCalendar.JULY, 1).getTimeInMillis(), 20}, + {new GregorianCalendar(1982, GregorianCalendar.JULY, 1).getTimeInMillis(), 21}, + {new GregorianCalendar(1983, GregorianCalendar.JULY, 1).getTimeInMillis(), 22}, + {new GregorianCalendar(1985, GregorianCalendar.JULY, 1).getTimeInMillis(), 23}, + {new GregorianCalendar(1988, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 24}, + {new GregorianCalendar(1990, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 25}, + {new GregorianCalendar(1991, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 26}, + {new GregorianCalendar(1992, GregorianCalendar.JULY, 1).getTimeInMillis(), 27}, + {new GregorianCalendar(1993, GregorianCalendar.JULY, 1).getTimeInMillis(), 28}, + {new GregorianCalendar(1994, GregorianCalendar.JULY, 1).getTimeInMillis(), 29}, + {new GregorianCalendar(1996, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 30}, + {new GregorianCalendar(1997, GregorianCalendar.JULY, 1).getTimeInMillis(), 31}, + {new GregorianCalendar(1999, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 32}, + {new GregorianCalendar(2006, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 33}, + {new GregorianCalendar(2009, GregorianCalendar.JANUARY, 1).getTimeInMillis(), 34},}; + + private DateUtils() {} + + public static int getLeapSecsForDate(Calendar utcCal) throws CommonsException { + long timeInMillis = utcCal.getTimeInMillis(); + for (int i = dateAndLeapSecs.length - 1; i >= 0; i--) { + if (dateAndLeapSecs[i][IndexType.DATE.index] < timeInMillis) { + return (int) dateAndLeapSecs[i][IndexType.LEAP_SECS.index]; + } + } + throw new CommonsException("No Leap Second found for given date!"); + } + + public static synchronized Calendar toTai(Calendar cal) throws CommonsException { + Calendar taiCal = Calendar.getInstance(createTaiTimeZone(getLeapSecsForDate(cal))); + taiCal.setTimeInMillis(cal.getTimeInMillis() + getLeapSecsForDate(cal) * 1000); + return taiCal; + } + + private static synchronized Calendar taiToUtc(Calendar taiCal) { + Calendar calUtc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + calUtc.setTimeInMillis(taiCal.getTimeInMillis() - taiCal.getTimeZone().getRawOffset()); + return calUtc; + } + + private static Calendar taiToLocal(Calendar taiCal) { + return toLocal(taiToUtc(taiCal)); + } + + public static synchronized Calendar toLocal(Calendar cal) { + if (cal.getTimeZone().getID().equals("TAI")) { + return taiToLocal(cal); + } else { + Calendar calLocal = Calendar.getInstance(); + calLocal.setTimeInMillis(cal.getTimeInMillis()); + return calLocal; + } + } + + public static synchronized Calendar toUtc(Calendar cal) { + if (cal.getTimeZone().getID().equals("TAI")) { + return taiToUtc(cal); + } else { + Calendar calUtc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + calUtc.setTimeInMillis(cal.getTimeInMillis()); + return calUtc; + } + } + + public static Calendar getCurrentUtcTime() { + return toUtc(getCurrentLocalTime()); + } + + public static Calendar getCurrentLocalTime() { + return Calendar.getInstance(); + } + + public static Calendar getCurrentTaiTime() throws CommonsException { + return toTai(getCurrentUtcTime()); + } + + public static String toCustomLocalFormat(Calendar cal, String format) { + return new SimpleDateFormat(format).format(cal.getTime()); + } + + public static String toString(Calendar cal) { + String timeZoneId = cal.getTimeZone().getID(); + if (timeZoneId.equals("UTC")) { + return utcFormat.format(cal.getTime()); + } else if (timeZoneId.equals("TAI")) { + return taiFormat.format(cal.getTime()) + "-0000" + (cal.getTimeZone().getRawOffset() / 1000); + } else { + return localFormat.format(cal.getTime()); + } + } + + public static synchronized Calendar toLocalCustomFormatCalendar(String calString, String format) + throws ParseException { + Calendar localCal = Calendar.getInstance(); + localCal.setTime(new SimpleDateFormat(format).parse(calString)); + return localCal; + } + + public static synchronized Calendar toCalendar(String calString, FormatType formatType) + throws ParseException { + Calendar cal = Calendar.getInstance(); + switch (formatType) { + case LOCAL_FORMAT: + cal.setTimeInMillis(localFormat.parse(calString).getTime()); + break; + case TAI_FORMAT: + cal.setTimeZone( + createTaiTimeZone(Integer.parseInt(calString.substring(calString.length() - 2)))); + calString = calString.substring(0, calString.length() - 5); + cal.setTimeInMillis(taiFormat.parse(calString).getTime()); + break; + case UTC_FORMAT: + cal.setTimeZone(TimeZone.getTimeZone("UTC")); + cal.setTimeInMillis(utcFormat.parse(calString).getTime()); + break; + default: + cal.setTimeInMillis(localFormat.parse(calString).getTime()); + } + return cal; + } + + public static double getTimeInSecs(Calendar cal, Calendar epoch) throws CommonsException { + return getTimeInMillis(cal, epoch) / 1000.0; + } + + public static String toString(double seconds) { + return new DecimalFormat("#.000").format(seconds); + } + + public static long getTimeInMillis(Calendar cal, Calendar epoch) throws CommonsException { + long epochDiffInMilli; + /** + * Fixes date conversion issues preventing tests passing in the UK but working elsewhere in the + * world. + */ + if (julianEpoch.getTimeZone().getID().equals("Europe/London")) { + epochDiffInMilli = epoch.getTimeInMillis() - (julianEpoch.getTimeInMillis() + + julianEpoch.getTimeZone().getOffset(julianEpoch.getTimeInMillis())); + } else { + epochDiffInMilli = epoch.getTimeInMillis() - julianEpoch.getTimeInMillis(); + } + if (cal.getTimeZone().getID().equals("TAI")) { + epochDiffInMilli += getLeapSecsForDate(epoch) * 1000; + } + long milliseconds = cal.getTimeInMillis(); + return milliseconds - epochDiffInMilli; + } + + private static TimeZone createTaiTimeZone(int leapSecs) { + return new SimpleTimeZone(leapSecs * 1000, "TAI"); + } + + public static void main(String[] args) throws ParseException, CommonsException { + Calendar curTime = getCurrentLocalTime(); + System.out.println("Test Time: " + toString( + toCalendar(toString(toTai(toCalendar("2008-01-20T16:29:55.000Z", FormatType.UTC_FORMAT))), + FormatType.TAI_FORMAT))); + System.out + .println("Current Local Time: " + toString(curTime) + " " + curTime.getTimeInMillis()); + System.out.println("Current UTC Time: " + + toString((curTime = toCalendar("2008-01-20T16:29:55.000Z", FormatType.UTC_FORMAT))) + " " + + toString(getTimeInSecs(curTime, tai93epoch))); + System.out.println("Current TAI Time: " + + toString((curTime = toTai(toCalendar("2008-01-20T16:29:55.000Z", FormatType.UTC_FORMAT)))) + + " " + toString(getTimeInSecs(curTime, tai93epoch))); + System.out.println("Current UTC Time: " + toString(taiToUtc(curTime))); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/EnvUtilities.java b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/EnvUtilities.java new file mode 100644 index 00000000..fba0b368 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/oodt/utils/EnvUtilities.java @@ -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 gov.nasa.pds.harvest.search.oodt.utils; + +// JDK imports +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author mattmann + * @author bfoster + * @author mstarch + * @version $Revision$ + * + *

+ * Environment Utilities for reading variables and setting them and such. + *

+ * . + */ +public final class EnvUtilities { + + private static final Logger LOG = Logger.getLogger(EnvUtilities.class.getName()); + public static final int INT = 4096; + + private EnvUtilities() throws InstantiationException { + throw new InstantiationException("Don't construct utility classes!"); + } + + private final static Properties environment = new Properties(); + static { + System.getenv().entrySet(); + for (Map.Entry entry : System.getenv().entrySet()) { + environment.setProperty(entry.getKey(), entry.getValue()); + } + } + + /** + * This method returns a particular named environment variable from the user's working environment + * using the {@link #getEnv()} method to grab that environment. + * + * @param envVarName The named environment variable to return. + * @return The environment variable value, as a String. + */ + public static String getEnv(String envVarName) { + return environment.getProperty(envVarName); + } + + /** + * This method does exactly the same thing as {@link #getEnvUsingWaitFor()}, except it uses + * System.getenv() + * + * @return The user's current environment, in a {@link Properties} object. + */ + public static Properties getEnv() { + return environment; + } + + /** + * This method grabs the current environment using the Linux shell program called + * 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$ + * + * + *

+ * A Utility class containing methods to write and transform XML objects. + *

+ */ + +public class XMLUtils { + /* our log stream */ + private final static Logger LOG = Logger.getLogger(XMLUtils.class.getName()); + + /** + *

+ * This method writes a DOM document to a file + *

+ * . + * + * @param doc The DOM document to write. + * @param filename The filename to write the DOM document to. + */ + public static void writeXmlFile(Document doc, String filename) { + // Prepare the output file + Result result = new StreamResult(filename); + transform(doc, result); + } + + public static void writeXmlToStream(Document doc, OutputStream stream) { + Result result = new StreamResult(stream); + transform(doc, result); + } + + private static void transform(Document doc, Result result) { + try { + // Prepare the DOM document for writing + Source source = new DOMSource(doc); + + // Write the DOM document to the file + Transformer xformer = TransformerFactory.newInstance().newTransformer(); + xformer.setOutputProperty(OutputKeys.INDENT, "yes"); + xformer.transform(source, result); + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage()); + } + + } + + public static List readMany(Element root, String elt) { + return readMany(root, elt, "UTF-8"); + } + + public static List readMany(Element root, String elt, String encoding) { + NodeList valueNodes = root.getElementsByTagName(elt); + List values = new Vector(); + + for (int i = 0; i < valueNodes.getLength(); i++) { + Element valElem = (Element) valueNodes.item(i); + String value; + + try { + value = URLDecoder.decode(DOMUtil.getSimpleElementText(valElem), encoding); + values.add(value); + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage()); + LOG.log(Level.WARNING, + "Error decoding tag: [" + elt + "]: val: [" + DOMUtil.getSimpleElementText(valElem) + + "] from metadata. Message: " + e.getMessage()); + } + } + + return values; + } + + public static String read(Element root, String elt) { + return read(root, elt, "UTF-8"); + } + + public static String read(Element root, String elt, String encoding) { + + String value = null; + try { + value = URLDecoder.decode(DOMUtil.getSimpleElementText(root, elt), encoding); + } catch (Exception e) { + LOG.log(Level.WARNING, + "Error decoding " + elt + "from metadata. " + "Message: " + e.getMessage()); + } + return value; + } + + public static Element getFirstElement(String name, Element root) { + NodeList list = root.getElementsByTagName(name); + if (list.getLength() > 0) { + return (Element) list.item(0); + } else { + return null; + } + } + + public static String getSimpleElementText(Element node, boolean trim) { + if (node.getChildNodes().item(0) instanceof Text) { + String elemTxt; + if (trim) { + elemTxt = node.getChildNodes().item(0).getNodeValue().trim(); + } else { + elemTxt = node.getChildNodes().item(0).getNodeValue(); + } + + return elemTxt; + } else { + return null; + } + } + + public static String getSimpleElementText(Element node) { + return getSimpleElementText(node, false); + } + + public static String getElementText(String elemName, Element root, boolean trim) { + Element elem = getFirstElement(elemName, root); + if (elem != null) { + return getSimpleElementText(elem, trim); + } else { + return null; + } + } + + public static String getElementText(String elemName, Element root) { + return getElementText(elemName, root, false); + } + + public static Document getDocumentRoot(InputStream is) { + // open up the XML file + DocumentBuilderFactory factory; + DocumentBuilder parser; + Document document; + InputSource inputSource; + + inputSource = new InputSource(is); + + try { + factory = DocumentBuilderFactory.newInstance(); + parser = factory.newDocumentBuilder(); + document = parser.parse(inputSource); + } catch (Exception e) { + LOG.log(Level.WARNING, "Unable to parse xml stream" + ": Reason is [" + e + "]"); + return null; + } + + return document; + } + + public static Element addNode(Document doc, Node parent, String name) { + Element child = doc.createElement(name); + parent.appendChild(child); + return child; + } + + public static void addNode(Document doc, Node parent, String name, String text) { + Element child = doc.createElement(name); + child.appendChild(doc.createTextNode(text)); + parent.appendChild(child); + } + + public static void addNode(Document doc, Node parent, String ns, String name, String text, + Map NS_MAP) { + Element child = doc.createElementNS((String) NS_MAP.get(ns), ns + ":" + name); + child.appendChild(doc.createTextNode(text)); + parent.appendChild(child); + } + + public static void addAttribute(Document doc, Element node, String name, String value) { + Attr attribute = doc.createAttribute(name); + attribute.setValue(value); + node.getAttributes().setNamedItem(attribute); + } + +} diff --git a/src/main/java/gov/nasa/pds/harvest/search/registry/BaseExtractor.java b/src/main/java/gov/nasa/pds/harvest/search/registry/BaseExtractor.java index ef67bbd8..64e0cb9a 100644 --- a/src/main/java/gov/nasa/pds/harvest/search/registry/BaseExtractor.java +++ b/src/main/java/gov/nasa/pds/harvest/search/registry/BaseExtractor.java @@ -1,9 +1,7 @@ package gov.nasa.pds.harvest.search.registry; import javax.xml.xpath.XPathExpression; - import org.w3c.dom.Document; - import gov.nasa.pds.harvest.search.util.XPathUtils; public class BaseExtractor diff --git a/src/main/java/gov/nasa/pds/harvest/search/util/PathUtils.java b/src/main/java/gov/nasa/pds/harvest/search/util/PathUtils.java new file mode 100644 index 00000000..fc7b5265 --- /dev/null +++ b/src/main/java/gov/nasa/pds/harvest/search/util/PathUtils.java @@ -0,0 +1,404 @@ +/* + * 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. + */ + + +//$Id$ + +package gov.nasa.pds.harvest.search.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.lang.StringUtils; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CasMetadataException; +import gov.nasa.pds.harvest.search.oodt.filemgr.exceptions.CommonsException; +import gov.nasa.pds.harvest.search.oodt.metadata.Metadata; +import gov.nasa.pds.harvest.search.oodt.utils.DateUtils; +import gov.nasa.pds.harvest.search.oodt.utils.EnvUtilities; + + +/** + * @author mattmann + * @author bfoster + * @version $Revision$ + * + *

+ * A Utility class for replacing environment variables and maniuplating file + * path strings. + *

. + */ +public final class PathUtils { + + public static String DELIMITER = ","; + + public static String replaceEnvVariables(String origPath) { + return replaceEnvVariables(origPath, null); + } + + public static String replaceEnvVariables(String origPath, Metadata metadata) { + return replaceEnvVariables(origPath, metadata, false); + } + + public static String replaceEnvVariables(String origPath, + Metadata metadata, boolean expand) { + StringBuilder finalPath = new StringBuilder(); + + for (int i = 0; i < origPath.length(); i++) { + if (origPath.charAt(i) == '[') { + VarData data = readEnvVarName(origPath, i); + String var; + if (metadata != null + && metadata.getMetadata(data.getFieldName()) != null) { + List valList = metadata.getAllMetadata(data.getFieldName()); + var = (String) valList.get(0); + if (expand) { + for (int j = 1; j < valList.size(); j++) { + var += DELIMITER + (String) valList.get(j); + } + } + } else { + var = EnvUtilities.getEnv(data.getFieldName()); + } + finalPath.append(var); + i = data.getEndIdx(); + } else { + finalPath.append(origPath.charAt(i)); + } + } + + return finalPath.toString(); + } + + public static String doDynamicReplacement(String string) + throws ParseException, CommonsException, CasMetadataException { + return doDynamicReplacement(string, null); + } + + public static String doDynamicReplacement(String string, Metadata metadata) + throws ParseException, CommonsException, CasMetadataException { + return PathUtils.replaceEnvVariables(doDynamicDateReplacement( + doDynamicDateRollReplacement( + doDynamicDateFormatReplacement( + doDynamicUtcToTaiDateReplacement( + doDynamicDateToSecsReplacement( + doDynamicDateToMillisReplacement( + string, metadata), + metadata), + metadata), + metadata), + metadata), + metadata), + metadata, true); + } + + public static String doDynamicDateReplacement(String string, + Metadata metadata) throws CasMetadataException, CommonsException { + Pattern datePattern = Pattern + .compile("\\[\\s*DATE\\s*(?:[+-]{1}[^\\.]{1,}?){0,1}\\.\\s*(?:(?:DAY)|(?:MONTH)|(?:YEAR)|(?:UTC)|(?:TAI)){1}\\s*\\]"); + Matcher dateMatcher = datePattern.matcher(string); + while (dateMatcher.find()) { + String dateString = string.substring(dateMatcher.start(), + dateMatcher.end()); + GregorianCalendar gc = new GregorianCalendar(); + + // roll the date if roll days was specfied + int plusMinusIndex; + if ((plusMinusIndex = dateString.indexOf('-')) != -1 + || (plusMinusIndex = dateString.indexOf('+')) != -1) { + int dotIndex; + if ((dotIndex = dateString.indexOf('.', plusMinusIndex)) != -1) { + int rollDays = Integer.parseInt(PathUtils + .replaceEnvVariables( + dateString.substring(plusMinusIndex, + dotIndex), metadata).replaceAll( + "[\\+\\s]", "")); + gc.add(GregorianCalendar.DAY_OF_YEAR, rollDays); + } else { + throw new CasMetadataException( + "Malformed dynamic date replacement specified (no dot separator) - '" + + dateString + "'"); + } + } + + // determine type and make the appropriate replacement + String[] splitDate = dateString.split("\\."); + if (splitDate.length < 2) { + throw new CasMetadataException("No date type specified - '" + dateString + + "'"); + } + String dateType = splitDate[1].replaceAll("[\\[\\]\\s]", ""); + String replacement; + if (dateType.equals("DAY")) { + replacement = StringUtils.leftPad(gc + .get(GregorianCalendar.DAY_OF_MONTH) + + "", 2, "0"); + } else if (dateType.equals("MONTH")) { + replacement = StringUtils.leftPad((gc + .get(GregorianCalendar.MONTH) + 1) + + "", 2, "0"); + } else if (dateType.equals("YEAR")) { + replacement = gc.get(GregorianCalendar.YEAR) + ""; + } else if (dateType.equals("UTC")) { + replacement = DateUtils.toString(DateUtils.toUtc(gc)); + } else if (dateType.equals("TAI")) { + replacement = DateUtils.toString(DateUtils.toTai(gc)); + } else { + throw new CasMetadataException("Invalid date type specified '" + + dateString + "'"); + } + + string = StringUtils.replace(string, dateString, replacement); + dateMatcher = datePattern.matcher(string); + } + return string; + } + + /** + * usage format: [DATE_ADD(,,,
)] + * example: [DATE_ADD(2009-12-31, yyyy-MM-dd, 1, day)] . . . output will be: 2010-01-01 + * - dynamic replacement is allowed for the as well, for example: + * [DATE_ADD([DATE.UTC], yyyy-MM-dd'T'HH:mm:ss.SSS'Z', 1, day)] will add one day to the + * current UTC time + */ + public static String doDynamicDateRollReplacement(String string, + Metadata metadata) throws ParseException, CasMetadataException, CommonsException { + Pattern dateFormatPattern = Pattern + .compile("\\[\\s*DATE_ADD\\s*\\(.{1,}?,.{1,}?,.{1,}?,.{1,}?\\)\\s*\\]"); + Matcher dateFormatMatcher = dateFormatPattern.matcher(string); + while (dateFormatMatcher.find()) { + String dateFormatString = string.substring(dateFormatMatcher + .start(), dateFormatMatcher.end()); + + // get arguments + Matcher argMatcher = Pattern.compile("\\(.*\\)").matcher( + dateFormatString); + argMatcher.find(); + String argsString = dateFormatString.substring(argMatcher.start() + 1, + argMatcher.end() - 1); + argsString = doDynamicReplacement(argsString, metadata); + String[] args = argsString.split(","); + String dateString = args[0].trim(); + dateString = doDynamicReplacement(dateString, metadata); + String dateFormat = args[1].trim(); + int addAmount = Integer.parseInt(args[2].trim()); + String addUnits = args[3].trim().toLowerCase(); + + // reformat date + Date date = new SimpleDateFormat(dateFormat).parse(dateString); + Calendar calendar = (Calendar) Calendar.getInstance().clone(); + calendar.setTime(date); + if (addUnits.equals("hr") || addUnits.equals("hour")) { + calendar.add(Calendar.HOUR_OF_DAY, addAmount); + } else if (addUnits.equals("min") || addUnits.equals("minute")) { + calendar.add(Calendar.MINUTE, addAmount); + } else if (addUnits.equals("sec") || addUnits.equals("second")) { + calendar.add(Calendar.SECOND, addAmount); + } else if (addUnits.equals("day")) { + calendar.add(Calendar.DAY_OF_YEAR, addAmount); + } else if (addUnits.equals("mo") || addUnits.equals("month")) { + calendar.add(Calendar.MONTH, addAmount); + } else if (addUnits.equals("yr") || addUnits.equals("year")) { + calendar.add(Calendar.YEAR, addAmount); + } + + String newDateString = new SimpleDateFormat(dateFormat).format(calendar.getTime()); + + // swap in date string + string = StringUtils.replace(string, dateFormatString, + newDateString); + dateFormatMatcher = dateFormatPattern.matcher(string); + } + + return string; + } + + public static String doDynamicDateFormatReplacement(String string, + Metadata metadata) throws ParseException, CasMetadataException, CommonsException { + Pattern dateFormatPattern = Pattern + .compile("\\[\\s*FORMAT\\s*\\(.{1,}?,.{1,}?,.{1,}?\\)\\s*\\]"); + Matcher dateFormatMatcher = dateFormatPattern.matcher(string); + while (dateFormatMatcher.find()) { + String dateFormatString = string.substring(dateFormatMatcher + .start(), dateFormatMatcher.end()); + + // get arguments + Matcher argMatcher = Pattern.compile("\\(.*\\)").matcher( + dateFormatString); + argMatcher.find(); + String argsString = dateFormatString.substring(argMatcher.start() + 1, + argMatcher.end() - 1); + argsString = doDynamicReplacement(argsString, metadata); + String[] args = argsString.split(","); + String curFormat = args[0].trim(); + String dateString = args[1].trim(); + String newFormat = args[2].trim(); + + // reformat date + Date date = new SimpleDateFormat(curFormat).parse(dateString); + String newDateString = new SimpleDateFormat(newFormat).format(date); + + // swap in date string + string = StringUtils.replace(string, dateFormatString, + newDateString); + dateFormatMatcher = dateFormatPattern.matcher(string); + } + + return string; + } + + /** + * Replaces String method of format [UTC_TO_TAI()] + * with TAI time with format: "yyyy-MM-dd'T'HH:mm:ss.SSS-0000" + */ + public static String doDynamicUtcToTaiDateReplacement(String string, + Metadata metadata) throws ParseException, CommonsException, CasMetadataException { + Pattern utcToTaiPattern = Pattern.compile("\\[\\s*UTC_TO_TAI\\s*\\(.{1,}?\\)\\s*\\]"); + Matcher matcher = utcToTaiPattern.matcher(string); + while (matcher.find()) { + String utcToTaiString = string.substring(matcher.start(), matcher.end()); + Matcher argMatcher = Pattern.compile("\\(.*\\)").matcher(utcToTaiString); + argMatcher.find(); + String utcDateString = + utcToTaiString.substring(argMatcher.start() + 1, argMatcher.end() - 1).trim(); + utcDateString = doDynamicReplacement(utcDateString, metadata); + string = StringUtils.replace(string, utcToTaiString, + DateUtils.toString(DateUtils.toTai(DateUtils.toCalendar(utcDateString, + DateUtils.FormatType.UTC_FORMAT)))); + matcher = utcToTaiPattern.matcher(string); + } + return string; + } + + /** + * Replaces String method of format [DATE_TO_SECS(,,)] + * with seconds between and + */ + public static String doDynamicDateToSecsReplacement(String string, + Metadata metadata) throws CommonsException, ParseException, CasMetadataException { + Pattern utcToTaiPattern = Pattern.compile("\\[\\s*DATE_TO_SECS\\s*\\(.{1,}?\\,.{1,}?,.{1,}?\\)\\s*\\]"); + Matcher matcher = utcToTaiPattern.matcher(string); + while (matcher.find()) { + String dateToSecsString = string.substring(matcher.start(), matcher.end()); + Matcher argMatcher = Pattern.compile("\\(.*\\)").matcher(dateToSecsString); + argMatcher.find(); + String argsString = dateToSecsString.substring(argMatcher.start() + 1, + argMatcher.end() - 1); + argsString = doDynamicReplacement(argsString, metadata); + String[] args = argsString.split(","); + String dateString = args[0].trim(); + String dateType = args[1].trim(); + String epochString = args[2].trim(); + Calendar date = DateUtils.toCalendar(dateString, DateUtils.FormatType.valueOf(dateType)); + Calendar epoch = DateUtils.toLocalCustomFormatCalendar(epochString, "yyyy-MM-dd"); + String seconds = DateUtils.toString(DateUtils.getTimeInSecs(date, epoch)); + string = StringUtils.replace(string, dateToSecsString, seconds); + matcher = utcToTaiPattern.matcher(string); + } + return string; + } + + /** + * Replaces String method of format [DATE_TO_MILLIS(,,)] + * with milliseconds between and + */ + public static String doDynamicDateToMillisReplacement(String string, + Metadata metadata) throws ParseException, CommonsException, CasMetadataException { + Pattern utcToTaiPattern = Pattern.compile("\\[\\s*DATE_TO_MILLIS\\s*\\(.{1,}?\\,.{1,}?,.{1,}?\\)\\s*\\]"); + Matcher matcher = utcToTaiPattern.matcher(string); + while (matcher.find()) { + String dateToMillisString = string.substring(matcher.start(), matcher.end()); + Matcher argMatcher = Pattern.compile("\\(.*\\)").matcher(dateToMillisString); + argMatcher.find(); + String argsString = dateToMillisString.substring(argMatcher.start() + 1, + argMatcher.end() - 1); + argsString = doDynamicReplacement(argsString, metadata); + String[] args = argsString.split(","); + String dateString = args[0].trim(); + String dateType = args[1].trim(); + String epochString = args[2].trim(); + Calendar date = DateUtils.toCalendar(dateString, DateUtils.FormatType.valueOf(dateType)); + Calendar epoch = DateUtils.toLocalCustomFormatCalendar(epochString, "yyyy-MM-dd"); + String milliseconds = DateUtils.getTimeInMillis(date, epoch) + ""; + string = StringUtils.replace(string, dateToMillisString, milliseconds); + matcher = utcToTaiPattern.matcher(string); + } + return string; + } + + private static VarData readEnvVarName(String origPathStr, int startIdx) { + StringBuilder varName = new StringBuilder(); + int idx = startIdx + 1; + + do { + varName.append(origPathStr.charAt(idx)); + idx++; + } while (origPathStr.charAt(idx) != ']'); + + VarData data = new PathUtils().new VarData(); + data.setFieldName(varName.toString()); + data.setEndIdx(idx); + return data; + + } + + class VarData { + + private String fieldName = null; + + private int endIdx = -1; + + public VarData() { + } + + /** + * @return the endIdx + */ + public int getEndIdx() { + return endIdx; + } + + /** + * @param endIdx + * the endIdx to set + */ + public void setEndIdx(int endIdx) { + this.endIdx = endIdx; + } + + /** + * @return the fieldName + */ + public String getFieldName() { + return fieldName; + } + + /** + * @param fieldName + * the fieldName to set + */ + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + } + +} diff --git a/src/main/resources/conf/harvest/examples/harvest-policy-example.xml b/src/main/resources/conf/harvest/examples/harvest-policy-example.xml index ec974e50..6768114e 100644 --- a/src/main/resources/conf/harvest/examples/harvest-policy-example.xml +++ b/src/main/resources/conf/harvest/examples/harvest-policy-example.xml @@ -41,7 +41,7 @@ --> - http://starbase.jpl.nasa.gov + http://pds.nasa.gov $HOME diff --git a/src/main/resources/conf/harvest/examples/harvest-policy-pds3.xml b/src/main/resources/conf/harvest/examples/harvest-policy-pds3.xml index e40d293c..49f1106c 100644 --- a/src/main/resources/conf/harvest/examples/harvest-policy-pds3.xml +++ b/src/main/resources/conf/harvest/examples/harvest-policy-pds3.xml @@ -25,7 +25,7 @@ - http://starbase.jpl.nasa.gov + http://pds.nasa.gov $HOME diff --git a/src/main/resources/conf/search/defaults/pds/pds4/browse.xml b/src/main/resources/conf/search/defaults/pds/pds4/browse.xml index f2ca3937..6a577425 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/browse.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/browse.xml @@ -169,16 +169,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/bundle.xml b/src/main/resources/conf/search/defaults/pds/pds4/bundle.xml index 9fd82ca6..4ef61c80 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/bundle.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/bundle.xml @@ -214,16 +214,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/collection.xml b/src/main/resources/conf/search/defaults/pds/pds4/collection.xml index 0ba1354b..deb2defb 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/collection.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/collection.xml @@ -203,16 +203,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/context.xml b/src/main/resources/conf/search/defaults/pds/pds4/context.xml index a880e85d..ff11e85d 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/context.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/context.xml @@ -275,16 +275,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/document.xml b/src/main/resources/conf/search/defaults/pds/pds4/document.xml index 5a8d7237..ae5bf197 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/document.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/document.xml @@ -192,16 +192,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/external.xml b/src/main/resources/conf/search/defaults/pds/pds4/external.xml index 73e4638a..ca4b254c 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/external.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/external.xml @@ -193,16 +193,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/file_text.xml b/src/main/resources/conf/search/defaults/pds/pds4/file_text.xml index 07aa2550..d4c156a2 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/file_text.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/file_text.xml @@ -168,16 +168,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/observational.xml b/src/main/resources/conf/search/defaults/pds/pds4/observational.xml index 270fbe60..8b29c299 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/observational.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/observational.xml @@ -193,16 +193,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/conf/search/defaults/pds/pds4/service.xml b/src/main/resources/conf/search/defaults/pds/pds4/service.xml index d14c0d75..cb989161 100644 --- a/src/main/resources/conf/search/defaults/pds/pds4/service.xml +++ b/src/main/resources/conf/search/defaults/pds/pds4/service.xml @@ -149,16 +149,16 @@ - file_ref.file_name + file_ref_file_name - file_ref.file_location + file_ref_file_location - file_ref.access_url + file_ref_access_url - file_ref.file_size + file_ref_file_size diff --git a/src/main/resources/policy/global-policy.xml b/src/main/resources/policy/global-policy.xml index 8b6054f1..5c11bfc8 100644 --- a/src/main/resources/policy/global-policy.xml +++ b/src/main/resources/policy/global-policy.xml @@ -284,9 +284,6 @@ //Context_Area/Primary_Result_Summary/Science_Facets/subfacet2 - - //Context_Area/Observing_System/Observing_System_Component[type='Instrument']/name - //Context_Area/Investigation_Area/name diff --git a/src/test/resources/conf/harvest-policy-master.xml b/src/test/resources/conf/harvest-policy-master.xml new file mode 100644 index 00000000..1cb5ea32 --- /dev/null +++ b/src/test/resources/conf/harvest-policy-master.xml @@ -0,0 +1,1323 @@ + + + + + + + + + + + + + {TEST_DATA_HOME} + + *.xml + *.lblx + + + + + + + http://pds.nasa.gov + $HOME + + + + + + + + + + + + + + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Ancillary/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Browse/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Text/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Context_Area/comment + + + //Context_Area/Time_Coordinates/start_date_time + + + //Context_Area/Time_Coordinates/stop_date_time + + + //Context_Area/Time_Coordinates/local_mean_solar_time + + + //Context_Area/Time_Coordinates/local_true_solar_time + + + //Context_Area/Time_Coordinates/solar_longitude + + + //Context_Area/Primary_Result_Summary/purpose + + + //Context_Area/Primary_Result_Summary/processing_level + + + //Context_Area/Primary_Result_Summary/description + + + //Context_Area/Primary_Result_Summary/Science_Facets/wavelength_range + + + //Context_Area/Primary_Result_Summary/Science_Facets/domain + + + //Context_Area/Primary_Result_Summary/Science_Facets/discipline_name + + + //Context_Area/Primary_Result_Summary/Science_Facets/facet1 + + + //Context_Area/Primary_Result_Summary/Science_Facets/subfacet1 + + + //Context_Area/Primary_Result_Summary/Science_Facets/facet2 + + + //Context_Area/Primary_Result_Summary/Science_Facets/subfacet2 + + + //Context_Area/Investigation_Area/name + + + //Context_Area/Investigation_Area/type + + + //Context_Area/Observing_System/name + + + //Context_Area/Observing_System/description + + + //Context_Area/Observing_System/Observing_System_Component/name + + + //Context_Area/Observing_System/Observing_System_Component/type + + + //Context_Area/Observing_System/Observing_System_Component/description + + + //Context_Area/Target_Identification/name + + + //Context_Area/Target_Identification/alternate_designation + + + //Context_Area/Target_Identification/type + + + //Context_Area/Target_Identification/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Native/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Observing_System/Observing_System_Component[type='Spacecraft']/name + + + //Observing_System/Observing_System_Component[type='Instrument']/name + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Observation_Area/comment + + + //Observation_Area/Time_Coordinates/start_date_time + + + //Observation_Area/Time_Coordinates/stop_date_time + + + //Observation_Area/Time_Coordinates/local_mean_solar_time + + + //Observation_Area/Time_Coordinates/local_true_solar_time + + + //Observation_Area/Time_Coordinates/solar_longitude + + + //Observation_Area/Primary_Result_Summary/purpose + + + //Observation_Area/Primary_Result_Summary/processing_level + + + //Observation_Area/Primary_Result_Summary/description + + + //Observation_Area/Primary_Result_Summary/Science_Facets/wavelength_range + + + //Observation_Area/Primary_Result_Summary/Science_Facets/domain + + + //Observation_Area/Primary_Result_Summary/Science_Facets/discipline_name + + + //Observation_Area/Primary_Result_Summary/Science_Facets/facet1 + + + //Observation_Area/Primary_Result_Summary/Science_Facets/subfacet1 + + + //Observation_Area/Primary_Result_Summary/Science_Facets/facet2 + + + //Observation_Area/Primary_Result_Summary/Science_Facets/subfacet2 + + + //Observation_Area/Investigation_Area/name + + + //Observation_Area/Investigation_Area/type + + + //Observation_Area/Observing_System/name + + + //Observation_Area/Observing_System/description + + + //Observation_Area/Observing_System/Observing_System_Component/name + + + //Observation_Area/Observing_System/Observing_System_Component/type + + + //Observation_Area/Observing_System/Observing_System_Component/description + + + //Observation_Area/Target_Identification/name + + + //Observation_Area/Target_Identification/alternate_designation + + + //Observation_Area/Target_Identification/type + + + //Observation_Area/Target_Identification/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Observational/File/file_name + + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Binary/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Context_Area/comment + + + //Context_Area/Time_Coordinates/start_date_time + + + //Context_Area/Time_Coordinates/stop_date_time + + + //Context_Area/Time_Coordinates/local_mean_solar_time + + + //Context_Area/Time_Coordinates/local_true_solar_time + + + //Context_Area/Time_Coordinates/solar_longitude + + + //Context_Area/Primary_Result_Summary/purpose + + + //Context_Area/Primary_Result_Summary/processing_level + + + //Context_Area/Primary_Result_Summary/description + + + //Context_Area/Primary_Result_Summary/Science_Facets/wavelength_range + + + //Context_Area/Primary_Result_Summary/Science_Facets/domain + + + //Context_Area/Primary_Result_Summary/Science_Facets/discipline_name + + + //Context_Area/Primary_Result_Summary/Science_Facets/facet1 + + + //Context_Area/Primary_Result_Summary/Science_Facets/subfacet1 + + + //Context_Area/Primary_Result_Summary/Science_Facets/facet2 + + + //Context_Area/Primary_Result_Summary/Science_Facets/subfacet2 + + + //Context_Area/Investigation_Area/name + + + //Context_Area/Investigation_Area/type + + + //Context_Area/Observing_System/name + + + //Context_Area/Observing_System/description + + + //Context_Area/Observing_System/Observing_System_Component/name + + + //Context_Area/Observing_System/Observing_System_Component/type + + + //Context_Area/Observing_System/Observing_System_Component/description + + + //Context_Area/Target_Identification/name + + + //Context_Area/Target_Identification/alternate_designation + + + //Context_Area/Target_Identification/type + + + //Context_Area/Target_Identification/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_SPICE_Kernel/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Observation_Area/Investigation_Area/name + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Service/name + + + //Service/abstract_desc + + + //Service/version_id + + + //Service/url + + + //Service/release_date + + + //Service/service_type + + + //Service/interface_type + + + //Service/category + + + //Service/software_language + + + //Service/supported_operating_system_note + + + //Service/system_requirements_note + + + //Service/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Service_Description/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + //Software/name + + //Software/version_id + + //Software/software_version_id + //Software/author_list + //Software/programmers_manual_id + //Software/software_id + //Software/software_type + //Software/users_manual_id + //Software/description + + + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_Encoded_Image/File/file_name + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //Reference_List/External_Reference/doi + + + //Reference_List/External_Reference/reference_text + + + //Reference_List/External_Reference/description + + + //Reference_List/Source_Product_External/curating_facility + + + //Reference_List/Source_Product_External/description + + + //Reference_List/Source_Product_External/doi + + + //Reference_List/Source_Product_External/external_source_product_identifier + + + //Reference_List/Source_Product_External/reference_type + + + + //File_Area_XML_Schema/File/file_name + + + + + + //container_type + + + + //Identification_Area/information_model_version + + + //Identification_Area/product_class + + + //Identification_Area/Alias_List/Alias/alternate_id + + + //Identification_Area/Alias_List/Alias/alternate_title + + + //Identification_Area/Citation_Information/author_list + + + //Identification_Area/Citation_Information/editor_list + + + //Identification_Area/Citation_Information/publication_year + + + //Identification_Area/Citation_Information/keyword + + + //Identification_Area/Citation_Information/description + + + //Identification_Area/Citation_Information/doi + + + //Identification_Area/Modification_History/Modification_Detail/modification_date + + + //Identification_Area/Modification_History/Modification_Detail/version_id + + + //Identification_Area/Modification_History/Modification_Detail/description + + + + //File/file_name + + + + + diff --git a/src/test/resources/data/test1/a17leamcal_custom/bundle.xml b/src/test/resources/data/test1/a17leamcal_custom/bundle.xml new file mode 100644 index 00000000..59cff7c0 --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/bundle.xml @@ -0,0 +1,123 @@ + + + + + + urn:nasa:pds:a17leamcal + 1.0 + Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Bundle + 1.11.0.0 + Product_Bundle + + Berg, O.E.; Williams, D.R.; Gaddy, M. + Williams, D.R.; McLaughlin, S.A. + 2017 + 10.17189/1519335 + This bundle contains a digital reproduction of one hand-written laboratory + notebook of calibration analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) + Experiment detector, which was identical to Pioneer 8 and 9 Cosmic Dust Detectors + (CDD). + + + + 2015-05-22 + 1.0 + Creation. + + + + + + + 1972-12-07Z + + 1977-09-30Z + + + Science + Derived + Digital reproduction of one hand-written laboratory notebook of calibration + analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) Experiment detector, which was + identical to the Pioneer 8 and 9 Cosmic Dust Detectors (CDD). + + + Apollo 17 + Mission + + urn:nasa:pds:context:investigation:mission.apollo_17 + bundle_to_investigation + + + + + Apollo 17 ALSEP + Spacecraft + + urn:nasa:pds:context:instrument_host:spacecraft.a17a + is_instrument_host + + + + Apollo 17 Lunar Ejecta And Meteorites Experiment + Instrument + + urn:nasa:pds:context:instrument:leam.a17a + is_instrument + + + + + Moon + Satellite + + urn:nasa:pds:context:target:satellite.earth.moon + bundle_to_target + + + + Dust + Dust + + urn:nasa:pds:context:target:dust.dust + bundle_to_target + + + + + + urn:nasa:pds:context:resource:resource.a17leamcal_online + bundle_to_resource + + + urn:nasa:pds:context:resource:resource.a17leamcal_2_online + bundle_to_resource + + + + Archive + + + + readme.txt + 600 + + + 0 + 7-Bit ASCII Text + Brief overview of this bundle. + Carriage-Return Line-Feed + + + + urn:nasa:pds:a17leamcal:calibration + Primary + bundle_has_calibration_collection + + + urn:nasa:pds:a17leamcal:data + Primary + bundle_has_data_collection + + diff --git a/src/test/resources/data/test1/a17leamcal_custom/collection_calibration.xml b/src/test/resources/data/test1/a17leamcal_custom/collection_calibration.xml new file mode 100644 index 00000000..2b1c76f8 --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/collection_calibration.xml @@ -0,0 +1,235 @@ + + + + + + urn:nasa:pds:a17leamcal:calibration + 1.0 + Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Collection + 1.7.0.0 + Product_Collection + + Berg, O.E.; Williams, D.R.; Gaddy, M. + Williams, D.R.; McLaughlin, S.A. + 2017 + This collection contains a digital reproduction of one hand-written laboratory + notebook of calibration analysis by Dr. Otto E. Berg for the Apollo 17 Lunar Ejecta And + Meteorites (LEAM) Experiment. Dr. Berg used this work along with analyses of data acquired by + the Pioneer 8 and 9 Cosmic Dust Detectors, which were identical to LEAM detector, to + calibrate the Apollo 17 LEAM data. Dr. Berg was the principal investigator for all three + instruments. + + + + 2015-05-22 + 1.0 + Creation. + + + + + + + 1972-12-07Z + + 1977-09-30Z + + + Science + Derived + Digital reproduction of one hand-written laboratory notebook of calibration + analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) Experiment detector, which was + identical to the Pioneer 8 and 9 Cosmic Dust Detectors (CDD). + + + Apollo 17 + Mission + + urn:nasa:pds:context:investigation:mission.apollo_17 + collection_to_investigation + + + + + Apollo 17 ALSEP + Spacecraft + + urn:nasa:pds:context:instrument_host:spacecraft.a17a + is_instrument_host + + + + Apollo 17 Lunar Ejecta And Meteorites Experiment + Instrument + + urn:nasa:pds:context:instrument:leam.a17a + is_instrument + + + + + Moon + Satellite + + urn:nasa:pds:context:target:satellite.earth.moon + collection_to_target + + + + Dust + Dust + + urn:nasa:pds:context:target:dust.dust + collection_to_target + + + + + + urn:nasa:pds:context:resource:resource.a17leamcal_online + collection_to_resource + + + urn:nasa:pds:context:resource:resource.a17leamcal_2_online + collection_to_resource + + + urn:nasa:pds:a17leamcal:calibration:overview + collection_to_document + + + urn:nasa:pds:apollodoc:a17doc:a17a_leam_overview + collection_to_document + Overview of the Apollo 17 ALSEP Lunar Ejecta And Meteorites (LEAM) + Experiment + + + urn:nasa:pds:pioneerdoc:p8doc:p8_cdd_overview + collection_to_document + Overview of the Pioneer 8 Cosmic Dust Detector (CDD); CDD data helped calibration + results from the Apollo 17 LEAM instrument, which was identical to the Pioneer CDDs + + + urn:nasa:pds:pioneerdoc:p9doc:p9_cdd_overview + collection_to_document + Overview of the Pioneer 9 Cosmic Dust Detector (CDD); CDD data helped calibration + results from the Apollo 17 LEAM instrument, which was identical to the Pioneer CDDs + + + urn:nasa:pds:pioneer89cdd:calibration + collection_to_calibration + This collection contains digital reproductions of two hand-written laboratory + notebooks of calibration analyses by Dr. Otto E. Berg for the Pioneer 8 and 9 Cosmic Dust + Detectors (CDD). + + + Apollo 17 Preliminary Science Report, NASA SP-330, published by NASA, + Washington, D.C., 1973. + + + Apollo Scientific Experiments Data Handbook, NASA Technical Memorandum + X-58131, JSC-09166, published by NASA Johnson Space Center, Houston, Texas, Aug. 1974 + (revised Apr. 1976). + + + Auer, S. and O.E. Berg, Levitated lunar surface dust as evidenced by the LEAM + experiment, In: Proceedings of European Planetary Science Congress 2008; Proceedings of the + conference held 21-25 September 2008 in Munster, Germany, p. 705, 2008. + + + Bates, J.R., W.W. Lauderdale, and H. Kernaghan, ALSEP Termination Report, + NASA Reference Publication Series, NASA RF-1036, published by NASA Johnson Space Center, + Houston, Texas, Apr. 1979. + + + 10.1029/GL001i007p00289 + Berg, O.E., F.F. Richardson, J.W. Rhee and S. Auer, Preliminary results of a + cosmic dust experiment on the moon, Geophysical Research Letters, Volume 1, Issue 7, pp. + 289-290, 1974. + + + 10.1007/3-540-07615-8_486B + Berg, O.E., H. Wolf and J. Rhee, Lunar Soil Movement Registered by the Apollo + 17 Cosmic Dust Experiment, In: Elsasser H., Fechting H. (eds); Interplanetary Dust and + Zodiacal Light, Lecture Notes in Physics, Volume 48, Springer, Berlin, Heidelberg, + 1976. + + + 10.1029/1999JE001165 + Davies, M.E., and T.R. Colvin, Lunar coordinates in the regions of the Apollo + landers, Journal of Geophysical Research, Volume 105, Issue E8, pages 20,227-20,280, + 2000. + + + 10.1016/j.pss.2011.04.005 + Grun, E., M. Horanyi and Z. Sternovsky, The lunar dust environment, Planetary + and Space Science, Volume 59, Issue 14, pp. 1672-1680, 2011. + + + 10.1016/j.pss.2013.10.005 + Grun, E. and M. Horanyi, A new look at Apollo 17 LEAM data: Nighttime dust + activity in 1976, Planetary and Space Science, Volume 89, pp. 2-14, 2013. + + + 10.1016/j.pss.2011.04.016 + O'Brien, B.J., Review of measurements of dust movements on the Moon during + Apollo, Planetary and Space Science, Volume 59, Issue 14, pp. 1708-1726, + 2011. + + + Perkins, D.H., Final Report - Analysis of LEAM experiment response to charged + particles, NASA-CR-147872, NASA contract no. NAS9-14751, Bendix Aerospace Systems Division, BSR + 4234, 1976. + + + Rhee, J.W., O.E. Berg and H. Wolf, Electrostatic dust transport and Apollo 17 + LEAM experiment, In: Space research XVII; Proceedings of the Open Meetings of Working Groups + on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and Excited + Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, Pergamon + Press, pp. 627-629, 1977. + + + Tomandl, D.A. and O.E. Berg, An upper limit for the flux of interstellar dust + grains in the solar system, In: Space research XVII; Proceedings of the Open Meetings of + Working Groups on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and + Excited Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, + Pergamon Press, pp. 631-635, 1977. + + + + Calibration + + + + collection_calibration_inventory.csv + + + 0 + PDS DSV 1 + 4 + Carriage-Return Line-Feed + Comma + + 2 + 0 + + Member Status + 1 + ASCII_String + 1 + %1s + + + LIDVID_LID + 2 + ASCII_LIDVID_LID + 255 + %-255s + + + inventory_has_member_product + + + diff --git a/src/test/resources/data/test1/a17leamcal_custom/collection_calibration_inventory.csv b/src/test/resources/data/test1/a17leamcal_custom/collection_calibration_inventory.csv new file mode 100644 index 00000000..798017af --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/collection_calibration_inventory.csv @@ -0,0 +1,4 @@ +P,urn:nasa:pds:a17leamcal:calibration:a17_leam_calib_notebook::1.0 +P,urn:nasa:pds:a17leamcal:calibration:a17_leam_calib_notebook_table_of_contents::1.0 +P,urn:nasa:pds:a17leamcal:calibration:a17_psr_ch16_leam::1.0 +P,urn:nasa:pds:a17leamcal:calibration:overview::1.0 diff --git a/src/test/resources/data/test1/a17leamcal_custom/collection_data.xml b/src/test/resources/data/test1/a17leamcal_custom/collection_data.xml new file mode 100644 index 00000000..2f6fb60a --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/collection_data.xml @@ -0,0 +1,230 @@ + + + + + + urn:nasa:pds:a17leamcal:data + 1.0 + Apollo 17 Lunar Ejecta And Meteorites Experiment Data Notebook Fake Test Collection + 1.7.0.0 + Product_Collection + + Berg, O.E.; Williams, D.R.; Gaddy, M. + Williams, D.R.; McLaughlin, S.A. + 2017 + Fake test collection + + + + 2015-05-22 + 1.0 + Creation. + + + + + + + 1972-12-07Z + + 1977-09-30Z + + + Science + Derived + Digital reproduction of one hand-written laboratory notebook of calibration + analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) Experiment detector, which was + identical to the Pioneer 8 and 9 Cosmic Dust Detectors (CDD). + + + Apollo 17 + Mission + + urn:nasa:pds:context:investigation:mission.apollo_17 + collection_to_investigation + + + + + Apollo 17 ALSEP + Spacecraft + + urn:nasa:pds:context:instrument_host:spacecraft.a17a + is_instrument_host + + + + Apollo 17 Lunar Ejecta And Meteorites Experiment + Instrument + + urn:nasa:pds:context:instrument:leam.a17a + is_instrument + + + + + Moon + Satellite + + urn:nasa:pds:context:target:satellite.earth.moon + collection_to_target + + + + Dust + Dust + + urn:nasa:pds:context:target:dust.dust + collection_to_target + + + + + + urn:nasa:pds:context:resource:resource.a17leamcal_online + collection_to_resource + + + urn:nasa:pds:context:resource:resource.a17leamcal_2_online + collection_to_resource + + + urn:nasa:pds:a17leamcal:calibration:overview + collection_to_document + + + urn:nasa:pds:apollodoc:a17doc:a17a_leam_overview + collection_to_document + Overview of the Apollo 17 ALSEP Lunar Ejecta And Meteorites (LEAM) + Experiment + + + urn:nasa:pds:pioneerdoc:p8doc:p8_cdd_overview + collection_to_document + Overview of the Pioneer 8 Cosmic Dust Detector (CDD); CDD data helped calibration + results from the Apollo 17 LEAM instrument, which was identical to the Pioneer CDDs + + + urn:nasa:pds:pioneerdoc:p9doc:p9_cdd_overview + collection_to_document + Overview of the Pioneer 9 Cosmic Dust Detector (CDD); CDD data helped calibration + results from the Apollo 17 LEAM instrument, which was identical to the Pioneer CDDs + + + urn:nasa:pds:pioneer89cdd:calibration + collection_to_calibration + This collection contains digital reproductions of two hand-written laboratory + notebooks of calibration analyses by Dr. Otto E. Berg for the Pioneer 8 and 9 Cosmic Dust + Detectors (CDD). + + + Apollo 17 Preliminary Science Report, NASA SP-330, published by NASA, + Washington, D.C., 1973. + + + Apollo Scientific Experiments Data Handbook, NASA Technical Memorandum + X-58131, JSC-09166, published by NASA Johnson Space Center, Houston, Texas, Aug. 1974 + (revised Apr. 1976). + + + Auer, S. and O.E. Berg, Levitated lunar surface dust as evidenced by the LEAM + experiment, In: Proceedings of European Planetary Science Congress 2008; Proceedings of the + conference held 21-25 September 2008 in Munster, Germany, p. 705, 2008. + + + Bates, J.R., W.W. Lauderdale, and H. Kernaghan, ALSEP Termination Report, + NASA Reference Publication Series, NASA RF-1036, published by NASA Johnson Space Center, + Houston, Texas, Apr. 1979. + + + 10.1029/GL001i007p00289 + Berg, O.E., F.F. Richardson, J.W. Rhee and S. Auer, Preliminary results of a + cosmic dust experiment on the moon, Geophysical Research Letters, Volume 1, Issue 7, pp. + 289-290, 1974. + + + 10.1007/3-540-07615-8_486B + Berg, O.E., H. Wolf and J. Rhee, Lunar Soil Movement Registered by the Apollo + 17 Cosmic Dust Experiment, In: Elsasser H., Fechting H. (eds); Interplanetary Dust and + Zodiacal Light, Lecture Notes in Physics, Volume 48, Springer, Berlin, Heidelberg, + 1976. + + + 10.1029/1999JE001165 + Davies, M.E., and T.R. Colvin, Lunar coordinates in the regions of the Apollo + landers, Journal of Geophysical Research, Volume 105, Issue E8, pages 20,227-20,280, + 2000. + + + 10.1016/j.pss.2011.04.005 + Grun, E., M. Horanyi and Z. Sternovsky, The lunar dust environment, Planetary + and Space Science, Volume 59, Issue 14, pp. 1672-1680, 2011. + + + 10.1016/j.pss.2013.10.005 + Grun, E. and M. Horanyi, A new look at Apollo 17 LEAM data: Nighttime dust + activity in 1976, Planetary and Space Science, Volume 89, pp. 2-14, 2013. + + + 10.1016/j.pss.2011.04.016 + O'Brien, B.J., Review of measurements of dust movements on the Moon during + Apollo, Planetary and Space Science, Volume 59, Issue 14, pp. 1708-1726, + 2011. + + + Perkins, D.H., Final Report - Analysis of LEAM experiment response to charged + particles, NASA-CR-147872, NASA contract no. NAS9-14751, Bendix Aerospace Systems Division, BSR + 4234, 1976. + + + Rhee, J.W., O.E. Berg and H. Wolf, Electrostatic dust transport and Apollo 17 + LEAM experiment, In: Space research XVII; Proceedings of the Open Meetings of Working Groups + on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and Excited + Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, Pergamon + Press, pp. 627-629, 1977. + + + Tomandl, D.A. and O.E. Berg, An upper limit for the flux of interstellar dust + grains in the solar system, In: Space research XVII; Proceedings of the Open Meetings of + Working Groups on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and + Excited Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, + Pergamon Press, pp. 631-635, 1977. + + + + Data + + + + collection_data_inventory.csv + + + 0 + PDS DSV 1 + 4 + Carriage-Return Line-Feed + Comma + + 2 + 0 + + Member Status + 1 + ASCII_String + 1 + %1s + + + LIDVID_LID + 2 + ASCII_LIDVID_LID + 255 + %-255s + + + inventory_has_member_product + + + diff --git a/src/test/resources/data/test1/a17leamcal_custom/collection_data_inventory.csv b/src/test/resources/data/test1/a17leamcal_custom/collection_data_inventory.csv new file mode 100644 index 00000000..5950c47f --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/collection_data_inventory.csv @@ -0,0 +1,4 @@ +P,urn:nasa:pds:a17leamcal:data:a17_leam_calib_notebook::1.0 +P,urn:nasa:pds:a17leamcal:data:a17_leam_calib_notebook_table_of_contents::1.0 +P,urn:nasa:pds:a17leamcal:data:a17_psr_ch16_leam::1.0 +P,urn:nasa:pds:a17leamcal:data:overview::1.0 diff --git a/src/test/resources/data/test1/a17leamcal_custom/readme.txt b/src/test/resources/data/test1/a17leamcal_custom/readme.txt new file mode 100644 index 00000000..b10fb312 --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/readme.txt @@ -0,0 +1,12 @@ +Bundle Overview +=============== + +This bundle contains the Apollo 17 Lunar Ejecta And Meteorites (LEAM) +Experiment Calibration Notebook Collection that consists of a digital +reproduction of one hand-written laboratory notebook of calibration analysis +by Dr. Otto E. Berg, the principal investigator. Dr. Berg used this work +along with analyses of data acquired by the Pioneer 8 and 9 Cosmic Dust +Detectors, which were identical to LEAM detector, to calibrate the Apollo 17 +LEAM data. The collection includes the LEAM chapter Apollo 17 Preliminary +Science Report as a supporting document. + diff --git a/src/test/resources/data/test1/a17leamcal_custom/resource_a17leamcal.xml b/src/test/resources/data/test1/a17leamcal_custom/resource_a17leamcal.xml new file mode 100644 index 00000000..595b77d5 --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/resource_a17leamcal.xml @@ -0,0 +1,32 @@ + + + + + + urn:nasa:pds:context:resource:resource.a17leamcal_online + 1.0 + Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Archive Online + 1.14.0.0 + Product_Context + + + 2020-09-09 + 1.0 + + Initial revision. + + + + + + + Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Online + Information.Science_Portal + https://pds-geosciences.wustl.edu/missions/apollo/index.htm + + Initial version of Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook + + + diff --git a/src/test/resources/data/test1/a17leamcal_custom/resource_a17leamcal_2.xml b/src/test/resources/data/test1/a17leamcal_custom/resource_a17leamcal_2.xml new file mode 100644 index 00000000..b43b54c2 --- /dev/null +++ b/src/test/resources/data/test1/a17leamcal_custom/resource_a17leamcal_2.xml @@ -0,0 +1,32 @@ + + + + + + urn:nasa:pds:context:resource:resource.a17leamcal_2_online + 1.0 + Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 Archive Online + 1.14.0.0 + Product_Context + + + 2020-09-09 + 1.0 + + Initial revision. + + + + + + + Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 Online + Information.Science_Portal + https://pds-geosciences.wustl.edu/lunar/urn-nasa-pds-a17leamcal/ + + Initial version of Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 + + + diff --git a/src/test/resources/data/test1/expected/solr_doc_expected.xml b/src/test/resources/data/test1/expected/solr_doc_expected.xml new file mode 100644 index 00000000..b665f57d --- /dev/null +++ b/src/test/resources/data/test1/expected/solr_doc_expected.xml @@ -0,0 +1,325 @@ + + +Digital reproduction of one hand-written laboratory notebook of calibration + analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) Experiment detector, which was + identical to the Pioneer 8 and 9 Cosmic Dust Detectors (CDD). +Apollo 17 +Apollo 17 ALSEP +urn:nasa:pds:a17leamcal:data +Data +Product_Collection +Product_Collection +Berg, O.E.; Williams, D.R.; Gaddy, M. +urn:nasa:pds:context:instrument:leam.a17a +11400 +241 +2015-05-22T00:00:00.000Z +Apollo 17 Preliminary Science Report, NASA SP-330, published by NASA, + Washington, D.C., 1973. +Apollo Scientific Experiments Data Handbook, NASA Technical Memorandum + X-58131, JSC-09166, published by NASA Johnson Space Center, Houston, Texas, Aug. 1974 + (revised Apr. 1976). +Auer, S. and O.E. Berg, Levitated lunar surface dust as evidenced by the LEAM + experiment, In: Proceedings of European Planetary Science Congress 2008; Proceedings of the + conference held 21-25 September 2008 in Munster, Germany, p. 705, 2008. +Bates, J.R., W.W. Lauderdale, and H. Kernaghan, ALSEP Termination Report, + NASA Reference Publication Series, NASA RF-1036, published by NASA Johnson Space Center, + Houston, Texas, Apr. 1979. +Berg, O.E., F.F. Richardson, J.W. Rhee and S. Auer, Preliminary results of a + cosmic dust experiment on the moon, Geophysical Research Letters, Volume 1, Issue 7, pp. + 289-290, 1974. +Berg, O.E., H. Wolf and J. Rhee, Lunar Soil Movement Registered by the Apollo + 17 Cosmic Dust Experiment, In: Elsasser H., Fechting H. (eds); Interplanetary Dust and + Zodiacal Light, Lecture Notes in Physics, Volume 48, Springer, Berlin, Heidelberg, + 1976. +Davies, M.E., and T.R. Colvin, Lunar coordinates in the regions of the Apollo + landers, Journal of Geophysical Research, Volume 105, Issue E8, pages 20,227-20,280, + 2000. +Grun, E., M. Horanyi and Z. Sternovsky, The lunar dust environment, Planetary + and Space Science, Volume 59, Issue 14, pp. 1672-1680, 2011. +Grun, E. and M. Horanyi, A new look at Apollo 17 LEAM data: Nighttime dust + activity in 1976, Planetary and Space Science, Volume 89, pp. 2-14, 2013. +O'Brien, B.J., Review of measurements of dust movements on the Moon during + Apollo, Planetary and Space Science, Volume 59, Issue 14, pp. 1708-1726, + 2011. +Perkins, D.H., Final Report - Analysis of LEAM experiment response to charged + particles, NASA-CR-147872, NASA contract no. NAS9-14751, Bendix Aerospace Systems Division, BSR + 4234, 1976. +Rhee, J.W., O.E. Berg and H. Wolf, Electrostatic dust transport and Apollo 17 + LEAM experiment, In: Space research XVII; Proceedings of the Open Meetings of Working Groups + on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and Excited + Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, Pergamon + Press, pp. 627-629, 1977. +Tomandl, D.A. and O.E. Berg, An upper limit for the flux of interstellar dust + grains in the solar system, In: Space research XVII; Proceedings of the Open Meetings of + Working Groups on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and + Excited Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, + Pergamon Press, pp. 631-635, 1977. +collection_data.xml +collection_data_inventory.csv +1977-09-30T00:00:00.000Z +Creation. +urn:nasa:pds:context:instrument_host:spacecraft.a17a +Spacecraft +Instrument +pds4 +Derived +Apollo 17 Lunar Ejecta And Meteorites Experiment +Fake test collection +1972-12-07T00:00:00.000Z +Moon +Dust +4 +Fake test collection +2017 +Apollo 17 Lunar Ejecta And Meteorites Experiment Data Notebook Fake Test Collection +/ds-view/pds/viewCollection.jsp?identifier=urn%3Anasa%3Apds%3Aa17leamcal%3Adata&version=1.0 +Collection +10.1029/GL001i007p00289 +10.1007/3-540-07615-8_486B +10.1029/1999JE001165 +10.1016/j.pss.2011.04.005 +10.1016/j.pss.2013.10.005 +10.1016/j.pss.2011.04.016 +Science +Williams, D.R.; McLaughlin, S.A. +nasa +urn:nasa:pds:context:target:satellite.earth.moon +urn:nasa:pds:context:target:dust.dust +collection_data_inventory.csv +Satellite +Dust +1.0 +urn:nasa:pds:context:investigation:mission.apollo_17 +pds4:urn:nasa:pds:a17leamcal:data +urn:nasa:pds:context:resource:resource.a17leamcal_online +urn:nasa:pds:context:resource:resource.a17leamcal_2_online +Mission +Apollo 17 ALSEP +Apollo 17 Lunar Ejecta And Meteorites Experiment + + +urn:nasa:pds:context:resource:resource.a17leamcal_online +Resource +Product_Context +Product_Context +1579 +2020-09-09T00:00:00.000Z +resource_a17leamcal.xml +https://pds-geosciences.wustl.edu/missions/apollo/index.htm + + Initial revision. + +Information.Science_Portal +pds4 + + Initial version of Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook + + + Initial version of Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook + +Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Archive Online +https://pds-geosciences.wustl.edu/missions/apollo/index.htm +Resource +nasa +1.0 +pds4:urn:nasa:pds:context:resource:resource.a17leamcal_online +Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Online + + +Digital reproduction of one hand-written laboratory notebook of calibration + analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) Experiment detector, which was + identical to the Pioneer 8 and 9 Cosmic Dust Detectors (CDD). +Apollo 17 +Apollo 17 ALSEP +urn:nasa:pds:a17leamcal +Product_Bundle +Product_Bundle +Berg, O.E.; Williams, D.R.; Gaddy, M. +urn:nasa:pds:context:instrument:leam.a17a +5346 +600 +2015-05-22T00:00:00.000Z +bundle.xml +readme.txt +1977-09-30T00:00:00.000Z +Creation. +urn:nasa:pds:context:instrument_host:spacecraft.a17a +Spacecraft +Instrument +pds4 +Derived +Archive +Apollo 17 Lunar Ejecta And Meteorites Experiment +10.17189/1519335 +This bundle contains a digital reproduction of one hand-written laboratory + notebook of calibration analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) + Experiment detector, which was identical to Pioneer 8 and 9 Cosmic Dust Detectors + (CDD). +1972-12-07T00:00:00.000Z +Moon +Dust +This bundle contains a digital reproduction of one hand-written laboratory + notebook of calibration analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) + Experiment detector, which was identical to Pioneer 8 and 9 Cosmic Dust Detectors + (CDD). +2017 +Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Bundle +/ds-view/pds/viewBundle.jsp?identifier=urn%3Anasa%3Apds%3Aa17leamcal&version=1.0 +Bundle +Science +Williams, D.R.; McLaughlin, S.A. +nasa +urn:nasa:pds:context:target:satellite.earth.moon +urn:nasa:pds:context:target:dust.dust +Satellite +Dust +1.0 +urn:nasa:pds:context:investigation:mission.apollo_17 +pds4:urn:nasa:pds:a17leamcal +urn:nasa:pds:context:resource:resource.a17leamcal_online +urn:nasa:pds:context:resource:resource.a17leamcal_2_online +Mission +urn:nasa:pds:a17leamcal:calibration +urn:nasa:pds:a17leamcal:data +Apollo 17 ALSEP +Apollo 17 Lunar Ejecta And Meteorites Experiment + + +urn:nasa:pds:context:resource:resource.a17leamcal_2_online +Resource +Product_Context +Product_Context +1592 +2020-09-09T00:00:00.000Z +resource_a17leamcal_2.xml +https://pds-geosciences.wustl.edu/lunar/urn-nasa-pds-a17leamcal/ + + Initial revision. + +Information.Science_Portal +pds4 + + Initial version of Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 + + + Initial version of Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 + +Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 Archive Online +https://pds-geosciences.wustl.edu/lunar/urn-nasa-pds-a17leamcal/ +Resource +nasa +1.0 +pds4:urn:nasa:pds:context:resource:resource.a17leamcal_2_online +Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook 2 Online + + +Digital reproduction of one hand-written laboratory notebook of calibration + analysis for the Apollo 17 Lunar Ejecta And Meteorites (LEAM) Experiment detector, which was + identical to the Pioneer 8 and 9 Cosmic Dust Detectors (CDD). +Apollo 17 +Apollo 17 ALSEP +urn:nasa:pds:a17leamcal:calibration +Calibration +Product_Collection +Product_Collection +Berg, O.E.; Williams, D.R.; Gaddy, M. +urn:nasa:pds:context:instrument:leam.a17a +11875 +269 +2015-05-22T00:00:00.000Z +Apollo 17 Preliminary Science Report, NASA SP-330, published by NASA, + Washington, D.C., 1973. +Apollo Scientific Experiments Data Handbook, NASA Technical Memorandum + X-58131, JSC-09166, published by NASA Johnson Space Center, Houston, Texas, Aug. 1974 + (revised Apr. 1976). +Auer, S. and O.E. Berg, Levitated lunar surface dust as evidenced by the LEAM + experiment, In: Proceedings of European Planetary Science Congress 2008; Proceedings of the + conference held 21-25 September 2008 in Munster, Germany, p. 705, 2008. +Bates, J.R., W.W. Lauderdale, and H. Kernaghan, ALSEP Termination Report, + NASA Reference Publication Series, NASA RF-1036, published by NASA Johnson Space Center, + Houston, Texas, Apr. 1979. +Berg, O.E., F.F. Richardson, J.W. Rhee and S. Auer, Preliminary results of a + cosmic dust experiment on the moon, Geophysical Research Letters, Volume 1, Issue 7, pp. + 289-290, 1974. +Berg, O.E., H. Wolf and J. Rhee, Lunar Soil Movement Registered by the Apollo + 17 Cosmic Dust Experiment, In: Elsasser H., Fechting H. (eds); Interplanetary Dust and + Zodiacal Light, Lecture Notes in Physics, Volume 48, Springer, Berlin, Heidelberg, + 1976. +Davies, M.E., and T.R. Colvin, Lunar coordinates in the regions of the Apollo + landers, Journal of Geophysical Research, Volume 105, Issue E8, pages 20,227-20,280, + 2000. +Grun, E., M. Horanyi and Z. Sternovsky, The lunar dust environment, Planetary + and Space Science, Volume 59, Issue 14, pp. 1672-1680, 2011. +Grun, E. and M. Horanyi, A new look at Apollo 17 LEAM data: Nighttime dust + activity in 1976, Planetary and Space Science, Volume 89, pp. 2-14, 2013. +O'Brien, B.J., Review of measurements of dust movements on the Moon during + Apollo, Planetary and Space Science, Volume 59, Issue 14, pp. 1708-1726, + 2011. +Perkins, D.H., Final Report - Analysis of LEAM experiment response to charged + particles, NASA-CR-147872, NASA contract no. NAS9-14751, Bendix Aerospace Systems Division, BSR + 4234, 1976. +Rhee, J.W., O.E. Berg and H. Wolf, Electrostatic dust transport and Apollo 17 + LEAM experiment, In: Space research XVII; Proceedings of the Open Meetings of Working Groups + on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and Excited + Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, Pergamon + Press, pp. 627-629, 1977. +Tomandl, D.A. and O.E. Berg, An upper limit for the flux of interstellar dust + grains in the solar system, In: Space research XVII; Proceedings of the Open Meetings of + Working Groups on Physical Sciences, June 8-19, 1976 and Symposium on Minor Constituents and + Excited Species, Philadelphia, Pa., June 9, 10, 1976. (A78-18101 05-42) Oxford and New York, + Pergamon Press, pp. 631-635, 1977. +collection_calibration.xml +collection_calibration_inventory.csv +1977-09-30T00:00:00.000Z +Creation. +urn:nasa:pds:context:instrument_host:spacecraft.a17a +Spacecraft +Instrument +pds4 +Derived +Apollo 17 Lunar Ejecta And Meteorites Experiment +This collection contains a digital reproduction of one hand-written laboratory + notebook of calibration analysis by Dr. Otto E. Berg for the Apollo 17 Lunar Ejecta And + Meteorites (LEAM) Experiment. Dr. Berg used this work along with analyses of data acquired by + the Pioneer 8 and 9 Cosmic Dust Detectors, which were identical to LEAM detector, to + calibrate the Apollo 17 LEAM data. Dr. Berg was the principal investigator for all three + instruments. +1972-12-07T00:00:00.000Z +Moon +Dust +4 +This collection contains a digital reproduction of one hand-written laboratory + notebook of calibration analysis by Dr. Otto E. Berg for the Apollo 17 Lunar Ejecta And + Meteorites (LEAM) Experiment. Dr. Berg used this work along with analyses of data acquired by + the Pioneer 8 and 9 Cosmic Dust Detectors, which were identical to LEAM detector, to + calibrate the Apollo 17 LEAM data. Dr. Berg was the principal investigator for all three + instruments. +2017 +Apollo 17 Lunar Ejecta And Meteorites Experiment Calibration Notebook Collection +/ds-view/pds/viewCollection.jsp?identifier=urn%3Anasa%3Apds%3Aa17leamcal%3Acalibration&version=1.0 +Collection +10.1029/GL001i007p00289 +10.1007/3-540-07615-8_486B +10.1029/1999JE001165 +10.1016/j.pss.2011.04.005 +10.1016/j.pss.2013.10.005 +10.1016/j.pss.2011.04.016 +Science +Williams, D.R.; McLaughlin, S.A. +nasa +urn:nasa:pds:context:target:satellite.earth.moon +urn:nasa:pds:context:target:dust.dust +collection_calibration_inventory.csv +Satellite +Dust +1.0 +urn:nasa:pds:context:investigation:mission.apollo_17 +pds4:urn:nasa:pds:a17leamcal:calibration +urn:nasa:pds:context:resource:resource.a17leamcal_online +urn:nasa:pds:context:resource:resource.a17leamcal_2_online +Mission +Apollo 17 ALSEP +Apollo 17 Lunar Ejecta And Meteorites Experiment + + diff --git a/src/test/resources/harvest-test-archive.tar.gz b/src/test/resources/harvest-test-archive.tar.gz deleted file mode 100644 index 36d25ea1..00000000 Binary files a/src/test/resources/harvest-test-archive.tar.gz and /dev/null differ diff --git a/src/test/resources/policy/unlabeled-files/harvest-policy-mslhaz_1xxx.xml b/src/test/resources/policy/unlabeled-files/harvest-policy-mslhaz_1xxx.xml deleted file mode 100644 index 427f9641..00000000 --- a/src/test/resources/policy/unlabeled-files/harvest-policy-mslhaz_1xxx.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - $HOME/test/msl/MSLHAZ_1XXX - - *.CAT - - - - - - - - http://starbase.jpl.nasa.gov - $HOME/test/msl - - - - - - - - - $HOME/test/msl/MSLHAZ_1XXX - - - - - - Product_File_Repository - - - Extra - - - - - - diff --git a/src/test/resources/policy/unlabeled-files/harvest-policy-mslmrd_0001.xml b/src/test/resources/policy/unlabeled-files/harvest-policy-mslmrd_0001.xml deleted file mode 100644 index ea1bfca5..00000000 --- a/src/test/resources/policy/unlabeled-files/harvest-policy-mslmrd_0001.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - $HOME/test/msl/MSLMRD_0001 - - - - - - - http://starbase.jpl.nasa.gov - $HOME/test/msl - - - - - - - - - $HOME/test/msl/MSLMRD_0001 - - - - - - Product_File_Repository - - - Extra - - - - - -