/** * @param url string representing the path portion of the URL of the binary * @param publication int representing the publication id * @return BinaryMeta the binary identified by url and publication * @throws ItemNotFoundException if the item identified by url and publication was not found */ public BinaryMeta getBinaryMetaByURL(String url, int publication) throws ItemNotFoundException { final BinaryMeta binaryMeta = WEB_BINARY_META_FACTORY.getMetaByURL(publication, url); if (binaryMeta == null) { throw new ItemNotFoundException("Unable to find binary by url '" + url + "' and publication '" + publication + "'."); } return binaryMeta; }
if (StringUtils.isEmpty(url)) { throw new ItemNotFoundException("Page Url was empty or could not be resolved."); LOG.trace(e.getLocalizedMessage(), e); LOG.warn("Page with url '{}' could not be found.", url); response.sendError(HttpServletResponse.SC_NOT_FOUND);
/** * @param id int representing the item id * @param publication int representing the publication id * @param variantId String representing the variant Id * @return BinaryData the binary identified by id, publication and variantId * @throws ItemNotFoundException if the item identified by id, publication and variantId was not found */ public BinaryData getBinaryDataById(int id, int publication, String variantId) throws ItemNotFoundException { final BinaryData binaryData; if (isEmpty(variantId)) { binaryData = BINARY_CONTENT_RETRIEVER.getBinary(publication, id); } else { binaryData = BINARY_CONTENT_RETRIEVER.getBinary(publication, id, variantId); } if (binaryData == null) { throw new ItemNotFoundException("Unable to find binary by id '" + id + "' and publication '" + publication + "'."); } return binaryData; }
cacheProvider.storeInItemCache(taxonomyURI, cacheElement); cacheElement.setExpired(true); throw new ItemNotFoundException("Taxonomy with uri: " + taxonomyURI + " not found."); cacheProvider.storeInItemCache(taxonomyURI, cacheElement); cacheElement.setExpired(true); LOG.error(e.getLocalizedMessage(), e); throw new IOException("Taxonomy with uri: " + taxonomyURI + " not found."); } catch (ParseException | SerializationException e) {
/** * Retrieves a list of URLs for all published Tridion Pages in a Publication. * * @param publication int representing the Publication id of the page * @return String representing the list of URLs (one URL per line) * @throws ItemNotFoundException if the requested page does not exist */ @Override public String getPageListByPublicationId(int publication) throws ItemNotFoundException { List<ItemMeta> itemMetas = null; try { ItemDAO itemDAO = (ItemDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping.PAGE_META); itemMetas = itemDAO.findAll(publication, ItemTypeSelector.PAGE); } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (itemMetas == null || itemMetas.isEmpty()) { throw new ItemNotFoundException("Unable to find page URL list by publication '" + publication + "'."); } StringBuilder result = new StringBuilder(); for (ItemMeta itemMeta : itemMetas) { result.append(((PageMeta) itemMeta).getUrl()).append("\r\n"); } return result.toString(); }
/** * 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; }
/** * 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; }
throw new ItemNotFoundException("Could not resolve Publication Id for binary path"); response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); LOG.error(e.getMessage(), e); throw new ItemNotFoundException(e);
public BinaryMeta getBinaryMetaByTcmUri(TCMURI binaryUri) throws ItemNotFoundException { BinaryMeta binaryMeta = WEB_BINARY_META_FACTORY.getMeta(binaryUri.toString()); if (binaryMeta == null) { throw new ItemNotFoundException("Unable to find binary by TCMURI '" + binaryUri.toString()); } return binaryMeta; }
/** * {@inheritDoc} */ @Override protected ComponentPresentation getDynamicComponentPresentationInternal(int componentId, int templateId, int publicationId) throws ItemNotFoundException, SerializationException { WebComponentPresentationFactory factory = FACTORY_CACHE.get(publicationId); if (factory == null) { factory = new WebComponentPresentationFactoryImpl(publicationId); FACTORY_CACHE.put(publicationId, factory); } com.tridion.dcp.ComponentPresentation result = templateId != 0 ? factory.getComponentPresentation(componentId, templateId) : factory.getComponentPresentationWithHighestPriority(componentId); if (result == null) { log.info(String.format(ERROR_MESSAGE, componentId, templateId, publicationId)); throw new ItemNotFoundException(String.format(ERROR_MESSAGE, componentId, templateId, publicationId)); } return getComponentPresentation(result.getContent()); }
/** * Retrieves the byte array content of a Tridion binary based on its TCM item id and publication id. * * @param id int representing the item id * @param publication int representing the publication id * @return byte[] the byte array of the binary content * @throws ItemNotFoundException if the item identified by id and publication was not found */ @Override public byte[] getBinaryContentById(int id, int publication) throws ItemNotFoundException { final BinaryData binaryData = BINARY_CONTENT_RETRIEVER.getBinary(publication, id); if (binaryData == null || binaryData.getDataSize() == 0) { throw new ItemNotFoundException("Unable to find binary content by id: tcm:" + publication + "-" + id); } try { return binaryData.getBytes().clone(); } catch (IOException e) { // TODO: wrap in provider exception throw new ItemNotFoundException(e); } }
/** * Retrieves the byte array content of a Tridion binary based on its TCM item id and publication id. * * TODO: interface and rework the pre Web 8 provider. * * @param id int representing the item id * @param publication int representing the publication id * @return byte[] the byte array of the binary content * @throws ItemNotFoundException if the item identified by id and publication was not found */ public byte[] getBinaryContentByIdAndVariantId(int id, int publication, String variantId) throws ItemNotFoundException { final BinaryData binaryData = BINARY_CONTENT_RETRIEVER.getBinary(publication, id, variantId); if (binaryData == null || binaryData.getDataSize() == 0) { throw new ItemNotFoundException("Unable to find binary content by id: tcm:" + publication + "-" + id + ", with variant Id: " + variantId); } try { return binaryData.getBytes().clone(); } catch (IOException e) { // TODO: wrap in provider exception throw new ItemNotFoundException(e); } }
/** * @param url string representing the path portion of the URL of the binary * @param publication int representing the publication id * @return BinaryVariant the binary identified by url and publication * @throws ItemNotFoundException if the item identified by url and publication was not found */ public BinaryVariant getBinaryVariantByURL(String url, int publication) throws ItemNotFoundException { BinaryVariant variant = null; try { BinaryVariantDAO variantDAO = (BinaryVariantDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping.BINARY_VARIANT); variant = variantDAO.findByURL(publication, url); } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (variant == null) { throw new ItemNotFoundException("Unable to find binary by url '" + url + "' and publication '" + publication + "'."); } return variant; }
/** * 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 { PageMeta meta = null; try { ItemDAO itemDAO = (ItemDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping.PAGE_META); meta = itemDAO.findByPageURL(publication, url); } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (meta == null) { throw new ItemNotFoundException("Unable to find page by url '" + url + "' and publication '" + publication + "'."); } return meta; }
/** * 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 { PageMeta meta = null; try { ItemDAO itemDAO = (ItemDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping.PAGE_META); meta = (PageMeta) itemDAO.findByPrimaryKey(publication, id); } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (meta == null) { throw new ItemNotFoundException("Unable to find page by id '" + id + "' and publication '" + publication + "'."); } return meta; }
/** * @param id int representing the item id * @param publication int representing the publication id * @param variantId String representing the variant Id. * @return BinaryVariant the binary identified by id, publication and variant Id (if not empty) * @throws ItemNotFoundException if the item identified by id and publication was not found */ public BinaryVariant getBinaryVariantById(int id, int publication, String variantId) throws ItemNotFoundException { BinaryVariant variant = null; try { BinaryVariantDAO variantDAO = (BinaryVariantDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping.BINARY_VARIANT); if (StringUtils.isEmpty(variantId)) { List<BinaryVariant> variants = variantDAO.findByPrimaryKey(publication, id); if (variants != null && !variants.isEmpty()) { // TODO: fix this. variant = variants.get(0); } } else { variant = variantDAO.findByPrimaryKey(publication, id, variantId); } } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (variant == null) { throw new ItemNotFoundException("Unable to find binary by id '" + id + "' and publication '" + publication + "'."); } return variant; }
/** * {@inheritDoc} */ @Override protected ComponentPresentation getDynamicComponentPresentationInternal(int componentId, int templateId, int publicationId) throws ItemNotFoundException, SerializationException { WebComponentPresentationFactory factory = FACTORY_CACHE.get(publicationId); if (factory == null) { factory = new WebComponentPresentationFactoryImpl(publicationId); FACTORY_CACHE.put(publicationId, factory); } com.tridion.dcp.ComponentPresentation result = templateId != 0 ? factory.getComponentPresentation(componentId, templateId) : factory.getComponentPresentationWithHighestPriority(componentId); if (result == null) { log.info(String.format(ERROR_MESSAGE, componentId, templateId, publicationId)); throw new ItemNotFoundException(String.format(ERROR_MESSAGE, componentId, templateId, publicationId)); } WebComponentPresentationAssembler assembler = new ComponentPresentationAssemblerImpl(publicationId); String assembledContent = assembler.getContent(result.getComponentId(), result.getComponentTemplateId()); return getComponentPresentation(assembledContent); }
/** * Retrieves the byte array content of a Tridion binary based on its TCM item id and publication id. * * @param id int representing the item id * @param publication int representing the publication id * @return byte[] the byte array of the binary content * @throws ItemNotFoundException if the item identified by id and publication was not found */ @Override public byte[] getBinaryContentById(int id, int publication) throws ItemNotFoundException { BinaryContentDAO contentDAO; BinaryContent content = null; try { contentDAO = (BinaryContentDAO) StorageManagerFactory.getDAO(publication, StorageTypeMapping .BINARY_CONTENT); content = contentDAO.findByPrimaryKey(publication, id, null); } catch (StorageException e) { LOG.error(e.getMessage(), e); } if (content == null) { throw new ItemNotFoundException("Unable to find binary content by id '" + id + "' and publication '" + publication + "'."); } return content.getContent(); }
@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 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."); }