/** * Retrieves content of a Page by looking the page up by its URL. * * @param url String representing the path part of the page URL * @param publication int representing the Publication id of the page * @return String representing the content of the Page * @throws SerializationException if something goes wrong deserializing * @throws ItemNotFoundException if the requested page does not exist */ @Override public String getPageContentByURL(String url, int publication) throws ItemNotFoundException, SerializationException { final PageMeta meta = getPageMetaByURL(url, publication); return getPageContentById(meta.getId(), meta.getPublicationId()); }
/** * <p>pageProvider.</p> * * @return a {@link org.dd4t.providers.impl.BrokerPageProvider} object. */ @Bean public BrokerPageProvider pageProvider() { BrokerPageProvider pageProvider = new BrokerPageProvider(); pageProvider.setContentIsCompressed("false"); return pageProvider; }
@Override public PageProviderResultItem<String> getPageById(final int id, final int publication) throws IOException, ItemNotFoundException, SerializationException { final PageMeta pageMeta = getPageMetaById(id, publication); PageProviderResultItem<String> pageResult = new PageResultItemImpl(pageMeta.getPublicationId(), pageMeta .getId(), pageMeta.getURLPath()); pageResult.setLastPublishDate(pageMeta.getLastPublicationDate()); pageResult.setRevisionDate(pageMeta.getModificationDate()); pageResult.setContentSource(getPageContentById(id, publication)); return pageResult; }
/** * Retrieves content of a Page by looking the page up by its item id and Publication id. * * @param id int representing the page item id * @param publication int representing the Publication id of the page * @return String representing the content of the Page * @throws ItemNotFoundException if the requested page does not exist */ @Override public String getPageContentById(int id, int publication) throws ItemNotFoundException, SerializationException { final CharacterData data = PAGE_CONTENT_RETRIEVER.getPageContent(publication, id); if (data == null) { throw new ItemNotFoundException("Unable to find page by id '" + id + "' and publication '" + publication + "'."); } try { return decodeAndDecompressContent(convertStreamToString(data.getInputStream())); } catch (IOException e) { throw new SerializationException(e); } }
String key = getKey(CacheType.PAGE_EXISTS, url); CacheElement<Integer> cacheElement = cacheProvider.loadPayloadFromLocalCache(key); Integer result = 0; final PageMeta pageMeta = getPageMetaByURL(url, publicationId); if (pageMeta != null) { result = 1;
@Override public DateTime getLastPublishDate(final String url, final int publication) throws ItemNotFoundException { final PageMeta pageMeta = getPageMetaByURL(url, publication); final Date lpd = pageMeta.getLastPublicationDate(); return lpd != null ? new DateTime(lpd) : Constants.THE_YEAR_ZERO; } }
@Override public String getPageContentById(final String tcmUri) throws ItemNotFoundException, ParseException, SerializationException { final TCMURI uri = new TCMURI(tcmUri); return getPageContentById(uri.getItemId(), uri.getPublicationId()); }
String key = getKey(CacheType.PAGE_EXISTS, url); CacheElement<Integer> cacheElement = cacheProvider.loadPayloadFromLocalCache(key); Integer result = null;
/** * Retrieves metadata of a Page by looking the page up by its item id and Publication id. * * @param id int representing the page item id * @param publication int representing the Publication id of the page * @return PageMeta representing the metadata of the Page * @throws ItemNotFoundException if the requested page does not exist */ public PageMeta getPageMetaById(int id, int publication) throws ItemNotFoundException { final WebPageMetaFactory webPageMetaFactory = getWebPageMetaFactory(publication); final PageMeta pageMeta = webPageMetaFactory.getMeta(id); if (pageMeta == null) { throw new ItemNotFoundException("Unable to find page by id '" + id + "' and publication '" + publication + "'."); } return pageMeta; }
@Override public PageProviderResultItem<String> getPageById(final int id, final int publication) throws IOException, ItemNotFoundException, SerializationException { final PageMeta pageMeta = getPageMetaById(id, publication); if (pageMeta == null) { throw new ItemNotFoundException("Unable to find page meta by id '" + id + "' and publication '" + publication + "'."); } PageProviderResultItem<String> pageResult = new PageResultItemImpl(pageMeta.getPublicationId(), pageMeta .getItemId(), pageMeta.getUrl()); pageResult.setLastPublishDate(pageMeta.getLastPublishDate()); pageResult.setRevisionDate(pageMeta.getModificationDate()); pageResult.setContentSource(getPageContentById(id, publication)); return pageResult; }
/** * Retrieves content of a Page by looking the page up by its item id and Publication id. * * @param id int representing the page item id * @param publication int representing the Publication id of the page * @return String representing the content of the Page * @throws ItemNotFoundException if the requested page does not exist */ @Override public String getPageContentById(int id, int publication) throws ItemNotFoundException, SerializationException { CharacterData data = null; try { PageDAO pageDAO = (PageDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping.PAGE); data = pageDAO.findByPrimaryKey(publication, id); } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (data == null) { throw new ItemNotFoundException("Unable to find page by id '" + id + "' and publication '" + publication + "'."); } try { return decodeAndDecompressContent(convertStreamToString(data.getInputStream())); } catch (IOException e) { throw new SerializationException(e); } }
@Override public DateTime getLastPublishDate(final String url, final int publication) throws ItemNotFoundException { PageMeta pageMeta = getPageMetaByURL(url, publication); Date lpd = pageMeta.getLastPublishDate(); return lpd != null ? new DateTime(pageMeta.getLastPublishDate()) : Constants.THE_YEAR_ZERO; }
@Override public String getPageContentById(final String tcmUri) throws ItemNotFoundException, ParseException, SerializationException { TCMURI uri = new TCMURI(tcmUri); return getPageContentById(uri.getItemId(), uri.getPublicationId()); }
/** * Retrieves metadata of a Page by looking the page up by its URL. * * @param url String representing the path part of the page URL * @param publication int representing the Publication id of the page * @return PageMeta representing the metadata of the Page * @throws ItemNotFoundException if the requested page does not exist */ public PageMeta getPageMetaByURL(String url, int publication) throws ItemNotFoundException { final WebPageMetaFactory webPageMetaFactory = getWebPageMetaFactory(publication); final PageMeta pageMeta = webPageMetaFactory.getMetaByURL(publication, url); if (pageMeta == null) { throw new ItemNotFoundException("Unable to find page by url '" + url + "' and publication '" + publication + "'."); } return pageMeta; }
/** * Retrieves content of a Page by looking the page up by its URL. * * @param url String representing the path part of the page URL * @param publication int representing the Publication id of the page * @return String representing the content of the Page * @throws SerializationException if the character stream cannot be read * @throws ItemNotFoundException if the requested page does not exist */ @Override public String getPageContentByURL(String url, int publication) throws ItemNotFoundException, SerializationException { PageMeta meta = getPageMetaByURL(url, publication); return getPageContentById(meta.getItemId(), meta.getPublicationId()); }
@Override public TCMURI getPageIdForUrl(final String url, final int publicationId) throws ItemNotFoundException, SerializationException { final PageMeta pageMeta = getPageMetaByURL(url, publicationId); if (pageMeta != null) { return new TCMURI(publicationId, pageMeta.getId(), pageMeta.getType(), pageMeta.getMajorVersion()); } throw new ItemNotFoundException("Page Id for URL not found."); }
@Override public PageProviderResultItem<String> getPageByURL(final String url, final int publication) throws ItemNotFoundException, SerializationException { final PageMeta pageMeta = getPageMetaByURL(url, publication); PageProviderResultItem<String> pageResult = new PageResultItemImpl(pageMeta.getPublicationId(), pageMeta .getId(), pageMeta.getURLPath()); pageResult.setLastPublishDate(pageMeta.getLastPublicationDate()); pageResult.setRevisionDate(pageMeta.getModificationDate()); pageResult.setContentSource(getPageContentById(pageMeta.getId(), pageMeta.getPublicationId())); return pageResult; }
@Override public TCMURI getPageIdForUrl(final String url, final int publicationId) throws ItemNotFoundException, SerializationException { PageMeta pageMeta = getPageMetaByURL(url, publicationId); if (pageMeta != null) { return new TCMURI(publicationId, pageMeta.getItemId(), pageMeta.getItemType(), pageMeta.getMajorVersion()); } throw new ItemNotFoundException("Page Id for URL not found."); }
@Override public PageProviderResultItem<String> getPageByURL(final String url, final int publication) throws ItemNotFoundException, SerializationException { PageMeta pageMeta = getPageMetaByURL(url, publication); if (pageMeta == null) { throw new ItemNotFoundException("Unable to find page meta by url '" + url + "' and publication '" + publication + "'."); } PageProviderResultItem<String> pageResult = new PageResultItemImpl(pageMeta.getPublicationId(), pageMeta .getItemId(), pageMeta.getUrl()); pageResult.setLastPublishDate(pageMeta.getLastPublishDate()); pageResult.setRevisionDate(pageMeta.getModificationDate()); pageResult.setContentSource(getPageContentById(pageMeta.getItemId(), pageMeta.getPublicationId())); return pageResult; }