protected void processDeleteLog(File inLog, MediaArchive inArchive, ConvertStatus inStatus) throws FileNotFoundException, IOException, Exception { BufferedReader reader = new BufferedReader(new FileReader(inLog)); try { String line = reader.readLine(); int count = 0; while (line != null) { String[] tabs = line.split("\t"); if (tabs.length > 3) { if ("Record deleted".equals(tabs[3])) { String catName = inLog.getName(); if (catName.indexOf('-') != -1) { catName = catName.substring(0, catName.indexOf('-')); } else if (catName.indexOf('.') != -1) { catName = catName.substring(0, catName.lastIndexOf('.')); } String recordId = tabs[4]; String cumulusid = catName + "_" + recordId; // /createCumulusID(catName, recordId); // catName = extractId(catName); // Category root = // inArchive.getStore().getCatalogArchive().getRootCatalog().getChildByName(catName); SearchQuery query = inArchive.getAssetSearcher().createSearchQuery(); query.addExact("cumulusid", cumulusid); HitTracker hits = inArchive.getAssetSearcher().search(query); if (hits.getTotal() > 0) { count++; String id = hits.get(0).get("id"); deleteAsset(inArchive, id); } else { log.debug("No record found " + catName + "dash" + recordId); } } } line = reader.readLine(); } if (count > 0) { inArchive.getAssetSearcher().flush(); logMessage(inStatus, "Removed " + count + " records"); } } finally { FileUtils.safeClose(reader); } }
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 }