Search in sources :

Example 1 with OperationResult

use of com.walmartlabs.concord.server.OperationResult in project concord by walmartlabs.

the class InventoryResource method createOrUpdate.

/**
 * Create or update a inventory.
 *
 * @param orgName organization's name
 * @param entry   inventory's data
 * @return
 */
@POST
@ApiOperation("Create or update inventory")
@Path("/{orgName}/inventory")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Validate
public CreateInventoryResponse createOrUpdate(@ApiParam @PathParam("orgName") String orgName, @ApiParam @Valid InventoryEntry entry) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    OperationResult result = storageManager.createOrUpdate(orgName, JsonStoreRequest.builder().id(entry.getId()).name(entry.getName()).owner(toOwner(entry.getOwner())).visibility(entry.getVisibility() != null ? entry.getVisibility() : JsonStoreVisibility.PUBLIC).build());
    UUID id = storageDao.getId(org.getId(), entry.getName());
    return new CreateInventoryResponse(result, id);
}
Also used : GenericOperationResult(com.walmartlabs.concord.server.GenericOperationResult) OperationResult(com.walmartlabs.concord.server.OperationResult) UUID(java.util.UUID) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) Validate(org.sonatype.siesta.Validate) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

GenericOperationResult (com.walmartlabs.concord.server.GenericOperationResult)1 OperationResult (com.walmartlabs.concord.server.OperationResult)1 OrganizationEntry (com.walmartlabs.concord.server.org.OrganizationEntry)1 ApiOperation (io.swagger.annotations.ApiOperation)1 UUID (java.util.UUID)1 Validate (org.sonatype.siesta.Validate)1