protected Asset createAssetFromPage(MediaArchive inArchive, User inUser, Page inAssetPage) { Asset asset = getAssetUtilities().createAssetIfNeeded(inAssetPage.getContentItem(), inArchive, inUser); boolean existing = true; if (asset == null) { // Should never call this String originals = "/WEB-INF/data" + inArchive.getCatalogHome() + "/originals/"; String sourcepath = inAssetPage.getPath().substring(originals.length()); asset = inArchive.getAssetBySourcePath(sourcepath); return asset; } if (asset.get("recordmodificationdate") == null) { existing = false; } inArchive.saveAsset(asset, inUser); if (existing) { inArchive.fireMediaEvent("asset/originalmodified", inUser, asset); } else { inArchive.fireMediaEvent("asset/assetcreated", inUser, asset); } inArchive.fireMediaEvent("importing/assetsimported", inUser, asset); return asset; }
public void filterOrderItems(WebPageRequest req) { ArrayList<String> list = new ArrayList<String>(); // add omitted orders to a list String publishtype = req.getRequestParameter("publishdestination.value"); String catalogid = req.findValue("catalogid"); HitTracker items = (HitTracker) req.getPageValue("orderitems"); if (items == null) { Order order = loadOrder(req); if (order != null) { String orderid = order.getId(); if (orderid == null) { orderid = req.getRequestParameter("orderid"); } items = getOrderManager().findOrderItems(req, catalogid, order); } } if (items != null) { // get searchers Searcher publishdestsearcher = getMediaArchive(req).getSearcherManager().getSearcher(catalogid, "publishdestination"); Data publisher = (Data) publishdestsearcher.searchById(publishtype); String publishername = publisher.getName(); Searcher convertpresetsearcher = getMediaArchive(req).getSearcherManager().getSearcher(catalogid, "convertpreset"); // see if convertpreset has the appropriate field String publishtofield = "publishto" + publishername.replace(" ", "").toLowerCase(); if (convertpresetsearcher.getDetail(publishtofield) != null) // field is present { for (int i = 0; i < items.size(); i++) { Data data = items.get(i); Asset asset = getMediaArchive(req).getAsset(data.get("assetid")); String fileformat = asset.get("fileformat"); String rendertype = getMediaArchive(req).getMediaRenderType(fileformat); // build query SearchQuery presetquery = convertpresetsearcher.createSearchQuery(); presetquery.append(publishtofield, "true").append("inputtype", rendertype); // execute query HitTracker hits = convertpresetsearcher.search(presetquery); if (hits.size() > 0) continue; list.add(asset.getId()); } } } req.putPageValue("invaliditems", list); // process this in step2 }