use of com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry in project concord by walmartlabs.
the class InventoryDataResource method data.
/**
* Modifies inventory data
*
* @param orgName organization's name
* @param inventoryName inventory's name
* @param itemPath inventory's data path
* @param data inventory's data
* @return full inventory data by path
*/
@POST
@ApiOperation("Modify inventory data")
@Path("/{orgName}/inventory/{inventoryName}/data/{itemPath:.*}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Object data(@ApiParam @PathParam("orgName") String orgName, @ApiParam @PathParam("inventoryName") String inventoryName, @ApiParam @PathParam("itemPath") String itemPath, @ApiParam Object data) {
// we expect all top-level entries to be JSON objects
if (!itemPath.contains("/") && !(data instanceof Map)) {
throw new ValidationErrorsException("Top-level inventory entries must be JSON objects. Got: " + data.getClass());
}
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry inventory = inventoryManager.assertAccess(org.getId(), null, inventoryName, ResourceAccessLevel.WRITER, true);
inventoryDataDao.merge(inventory.id(), itemPath, data);
return build(inventory.id(), itemPath);
}
Aggregations