Author: pramirez
Date: Thu Sep 27 01:00:17 2012
New Revision: 1390797
URL: http://svn.apache.org/viewvc?rev=1390797&view=rev
Log:
Guard for null pages when product types have no products. Updated
indexer.properties to include a mapping for the unique id as this is essential
for indexing.
Modified:
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java
oodt/trunk/filemgr/src/main/resources/indexer.properties
Modified:
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java?rev=1390797&r1=1390796&r2=1390797&view=diff
==============================================================================
---
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java
(original)
+++
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/SolrIndexer.java
Thu Sep 27 01:00:17 2012
@@ -181,11 +181,13 @@ public class SolrIndexer {
// The solr field name this metadata key will be mapped
to
String fieldName =
config.getMapProperties().getProperty(key);
List<String> values = metadata.getAllMetadata(key);
- for (String value : values) {
- // Add each metadata value into the
- if (value != null &&
!config.getIgnoreValues().contains(value.trim())) {
- LOG.fine("Adding field: " + fieldName +
" value: " + value);
- doc.addField(fieldName, value);
+ if (values != null) {
+ for (String value : values) {
+ // Add each metadata value into the
+ if (value != null &&
!config.getIgnoreValues().contains(value.trim())) {
+ LOG.fine("Adding field: " +
fieldName + " value: " + value);
+ doc.addField(fieldName, value);
+ }
}
}
}
@@ -292,6 +294,19 @@ public class SolrIndexer {
}
LOG.info("Finished indexing product types.");
}
+
+ /**
+ * Suppresses exception that occurred with older file managers.
+ */
+ private ProductPage safeFirstPage(XmlRpcFileManagerClient fmClient,
ProductType type) {
+ ProductPage page = null;
+ try {
+ page = fmClient.getFirstPage(type);
+ } catch (Exception e) {
+ LOG.info("No products found for: " + type.getName());
+ }
+ return page;
+ }
/**
* This method indexes all products retrieved from the File Manager to
the
@@ -315,7 +330,7 @@ public class SolrIndexer {
if
(!config.getIgnoreTypes().contains(type.getName().trim())) {
LOG.info("Paging through products for
product type: "
+ type.getName());
- for (ProductPage page =
fmClient.getFirstPage(type); page
+ for (ProductPage page =
safeFirstPage(fmClient, type); page != null && !page
.isLastPage(); page =
fmClient.getNextPage(type, page)) {
for (Product product :
page.getPageProducts()) {
try {
@@ -329,18 +344,18 @@ public class SolrIndexer {
}
}
}
+ LOG.info("Finished indexing products.");
} catch (MalformedURLException e) {
LOG.severe("File Manager URL is malformed: " +
e.getMessage());
} catch (ConnectionException e) {
LOG.severe("Could not connect to File Manager: " +
e.getMessage());
} catch (CatalogException e) {
- LOG.severe("Could not retrieve product from File
Manager: "
+ LOG.severe("Could not retrieve products from File
Manager: "
+ e.getMessage());
} catch (RepositoryManagerException e) {
LOG.severe("Could not retrieve product types from File
Manager: "
+ e.getMessage());
}
- LOG.info("Finished indexing products.");
}
/**
Modified: oodt/trunk/filemgr/src/main/resources/indexer.properties
URL:
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/resources/indexer.properties?rev=1390797&r1=1390796&r2=1390797&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/main/resources/indexer.properties (original)
+++ oodt/trunk/filemgr/src/main/resources/indexer.properties Thu Sep 27
01:00:17 2012
@@ -39,6 +39,9 @@ config.access.url=http://localhost:8080/
# the actual value for the [ProductId]
config.replacement.keys=ProductURL
+# Must have map for unique id in Solr
+map.CAS.ProductId=id
+
# Map from File Manager terminology into Solr
# index doc field terminology. Only mapped fields
# will be added to the Solr index.