/** * @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 FcrepoResponse response = testClient.put(destinationURI).perform(); try { log.info(IOUtils.toString(response.getBody(), UTF_8)); } catch (IOException e) { log.info(getMessage(e)); } } catch (FcrepoOperationFailedException e) { log.info(getMessage(e)); throw new ModellerClientFailedException(e); } }
/** * @param destinationURI URI * @param resourceFile File * @param contentType String * @throws ModellerClientFailedException Throwable */ public static void doBinaryPut(final URI destinationURI, final File 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); } catch (IOException e) { e.printStackTrace(); } }
/** * @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); } }
/** * @param containerURI URI * @return resources * @throws ModellerClientFailedException Throwable */ public static String doGetContainerResources(final URI containerURI) throws ModellerClientFailedException { final FcrepoClient testClient; testClient = FcrepoClient.client().throwExceptionOnFailure().build(); try (FcrepoResponse response = testClient.get(containerURI).accept("text/turtle").perform()) { return IOUtils.toString(response.getBody(), "UTF-8"); } catch (FcrepoOperationFailedException e) { log.info(getMessage(e)); throw new ModellerClientFailedException(e); } catch (IOException e) { e.printStackTrace(); } return null; } }
/** * Create a FcrepoProducer object * * @param endpoint the FcrepoEndpoint corresponding to the exchange. */ public FcrepoProducer(final FcrepoEndpoint endpoint) { super(endpoint); this.endpoint = endpoint; this.transactionTemplate = endpoint.createTransactionTemplate(); final FcrepoClient.FcrepoClientBuilder builder = client() .credentials(endpoint.getAuthUsername(), endpoint.getAuthPassword()) .authScope(endpoint.getAuthHost()); if (endpoint.getThrowExceptionOnFailure()) { this.fcrepoClient = builder.throwExceptionOnFailure().build(); } else { this.fcrepoClient = builder.build(); } }
/** * @param destinationURI URI * @param resourceFile ByteArrayInputStream * @param contentType String * @throws ModellerClientFailedException Throwable */ public static void doStreamPut(final URI destinationURI, final ByteArrayInputStream 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); } }
/** * Instantiates default implementations of the underlying Fedora client, JSON adapter, and OkHttpClient. */ public FedoraPassCrudClient() { this(FcrepoClient.client() .credentials(FedoraConfig.getUserName(), FedoraConfig.getPassword()) .throwExceptionOnFailure() .build(), new PassJsonAdapterBasic()); }
private FcrepoClient getClient() { if (fcrepoClient == null) { return client().credentials(authUsername, authPassword).authScope(authHost) .throwExceptionOnFailure().build(); } return fcrepoClient; } }
/** * Instantiates default implementations of the underlying Fedora client, JSON adapter, and OkHttpClient. */ public FedoraPassCrudClient() { this(FcrepoClient.client() .credentials(FedoraConfig.getUserName(), FedoraConfig.getPassword()) .throwExceptionOnFailure() .build(), new PassJsonAdapterBasic()); }