@Test public final void testWARCGetHeaders() throws Exception { long length = 7250; long offset = 1723422; String name = "http: HarvestResourceDTO dto = new ArcHarvestResourceDTO(targetInstanceOid, harvestResultNumber, 54321, name, length, offset, 0, TestCWARC, 200, true); Header[] headers = testInstance.getHeaders(new Long(targetInstanceOid).toString(), harvestResultNumber, dto); assertTrue(headers != null); assertTrue(headers.length == 4); }
public Header[] getHeaders(String targetInstanceName, int harvestResultNumber, HarvestResourceDTO resourcex) throws DigitalAssetStoreException { if (log.isDebugEnabled()) { log.debug("Start of getHeaders()"); log.debug("Casting the DTO to ArcHarvestResult"); } Header[] headers = new Header[0]; ArchiveRecord record = null; ArchiveReader reader = null; ArcHarvestResourceDTO resource = (ArcHarvestResourceDTO) resourcex; if (log.isDebugEnabled()) { log.debug("Determining the filename"); } File source = new File(this.baseDir, "/" + targetInstanceName + "/" + harvestResultNumber + "/" + resource.getArcFileName()); try { if (log.isDebugEnabled()) { log.debug("Create the Archive File Reader"); } try { reader = ArchiveReaderFactory.get(source); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Could not read headers for ArchiveRecord from " + source.getAbsolutePath() + " from local store"); } source = new File(fileArchive.getArchiveRepository() + "/" + targetInstanceName + "/" + fileArchive.getArchiveArcDirectory() + "/" + resource.getArcFileName()); if (log.isWarnEnabled()) { log.info("trying filestore " + source.getAbsolutePath()); } reader = ArchiveReaderFactory.get(source); } if (log.isDebugEnabled()) { log.debug("Skipping to the appropriate record at offset: " + resource.getResourceOffset()); } record = reader.get(resource.getResourceOffset()); if (record instanceof ARCRecord) { log.debug("Reading the headers"); ((ARCRecord) record).skipHttpHeader(); headers = ((ARCRecord) record).getHttpHeaders(); } else { log.debug("Reading the headers"); skipStatusLine(record); headers = HttpParser.parseHeaders(record, WARCConstants.DEFAULT_ENCODING); } return headers; } catch (IOException ex) { if (log.isWarnEnabled()) { log.warn("Error reading headers from ArchiveRecord: " + ex.getMessage()); } } finally { try { if (record != null) record.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close record failed " + ex.getMessage(), ex); } } try { if (record != null) reader.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close reader failed " + ex.getMessage(), ex); } } if (log.isDebugEnabled()) { log.debug("End of method"); } } return null; }
ArcDigitalAssetStoreService implements DigitalAssetStore,
        LogProvider { public Header[] getHeaders(String targetInstanceName, int harvestResultNumber, HarvestResourceDTO resourcex) throws DigitalAssetStoreException { if (log.isDebugEnabled()) { log.debug("Start of getHeaders()"); log.debug("Casting the DTO to ArcHarvestResult"); } Header[] headers = new Header[0]; ArchiveRecord record = null; ArchiveReader reader = null; ArcHarvestResourceDTO resource = (ArcHarvestResourceDTO) resourcex; if (log.isDebugEnabled()) { log.debug("Determining the filename"); } File source = new File(this.baseDir, "/" + targetInstanceName + "/" + harvestResultNumber + "/" + resource.getArcFileName()); try { if (log.isDebugEnabled()) { log.debug("Create the Archive File Reader"); } try { reader = ArchiveReaderFactory.get(source); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Could not read headers for ArchiveRecord from " + source.getAbsolutePath() + " from local store"); } source = new File(fileArchive.getArchiveRepository() + "/" + targetInstanceName + "/" + fileArchive.getArchiveArcDirectory() + "/" + resource.getArcFileName()); if (log.isWarnEnabled()) { log.info("trying filestore " + source.getAbsolutePath()); } reader = ArchiveReaderFactory.get(source); } if (log.isDebugEnabled()) { log.debug("Skipping to the appropriate record at offset: " + resource.getResourceOffset()); } record = reader.get(resource.getResourceOffset()); if (record instanceof ARCRecord) { log.debug("Reading the headers"); ((ARCRecord) record).skipHttpHeader(); headers = ((ARCRecord) record).getHttpHeaders(); } else { log.debug("Reading the headers"); skipStatusLine(record); headers = HttpParser.parseHeaders(record, WARCConstants.DEFAULT_ENCODING); } return headers; } catch (IOException ex) { if (log.isWarnEnabled()) { log.warn("Error reading headers from ArchiveRecord: " + ex.getMessage()); } } finally { try { if (record != null) record.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close record failed " + ex.getMessage(), ex); } } try { if (record != null) reader.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close reader failed " + ex.getMessage(), ex); } } if (log.isDebugEnabled()) { log.debug("End of method"); } } return null; } }
ArcDigitalAssetStoreService implements DigitalAssetStore,
        LogProvider { public Header[] getHeaders(String targetInstanceName, int harvestResultNumber, HarvestResourceDTO resourcex) throws DigitalAssetStoreException { if (log.isDebugEnabled()) { log.debug("Start of getHeaders()"); log.debug("Casting the DTO to ArcHarvestResult"); } Header[] headers = new Header[0]; ArchiveRecord record = null; ArchiveReader reader = null; ArcHarvestResourceDTO resource = (ArcHarvestResourceDTO) resourcex; if (log.isDebugEnabled()) { log.debug("Determining the filename"); } File source = new File(this.baseDir, "/" + targetInstanceName + "/" + harvestResultNumber + "/" + resource.getArcFileName()); try { if (log.isDebugEnabled()) { log.debug("Create the Archive File Reader"); } try { reader = ArchiveReaderFactory.get(source); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Could not read headers for ArchiveRecord from " + source.getAbsolutePath() + " from local store"); } source = new File(fileArchive.getArchiveRepository() + "/" + targetInstanceName + "/" + fileArchive.getArchiveArcDirectory() + "/" + resource.getArcFileName()); if (log.isWarnEnabled()) { log.info("trying filestore " + source.getAbsolutePath()); } reader = ArchiveReaderFactory.get(source); } if (log.isDebugEnabled()) { log.debug("Skipping to the appropriate record at offset: " + resource.getResourceOffset()); } record = reader.get(resource.getResourceOffset()); if (record instanceof ARCRecord) { log.debug("Reading the headers"); ((ARCRecord) record).skipHttpHeader(); headers = ((ARCRecord) record).getHttpHeaders(); } else { log.debug("Reading the headers"); skipStatusLine(record); headers = HttpParser.parseHeaders(record, WARCConstants.DEFAULT_ENCODING); } return headers; } catch (IOException ex) { if (log.isWarnEnabled()) { log.warn("Error reading headers from ArchiveRecord: " + ex.getMessage()); } } finally { try { if (record != null) record.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close record failed " + ex.getMessage(), ex); } } try { if (record != null) reader.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close reader failed " + ex.getMessage(), ex); } } if (log.isDebugEnabled()) { log.debug("End of method"); } } return null; }  }
ArcDigitalAssetStoreService implements DigitalAssetStore,
        LogProvider { public Header[] getHeaders(String targetInstanceName, int harvestResultNumber, HarvestResourceDTO resourcex) throws DigitalAssetStoreException { if (log.isDebugEnabled()) { log.debug("Start of getHeaders()"); log.debug("Casting the DTO to ArcHarvestResult"); } Header[] headers = new Header[0]; ArchiveRecord record = null; ArchiveReader reader = null; ArcHarvestResourceDTO resource = (ArcHarvestResourceDTO) resourcex; if (log.isDebugEnabled()) { log.debug("Determining the filename"); } File source = new File(this.baseDir, "/" + targetInstanceName + "/" + harvestResultNumber + "/" + resource.getArcFileName()); try { if (log.isDebugEnabled()) { log.debug("Create the Archive File Reader"); } try { reader = ArchiveReaderFactory.get(source); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Could not read headers for ArchiveRecord from " + source.getAbsolutePath() + " from local store"); } source = new File(fileArchive.getArchiveRepository() + "/" + targetInstanceName + "/" + fileArchive.getArchiveArcDirectory() + "/" + resource.getArcFileName()); if (log.isWarnEnabled()) { log.info("trying filestore " + source.getAbsolutePath()); } reader = ArchiveReaderFactory.get(source); } if (log.isDebugEnabled()) { log.debug("Skipping to the appropriate record at offset: " + resource.getResourceOffset()); } record = reader.get(resource.getResourceOffset()); if (record instanceof ARCRecord) { log.debug("Reading the headers"); ((ARCRecord) record).skipHttpHeader(); headers = ((ARCRecord) record).getHttpHeaders(); } else { log.debug("Reading the headers"); skipStatusLine(record); headers = HttpParser.parseHeaders(record, WARCConstants.DEFAULT_ENCODING); } return headers; } catch (IOException ex) { if (log.isWarnEnabled()) { log.warn("Error reading headers from ArchiveRecord: " + ex.getMessage()); } } finally { try { if (record != null) record.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close record failed " + ex.getMessage(), ex); } } try { if (record != null) reader.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close reader failed " + ex.getMessage(), ex); } } if (log.isDebugEnabled()) { log.debug("End of method"); } } return null; }  void save(String targetInstanceName, String directory, File file); void save(String targetInstanceName, String directory, File[] files); void save(String targetInstanceName, File[] files); void save(String targetInstanceName, File file); @SuppressWarnings("finally") File getResource(String targetInstanceName, int harvestResultNumber,
                            HarvestResourceDTO resourcex); byte[] getSmallResource(String targetInstanceName,
                                   int harvestResultNumber, HarvestResourceDTO resourcex); Header[] getHeaders(String targetInstanceName,
                               int harvestResultNumber, HarvestResourceDTO resourcex); HarvestResultDTO copyAndPrune(String targetInstanceName,
                                         int orgHarvestResultNum, int newHarvestResultNum,
                                         List<String> urisToDelete, List<HarvestResourceDTO> hrsToImport); File getLogFile(String aJob, String aFileName); List<String> getLogFileNames(String aJob); LogFilePropertiesDTO[] getLogFileAttributes(String aJob); void purge(String[] targetInstanceNames); void purgeAbortedTargetInstances(String[] targetInstanceNames); void submitToArchive(String targetInstanceOid, String SIP,
                                Map xAttributes, int harvestNumber); CustomDepositFormResultDTO getCustomDepositFormDetails(
            CustomDepositFormCriteriaDTO criteria); void setArchive(Archive archive); void setBaseDir(String baseDir); void initiateIndexing(ArcHarvestResultDTO harvestResult); void initiateRemoveIndexes(ArcHarvestResultDTO harvestResult); Boolean checkIndexing(Long harvestResultOid); void setIndexer(Indexer indexer); void setDasFileMover(DasFileMover fileMover); void setWsEndPoint(WebServiceEndPoint wsEndPoint); void setPageImagePrefix(String pageImagePrefix); String getPageImagePrefix(); void setAqaReportPrefix(String aqaReportPrefix); String getAqaReportPrefix(); void setFileArchive(FileArchive fileArchive); }
ArcDigitalAssetStoreService implements DigitalAssetStore,
        LogProvider { public Header[] getHeaders(String targetInstanceName, int harvestResultNumber, HarvestResourceDTO resourcex) throws DigitalAssetStoreException { if (log.isDebugEnabled()) { log.debug("Start of getHeaders()"); log.debug("Casting the DTO to ArcHarvestResult"); } Header[] headers = new Header[0]; ArchiveRecord record = null; ArchiveReader reader = null; ArcHarvestResourceDTO resource = (ArcHarvestResourceDTO) resourcex; if (log.isDebugEnabled()) { log.debug("Determining the filename"); } File source = new File(this.baseDir, "/" + targetInstanceName + "/" + harvestResultNumber + "/" + resource.getArcFileName()); try { if (log.isDebugEnabled()) { log.debug("Create the Archive File Reader"); } try { reader = ArchiveReaderFactory.get(source); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Could not read headers for ArchiveRecord from " + source.getAbsolutePath() + " from local store"); } source = new File(fileArchive.getArchiveRepository() + "/" + targetInstanceName + "/" + fileArchive.getArchiveArcDirectory() + "/" + resource.getArcFileName()); if (log.isWarnEnabled()) { log.info("trying filestore " + source.getAbsolutePath()); } reader = ArchiveReaderFactory.get(source); } if (log.isDebugEnabled()) { log.debug("Skipping to the appropriate record at offset: " + resource.getResourceOffset()); } record = reader.get(resource.getResourceOffset()); if (record instanceof ARCRecord) { log.debug("Reading the headers"); ((ARCRecord) record).skipHttpHeader(); headers = ((ARCRecord) record).getHttpHeaders(); } else { log.debug("Reading the headers"); skipStatusLine(record); headers = HttpParser.parseHeaders(record, WARCConstants.DEFAULT_ENCODING); } return headers; } catch (IOException ex) { if (log.isWarnEnabled()) { log.warn("Error reading headers from ArchiveRecord: " + ex.getMessage()); } } finally { try { if (record != null) record.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close record failed " + ex.getMessage(), ex); } } try { if (record != null) reader.close(); } catch (Exception ex) { if (log.isErrorEnabled()) { log.error("close reader failed " + ex.getMessage(), ex); } } if (log.isDebugEnabled()) { log.debug("End of method"); } } return null; }  void save(String targetInstanceName, String directory, File file); void save(String targetInstanceName, String directory, File[] files); void save(String targetInstanceName, File[] files); void save(String targetInstanceName, File file); @SuppressWarnings("finally") File getResource(String targetInstanceName, int harvestResultNumber,
                            HarvestResourceDTO resourcex); byte[] getSmallResource(String targetInstanceName,
                                   int harvestResultNumber, HarvestResourceDTO resourcex); Header[] getHeaders(String targetInstanceName,
                               int harvestResultNumber, HarvestResourceDTO resourcex); HarvestResultDTO copyAndPrune(String targetInstanceName,
                                         int orgHarvestResultNum, int newHarvestResultNum,
                                         List<String> urisToDelete, List<HarvestResourceDTO> hrsToImport); File getLogFile(String aJob, String aFileName); List<String> getLogFileNames(String aJob); LogFilePropertiesDTO[] getLogFileAttributes(String aJob); void purge(String[] targetInstanceNames); void purgeAbortedTargetInstances(String[] targetInstanceNames); void submitToArchive(String targetInstanceOid, String SIP,
                                Map xAttributes, int harvestNumber); CustomDepositFormResultDTO getCustomDepositFormDetails(
            CustomDepositFormCriteriaDTO criteria); void setArchive(Archive archive); void setBaseDir(String baseDir); void initiateIndexing(ArcHarvestResultDTO harvestResult); void initiateRemoveIndexes(ArcHarvestResultDTO harvestResult); Boolean checkIndexing(Long harvestResultOid); void setIndexer(Indexer indexer); void setDasFileMover(DasFileMover fileMover); void setWsEndPoint(WebServiceEndPoint wsEndPoint); void setPageImagePrefix(String pageImagePrefix); String getPageImagePrefix(); void setAqaReportPrefix(String aqaReportPrefix); String getAqaReportPrefix(); void setFileArchive(FileArchive fileArchive);  }