Search in sources :

Example 1 with JsonStoreEntry

use of com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry in project concord by walmartlabs.

the class ConsoleService method isStorageQueryExists.

@GET
@Path("/org/{orgName}/jsonstore/{storeName}/query/{queryName}/exists")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public boolean isStorageQueryExists(@PathParam("orgName") @ConcordKey String orgName, @PathParam("storeName") String storeName, @PathParam("queryName") String queryName) {
    try {
        OrganizationEntry org = orgManager.assertAccess(orgName, true);
        JsonStoreEntry storage = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
        return storageQueryDao.getId(storage.id(), queryName) != null;
    } catch (UnauthorizedException e) {
        return false;
    }
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Example 2 with JsonStoreEntry

use of com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry in project concord by walmartlabs.

the class InventoryDataResource method get.

/**
 * Returns an existing inventory data.
 *
 * @param orgName       organization's name
 * @param inventoryName inventory's name
 * @param itemPath      data item path
 * @return
 */
@GET
@ApiOperation("Get inventory data")
@Path("/{orgName}/inventory/{inventoryName}/data/{itemPath:.*}")
@Produces(MediaType.APPLICATION_JSON)
public Object get(@ApiParam @PathParam("orgName") String orgName, @ApiParam @PathParam("inventoryName") String inventoryName, @ApiParam @PathParam("itemPath") String itemPath, @ApiParam @QueryParam("singleItem") @DefaultValue("false") boolean singleItem) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    JsonStoreEntry inventory = inventoryManager.assertAccess(org.getId(), null, inventoryName, ResourceAccessLevel.READER, true);
    if (singleItem) {
        return inventoryDataDao.getSingleItem(inventory.id(), itemPath);
    } else {
        return build(inventory.id(), itemPath);
    }
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with JsonStoreEntry

use of com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry in project concord by walmartlabs.

the class AuditLogResource method getEffectiveJsonStoreId.

private UUID getEffectiveJsonStoreId(UUID effectiveOrgId, Map<String, String> details) {
    UUID jsonStoreId = getUUID(details, "jsonStoreId");
    String jsonStoreName = details.get("jsonStoreName");
    if (effectiveOrgId == null && jsonStoreId == null && jsonStoreName != null) {
        throw new ValidationErrorsException("'orgId' or 'orgName' is required");
    }
    if (jsonStoreId != null || jsonStoreName != null) {
        JsonStoreEntry store = jsonStoreAccessManager.assertAccess(effectiveOrgId, jsonStoreId, jsonStoreName, ResourceAccessLevel.READER, true);
        return store.id();
    }
    return null;
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) UUID(java.util.UUID) ValidationErrorsException(org.sonatype.siesta.ValidationErrorsException)

Example 4 with JsonStoreEntry

use of com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry in project concord by walmartlabs.

the class InventoryDataResource method delete.

/**
 * Deletes inventory data
 *
 * @param orgName       organization's name
 * @param inventoryName inventory's name
 * @param itemPath      inventory's data path
 * @return
 */
@DELETE
@ApiOperation("Delete inventory data")
@Path("/{orgName}/inventory/{inventoryName}/data/{itemPath:.*}")
@Produces(MediaType.APPLICATION_JSON)
public DeleteInventoryDataResponse delete(@ApiParam @PathParam("orgName") String orgName, @ApiParam @PathParam("inventoryName") String inventoryName, @ApiParam @PathParam("itemPath") String itemPath) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    JsonStoreEntry inventory = inventoryManager.assertAccess(org.getId(), null, inventoryName, ResourceAccessLevel.WRITER, true);
    inventoryDataDao.delete(inventory.id(), itemPath);
    return new DeleteInventoryDataResponse();
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with JsonStoreEntry

use of com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry in project concord by walmartlabs.

the class InventoryDataResource method list.

/**
 * Returns all inventory data for inventory.
 *
 * @param orgName       organization's name
 * @param inventoryName inventory's name
 * @return
 */
@GET
@ApiOperation("List inventory data")
@Path("/{orgName}/inventory/{inventoryName}/data")
@Produces(MediaType.APPLICATION_JSON)
public List<Map<String, Object>> list(@ApiParam @PathParam("orgName") String orgName, @ApiParam @PathParam("inventoryName") String inventoryName) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    JsonStoreEntry inventory = inventoryManager.assertAccess(org.getId(), null, inventoryName, ResourceAccessLevel.READER, true);
    return inventoryDataDao.list(inventory.id());
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

JsonStoreEntry (com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry)6 OrganizationEntry (com.walmartlabs.concord.server.org.OrganizationEntry)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)2 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)1 Map (java.util.Map)1 UUID (java.util.UUID)1 UnauthorizedException (org.apache.shiro.authz.UnauthorizedException)1