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.º 2
0
 protected void writeCu(CachedUrl cu) throws IOException {
   String url = cu.getUrl();
   long contentSize = cu.getContentSize();
   CIProperties props = cu.getProperties();
   long fetchTime = Long.parseLong(props.getProperty(CachedUrl.PROPERTY_FETCH_TIME));
   InputStream contentIn = cu.getUnfilteredInputStream();
   try {
     if (isResponse) {
       String hdrString = getHttpResponseString(cu);
       long size = contentSize + hdrString.length();
       InputStream headerIn = new ReaderInputStream(new StringReader(hdrString));
       InputStream concat = new SequenceInputStream(headerIn, contentIn);
       try {
         aw.write(xlateFilename(url), cu.getContentType(), getHostIp(), fetchTime, size, concat);
       } finally {
         IOUtil.safeClose(concat);
       }
     } else {
       aw.write(
           xlateFilename(url),
           cu.getContentType(),
           getHostIp(),
           fetchTime,
           cu.getContentSize(),
           contentIn);
     }
   } finally {
     AuUtil.safeRelease(cu);
   }
 }
Exemplo n.º 3
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();
  }
 private void setContents(String s) {
   contents = s;
   props.setProperty("Content-Length", "" + s.length());
 }
 /**
  * Create a CachedUrl with content
  *
  * @param owner the CUS owner
  * @param url the url
  * @param type the type
  * @param contents the contents
  */
 public SCU(CachedUrlSet owner, String url, String type, String contents) {
   this(owner, url);
   setContents(contents);
   props.setProperty(CachedUrl.PROPERTY_CONTENT_TYPE, type);
 }