/** * Returns the given entry's with the given id or null if it doesn't exist. */ private BaseContentEntry<?> getEntryById(BaseContentEntry<?> entry, SitesService sitesService) { try { return sitesService.getEntry(new URL(entry.getId()), entry.getClass()); } catch (IOException e) { return null; } catch (ServiceException e) { return null; } }
private List<BasePageEntry<?>> getAncestors(BaseContentEntry<?> entry, EntryStore entryStore) { BasePageEntry<?> parent = entryStore.getParent(entry.getId()); if (parent == null) { return Lists.newLinkedList(); } List<BasePageEntry<?>> ancestors = getAncestors(parent, entryStore); ancestors.add(parent); return ancestors; } }
@Override public void addEntry(BaseContentEntry<?> entry) { checkNotNull(entry); String id = entry.getId(); if (id != null && entries.get(id) == null) { entries.put(id, entry); String parentId = EntryUtils.getParentId(entry); if (parentId == null) { if (isPage(entry)) { topLevelEntries.add((BasePageEntry<?>) entry); } else { LOGGER.log(Level.WARNING, "All non-page entries must have a parent!"); } } else { children.put(parentId, entry); } } else { LOGGER.log(Level.WARNING, "All entries should have a unique non-null id!"); } }
@Override public BaseContentEntry<?> updateEntry(BaseContentEntry<?> oldEntry, BaseContentEntry<?> newEntry, SitesService sitesService) { try { checkNotNull(oldEntry, "oldEntry"); checkNotNull(newEntry, "newEntry"); checkNotNull(sitesService, "sitesService"); return sitesService.update(new URL(oldEntry.getId()), newEntry, oldEntry.getEtag()); } catch (IOException e) { LOGGER.log(Level.WARNING, "Unable to update entry:" + oldEntry, e); return null; } catch (NullPointerException e) { LOGGER.log(Level.WARNING, "Unable to update entry:" + oldEntry, e); return null; } catch (ServiceException e) { LOGGER.log(Level.WARNING, "Unable to update entry:" + oldEntry, e); return null; } }
private String getPathToRoot(BaseContentEntry<?> entry, EntryStore entryStore) { BasePageEntry<?> parent = entryStore.getParent(entry.getId()); if (parent == null) { return "../"; } return getPathToRoot(parent, entryStore) + "../"; }
private String getSiteRoot(BaseContentEntry<?> entry, EntryStore entryStore) { BasePageEntry<?> parent = entryStore.getParent(entry.getId()); if (parent == null) { return "../"; } return getSiteRoot(parent, entryStore) + "../"; } }
/** * Creates a new hAtom "hentry" element of the given type for the given entry. */ static XmlElement getEntryElement(BaseContentEntry<?> entry, String elementType) { checkNotNull(entry, "entry"); checkNotNull(elementType, "elementType"); XmlElement element = new XmlElement(elementType); element.setAttribute("id", entry.getId()); element.setAttribute("class", "hentry " + getType(entry).toString()); return element; }
URL feedUrl; try { feedUrl = new URL(page.getId().replace("content", "revision")); } catch (MalformedURLException e) { LOGGER.log(Level.WARNING, "Invalid revisions URL!", e); for (BaseContentEntry<?> entry : feedProvider.getEntries(feedUrl, sitesService)) { entry.setId(page.getId()); revisions.add(entry);
XmlElement mainDiv = new XmlElement("div"); mainDiv.setAttribute("class", "hentry " + getType(entry).toString()); mainDiv.setAttribute("id", entry.getId()); if (entryStore.getParent(entry.getId()) != null) { List<BasePageEntry<?>> ancestors = getAncestors(entry, entryStore); mainDiv.addElement(ancestorLinksRenderer.renderAncestorLinks(ancestors)); List<ListItemEntry> listItems = Lists.newArrayList(); List<BasePageEntry<?>> subpages = Lists.newArrayList(); for (BaseContentEntry<?> child : entryStore.getChildren(entry.getId())) { switch(getType(child)) { case ANNOUNCEMENT: