Exemplo n.º 1
0
 /**
  * Returns the base url of the provided CachedUrl, checking to see if it's the result of a
  * redirect.
  */
 public static String getBaseUrl(CachedUrl cu) {
   // See the comments in LockssResourceHandler.handleLockssRedirect();
   // this is the same logic.
   CIProperties props = cu.getProperties();
   if (props != null) {
     String redir = props.getProperty(CachedUrl.PROPERTY_CONTENT_URL);
     if (redir != null) {
       return redir;
     } else {
       String url = cu.getUrl();
       String nodeUrl = props.getProperty(CachedUrl.PROPERTY_NODE_URL);
       if (nodeUrl != null && !nodeUrl.equals(url)) {
         log.debug("getBaseUrl(" + url + "), nodeUrl: " + nodeUrl);
         if (dirNodeCheckSlash) {
           URI uri = new URI(url);
           if (!uri.getPath().endsWith("/")) {
             URI nodeUri = new URI(nodeUrl);
             if (nodeUri.getPath().endsWith("/")) {
               return nodeUrl;
             }
           }
         } else {
           return nodeUrl;
         }
       }
     }
   }
   return cu.getUrl();
 }
 private CIProperties getContentRisProperties() {
   CIProperties cProps = new CIProperties();
   // the CU checks the X-Lockss-content-type, not the content-type to determine encoding
   cProps.put(CachedUrl.PROPERTY_CONTENT_TYPE, "text/plain; charset=UTF-8");
   cProps.put("Content-type", "text/plain; charset=UTF-8");
   return cProps;
 }
Exemplo n.º 3
0
  public void setUp() throws Exception {
    super.setUp();
    theDaemon = getMockLockssDaemon();
    tempDir = getTempDir();
    String tempDirPath = tempDir.getAbsolutePath();
    System.setProperty("java.io.tmpdir", tempDirPath);

    Properties p = new Properties();
    p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb");
    p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1");
    p.setProperty(V3LcapMessage.PARAM_REPAIR_DATA_THRESHOLD, "4096");
    ConfigurationUtil.setCurrentConfigFromProps(p);
    IdentityManager idmgr = theDaemon.getIdentityManager();
    idmgr.startService();
    mPollMgr = new MockPollManager();
    theDaemon.setPollManager(mPollMgr);
    try {
      m_testID = idmgr.stringToPeerIdentity("127.0.0.1");
    } catch (IOException ex) {
      fail("can't open test host 127.0.0.1: " + ex);
    }
    m_repairProps = new CIProperties();
    m_repairProps.setProperty("key1", "val1");
    m_repairProps.setProperty("key2", "val2");
    m_repairProps.setProperty("key3", "val3");

    m_testVoteBlocks = V3TestUtils.makeVoteBlockList(10);
    m_testMsg = this.makeTestVoteMessage(m_testVoteBlocks);
  }
Exemplo n.º 4
0
  protected CIProperties makeCIProperties(ArchiveRecordHeader elementHeader) throws IOException {
    CIProperties ret = new CIProperties();
    Set elementHeaderFieldKeys = elementHeader.getHeaderFieldKeys();
    for (Iterator i = elementHeaderFieldKeys.iterator(); i.hasNext(); ) {
      String key = (String) i.next();
      try {

        Object valueObject = elementHeader.getHeaderValue(key);

        if (valueObject == null) {
          logger.warning("Ignoring null value for key '" + key + "'.");
        } else {
          String value = valueObject.toString();
          logger.debug3(key + ": " + value);
          ret.put(key, value);
        }

      } catch (ClassCastException ex) {
        logger.error("makeCIProperties: " + key + " threw ", ex);
        throw new CacheException.ExploderException(ex);
      }
    }
    return (ret);
  }
  public void setUp() throws Exception {
    super.setUp();

    tarHeader = new CIProperties();
    tarHeader.put(CachedUrl.PROPERTY_CONTENT_TYPE, "application/tar");
    tarAu = createTarAu();

    // for tests that also check for content
    els_mle =
        new FileMetadataListExtractor(
            new ElsevierDTD5XmlSourceMetadataExtractorFactory
                .ElsevierDTD5XmlSourceMetadataExtractor());
    // for tests that use a no-check-for-pdf version of the extractor
    nocheck_mle = new FileMetadataListExtractor(new TestElsevierDTD5MetadataExtractor());
    setUpExpectedTarContent();
  }