Skip to content
Browse files

Check contentType support on getSiteContentIterator

  • Loading branch information...
1 parent 4dfe7d5 commit 7c24a263505fceecaa1b311f01ed34da39315615 @ColinHebert committed May 18, 2012
View
31 impl/src/main/java/uk/ac/ox/oucs/search/solr/producer/ContentHostingContentProducer.java
@@ -48,7 +48,7 @@ public String getTitle(String reference) {
@Override
public Integer getAction(Event event) {
- if (!isContentTypeSupported(getResourceType(event.getResource())))
+ if (!isContentTypeSupported(getContentType(event.getResource())))
return SolrSearchIndexBuilder.ItemAction.UNKNOWN.getItemAction();
String eventName = event.getEvent();
@@ -62,7 +62,7 @@ public Integer getAction(Event event) {
}
}
- private String getResourceType(String reference) {
+ private String getContentType(String reference) {
try {
return contentHostingService.getResource(getId(reference)).getContentType();
} catch (IdUnusedException e) {
@@ -93,18 +93,41 @@ public String getTool() {
return new Iterator<String>() {
Iterator<ContentResource> scIterator = siteContent.iterator();
+ String nextReference;
+ boolean hasNext = true;
+
+ {
+ checkForNext();
+ }
public boolean hasNext() {
- return scIterator.hasNext();
+ return hasNext;
}
public String next() {
- return scIterator.next().getReference();
+ if(!hasNext)
+ throw new NoSuchElementException();
+
+ String nextReference = this.nextReference;
+ checkForNext();
+ return nextReference;
}
public void remove() {
throw new UnsupportedOperationException("Remove is not implemented ");
}
+
+ private void checkForNext() {
+ while (scIterator.hasNext()) {
+ String reference = scIterator.next().getReference();
+ String contentType = getContentType(reference);
+ if (isContentTypeSupported(contentType)) {
+ nextReference = reference;
+ return;
+ }
+ }
+ hasNext = false;
+ }
};
}

0 comments on commit 7c24a26

Please sign in to comment.
Something went wrong with that request. Please try again.