Author: luca
Date: Sun Feb 3 14:44:14 2013
New Revision: 1441917
URL: http://svn.apache.org/viewvc?rev=1441917&view=rev
Log:
Allowing LuceneCatalog addMetadata and addReferences to retrieve product from
index to cache, if not found in cache already, instead of throwing exception
(OODT-551 and OODT-557)
Modified:
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
Modified:
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java?rev=1441917&r1=1441916&r2=1441917&view=diff
==============================================================================
---
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
(original)
+++
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/catalog/LuceneCatalog.java
Sun Feb 3 14:44:14 2013
@@ -157,10 +157,17 @@ public class LuceneCatalog implements Ca
CompleteProduct p = CATALOG_CACHE.get(product.getProductId());
if (p == null) {
- throw new CatalogException(
- "Attempt to add metadata to a product: ["
- + product.getProductName()
- + "] that isn't the local cache!");
+ // move product from index to cache
+ // it will be moved back after metadata is added
+ p = getCompleteProductById(product.getProductId(), true, true);
+ LOG.log(Level.FINE, "Product not found in local cache,
retrieved from index");
+ removeProduct(product);
+ }
+
+ if (p == null) {
+ throw new CatalogException("Product ["+ product.getProductName()
+ + "] not found either in local
cache or in index");
+
} else {
p.setMetadata(m);
if (hasMetadataAndRefs(p)) {
@@ -336,10 +343,17 @@ public class LuceneCatalog implements Ca
.getProductId());
if (p == null) {
- throw new CatalogException(
- "Attempt to add references to a product: ["
- + product.getProductName()
- + "] that isn't the local cache!");
+ // move product from index to cache
+ // it will be moved back after metadata is added
+ p = getCompleteProductById(product.getProductId(), true, true);
+ LOG.log(Level.FINE, "Product not found in local cache,
retrieved from index");
+ removeProduct(product);
+ }
+
+ if (p == null) {
+ throw new CatalogException("Product ["+ product.getProductName()
+ + "] not found either in local
cache or in index");
+
} else {
p.getProduct().setProductReferences(product.getProductReferences());
if (hasMetadataAndRefs(p)) {