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);
    }
  }
예제 #2
0
  protected XmlFile load(String inId, String path, String inElementName, ContentItem input)
      throws OpenEditException {
    // log.info("Loading " + path);
    boolean found = false;

    XmlFile element;
    Element root = null;
    if (!input.exists()) {
      if (inElementName == null) {
        root = DocumentHelper.createElement("root");
      } else {
        if (inElementName.endsWith("y")) {
          root =
              DocumentHelper.createElement(
                  inElementName.substring(0, inElementName.length() - 1) + "ies");
        } else {
          root = DocumentHelper.createElement(inElementName + "s");
        }
      }
    } else {
      found = true;
      InputStream in = input.getInputStream();
      try {
        root = getXmlUtil().getXml(in, "UTF-8");
      } catch (OpenEditException ex) {
        log.error("file problem: " + path, ex);
        throw ex;
      } finally {
        FileUtils.safeClose(in);
      }
    }
    element = new XmlFile();
    element.setRoot(root);
    element.setExist(found);
    element.setElementName(inElementName);
    element.setPath(path);
    element.setLastModified(input.lastModified().getTime());
    element.setId(inId);

    return element;
  }