コード例 #1
0
 /**
  * Checks the consistency of the node, and continues with its children if it's consistent.
  *
  * @param node RepositoryNodeImpl the node to check
  */
 private void recurseConsistencyCheck(RepositoryNodeImpl node) {
   logger.debug2("Checking node '" + node.getNodeUrl() + "'...");
   // check consistency at each node
   // correct/deactivate as necessary
   // 'checkNodeConsistency()' will repair if possible
   if (node.checkNodeConsistency()) {
     logger.debug3("Node consistent; recursing on children...");
     List children = node.getNodeList(null, false);
     Iterator iter = children.iterator();
     while (iter.hasNext()) {
       RepositoryNodeImpl child = (RepositoryNodeImpl) iter.next();
       recurseConsistencyCheck(child);
     }
   } else {
     logger.debug3("Node inconsistent; deactivating...");
     deactivateInconsistentNode(node);
   }
 }
コード例 #2
0
 /**
  * mapUrlToFileLocation() is the method used to resolve urls into file names. This maps a given
  * url to a file location, using the au top directory as the base. It creates directories which
  * mirror the html string, so 'http://www.journal.org/issue1/index.html' would be cached in the
  * file: <rootLocation>/www.journal.org/http/issue1/index.html
  *
  * @param rootLocation the top directory for ArchivalUnit this URL is in
  * @param urlStr the url to translate
  * @return the url file location
  * @throws java.net.MalformedURLException
  */
 public static String mapUrlToFileLocation(String rootLocation, String urlStr)
     throws MalformedURLException {
   int totalLength = rootLocation.length() + urlStr.length();
   URL url = new URL(urlStr);
   StringBuilder buffer = new StringBuilder(totalLength);
   buffer.append(rootLocation);
   if (!rootLocation.endsWith(File.separator)) {
     buffer.append(File.separator);
   }
   buffer.append(url.getHost().toLowerCase());
   int port = url.getPort();
   if (port != -1) {
     buffer.append(PORT_SEPARATOR);
     buffer.append(port);
   }
   buffer.append(File.separator);
   buffer.append(url.getProtocol());
   if (RepositoryManager.isEnableLongComponents()) {
     String escapedPath =
         escapePath(
             StringUtil.replaceString(url.getPath(), UrlUtil.URL_PATH_SEPARATOR, File.separator));
     String query = url.getQuery();
     if (query != null) {
       escapedPath = escapedPath + "?" + escapeQuery(query);
     }
     String encodedPath = RepositoryNodeImpl.encodeUrl(escapedPath);
     // encodeUrl strips leading / from path
     buffer.append(File.separator);
     buffer.append(encodedPath);
   } else {
     buffer.append(
         escapePath(
             StringUtil.replaceString(url.getPath(), UrlUtil.URL_PATH_SEPARATOR, File.separator)));
     String query = url.getQuery();
     if (query != null) {
       buffer.append("?");
       buffer.append(escapeQuery(query));
     }
   }
   return buffer.toString();
 }
コード例 #3
0
 /**
  * This is called when a node is in an inconsistent state. It simply creates some necessary
  * directories and deactivates the node. Future polls should restore it properly.
  *
  * @param node the inconsistent node
  */
 void deactivateInconsistentNode(RepositoryNodeImpl node) {
   logger.warning("Deactivating inconsistent node.");
   FileUtil.ensureDirExists(node.contentDir);
   // manually deactivate
   node.deactivateContent();
 }