Search in sources :

Example 76 with Produces

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);
}
Also used : AccountJson(org.killbill.billing.jaxrs.json.AccountJson) Account(org.killbill.billing.account.api.Account) TenantContext(org.killbill.billing.util.callcontext.TenantContext) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) URI(java.net.URI) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 77 with Produces

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;
}
Also used : POST(javax.ws.rs.POST) GET(javax.ws.rs.GET) PUT(javax.ws.rs.PUT) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 78 with Produces

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;
}
Also used : POST(javax.ws.rs.POST) GET(javax.ws.rs.GET) PUT(javax.ws.rs.PUT) UUID(com.intel.mtwilson.util.io.UUID) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 79 with Produces

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);
}
Also used : AssetTagCertBO(com.intel.mtwilson.as.business.AssetTagCertBO) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 80 with Produces

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);
}
Also used : AssetTagCertBO(com.intel.mtwilson.as.business.AssetTagCertBO) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

Produces (javax.ws.rs.Produces)1150 Path (javax.ws.rs.Path)844 GET (javax.ws.rs.GET)724 Consumes (javax.ws.rs.Consumes)306 POST (javax.ws.rs.POST)304 ApiOperation (io.swagger.annotations.ApiOperation)275 ApiResponses (io.swagger.annotations.ApiResponses)218 IOException (java.io.IOException)143 Response (javax.ws.rs.core.Response)139 WebApplicationException (javax.ws.rs.WebApplicationException)115 URI (java.net.URI)110 TimedResource (org.killbill.commons.metrics.TimedResource)109 Timed (com.codahale.metrics.annotation.Timed)103 ArrayList (java.util.ArrayList)91 PUT (javax.ws.rs.PUT)89 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)85 HashMap (java.util.HashMap)68 Map (java.util.Map)63 UUID (java.util.UUID)63 DELETE (javax.ws.rs.DELETE)62