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


Java FcrepoClient类代码示例

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


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

示例1: Importer

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Constructor that takes the Import/Export configuration
 *
 * @param config for import
 * @param clientBuilder for sending resources to Fedora
 */
public Importer(final Config config, final FcrepoClient.FcrepoClientBuilder clientBuilder) {
    this.config = config;
    this.clientBuilder = clientBuilder;
    this.importLogger = config.getAuditLog();
    if (config.getBagProfile() == null) {
        this.bag = null;
        this.sha1 = null;
        this.sha1FileMap = null;
    } else {

        try {
            final File bagdir = config.getBaseDirectory().getParentFile();
            // TODO: Maybe use this once we get an updated release of bagit-java library
            //if (verifyBag(bagdir)) {
            final Path manifestPath = Paths.get(bagdir.getAbsolutePath()).resolve("manifest-sha1.txt");
            this.sha1FileMap = TransferProcess.getSha1FileMap(bagdir, manifestPath);
            this.sha1 = MessageDigest.getInstance("SHA-1");
            // }
        } catch (NoSuchAlgorithmException e) {
            // never happens with known algorithm names
        }
    }
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:30,代码来源:Importer.java

示例2: isRepositoryRoot

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Utility method to determine whether the current uri is repository root or not. The repository root is the
 * container with type fcrepo:RepositoryRoot
 * @param uri the URI for the resource
 * @param client the FcrepoClient to query the repository
 * @param config the Config for import/export
 * @throws IOException if there is a error with the network connection
 * @throws FcrepoOperationFailedException if there is a error with Fedora
 * @return True if the URI is the root of the repository
 */
public static boolean isRepositoryRoot(final URI uri, final FcrepoClient client, final Config config)
        throws IOException, FcrepoOperationFailedException {
    final String userName = config.getUsername();
    final String rdfLanguage = config.getRdfLanguage();
    try (FcrepoResponse response = client.head(uri).disableRedirects().perform()) {
        checkValidResponse(response, uri, userName);
        // The repository root will not be a binary
        if (response.getLinkHeaders("type").contains(URI.create(NON_RDF_SOURCE.getURI()))) {
            return false;
        }
        try (FcrepoResponse resp = client.get(uri).accept(rdfLanguage).disableRedirects()
                .perform()) {
            final Model model = createDefaultModel().read(resp.getBody(), null, rdfLanguage);
            if (model.contains(null, RDF_TYPE, REPOSITORY_ROOT)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:31,代码来源:TransferProcess.java

示例3: mockGetResponse

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Mocks a successful GET request response
 * 
 * @param client client
 * @param uri uri of destination being mocked
 * @param typeLinks type links
 * @param describedbyLinks described by links
 * @param body body of response
 * @throws FcrepoOperationFailedException client failures
 */
public static void mockGetResponse(final FcrepoClient client, final URI uri, final List<URI> typeLinks,
        final List<URI> describedbyLinks, final String body) throws FcrepoOperationFailedException {
    final GetBuilder getBuilder = mock(GetBuilder.class);
    final FcrepoResponse getResponse = mock(FcrepoResponse.class);
    when(client.get(eq(uri))).thenReturn(getBuilder);
    when(getBuilder.accept(isA(String.class))).thenReturn(getBuilder);
    when(getBuilder.disableRedirects()).thenReturn(getBuilder);
    when(getBuilder.perform()).thenReturn(getResponse);
    when(getResponse.getBody()).thenAnswer(new Answer<InputStream>() {
        @Override
        public InputStream answer(final InvocationOnMock invocation) throws Throwable {
            return new ByteArrayInputStream(body.getBytes());
        }
    });
    when(getResponse.getUrl()).thenReturn(uri);
    when(getResponse.getLinkHeaders(eq("describedby"))).thenReturn(describedbyLinks);
    when(getResponse.getStatusCode()).thenReturn(200);
    when(getResponse.getLinkHeaders(eq("type"))).thenReturn(typeLinks);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:30,代码来源:ResponseMocker.java

示例4: incomingInterceptRespomseCodeTest

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
@Test
public void incomingInterceptRespomseCodeTest() throws Exception {
    registerExtension(testResource("objects/extension_InterceptingModalityIT.ttl"));

    registerService(testResource("objects/service_InterceptingServiceIT.ttl"));

    final String LOCATION = "http://example.org/Location";
    final int RESPONSE_CODE = 418;

    responseFromService.setHeader(Exchange.HTTP_RESPONSE_CODE, RESPONSE_CODE);
    responseFromService.setHeader("Location", LOCATION);

    final URI objectContainer_intercept = routing.of(REQUEST_URI).interceptUriFor(objectContainer);

    final URI object = postFromTestResource("objects/object_InterceptingServiceIT.ttl",
            objectContainer_intercept);

    try (FcrepoResponse response = FcrepoClient.client().build().get(object).perform()) {

        assertEquals(RESPONSE_CODE, response.getStatusCode());
        assertEquals(LOCATION, response.getHeaderValue("Location"));
    }
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:24,代码来源:InterceptingModalityIT.java

示例5: doStreamPut

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * doStreamPut.
 *
 * @param destinationURI URI
 * @param resourceFile   ByteArrayInputStream
 * @param contentType    String
 * @throws ModellerClientFailedException Throwable
 */
public static void doStreamPut(final URI destinationURI, final InputStream resourceFile,
                               final String contentType) throws ModellerClientFailedException {
    final FcrepoClient testClient;
    testClient = FcrepoClient.client().throwExceptionOnFailure().build();
    try {
        final FcrepoResponse response =
                testClient.put(destinationURI).body(resourceFile, contentType).perform();
        log.info(String.valueOf(response.getStatusCode()));
    } catch (FcrepoOperationFailedException e) {
        log.info(getMessage(e));
        throw new ModellerClientFailedException(e);
    }
}
 
开发者ID:pan-dora,项目名称:modeller,代码行数:22,代码来源:ModellerClient.java

示例6: doPut

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * doPut.
 *
 * @param destinationURI URI
 * @throws ModellerClientFailedException Throwable
 */
public static void doPut(final URI destinationURI) throws ModellerClientFailedException {
    final FcrepoClient testClient;
    testClient = FcrepoClient.client().throwExceptionOnFailure().build();
    try {
        final InputStream resourceFile = getFile("data/emptyFile.txt");
        final String contentType = "text/turtle";
        final FcrepoResponse response =
                testClient.put(destinationURI).body(resourceFile, contentType).perform();
        log.info(String.valueOf(response.getStatusCode()));
    } catch (FcrepoOperationFailedException e) {
        log.info(getMessage(e));
        throw new ModellerClientFailedException(e);
    }
}
 
开发者ID:pan-dora,项目名称:modeller,代码行数:21,代码来源:ModellerClient.java

示例7: doPatch

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * doPatch.
 *
 * @param destinationURI URI
 * @param rdfBody        InputStream
 * @throws ModellerClientFailedException Throwable
 */
public static void doPatch(final URI destinationURI, final InputStream rdfBody)
        throws ModellerClientFailedException {
    final FcrepoClient testClient;
    testClient = FcrepoClient.client().throwExceptionOnFailure().build();
    try {
        final FcrepoResponse response =
                testClient.patch(destinationURI).body(rdfBody).perform();
        log.info(String.valueOf(response.getStatusCode()));
    } catch (FcrepoOperationFailedException e) {
        log.info(getMessage(e));
        throw new ModellerClientFailedException(e);
    }
}
 
开发者ID:pan-dora,项目名称:modeller,代码行数:21,代码来源:ModellerClient.java

示例8: AbstractResourceIT

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
AbstractResourceIT() {
    clientBuilder = FcrepoClient.client().credentials(USERNAME, PASSWORD).authScope("localhost");
    setDefaultHttpClient(new FcrepoHttpClientBuilder(USERNAME, PASSWORD, "localhost").build());

    final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(Integer.MAX_VALUE);
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:10,代码来源:AbstractResourceIT.java

示例9: setUp

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    clientBuilder = mock(FcrepoClient.FcrepoClientBuilder.class);
    client = mock(FcrepoClient.class);
    when(clientBuilder.build()).thenReturn(client);

    headResponse = mock(FcrepoResponse.class);
    rootResource = new URI("http://localhost:8080/rest");
    resource = new URI("http://localhost:8080/rest/1");
    resource2 = new URI("http://localhost:8080/rest/1/2");
    resource3 = new URI("http://localhost:8080/rest/file1");
    resource4 = new URI("http://localhost:8080/rest/file1/fcr:metadata");
    resource5 = new URI("http://localhost:8080/rest/alt_description");

    binaryLinks = Arrays.asList(new URI(NON_RDF_SOURCE.getURI()));
    containerLinks = Arrays.asList(new URI(CONTAINER.getURI()));
    descriptionLinks = Arrays.asList(new URI(RDF_SOURCE.getURI()));
    describedbyLinks = Arrays.asList(new URI(resource4.toString()), new URI(resource5.toString()));

    mockResponse(resource, containerLinks, new ArrayList<>(), "{\"@id\":\"" + resource.toString()
            + "\",\"@type\":[\"" + REPOSITORY_NAMESPACE + "RepositoryRoot\"],\""
            + CONTAINS.getURI() + "\":[{\"@id\":\"" + resource2.toString() + "\"}]}");
    mockResponse(resource2, containerLinks, new ArrayList<>(), "{\"@id\":\"" + resource2.toString() + "\"}");
    mockResponse(resource3, binaryLinks, describedbyLinks, "binary");
    mockResponse(resource4, descriptionLinks, new ArrayList<>(), "{\"@id\":\"" + resource4.toString() + "\"}");
    mockResponse(resource5, containerLinks, new ArrayList<>(), "{\"@id\":\"" + resource5.toString() + "\"}");
    mockResponse(rootResource, containerLinks, new ArrayList<>(), "{\"@id\":\"" + rootResource.toString()
            + "\",\"@type\":[\"" + REPOSITORY_ROOT.getURI() + "\"]}");
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:30,代码来源:ExporterTest.java

示例10: testIsrepositoryRoot

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
@Test
public void testIsrepositoryRoot() throws Exception {
    final String rdfLanguage = "application/ld+json";
    final Config config = mock(Config.class);
    final URI uri = URI.create("http://localhost:8080/fcrepo");
    client = mock(FcrepoClient.class);

    final HeadBuilder headBuilder = mock(HeadBuilder.class);
    final FcrepoResponse headResponse = mock(FcrepoResponse.class);
    when(client.head(eq(uri))).thenReturn(headBuilder);
    when(headBuilder.disableRedirects()).thenReturn(headBuilder);
    when(headBuilder.perform()).thenReturn(headResponse);
    when(headResponse.getStatusCode()).thenReturn(200);

    final GetBuilder getBuilder = mock(GetBuilder.class);
    final FcrepoResponse getResponse = mock(FcrepoResponse.class);
    when(config.getRdfLanguage()).thenReturn(rdfLanguage);
    when(client.get(isA(URI.class))).thenReturn(getBuilder);
    when(getBuilder.accept(isA(String.class))).thenReturn(getBuilder);
    when(getBuilder.disableRedirects()).thenReturn(getBuilder);
    when(getBuilder.perform()).thenReturn(getResponse);
    when(getResponse.getBody()).thenReturn(
            new ByteArrayInputStream(("{\"@type\":[\"" + CONTAINER + "\"]}").getBytes()));
    assertFalse(TransferProcess.isRepositoryRoot(uri, client, config));

    when(getResponse.getBody()).thenReturn(new ByteArrayInputStream(
            ("{\"@type\":[\"" + REPOSITORY_NAMESPACE + "RepositoryRoot\"]}").getBytes()));
    assertTrue(TransferProcess.isRepositoryRoot(uri, client, config));
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:30,代码来源:TransferProcessTest.java

示例11: mockHeadResponse

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Mocks a successful HEAD request response
 * 
 * @param client client
 * @param uri uri of destination being mocked
 * @param typeLinks type links
 * @param describedbyLinks described by links
 * @throws FcrepoOperationFailedException client failures
 */
public static void mockHeadResponse(final FcrepoClient client, final URI uri, final List<URI> typeLinks,
        final List<URI> describedbyLinks) throws FcrepoOperationFailedException {
    final HeadBuilder headBuilder = mock(HeadBuilder.class);
    final FcrepoResponse headResponse = mock(FcrepoResponse.class);
    when(client.head(eq(uri))).thenReturn(headBuilder);
    when(headBuilder.disableRedirects()).thenReturn(headBuilder);
    when(headBuilder.perform()).thenReturn(headResponse);
    when(headResponse.getUrl()).thenReturn(uri);
    when(headResponse.getLinkHeaders(eq("describedby"))).thenReturn(describedbyLinks);
    when(headResponse.getStatusCode()).thenReturn(200);
    when(headResponse.getLinkHeaders(eq("type"))).thenReturn(typeLinks);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:22,代码来源:ResponseMocker.java

示例12: mockGetResponseError

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Mocks an unsuccessful GET request response
 * 
 * @param client client
 * @param uri uri of destination being mocked
 * @param statusCode the status code for the response
 * @throws FcrepoOperationFailedException client failures
 */
public static void mockGetResponseError(final FcrepoClient client, final URI uri, final int statusCode)
        throws FcrepoOperationFailedException {
    final GetBuilder getBuilder = mock(GetBuilder.class);
    final FcrepoResponse getResponse = mock(FcrepoResponse.class);
    when(client.get(eq(uri))).thenReturn(getBuilder);
    when(getBuilder.accept(isA(String.class))).thenReturn(getBuilder);
    when(getBuilder.disableRedirects()).thenReturn(getBuilder);
    when(getBuilder.perform()).thenReturn(getResponse);
    when(getResponse.getStatusCode()).thenReturn(statusCode);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:19,代码来源:ResponseMocker.java

示例13: mockHeadResponseError

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Mocks an unsuccessful HEAD request response
 * 
 * @param client client
 * @param uri uri of destination being mocked
 * @param statusCode the status code for the response
 * @throws FcrepoOperationFailedException client failures
 */
public static void mockHeadResponseError(final FcrepoClient client, final URI uri, final int statusCode)
        throws FcrepoOperationFailedException {
    final HeadBuilder headBuilder = mock(HeadBuilder.class);
    final FcrepoResponse response = mock(FcrepoResponse.class);
    when(client.head(eq(uri))).thenReturn(headBuilder);
    when(headBuilder.disableRedirects()).thenReturn(headBuilder);
    when(headBuilder.perform()).thenReturn(response);
    when(response.getStatusCode()).thenReturn(statusCode);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:18,代码来源:ResponseMocker.java

示例14: Walker

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param config of Walker
 */
public Walker(final WalkerConfig config) {
    this.baseUrl = config.getBaseUrl();

    connectionManager.setMaxTotal(Integer.MAX_VALUE);
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
    client = FcrepoClient.client().credentials(config.getUsername(), config.getPassword()).build();
}
 
开发者ID:awoods,项目名称:fcrepo-java-client-etc,代码行数:14,代码来源:Walker.java

示例15: noInstanceTest

import org.fcrepo.client.FcrepoClient; //导入依赖的package包/类
@Test
public void noInstanceTest() throws Exception {
    // Register the extension

    extensionRegistry.put(testResource(
            "objects/extension_ExposedServiceIT_noInstance.ttl"));

    // Register the service
    serviceRegistry.put(testResource("objects/service_ExposedServiceIT_noInstance.ttl"));

    // Do NOT register a service instance.

    // Create the object
    final URI object = postFromTestResource("objects/object_ExposedServiceIT_noInstance.ttl", objectContainer);

    // Update all services
    bundleContext.getServiceReferences(Updateable.class, null).stream()
            .map(bundleContext::getService)
            .forEach(Updateable::update);

    // Look at the service document to discover the exposed URI
    try (WebResource resource = discovery
            .getServiceDocumentFor(object, routingFactory.of(requestURI), "text/turtle")) {
        final Model doc = parse(resource);

        final String sparql = "CONSTRUCT { ?endpoint <test:/endpointFor> ?serviceInstance . } WHERE { " +
                String.format("?serviceInstance <%s> <%s> . ", RDF_TYPE, CLASS_SERVICE_INSTANCE) +
                String.format("?serviceInstance <%s> ?endpoint . ", PROP_HAS_ENDPOINT) +
                "}";
        exposedServiceEndpoint = subjectsOf(query(sparql, doc)).iterator().next();
    }

    try (final FcrepoResponse response = FcrepoClient.client().build().post(exposedServiceEndpoint).perform()) {
        // We want a 404
        assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusCode());
    }
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:38,代码来源:ExposedServiceIT.java


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