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


Java FcrepoResponse.getLocation方法代码示例

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


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

示例1: testGetRange

import org.fcrepo.client.FcrepoResponse; //导入方法依赖的package包/类
@Test
public void testGetRange() throws Exception {
    // Creating a binary for retrieval
    final String mimetype = "text/plain";
    final String bodyContent = "Hello world";
    final FcrepoResponse response = client.post(new URI(serverAddress))
            .body(new ByteArrayInputStream(bodyContent.getBytes()), mimetype)
            .perform();

    final URI url = response.getLocation();

    // Get the content of the object after the first 6 bytes
    final FcrepoResponse rangeResp = client.get(url)
            .range(6L, null)
            .perform();

    final String content = IOUtils.toString(rangeResp.getBody(), "UTF-8");
    assertEquals("Body did not contain correct range of original content", "world", content);
    assertEquals(PARTIAL_CONTENT.getStatusCode(), rangeResp.getStatusCode());
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-java-client,代码行数:21,代码来源:FcrepoClientIT.java

示例2: testGetDisableRedirects

import org.fcrepo.client.FcrepoResponse; //导入方法依赖的package包/类
@Test
public void testGetDisableRedirects() throws Exception {
    // Creating a binary with external content for retrieval
    final String mimetype = "message/external-body; access-type=URL; URL=\"http://www.example.com/file\"";
    final FcrepoResponse response = client.post(new URI(serverAddress))
            .body(new ByteArrayInputStream(new byte[]{}), mimetype)
            .perform();

    final URI url = response.getLocation();

    // Make sure the response is the redirect itself, not the URL being redirected to
    final FcrepoResponse getResponse = client.get(url).disableRedirects().perform();
    assertEquals(307, getResponse.getStatusCode());
    assertEquals(url, getResponse.getUrl());
    assertEquals(URI.create("http://www.example.com/file"), getResponse.getLocation());
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-java-client,代码行数:17,代码来源:FcrepoClientIT.java

示例3: doBegin

import org.fcrepo.client.FcrepoResponse; //导入方法依赖的package包/类
@Override
protected void doBegin(final Object transaction, final TransactionDefinition definition) {
    final FcrepoResponse response;
    final InputStream is = null;
    final String contentType = null;
    final FcrepoTransactionObject tx = (FcrepoTransactionObject)transaction;

    if (tx.getSessionId() == null) {
        try {
            response = getClient().post(URI.create(baseUrl + TRANSACTION))
                .body(is, contentType).perform();
        } catch (final FcrepoOperationFailedException ex) {
            LOGGER.debug("HTTP Operation failed: ", ex);
            throw new CannotCreateTransactionException("Could not create fcrepo transaction");
        }

        if (response != null && response.getLocation() != null) {
            tx.setSessionId(response.getLocation().toString().substring(baseUrl.length() + 1));
        } else {
            throw new CannotCreateTransactionException("Invalid response while creating transaction");
        }
    }
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-camel,代码行数:24,代码来源:FcrepoTransactionManager.java

示例4: getMetadataUri

import org.fcrepo.client.FcrepoResponse; //导入方法依赖的package包/类
/**
 * Retrieve the resource location from a HEAD request.
 */
private URI getMetadataUri(final String url)
        throws FcrepoOperationFailedException {
    final FcrepoResponse headResponse = fcrepoClient.head(URI.create(url)).perform();
    if (headResponse.getLocation() != null) {
        return headResponse.getLocation();
    } else {
        return URI.create(url);
    }
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-camel,代码行数:13,代码来源:FcrepoProducer.java


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