Added: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/LuceneQueryCliAction.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/LuceneQueryCliAction.java?rev=1210199&view=auto
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/LuceneQueryCliAction.java
 (added)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/LuceneQueryCliAction.java
 Sun Dec  4 20:17:53 2011
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.filemgr.cli.action;
+
+//JDK imports
+import java.util.List;
+
+//Apache imports
+import org.apache.commons.lang.Validate;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.RangeQuery;
+import org.apache.lucene.search.TermQuery;
+
+//OODT imports
+import org.apache.oodt.cas.cli.exception.CmdLineActionException;
+import org.apache.oodt.cas.filemgr.structs.BooleanQueryCriteria;
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.ProductType;
+import org.apache.oodt.cas.filemgr.structs.QueryCriteria;
+import org.apache.oodt.cas.filemgr.structs.RangeQueryCriteria;
+import org.apache.oodt.cas.filemgr.structs.TermQueryCriteria;
+import org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient;
+import org.apache.oodt.cas.filemgr.tools.CASAnalyzer;
+
+//Google imports
+import com.google.common.collect.Lists;
+
+/**
+ * A {@link CmdLineAction} which converts a Lucene-like query into a File
+ * Manager {@link Query} and returns the results.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class LuceneQueryCliAction extends FileManagerCliAction {
+
+   private static final String FREE_TEXT_BLOCK = "__FREE__";
+
+   private String query;
+
+   @Override
+   public void execute(ActionMessagePrinter printer)
+         throws CmdLineActionException {
+      try {
+         Validate.notNull(query, "Must specify query");
+
+         XmlRpcFileManagerClient client = getClient();
+         List<ProductType> productTypes = client.getProductTypes();
+         if (productTypes == null) {
+            throw new Exception("FileManager return null list of product 
types");
+         }
+         org.apache.oodt.cas.filemgr.structs.Query casQuery = new 
org.apache.oodt.cas.filemgr.structs.Query();
+         
casQuery.setCriteria(Lists.newArrayList(generateCASQuery(parseQuery(query))));
+
+         List<String> productIds = query(client, casQuery, productTypes);
+         if (productIds == null) {
+            throw new Exception("FileManager returned null list of Product 
IDs");
+         }
+         for (String productId : productIds) {
+            printer.println(productId);
+         }
+      } catch (Exception e) {
+         throw new CmdLineActionException("Failed to perform lucene query '"
+               + query + "' : " + e.getMessage(), e);
+      }
+   }
+
+   public void setQuery(String query) {
+      this.query = query;
+   }
+
+   private Query parseQuery(String query) throws ParseException {
+      // note that "__FREE__" is a control work for free text searching
+      return (Query) new QueryParser(FREE_TEXT_BLOCK, new CASAnalyzer())
+            .parse(query);
+   }
+
+   private List<String> query(XmlRpcFileManagerClient client,
+         org.apache.oodt.cas.filemgr.structs.Query fmQuery,
+         List<ProductType> productTypes) throws Exception {
+      List<String> productIds = Lists.newArrayList();
+      for (ProductType type : productTypes) {
+         List<Product> products = client.query(fmQuery, type);
+         if (products == null) {
+            throw new Exception(
+                  "FileManager returned null products for query '" + query
+                        + "' and product type '" + type.getName() + "'");
+         }
+         for (Product product : products) {
+            productIds.add(product.getProductId());
+         }
+      }
+      return productIds;
+   }
+
+   private QueryCriteria generateCASQuery(Query luceneQuery)
+         throws Exception {
+      if (luceneQuery instanceof TermQuery) {
+         Term t = ((TermQuery) luceneQuery).getTerm();
+         if (t.field().equals(FREE_TEXT_BLOCK)) {
+            throw new Exception("Free text blocks not supported!");
+         } else {
+            return new TermQueryCriteria(t.field(), t.text());
+         }
+      } else if (luceneQuery instanceof PhraseQuery) {
+         Term[] t = ((PhraseQuery) luceneQuery).getTerms();
+         if (t[0].field().equals(FREE_TEXT_BLOCK)) {
+            throw new Exception("Free text blocks not supported!");
+         } else {
+            BooleanQueryCriteria bqc = new BooleanQueryCriteria();
+            bqc.setOperator(BooleanQueryCriteria.AND);
+            for (int i = 0; i < t.length; i++) {
+               bqc.addTerm(new TermQueryCriteria(t[i].field(), t[i]
+                     .text()));
+            }
+            return bqc;
+         }
+      } else if (luceneQuery instanceof RangeQuery) {
+         Term startT = ((RangeQuery) luceneQuery).getLowerTerm();
+         Term endT = ((RangeQuery) luceneQuery).getUpperTerm();
+         return new RangeQueryCriteria(startT.field(), startT
+               .text(), endT.text(), ((RangeQuery) luceneQuery).isInclusive());
+      } else if (luceneQuery instanceof BooleanQuery) {
+         BooleanClause[] clauses = ((BooleanQuery) luceneQuery).getClauses();
+         BooleanQueryCriteria bqc = new BooleanQueryCriteria();
+         bqc.setOperator(BooleanQueryCriteria.AND);
+         for (int i = 0; i < clauses.length; i++) {
+            if (clauses[i].getOccur().equals(BooleanClause.Occur.SHOULD)) {
+               bqc.setOperator(BooleanQueryCriteria.OR);
+            }
+            bqc.addTerm(generateCASQuery(clauses[i].getQuery()));
+         }
+         return bqc;
+      } else {
+         throw new Exception(
+               "Error parsing query! Cannot determine clause type: ["
+                     + luceneQuery.getClass().getName() + "] !");
+      }
+   }
+}

Propchange: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/LuceneQueryCliAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/SqlQueryCliAction.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/SqlQueryCliAction.java?rev=1210199&view=auto
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/SqlQueryCliAction.java
 (added)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/SqlQueryCliAction.java
 Sun Dec  4 20:17:53 2011
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.filemgr.cli.action;
+
+//JDK imports
+import java.util.List;
+
+//Apache imports
+import org.apache.commons.lang.Validate;
+
+//OODT imports
+import org.apache.oodt.cas.cli.exception.CmdLineActionException;
+import org.apache.oodt.cas.filemgr.structs.query.ComplexQuery;
+import org.apache.oodt.cas.filemgr.structs.query.QueryFilter;
+import org.apache.oodt.cas.filemgr.structs.query.QueryResult;
+import org.apache.oodt.cas.filemgr.structs.query.conv.VersionConverter;
+import org.apache.oodt.cas.filemgr.structs.query.filter.FilterAlgor;
+import org.apache.oodt.cas.filemgr.util.SqlParser;
+
+/**
+ * A {@link CmdLineAction} which queries the FileManager by parsing an SQL like
+ * query into a FileManager {@link Query}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class SqlQueryCliAction extends FileManagerCliAction {
+
+   private String query;
+   private String sortBy;
+   private String outputFormat;
+   private String delimiter;
+
+   private List<String> reducedProductTypes;
+   private List<String> reducedMetadataKeys;
+
+   private FilterAlgor filterAlgor;
+   private String startDateTimeMetKey;
+   private String endDateTimeMetKey;
+   private String priorityMetKey;
+   private VersionConverter versionConverter;
+
+   public SqlQueryCliAction() {
+      delimiter = "\n";
+   }
+
+   @Override
+   public void execute(ActionMessagePrinter printer)
+         throws CmdLineActionException {
+      try {
+         Validate.notNull(query, "Must specify query");
+
+         ComplexQuery complexQuery = SqlParser.parseSqlQuery(query);
+         complexQuery.setSortByMetKey(sortBy);
+         complexQuery.setToStringResultFormat(outputFormat);
+         complexQuery.setReducedProductTypeNames(reducedProductTypes);
+         complexQuery.setReducedMetadata(reducedMetadataKeys);
+         if (filterAlgor != null) {
+            Validate.notNull(startDateTimeMetKey,
+                  "Must specify startDateTimeMetKey");
+            Validate.notNull(endDateTimeMetKey,
+                  "Must specify endDateTimeMetKey");
+            Validate.notNull(priorityMetKey, "Must specify priorityMetKey");
+            QueryFilter filter = new QueryFilter(startDateTimeMetKey,
+                  endDateTimeMetKey, priorityMetKey, filterAlgor);
+            if (versionConverter != null) {
+               filter.setConverter(versionConverter);
+            }
+            complexQuery.setQueryFilter(filter);
+         }
+         List<QueryResult> results = getClient().complexQuery(complexQuery);
+         StringBuffer returnString = new StringBuffer("");
+         for (QueryResult qr : results) {
+            returnString.append(qr.toString() + delimiter);
+         }
+         printer.println(returnString.substring(0, returnString.length()
+               - delimiter.length()));
+      } catch (Exception e) {
+         throw new CmdLineActionException("Failed to perform sql query for"
+               + " query '"
+               + query
+               + "', sortBy '"
+               + sortBy
+               + "', "
+               + "outputFormat '"
+               + outputFormat
+               + "', and delimiter '"
+               + delimiter
+               + "', filterAlgor '"
+               + (filterAlgor != null ? filterAlgor.getClass()
+                     .getCanonicalName() : null)
+               + "', startDateTimeMetKey '"
+               + startDateTimeMetKey
+               + "', endDateTimeMetKey '"
+               + endDateTimeMetKey
+               + "', priorityMetKey '"
+               + priorityMetKey
+               + "', "
+               + (versionConverter != null ? versionConverter.getClass()
+                     .getCanonicalName() : null) + "' : " + e.getMessage(), e);
+      }
+   }
+
+   public void setQuery(String query) {
+      this.query = query;
+   }
+
+   public void setSortBy(String sortBy) {
+      this.sortBy = sortBy;
+   }
+
+   public void setOutputFormat(String outputFormat) {
+      this.outputFormat = outputFormat;
+   }
+
+   public void setDelimiter(String delimiter) {
+      this.delimiter = delimiter;
+   }
+
+   public void setReducedProductTypes(List<String> reducedProductTypes) {
+      this.reducedProductTypes = reducedProductTypes;
+   }
+
+   public void setReducedMetadataKeys(List<String> reducedMetadataKeys) {
+      this.reducedMetadataKeys = reducedMetadataKeys;
+   }
+
+   public void setStartDateTimeMetKey(String startDateTimeMetKey) {
+      this.startDateTimeMetKey = startDateTimeMetKey;
+   }
+
+   public void setEndDateTimeMetKey(String endDateTimeMetKey) {
+      this.endDateTimeMetKey = endDateTimeMetKey;
+   }
+
+   public void setPriorityMetKey(String priorityMetKey) {
+      this.priorityMetKey = priorityMetKey;
+   }
+
+   public void setConverter(VersionConverter versionConverter) {
+      this.versionConverter = versionConverter;
+   }
+
+   public void setFilterAlgor(FilterAlgor filterAlgor) {
+      this.filterAlgor = filterAlgor;
+   }
+}

Propchange: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/cli/action/SqlQueryCliAction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java?rev=1210199&r1=1210198&r2=1210199&view=diff
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
 (original)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/system/XmlRpcFileManagerClient.java
 Sun Dec  4 20:17:53 2011
@@ -19,7 +19,6 @@ package org.apache.oodt.cas.filemgr.syst
 
 //APACHE imports
 import org.apache.xmlrpc.CommonsXmlRpcTransport;
-import org.apache.xmlrpc.CommonsXmlRpcTransportFactory;
 import org.apache.xmlrpc.XmlRpcClient;
 import org.apache.xmlrpc.XmlRpcClientException;
 import org.apache.xmlrpc.XmlRpcException;
@@ -28,11 +27,9 @@ import org.apache.xmlrpc.XmlRpcTransport
 
 //JDK imports
 import java.net.URL;
-import java.net.URI;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 import java.util.logging.Level;
@@ -47,9 +44,8 @@ import org.apache.commons.httpclient.Htt
 import org.apache.commons.httpclient.HttpMethodRetryHandler;
 import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.oodt.cas.metadata.Metadata;
-import org.apache.oodt.cas.metadata.SerializableMetadata;
+import org.apache.oodt.cas.cli.CmdLineUtility;
 import org.apache.oodt.cas.filemgr.structs.exceptions.CatalogException;
-import 
org.apache.oodt.cas.filemgr.structs.exceptions.QueryFormulationException;
 import 
org.apache.oodt.cas.filemgr.structs.exceptions.RepositoryManagerException;
 import org.apache.oodt.cas.filemgr.structs.exceptions.ValidationLayerException;
 import org.apache.oodt.cas.filemgr.structs.Element;
@@ -62,7 +58,6 @@ import org.apache.oodt.cas.filemgr.struc
 import org.apache.oodt.cas.filemgr.util.GenericFileManagerObjectFactory;
 import org.apache.oodt.cas.filemgr.util.XmlRpcStructFactory;
 import org.apache.oodt.cas.filemgr.versioning.Versioner;
-import org.apache.oodt.cas.filemgr.versioning.VersioningUtils;
 import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
 import org.apache.oodt.cas.filemgr.datatransfer.DataTransfer;
 import org.apache.oodt.cas.filemgr.structs.exceptions.DataTransferException;
@@ -71,8 +66,8 @@ import org.apache.oodt.cas.filemgr.struc
 import org.apache.oodt.cas.filemgr.structs.query.QueryResult;
 
 /**
- * @author mattmann
- * @author bfoster
+ * @author mattmann (Chris Mattmann)
+ * @author bfoster (Brian Foster)
  * @version $Revision$
  * 
  * <p>
@@ -95,6 +90,10 @@ public class XmlRpcFileManagerClient {
     /* data transferer needed if client is request to move files itself */
     private DataTransfer dataTransfer = null;
 
+    public XmlRpcFileManagerClient(final URL url) throws ConnectionException {
+       this(url, true);
+    }
+
     /**
      * <p>
      * Constructs a new XmlRpcFileManagerClient with the given 
<code>url</code>.
@@ -102,8 +101,11 @@ public class XmlRpcFileManagerClient {
      * 
      * @param url
      *            The url pointer to the xml rpc file manager service.
+     * @param testConnection
+     *            Whether or not to check if server at given url is alive.
      */
-    public XmlRpcFileManagerClient(final URL url) throws ConnectionException {
+    public XmlRpcFileManagerClient(final URL url, boolean testConnection)
+          throws ConnectionException {
         // set up the configuration, if there is any
         if (System.getProperty("org.apache.oodt.cas.filemgr.properties") != 
null) {
             String configFile = System
@@ -174,7 +176,7 @@ public class XmlRpcFileManagerClient {
         client = new XmlRpcClient(url, transportFactory);
         fileManagerUrl = url;
 
-        if (!isAlive()) {
+        if (testConnection && !isAlive()) {
             throw new ConnectionException("Exception connecting to filemgr: ["
                     + this.fileManagerUrl + "]");
         }
@@ -1280,524 +1282,9 @@ public class XmlRpcFileManagerClient {
                         .execute("filemgr.getCatalogQuery", args));
     }
 
-    public static void main(String[] args) throws MalformedURLException,
-            CatalogException, RepositoryManagerException, URISyntaxException {
-
-        String addProductTypeOperation = "--addProductType --typeName <name> 
--typeDesc <description> --repository <path> --versionClass <classname of 
versioning impl>\n";
-        String ingestProductOperation = "--ingestProduct --productName <name> 
--productStructure <Hierarchical|Flat> --productTypeName <name of product type> 
--metadataFile <file> [--clientTransfer --dataTransfer <java class name of data 
transfer factory>] --refs <ref1>...<refn>\n";
-        String hasProductOperation = "--hasProduct --productName <name>\n";
-        String getProductTypeByNameOperation = "--getProductTypeByName 
--productTypeName <name>\n";
-        String getNumProductsOperation = "--getNumProducts --productTypeName 
<name>\n";
-        String getFirstPageOperation = "--getFirstPage --productTypeName 
<name>\n";
-        String getNextPageOperation = "--getNextPage --productTypeName <name> 
--currentPageNum <number>\n";
-        String getPrevPageOperation = "--getPrevPage --productTypeName <name> 
--currentPageNum <number>\n";
-        String getLastPageOperation = "--getLastPage --productTypeName 
<name>\n";
-        String getCurrentTransferOperation = "--getCurrentTransfer\n";
-        String getCurrentTransfersOperation = "--getCurrentTransfers\n";
-        String getProductPctTransferredOperation = "--getProductPctTransferred 
--productId <id> --productTypeName <name>\n";
-        String getFilePctTransferOperation = "--getFilePctTransferred 
--origRef <uri>\n";
-
-        String usage = "filemgr-client --url <url to xml rpc service> 
--operation [<operation> [params]]\n"
-                + "operations:\n"
-                + addProductTypeOperation
-                + ingestProductOperation
-                + hasProductOperation
-                + getProductTypeByNameOperation
-                + getNumProductsOperation
-                + getFirstPageOperation
-                + getNextPageOperation
-                + getPrevPageOperation
-                + getLastPageOperation
-                + getCurrentTransferOperation
-                + getCurrentTransfersOperation
-                + getProductPctTransferredOperation
-                + getFilePctTransferOperation;
-
-        String operation = null, url = null;
-
-        for (int i = 0; i < args.length; i++) {
-            if (args[i].equals("--operation")) {
-                operation = args[++i];
-            } else if (args[i].equals("--url")) {
-                url = args[++i];
-            }
-        }
-
-        if (operation == null) {
-            System.err.println(usage);
-            System.exit(1);
-        }
-
-        // create the client
-        XmlRpcFileManagerClient client = null;
-        try {
-            client = new XmlRpcFileManagerClient(new URL(url));
-        } catch (ConnectionException e) {
-            System.err.println("Could not connect to filemgr");
-            System.exit(1);
-        }
-
-        if (operation.equals("--addProductType")) {
-            String typeName = null, typeDesc = null, typeVers = null, typeRepo 
= null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--typeName")) {
-                    typeName = args[++i];
-                } else if (args[i].equals("--typeDesc")) {
-                    typeDesc = args[++i];
-                } else if (args[i].equals("--repository")) {
-                    typeRepo = args[++i];
-                } else if (args[i].equals("--versionClass")) {
-                    typeVers = args[++i];
-                }
-            }
-
-            if (typeName == null || typeDesc == null || typeVers == null
-                    || typeRepo == null) {
-                System.err.println(addProductTypeOperation);
-                System.exit(1);
-            }
-
-            ProductType type = new ProductType();
-            type.setName(typeName);
-            type.setDescription(typeDesc);
-            type.setProductRepositoryPath(typeRepo);
-            type.setVersioner(typeVers);
-
-            System.out.println("addProductType: Result: "
-                    + client.addProductType(type));
-
-        } else if (operation.equals("--ingestProduct")) {
-            String productName = null, productStructure = null, 
productTypeName = null, metadataFileName = null;
-            boolean clientTransfer = false;
-            String dataTransferClass = null;
-            Vector<String> refs = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productName")) {
-                    productName = args[++i];
-                } else if (args[i].equals("--productStructure")) {
-                    productStructure = args[++i];
-                } else if (args[i].equals("--productTypeName")) {
-                    productTypeName = args[++i];
-                } else if (args[i].equals("--metadataFile")) {
-                    metadataFileName = args[++i];
-                } else if (args[i].equals("--refs")) {
-                    refs = new Vector<String>();
-                    for (int j = i + 1; j < args.length; j++) {
-                        refs.add(args[j]);
-                    }
-                } else if (args[i].equals("--clientTransfer")) {
-                    clientTransfer = true;
-                } else if (args[i].equals("--dataTransfer")) {
-                    dataTransferClass = args[++i];
-                }
-            }
-
-            if (productName == null || productStructure == null
-                    || productTypeName == null || metadataFileName == null
-                    || refs == null
-                    || (clientTransfer && dataTransferClass == null)) {
-                System.err.println(ingestProductOperation);
-                System.exit(1);
-            }
-
-            Product product = new Product();
-            product.setProductName(productName);
-            product.setProductStructure(productStructure);
-            product
-                    .setProductType(client
-                            .getProductTypeByName(productTypeName));
-
-            if (clientTransfer) {
-                client.setDataTransfer(GenericFileManagerObjectFactory
-                        .getDataTransferServiceFromFactory(dataTransferClass));
-            }
-
-            // need to build up the ref uri list in case the Product structure
-            // is
-            // heirarchical
-            if (product.getProductStructure().equals(
-                    Product.STRUCTURE_HIERARCHICAL)) {
-                String ref = (String) refs.get(0);
-                refs.addAll(VersioningUtils.getURIsFromDir(new File(
-                        new URI(ref))));
-            }
-
-            // add Product References from the URI list
-            VersioningUtils.addRefsFromUris(product, refs);
-
-            try {
-                Metadata metadata = null;
-                URL metaUrl = new File(new URI(metadataFileName)).toURL();
-                metadata = new SerializableMetadata(metaUrl.openStream());
-                System.out.println("ingestProduct: Result: "
-                        + client.ingestProduct(product, metadata,
-                                clientTransfer));
-            } catch (Exception e) {
-                e.printStackTrace();
-                LOG.log(Level.SEVERE, "Exception ingesting product!: Message: "
-                        + e.getMessage());
-                throw new RuntimeException(e);
-            }
-
-        } else if (operation.equals("--hasProduct")) {
-            String productName = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productName")) {
-                    productName = args[++i];
-                }
-            }
-
-            if (productName == null) {
-                System.err.println(hasProductOperation);
-                System.exit(1);
-            }
-
-            try {
-                System.out.println("hasProduct: Result: "
-                        + client.hasProduct(productName));
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-        } else if (operation.equals("--getProductTypeByName")) {
-            String productTypeName = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productTypeName")) {
-                    productTypeName = args[++i];
-                }
-            }
-
-            if (productTypeName == null) {
-                System.err.println(getProductTypeByNameOperation);
-                System.exit(1);
-            }
-
-            try {
-                ProductType type = 
client.getProductTypeByName(productTypeName);
-                System.out.println("getProductTypeByName: Result: [name="
-                        + type.getName() + ", description="
-                        + type.getDescription() + ", id="
-                        + type.getProductTypeId() + ", versionerClass="
-                        + type.getVersioner() + ", repositoryPath="
-                        + type.getProductRepositoryPath() + "]");
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-        } else if (operation.equals("--getNumProducts")) {
-            String typeName = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productTypeName")) {
-                    typeName = args[++i];
-                }
-            }
-
-            if (typeName == null) {
-                System.err.println(getNumProductsOperation);
-                System.exit(1);
-            }
-
-            try {
-                System.out.println("Type: ["
-                        + typeName
-                        + "], Num Products: ["
-                        + client.getNumProducts(client
-                                .getProductTypeByName(typeName)) + "]");
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-        } else if (operation.equals("--getFirstPage")) {
-            String typeName = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productTypeName")) {
-                    typeName = args[++i];
-                }
-            }
-
-            if (typeName == null) {
-                System.err.println(getFirstPageOperation);
-                System.exit(1);
-            }
-
-            try {
-                ProductType type = client.getProductTypeByName(typeName);
-                ProductPage firstPage = client.getFirstPage(type);
-
-                System.out.println("Page: [num=" + firstPage.getPageNum()
-                        + ", totalPages=" + firstPage.getTotalPages()
-                        + ", pageSize=" + firstPage.getPageSize() + "]");
-                System.out.println("Products:");
-
-                if (firstPage.getPageProducts() != null
-                        && firstPage.getPageProducts().size() > 0) {
-                    for (Iterator<Product> i = firstPage.getPageProducts()
-                            .iterator(); i.hasNext();) {
-                        Product p = i.next();
-                        System.out.println("Product: [id=" + p.getProductId()
-                                + ",name=" + p.getProductName() + ",type="
-                                + p.getProductType().getName() + ",structure="
-                                + p.getProductStructure() + ", transferStatus="
-                                + p.getTransferStatus() + "]");
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-
-        } else if (operation.equals("--getNextPage")) {
-            String typeName = null;
-            int currentPageNum = -1;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productTypeName")) {
-                    typeName = args[++i];
-                } else if (args[i].equals("--currentPageNum")) {
-                    currentPageNum = Integer.parseInt(args[++i]);
-                }
-            }
-
-            if (typeName == null || currentPageNum == -1) {
-                System.err.println(getNextPageOperation);
-                System.exit(1);
-            }
-
-            try {
-                ProductType type = client.getProductTypeByName(typeName);
-                ProductPage firstPage = client.getFirstPage(type);
-                ProductPage currentPage = new ProductPage();
-                currentPage.setPageNum(currentPageNum);
-                currentPage.setPageSize(firstPage.getPageSize());
-                currentPage.setTotalPages(firstPage.getTotalPages());
-                ProductPage nextPage = client.getNextPage(type, currentPage);
-
-                System.out.println("Page: [num=" + nextPage.getPageNum()
-                        + ", totalPages=" + nextPage.getTotalPages()
-                        + ", pageSize=" + nextPage.getPageSize() + "]");
-                System.out.println("Products:");
-
-                if (nextPage.getPageProducts() != null
-                        && nextPage.getPageProducts().size() > 0) {
-                    for (Iterator<Product> i = nextPage.getPageProducts()
-                            .iterator(); i.hasNext();) {
-                        Product p = i.next();
-                        System.out.println("Product: [id=" + p.getProductId()
-                                + ",name=" + p.getProductName() + ",type="
-                                + p.getProductType().getName() + ",structure="
-                                + p.getProductStructure() + ", transferStatus="
-                                + p.getTransferStatus() + "]");
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-        } else if (operation.equals("--getPrevPage")) {
-            String typeName = null;
-            int currentPageNum = -1;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productTypeName")) {
-                    typeName = args[++i];
-                } else if (args[i].equals("--currentPageNum")) {
-                    currentPageNum = Integer.parseInt(args[++i]);
-                }
-            }
-
-            if (typeName == null || currentPageNum == -1) {
-                System.err.println(getNextPageOperation);
-                System.exit(1);
-            }
-
-            try {
-                ProductType type = client.getProductTypeByName(typeName);
-                ProductPage firstPage = client.getFirstPage(type);
-                ProductPage currentPage = new ProductPage();
-                currentPage.setPageNum(currentPageNum);
-                currentPage.setPageSize(firstPage.getPageSize());
-                currentPage.setTotalPages(firstPage.getTotalPages());
-                ProductPage prevPage = client.getPrevPage(type, currentPage);
-
-                System.out.println("Page: [num=" + prevPage.getPageNum()
-                        + ", totalPages=" + prevPage.getTotalPages()
-                        + ", pageSize=" + prevPage.getPageSize() + "]");
-                System.out.println("Products:");
-
-                if (prevPage.getPageProducts() != null
-                        && prevPage.getPageProducts().size() > 0) {
-                    for (Iterator<Product> i = prevPage.getPageProducts()
-                            .iterator(); i.hasNext();) {
-                        Product p = i.next();
-                        System.out.println("Product: [id=" + p.getProductId()
-                                + ",name=" + p.getProductName() + ",type="
-                                + p.getProductType().getName() + ",structure="
-                                + p.getProductStructure() + ", transferStatus="
-                                + p.getTransferStatus() + "]");
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-        } else if (operation.equals("--getLastPage")) {
-            String typeName = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productTypeName")) {
-                    typeName = args[++i];
-                }
-            }
-
-            if (typeName == null) {
-                System.err.println(getLastPageOperation);
-                System.exit(1);
-            }
-
-            try {
-                ProductType type = client.getProductTypeByName(typeName);
-                ProductPage lastPage = client.getLastPage(type);
-
-                System.out.println("Page: [num=" + lastPage.getPageNum()
-                        + ", totalPages=" + lastPage.getTotalPages()
-                        + ", pageSize=" + lastPage.getPageSize() + "]");
-                System.out.println("Products:");
-
-                if (lastPage.getPageProducts() != null
-                        && lastPage.getPageProducts().size() > 0) {
-                    for (Iterator<Product> i = lastPage.getPageProducts()
-                            .iterator(); i.hasNext();) {
-                        Product p = i.next();
-                        System.out.println("Product: [id=" + p.getProductId()
-                                + ",name=" + p.getProductName() + ",type="
-                                + p.getProductType().getName() + ",structure="
-                                + p.getProductStructure() + ", transferStatus="
-                                + p.getTransferStatus() + "]");
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-
-        } else if (operation.equals("--getCurrentTransfer")) {
-            FileTransferStatus status = null;
-
-            try {
-                status = client.getCurrentFileTransfer();
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-
-            System.out.println("File Transfer: [ref={orig="
-                    + status.getFileRef().getOrigReference() + ",ds="
-                    + status.getFileRef().getDataStoreReference()
-                    + "},product=" + status.getParentProduct().getProductName()
-                    + ",fileSize=" + status.getFileRef().getFileSize()
-                    + ",amtTransferred=" + status.getBytesTransferred()
-                    + ",pct=" + status.computePctTransferred() + "]");
-        } else if (operation.equals("--getCurrentTransfers")) {
-            List<FileTransferStatus> statuses = null;
-
-            try {
-                statuses = client.getCurrentFileTransfers();
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-
-            if (statuses != null && statuses.size() > 0) {
-                for (Iterator<FileTransferStatus> i = statuses.iterator(); i
-                        .hasNext();) {
-                    FileTransferStatus status = i.next();
-                    System.out.println("File Transfer: [ref={orig="
-                            + status.getFileRef().getOrigReference() + ",ds="
-                            + status.getFileRef().getDataStoreReference()
-                            + "},product="
-                            + status.getParentProduct().getProductName()
-                            + ",fileSize=" + status.getFileRef().getFileSize()
-                            + ",amtTransferred=" + status.getBytesTransferred()
-                            + ",pct=" + status.computePctTransferred() + "]");
-                }
-            }
-        } else if (operation.equals("--getProductPctTransferred")) {
-            String productTypeName = null, productId = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--productId")) {
-                    productId = args[++i];
-                } else if (args[i].equals("--productTypeName")) {
-                    productTypeName = args[++i];
-                }
-            }
-
-            if (productTypeName == null || productId == null) {
-                System.err.println(getProductPctTransferredOperation);
-                System.exit(1);
-            }
-
-            Product product = new Product();
-            product.setProductName(" ");
-            product.setProductStructure(" ");
-            product
-                    .setProductType(client
-                            .getProductTypeByName(productTypeName));
-            product.setProductId(productId);
-
-            double pct = 0.0;
-
-            try {
-                pct = client.getProductPctTransferred(product);
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-
-            System.out.println("Product: [id=" + productId + ", transferPct="
-                    + pct + "]");
-
-        } else if (operation.equals("--getFilePctTransferred")) {
-            String origFileRef = null;
-
-            for (int i = 4; i < args.length; i++) {
-                if (args[i].equals("--origRef")) {
-                    origFileRef = args[++i];
-                }
-            }
-
-            if (origFileRef == null) {
-                System.err.println(getFilePctTransferOperation);
-                System.exit(1);
-            }
-
-            Reference ref = new Reference();
-            ref.setOrigReference(origFileRef);
-            ref.setDataStoreReference("file:/foo/bar"); // doesn't matter: 
won't
-            // be
-            // used in the comparison on
-            // the server side
-
-            double pct = 0.0;
-
-            try {
-                pct = client.getRefPctTransferred(ref);
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new RuntimeException(e);
-            }
-
-            System.out.println("Reference: [origRef=" + origFileRef
-                    + ",transferPct=" + pct + "]");
-        } else
-            throw new IllegalArgumentException("Unknown Operation!");
-
+    public static void main(String[] args) {
+       CmdLineUtility cmdLineUtility = new CmdLineUtility();
+       cmdLineUtility.run(args);
     }
 
     /**

Modified: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java?rev=1210199&r1=1210198&r2=1210199&view=diff
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java
 (original)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/DeleteProduct.java
 Sun Dec  4 20:17:53 2011
@@ -48,6 +48,7 @@ import java.util.Vector;
  * </p>
  * 
  */
+@Deprecated
 public class DeleteProduct {
 
     /* our log stream */

Modified: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java?rev=1210199&r1=1210198&r2=1210199&view=diff
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java
 (original)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataDumper.java
 Sun Dec  4 20:17:53 2011
@@ -41,6 +41,7 @@ import java.util.logging.Logger;
  * {@link Product}.
  * </p>.
  */
+@Deprecated
 public final class MetadataDumper {
 
     /* our log stream */

Modified: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java?rev=1210199&r1=1210198&r2=1210199&view=diff
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java
 (original)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/QueryTool.java
 Sun Dec  4 20:17:53 2011
@@ -60,6 +60,7 @@ import org.apache.lucene.search.TermQuer
  * A tool to return product ids given a {@link Query} against the File Manager.
  * </p>
  */
+@Deprecated
 public final class QueryTool {
 
     private static String freeTextBlock = "__FREE__";

Added: oodt/trunk/filemgr/src/main/resources/cmd-line-actions.xml
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/resources/cmd-line-actions.xml?rev=1210199&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/resources/cmd-line-actions.xml (added)
+++ oodt/trunk/filemgr/src/main/resources/cmd-line-actions.xml Sun Dec  4 
20:17:53 2011
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+  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.
+
+  Author: bfoster (Brian Foster)
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:p="http://www.springframework.org/schema/p";
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>
+
+       <bean id="AddProductType" 
class="org.apache.oodt.cas.filemgr.cli.action.AddProductTypeCliAction">
+               <property name="description" value="Adds a ProductType to list 
of supported ProductTypes" />
+       </bean>
+  <bean id="DeleteProductByName" 
class="org.apache.oodt.cas.filemgr.cli.action.DeleteProductByNameCliAction">
+    <property name="description" value="Delete Product by name" />
+  </bean>
+  <bean id="DeleteProductById" 
class="org.apache.oodt.cas.filemgr.cli.action.DeleteProductByIdCliAction">
+    <property name="description" value="Delete Product by ID" />
+  </bean>
+  <bean id="DumpMetadata" 
class="org.apache.oodt.cas.filemgr.cli.action.DumpMetadataCliAction">
+    <property name="description" value="Dumps Product Metadata out to XML" />
+  </bean>
+       <bean id="GetCurrentTransfer" 
class="org.apache.oodt.cas.filemgr.cli.action.GetCurrentTransferCliAction">
+    <property name="description" value="Gets the status of the current Product 
file transfer" />
+  </bean>
+  <bean id="GetCurrentTransfers" 
class="org.apache.oodt.cas.filemgr.cli.action.GetCurrentTransfersCliAction">
+    <property name="description" value="Gets the status of the current Product 
file transfers" />
+  </bean>
+  <bean id="GetFilePercentTransferred" 
class="org.apache.oodt.cas.filemgr.cli.action.GetFilePercentTransferredCliAction">
+    <property name="description" value="Gets the percent amount transferred of 
given file" />
+  </bean>
+  <bean id="GetFirstPage" 
class="org.apache.oodt.cas.filemgr.cli.action.GetFirstPageCliAction">
+    <property name="description" value="Gets first page of Products of given 
ProductType" />
+  </bean>
+  <bean id="GetLastPage" 
class="org.apache.oodt.cas.filemgr.cli.action.GetLastPageCliAction">
+    <property name="description" value="Gets last page of Products of given 
ProductType" />
+  </bean>
+  <bean id="GetNextPage" 
class="org.apache.oodt.cas.filemgr.cli.action.GetNextPageCliAction">
+    <property name="description" value="Gets next page of Products of given 
ProductType" />
+  </bean>
+  <bean id="GetNumProducts" 
class="org.apache.oodt.cas.filemgr.cli.action.GetNumProductsCliAction">
+    <property name="description" value="Gets number of Products ingested for a 
given ProductType" />
+  </bean>
+  <bean id="GetPrevPage" 
class="org.apache.oodt.cas.filemgr.cli.action.GetPrevPageCliAction">
+    <property name="description" value="Gets prev page of Products of given 
ProductType" />
+  </bean>
+  <bean id="GetProductByName" 
class="org.apache.oodt.cas.filemgr.cli.action.GetProductByNameCliAction">
+    <property name="description" value="Get Product info by name" />
+  </bean>
+  <bean id="GetProductById" 
class="org.apache.oodt.cas.filemgr.cli.action.GetProductByIdCliAction">
+    <property name="description" value="Gets Product info by ID" />
+  </bean>
+  <bean id="GetProductPercentTransferred" 
class="org.apache.oodt.cas.filemgr.cli.action.GetProductPercentTransferredCliAction">
+    <property name="description" value="Gets percent amount transferred of a 
Products data files" />
+  </bean>
+  <bean id="GetProductTypeByName" 
class="org.apache.oodt.cas.filemgr.cli.action.GetProductTypeByNameCliAction">
+    <property name="description" value="Gets a ProductType by its name" />
+  </bean>
+  <bean id="HasProduct" 
class="org.apache.oodt.cas.filemgr.cli.action.HasProductCliAction">
+    <property name="description" value="Checks if Product with given name has 
been ingested" />
+  </bean>
+  <bean id="IngestProduct" 
class="org.apache.oodt.cas.filemgr.cli.action.IngestProductCliAction">
+    <property name="description" value="Ingests a Product" />
+  </bean>
+  <bean id="LuceneQuery" 
class="org.apache.oodt.cas.filemgr.cli.action.LuceneQueryCliAction">
+    <property name="description" value="Queries by parsing an Lucene-like 
query into a FileManager Query" />
+  </bean>
+  <bean id="SqlQuery" 
class="org.apache.oodt.cas.filemgr.cli.action.SqlQueryCliAction">
+    <property name="description" value="Queries by parsing an SQL-like query 
into a FileManager Query" />
+    <property name="detailedDescription">
+      <value>
+ This supports sending queries to the FileManager in form of
+  SELECT [Elements] FROM [ProductTypes] WHERE [where-clause], where:
+   - [Elements]: is a comma separated list of Element names; may also be * 
which
+    represents all Elements
+   - [ProductTypes]: is a comma separated list of ProductType names; may also
+    be * which represents all ProductTypes
+   - [where-clause]: is an optional Element name filter supporting the 
following:
+      * AND and OR boolean operators
+      * () grouping of queries
+      * element-name == 'element-value'
+      * element-name &#60; 'element-value'
+      * element-name &#62; 'element-value'
+      * element-name &#60;= 'element-value'
+      * element-name &#62;= 'element-value'"
+
+ An additional post-query FilterAlgor can also be specified where you specify
+  which Metadata fields which should be used as each Product's StartDateTime,
+  EndDateTime, and Priority values
+      </value>
+    </property>
+    <property name="examples">
+      <value>
+ (Assume you have a ProductType, GenericFile, which supports the
+    Elements: Filename, NominalDate, Group, and DataVersion)
+  $ ./filemgr-client -u http://localhost:9000 -op -sql
+    -q "SELECT Filename FROM GenericFile WHERE (NominalDate == '2011-20-10' OR
+      NominalDate == '2011-20-11') AND Group == 'Test' AND DataVersion > '1.0'"
+ (Returns all Products in FileManager -- use with care)
+  $ ./filemgr-client -u http://localhost:9000 -op -sql -q "SELECT * FROM *"
+      </value>
+    </property>
+  </bean>
+</beans>

Propchange: oodt/trunk/filemgr/src/main/resources/cmd-line-actions.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to