Hi Liam,
the result of pageStore.getChildren(Page.class, true); is of type Listable<Page> which is a subclass of Iterable. You can iterate directly over that result and there is no need to get an iterator object first.
Try it this way:
...
Listable<Page> pages = pageStore.getChildren(Page.class, true);
int topicPageCount = 0;
Map<ContentEditor, List<Page>> pagesPerEditor = new HashMap<ContentEditor, List<Page>>();
for (Page page : pages) {
[add some magic here]
}
...
The documentation for the class Iterable says that you should not to "toList()" or something but instead use the iterable directly. See: http://www.e-spirit.com/odfs52/access/de/espirit/common/util/Listable.html#toList()
Also try to just hold the data you need in the memory and minimize the usage of FirstSpirit objects and the number of times you access e.g. a store! This might decrease your memory usage.
For example try something like this:
public class PageEntity {
private String refName;
private String displayName;
public PageEntity(Page page, Language language) {
refName = page.getReferenceName();
displayName = page.getDisplayName(language);
}
public String getRefName() {
return refName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public void setRefName(String refName) {
this.refName = refName;
}
}
Map<ContentEditor, List<PageEntity>> pagesPerEditor = new HashMap<>();
...
pagesPerEditor.get(ce).add(new PageEntity(page, language));
...
for (PageEntity p : pagesPerEditor.get(ce)) {
String url = getPageUrl(p);
context.logError("\t" + p.getRefName() + ", " + p.getDisplayName() + ", " + url);
}
instead of this:
Map<ContentEditor, List<Page>> pagesPerEditor = new HashMap<ContentEditor, List<Page>>();
...
pagesPerEditor.get(ce).add(page);
...
for (Page p : pagesPerEditor.get(ce)) {
String url = getPageUrl(p);
context.logError("\t" + p.getReferenceName() + ", " + p.getDisplayName(language) + ", " + url);
}
Maybe this will solve your problem.
Greetings
Sandro