Uploaded image for project: 'OODT (Retired)'
  1. OODT (Retired)
  2. OODT-521

ExpImpCatalog Tool doesn't wrap product_type_id in single quotes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 0.4
    • 0.9
    • file manager
    • None
    • centOS

    Description

      When using the ExpImpCatalog tool to migrate from a Lucene based catalog into a PostgreSQL catalog I encountered the following error:

      INFO: Cataloging Product: [MOD09GA.A2012297.h09v04.005.NRT.hdf]
      Oct 25, 2012 10:48:16 AM org.apache.oodt.cas.filemgr.catalog.DataSourceCatalog addProduct
      FINE: addProduct: Executing: INSERT INTO products (product_name, product_structure, product_transfer_status, product_type_id) VALUES ('MOD09GA.A2012297.h09v04.005.NRT.hdf', 'Flat', 'RECEIVED', urn:snow:MOD09GANRT)
      org.postgresql.util.PSQLException: ERROR: syntax error at or near ":"
        Position: 168
              at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
              at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
              at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
              at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:403)
      

      So I looked into the source code at:
      https://svn.apache.org/repos/asf/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/DataSourceCatalog.java

      And on line 243:

      DataSourceCatalog.java
                  addProductSql = "INSERT INTO products (product_name, product_structure, product_transfer_status, product_type_id) "
                          + "VALUES ('"
                          + product.getProductName()
                          + "', '"
                          + product.getProductStructure()
                          + "', '"
                          + product.getTransferStatus()
                          + "', "
                          + productTypeIdStr
                          + ")";
      

      The other values are wrapped in single quotes. I think if I also wrap the last element in single quotes this Error should be resolved.

      I will test this against my current migration task and post a patch.

      Attachments

        Activity

          People

            cgoodale Cameron Goodale
            cgoodale Cameron Goodale
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: