本文整理汇总了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());
}
示例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());
}
示例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");
}
}
}
示例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);
}
}