当前位置: 首页>>代码示例>>Java>>正文


Java CaptureSearchResult.setFile方法代码示例

本文整理汇总了Java中org.archive.wayback.core.CaptureSearchResult.setFile方法的典型用法代码示例。如果您正苦于以下问题:Java CaptureSearchResult.setFile方法的具体用法?Java CaptureSearchResult.setFile怎么用?Java CaptureSearchResult.setFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.archive.wayback.core.CaptureSearchResult的用法示例。


在下文中一共展示了CaptureSearchResult.setFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.archive.wayback.core.CaptureSearchResult; //导入方法依赖的package包/类
@Override
public void setUp() {
    super.setUp();
    JMSConnectionMockupMQ.useJMSConnectionMockupMQ();
    FileUtils.removeRecursively(TestInfo.WORKING_DIR);
    TestFileUtils.copyDirectoryNonCVS(TestInfo.ORIGINALS_DIR, TestInfo.WORKING_DIR);
    
    Settings.set(JMSArcRepositoryClient.ARCREPOSITORY_GET_TIMEOUT, "1000");
    assertTrue("Should get a mock connection",
        JMSConnectionFactory.getInstance() instanceof JMSConnectionMockupMQ);
    arc = (ArcRepositoryClient) ArcRepositoryClientFactory.getPreservationInstance();

    netarchiveResourceStore = new NetarchiveResourceStore();

    metadataResource = new CaptureSearchResult();
    metadataResource.setFile(metadataFile);
    metadataResource.setOffset(0L);

    uploadResource = new CaptureSearchResult();
    uploadResource.setFile(uploadFile);
    uploadResource.setOffset(2041L);

    httpResource = new CaptureSearchResult();
    httpResource.setOriginalUrl("http://www.netarkivet.dk/");
    httpResource.setOffset(0L);
    httpResource.setFile(metadataFile);


    resourceNotAvaliable = new CaptureSearchResult();
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:31,代码来源:NetarchiveResourceStoreWarcTester.java

示例2: adaptInner

import org.archive.wayback.core.CaptureSearchResult; //导入方法依赖的package包/类
private CaptureSearchResult adaptInner(ARCRecord rec) throws IOException {
    rec.close();
    ARCRecordMetaData meta = rec.getMetaData();

    CaptureSearchResult result = new CaptureSearchResult();
    String arcName = meta.getArc();
    int index = arcName.lastIndexOf(File.separator);
    if (index > 0 && (index + 1) < arcName.length()) {
        arcName = arcName.substring(index + 1);
    }
    result.setFile(arcName);
    result.setOffset(meta.getOffset());

    // initialize with default HTTP code...
    result.setHttpCode("-");

    result.setDigest(rec.getDigestStr());
    result.setMimeType(meta.getMimetype());
    result.setCaptureTimestamp(meta.getDate());

    String uriStr = meta.getUrl();
    if (uriStr.startsWith(ARCRecord.ARC_MAGIC_NUMBER)) {
        // skip filedesc record altogether...
        return null;
    }
    if (uriStr.startsWith(WaybackConstants.DNS_URL_PREFIX)) {
        // skip URL + HTTP header processing for dns records...

        result.setOriginalUrl(uriStr);
        result.setRedirectUrl("-");
        result.setUrlKey(uriStr);

    } else {

        result.setOriginalUrl(uriStr);

        String statusCode = (meta.getStatusCode() == null) ? "-" : meta
                .getStatusCode();
        result.setHttpCode(statusCode);

        String redirectUrl = "-";
        Header[] headers = rec.getHttpHeaders();
        if (headers != null) {

            for (int i = 0; i < headers.length; i++) {
                if (headers[i].getName().equals(
                        WaybackConstants.LOCATION_HTTP_HEADER)) {

                    String locationStr = headers[i].getValue();
                    // TODO "Location" is supposed to be absolute:
                    // (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html)
                    // (section 14.30) but Content-Location can be
                    // relative.
                    // is it correct to resolve a relative Location, as
                    // we are?
                    // it's also possible to have both in the HTTP
                    // headers...
                    // should we prefer one over the other?
                    // right now, we're ignoring "Content-Location"
                    redirectUrl = NetarchiveSuiteUrlOperations.resolveUrl(
                            uriStr, locationStr);

                    break;
                }
            }
            result.setRedirectUrl(redirectUrl);

            String urlKey = canonicalizer.urlStringToKey(meta.getUrl());
            result.setUrlKey(urlKey);
        }
    }
    return result;
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:74,代码来源:NetarchiveSuiteARCRecordToSearchResultAdapter.java

示例3: genericResult

import org.archive.wayback.core.CaptureSearchResult; //导入方法依赖的package包/类
private CaptureSearchResult genericResult(WARCRecord rec) {

		CaptureSearchResult result = new CaptureSearchResult();

		result.setMimeType(DEFAULT_VALUE);
		result.setHttpCode(DEFAULT_VALUE);
		result.setRedirectUrl(DEFAULT_VALUE);

		ArchiveRecordHeader header = rec.getHeader();

		String file = transformWARCFilename(header.getReaderIdentifier());
		long offset = header.getOffset();
		
		result.setCaptureTimestamp(transformWARCDate(header.getDate()));
		result.setFile(file);
		result.setOffset(offset);
		result.setDigest(transformWARCDigest(header.getHeaderValue(
				WARCRecord.HEADER_KEY_PAYLOAD_DIGEST)));
		
		String origUrl = header.getUrl();
		if(origUrl == null) {
			String type = header.getHeaderValue(WARCConstants.HEADER_KEY_TYPE).toString();
			if(type.equals(WARCConstants.WARCINFO)) {
				String filename = header.getHeaderValue(
						WARCConstants.HEADER_KEY_FILENAME).toString();
				result.setOriginalUrl("filedesc:"+filename);
				result.setUrlKey("filedesc:"+filename);				
			} else {
				result.setOriginalUrl(DEFAULT_VALUE);
				result.setUrlKey(DEFAULT_VALUE);
			}

			
		} else {
			result.setOriginalUrl(origUrl);
			try {
				String urlKey = canonicalizer.urlStringToKey(origUrl);
				result.setUrlKey(urlKey);
			} catch (URIException e) {
				String shortUrl = 
					(origUrl.length() < 100) 
					? origUrl
					:origUrl.substring(0,100);
				LOGGER.warning("FAILED canonicalize(" + shortUrl + "):" + 
						file + " " + offset);
				result.setUrlKey(origUrl);
			}
		}
		return result;
	}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:51,代码来源:NetarchiveSuiteWARCRecordToSearchResultAdapter.java


注:本文中的org.archive.wayback.core.CaptureSearchResult.setFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。