private URI buildResourceUri(final String... path) { final UriBuilder uriBuilder = uriInfo.getBaseUriBuilder(); uriBuilder.segment(path); URI uri = uriBuilder.build(); try {
uriBuilder.segment("process-groups", groupId, "templates", "import"); final URI importUri = uriBuilder.build();
private URI toUri(String table, String blobId) { return _blobStore.clone().segment(table, blobId).build(); }
private URI toUri(String table, String blobId) { return _blobStore.clone().segment(table, blobId).build(); }
protected UriBuilder getPollUriBuilder(String subscription, Duration claimTtl, int limit) { return _databus.clone() .segment(subscription, "poll") .queryParam("ttl", Ttls.toSeconds(claimTtl, 0, Integer.MAX_VALUE)) .queryParam("limit", limit) .queryParam("partitioned", _partitionSafe); }
@GET @Produces({BASE_XML_MEDIA_TYPE, BASE_JSON_MEDIA_TYPE}) public Response whoami() { User currentUser = user.get(); if(currentUser == null) { return Response.status(Status.UNAUTHORIZED).build(); } String userId = currentUser.getId(); return Response.seeOther( UriBuilder.fromResource(UserResource.class).segment(userId).build()) .build(); } }
@Override public boolean contains(@PartitionKey String word) { try { URI uri = _service.clone().segment("contains", word).build(); return _client .target(_service) .path("contains") .path(word) .request() .get(Boolean.class); } catch (WebApplicationException e) { throw convertException(e); } }
@Override public EmoApiKey getApiKeyByKey(String apiKey, String key) { checkNotNull(key, "key"); URI uri = _uac.clone() .segment("api-key") .segment("_key") .segment(key) .build(); EmoResponse response = _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(EmoResponse.class); return getApiKeyFromResponse(response); }
@GET @Consumes({ "application/xml", "text/xml", "application/json" }) public Employee get(@Context UriInfo uriInfo) { // load employee with requested id final Employee employee = this.employeeMgr.getFull(this.staffNo); // set department uri final UriBuilder departmentUB = uriInfo.getBaseUriBuilder(); departmentUB.segment("departments", "{depId}"); final String department = employee.getDepartment(); employee.setDepartmentUri(departmentUB.build(department)); return employee; }
public Pizza getPizza() { URI uri = uriBuilder.clone() .segment("pizza") .build(); return jerseyClient.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .get(Pizza.class); }
@Override public EmoApiKey getApiKey(String apiKey, String id) { checkNotNull(id, "id"); URI uri = _uac.clone() .segment("api-key") .segment(id) .build(); EmoResponse response = _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(EmoResponse.class); return getApiKeyFromResponse(response); }
@POST @Consumes({ BASE_JSON_MEDIA_TYPE, BASE_XML_MEDIA_TYPE }) public Response create(REP representation) { DOMAIN entity = getConverter().to(uriInfo, representation); getRepository().store(entity); return Response.created( UriBuilder.fromResource(getResourceClass()).segment("{id}").build(entity.getId())).build(); }
protected void doUnclaimAll(String apiKey, String queue) { checkNotNull(queue, "queue"); try { URI uri = _queueService.clone() .segment(queue, "unclaimall") .queryParam("partitioned", _partitionSafe) .build(); _client.resource(uri) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Map<String, Object> getTableTemplate(String apiKey, String table) { checkNotNull(table, "table"); try { URI uri = _dataStore.clone() .segment("_table", table) .build(); return _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(new TypeReference<Map<String,Object>>(){}); } catch (EmoClientException e) { throw convertException(e); } }
@Override public long getTableApproximateSize(String apiKey, String table) { checkNotNull(table, "table"); try { URI uri = _blobStore.clone() .segment("_table", table, "size") .build(); return _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(Long.class); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Map<StashTimeKey, StashRunTimeInfo> getAllStashTimes() { try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time") .build(); return _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .get(Map.class); } catch (UniformInterfaceException e) { throw convertException(e); } }
@Override public Map<StashTimeKey, StashRunTimeInfo> getAllStashTimes() { try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time") .build(); return _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .get(Map.class); } catch (UniformInterfaceException e) { throw convertException(e); } }
@Override public Iterator<EmoRole> getAllRoles(String apiKey) { try { URI uri = _uac.clone() .segment("role") .build(); return _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(new TypeReference<Iterator<EmoRole>>(){}); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Collection<String> getTablePlacements(String apiKey) { try { URI uri = _blobStore.clone() .segment("_tableplacement") .build(); return _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(new TypeReference<List<String>>(){}); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Collection<String> getTablePlacements(String apiKey) { try { URI uri = _dataStore.clone() .segment("_tableplacement") .build(); return _client.resource(uri) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .get(new TypeReference<List<String>>(){}); } catch (EmoClientException e) { throw convertException(e); } }