@Override public List<URI> getChildren(URI resource) { try (final FcrepoResponse response = client.get(resource) .accept("application/n-triples") .preferRepresentation(asList(PREFER_CONTAINMENT), emptyList()).perform()) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.getBody(), UTF_8))) { final List<URI> children = new ArrayList<>(); for (String line = reader.readLine(); line != null; line = reader.readLine()) { final Matcher aclFinder = childPattern.matcher(line); if (aclFinder.matches()) { children.add(URI.create(aclFinder.group(1))); } } return children; } } catch (final Exception e) { throw new RuntimeException("Error getting children of " + resource, e); } } }
/** * Make a GET request to retrieve the content of a resource * * @param url the URL of the resource to which to GET * @return a get request builder object */ public GetBuilder get(final URI url) { return new GetBuilder(url, this); }
/** * Set the prefer header for this request to representation, to indicate that links to other resources and their * properties should also be included. The set of properties returned can be further specified by providing lists * of LDP defined preferences to omit or include. * * @param includeUris URIs of LDP defined preferences to include * @param omitUris URIs of LDP defined preferences to omit * @return this builder */ public GetBuilder preferRepresentation(final List<URI> includeUris, final List<URI> omitUris) { request.setHeader(PREFER, buildPrefer(includeUris, omitUris)); return this; }
List<URI> omits = Collections.singletonList(URI.create(SERVER_MANAGED_OMITTYPE)); try (FcrepoResponse response = new GetBuilder(passEntityUri, client) .accept(COMPACTED_ACCEPTTYPE) .preferRepresentation(include, omits) .perform()) {
case GET: default: final GetBuilder get = fcrepoClient.get(getUri(endpoint, url)).accept(accept); final String preferHeader = in.getHeader(FCREPO_PREFER, "", String.class); if (!preferHeader.isEmpty()) { final FcrepoPrefer prefer = new FcrepoPrefer(preferHeader); if (prefer.isMinimal()) { response = get.preferMinimal().perform(); } else if (prefer.isRepresentation()) { response = get.preferRepresentation(prefer.getInclude(), prefer.getOmit()).perform(); } else { response = get.perform(); final List<URI> omit = getPreferOmit(endpoint); if (include.isEmpty() && omit.isEmpty()) { response = get.perform(); } else { response = get.preferRepresentation(include, omit).perform();
/** * @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; } }
List<URI> omits = Collections.singletonList(URI.create(SERVER_MANAGED_OMITTYPE)); try (FcrepoResponse response = new GetBuilder(passEntityUri, client) .accept(COMPACTED_ACCEPTTYPE) .preferRepresentation(include, omits) .perform()) {
try (FcrepoResponse response = new GetBuilder(uri, client) .accept(COMPACTED_ACCEPTTYPE) .preferRepresentation(null, omits) .perform()) {
@Override public List<URI> getChildren(URI resource) { try (final FcrepoResponse response = client.get(resource) .accept("application/n-triples") .preferRepresentation(asList(PREFER_CONTAINMENT), emptyList()).perform()) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.getBody(), UTF_8))) { final List<URI> children = new ArrayList<>(); for (String line = reader.readLine(); line != null; line = reader.readLine()) { final Matcher aclFinder = childPattern.matcher(line); if (aclFinder.matches()) { children.add(URI.create(aclFinder.group(1))); } } return children; } } catch (final Exception e) { throw new RuntimeException("Error getting children of " + resource, e); } } }
try (FcrepoResponse response = new GetBuilder(uri, client) .accept(COMPACTED_ACCEPTTYPE) .preferRepresentation(null, omits) .perform()) {