[ 
https://issues.apache.org/jira/browse/OODT-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13669302#comment-13669302
 ] 

Luca Cinquini commented on OODT-615:
------------------------------------

Hi Chris,
good idea in principle but I think the current implementation of 
XmlRpcFileManager does expect "null" - if it finds a null, it returns a 
boolean=false to the XmlRpc client.
The LuceneCatalog implementation behaves the same, see for example:

    private Product getProductByName(String productName, boolean getRefs)
            throws CatalogException {
        IndexSearcher searcher = null;
        try {
            searcher = new IndexSearcher(indexFilePath);
            Term productIdTerm = new Term("product_name", productName);
            org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
            Sort sort = new Sort(new SortField("CAS.ProductReceivedTime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            // should be > 0 hits
            if (hits.length() > 0) {
                // just get the first hit back
                Document productDoc = hits.doc(0);
                CompleteProduct prod = toCompleteProduct(productDoc, getRefs,
                        false);
                return prod.getProduct();
            } else {
                LOG.log(Level.FINEST, "Request for product by name: ["
                        + productName + "] returned no results");
                return null;
            }

        } catch (IOException e) {
            LOG.log(Level.WARNING,
                    "IOException when opening index directory: ["
                            + indexFilePath + "] for search: Message: "
                            + e.getMessage());
            throw new CatalogException(e.getMessage());
        } finally {
            if (searcher != null) {
                try {
                    searcher.close();
                } catch (Exception ignore) {
                }
                searcher = null;
            }
        }
    }

thanks, Luca


On May 29, 2013, at 8:29 AM, Chris A. Mattmann (JIRA) wrote:


   [ 
https://issues.apache.org/jira/browse/OODT-615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13669293#comment-13669293
 ]

Chris A. Mattmann commented on OODT-615:
----------------------------------------

Hey Luca, is it worth returning Collections.EMPTY_LIST? I know that XmlRpc 
doesn't love null...

SolrCatalog implementation of FileManager throws exception if no product is 
found
---------------------------------------------------------------------------------

               Key: OODT-615
               URL: https://issues.apache.org/jira/browse/OODT-615
           Project: OODT
        Issue Type: Bug
        Components: file manager
  Affects Versions: 0.6
          Reporter: Luca Cinquini
          Assignee: Luca Cinquini
           Fix For: 0.6


Currently, the method extractCompleteProduct() of SolrCatalog throws an 
exception if no matching product is found. The exception propagates all the way 
up to the XmlRpcFileManager causing the method hasProduct() to fail, instead of 
returning false.
Rather the extractCompleteProduct() method should return "null" if the number 
of documents found by the query is Solr, since this is what is expected by the 
XmlRpcFileManager.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


                
> SolrCatalog implementation of FileManager throws exception if no product is 
> found
> ---------------------------------------------------------------------------------
>
>                 Key: OODT-615
>                 URL: https://issues.apache.org/jira/browse/OODT-615
>             Project: OODT
>          Issue Type: Bug
>          Components: file manager
>    Affects Versions: 0.6
>            Reporter: Luca Cinquini
>            Assignee: Luca Cinquini
>             Fix For: 0.6
>
>
> Currently, the method extractCompleteProduct() of SolrCatalog throws an 
> exception if no matching product is found. The exception propagates all the 
> way up to the XmlRpcFileManager causing the method hasProduct() to fail, 
> instead of returning false.
> Rather the extractCompleteProduct() method should return "null" if the number 
> of documents found by the query is Solr, since this is what is expected by 
> the XmlRpcFileManager.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to