use of javax.ws.rs.Produces in project killbill by killbill.
the class AccountResource method getAccounts.
@TimedResource
@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "List accounts", response = AccountJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAccounts(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset, @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit, @QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance, @QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
final TenantContext tenantContext = context.createContext(request);
final Pagination<Account> accounts = accountUserApi.getAccounts(offset, limit, tenantContext);
final URI nextPageUri = uriBuilder.nextPage(AccountResource.class, "getAccounts", accounts.getNextOffset(), limit, ImmutableMap.<String, String>of(QUERY_ACCOUNT_WITH_BALANCE, accountWithBalance.toString(), QUERY_ACCOUNT_WITH_BALANCE_AND_CBA, accountWithBalanceAndCBA.toString(), QUERY_AUDIT, auditMode.getLevel().toString()));
return buildStreamingPaginationResponse(accounts, new Function<Account, AccountJson>() {
@Override
public AccountJson apply(final Account account) {
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext);
return getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext);
}
}, nextPageUri);
}
use of javax.ws.rs.Produces in project OpenAttestation by OpenAttestation.
the class AbstractJsonapiResource method storeJsonapiCollection.
/**
* Replace an item in the collection. Input Content-Type is
* application/vnd.api+json Output Content-Type is application/vnd.api+json
*
* The input item must be wrapped in a collection. The output item is always
* wrapped in a collection.
*
* @param locator
* @param collection
* @return
*/
@Path("/{id}")
@PUT
@Consumes(DataMediaType.APPLICATION_VND_API_JSON)
@Produces(DataMediaType.APPLICATION_VND_API_JSON)
public C storeJsonapiCollection(@BeanParam L locator, C collection) {
// misnomer, what we really mean is "store one but wrapped ina collection for jsonapi"
log.debug("storeCollection");
ValidationUtil.validate(collection);
List<T> list = collection.getDocuments();
if (list == null || list.isEmpty()) {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
T item = list.get(0);
locator.copyTo(item);
if (item == null) {
getRepository().create(item);
} else {
getRepository().store(item);
}
return collection;
}
use of javax.ws.rs.Produces in project OpenAttestation by OpenAttestation.
the class AbstractJsonapiResource method createJsonapiCollection.
/**
* Add an item to the collection. Input Content-Type is
* application/vnd.api+json Output Content-Type is application/vnd.api+json
*
* The input must represent a collection of items to add, even if the
* collection only contains a single item.
*
*
* @param collection
* @return
*/
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public C createJsonapiCollection(C collection) {
log.debug("createCollection");
ValidationUtil.validate(collection);
// this behavior of autmoatically generating uuids if client didn't provide could be implemented in one place and reused in all create() methods... the utility could accept a DocumentCollection and set the ids...
for (T item : collection.getDocuments()) {
if (item.getId() == null) {
item.setId(new UUID());
}
getRepository().create(item);
}
return collection;
}
use of javax.ws.rs.Produces in project OpenAttestation by OpenAttestation.
the class AssetTagCert method revokeAssetTagCertificate.
/**
* This REST API would be called by tag provisioning service whenever a valid asset tag certificate is revoked.
* @param atagObj
* @return
*/
//@RolesAllowed({"AssetTagManagement"})
// @RequiresPermissions({"tag_certificates:store"})
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String revokeAssetTagCertificate(AssetTagCertRevokeRequest atagObj) {
boolean result;
AssetTagCertBO object = new AssetTagCertBO();
result = object.revokeAssetTagCertificate(atagObj, null);
return Boolean.toString(result);
}
use of javax.ws.rs.Produces in project OpenAttestation by OpenAttestation.
the class AssetTagCert method importAssetTagCertificate.
/**
* This REST API would be called by the tag provisioning service whenever a new asset tag certificate is generated for a host.
* Initially we would stored this asset tag certificate in the DB without being mapped to any host. After the host is registered, then
* the asset tag certificate would be mapped to it.
* @param atagObj
* @return
*/
//@RolesAllowed({"AssetTagManagement"})
// @RequiresPermissions({"tag_certificates:create","hosts:search"})
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String importAssetTagCertificate(AssetTagCertCreateRequest atagObj) {
AssetTagCertBO object = new AssetTagCertBO();
boolean result = object.importAssetTagCertificate(atagObj, null);
return Boolean.toString(result);
}
Aggregations