use of com.walmartlabs.concord.server.org.OrganizationEntry 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();
}
use of com.walmartlabs.concord.server.org.OrganizationEntry 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());
}
use of com.walmartlabs.concord.server.org.OrganizationEntry 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);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class ConsoleService method isRepositoryExists.
@GET
@Path("/org/{orgName}/project/{projectName}/repo/{repoName}/exists")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public boolean isRepositoryExists(@PathParam("orgName") @ConcordKey String orgName, @PathParam("projectName") @ConcordKey String projectName, @PathParam("repoName") String repoName) {
try {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
UUID projectId = projectDao.getId(org.getId(), projectName);
if (projectId == null) {
throw new ConcordApplicationException("Project not found: " + projectName, Status.BAD_REQUEST);
}
return repositoryDao.getId(projectId, repoName) != null;
} catch (UnauthorizedException e) {
return false;
}
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class UserDao method getUserInfo.
private UserEntry getUserInfo(DSLContext tx, Record7<UUID, String, String, String, String, String, Boolean> r) {
// TODO join?
Field<String> orgNameField = select(ORGANIZATIONS.ORG_NAME).from(ORGANIZATIONS).where(ORGANIZATIONS.ORG_ID.eq(TEAMS.ORG_ID)).asField();
SelectConditionStep<Record1<UUID>> teamIds = select(V_USER_TEAMS.TEAM_ID).from(V_USER_TEAMS).where(V_USER_TEAMS.USER_ID.eq(r.get(USERS.USER_ID)));
List<OrganizationEntry> orgs = tx.selectDistinct(TEAMS.ORG_ID, orgNameField).from(TEAMS).where(TEAMS.TEAM_ID.in(teamIds)).fetch(e -> new OrganizationEntry(e.value1(), e.value2(), null, null, null, null));
SelectConditionStep<Record1<String[]>> permissions = select(arrayAgg(PERMISSIONS.PERMISSION_NAME)).from(PERMISSIONS).where(PERMISSIONS.PERMISSION_ID.in(select(ROLE_PERMISSIONS.PERMISSION_ID).from(ROLE_PERMISSIONS).where(ROLE_PERMISSIONS.ROLE_ID.in(ROLES.ROLE_ID))));
SelectConditionStep<Record1<UUID>> roleIds = select(USER_ROLES.ROLE_ID).from(USER_ROLES).where(USER_ROLES.USER_ID.eq(r.get(USERS.USER_ID)));
List<RoleEntry> roles = tx.select(ROLES.ROLE_ID, ROLES.ROLE_NAME, isnull(permissions.asField(), new String[] {})).from(ROLES).where(ROLES.ROLE_ID.in(roleIds)).fetch(e -> new RoleEntry(e.value1(), e.value2(), new HashSet<>(Arrays.asList(e.value3()))));
return new UserEntry(r.get(USERS.USER_ID), r.get(USERS.USERNAME), r.get(USERS.DOMAIN), r.get(USERS.DISPLAY_NAME), new HashSet<>(orgs), UserType.valueOf(r.get(USERS.USER_TYPE)), r.get(USERS.USER_EMAIL), new HashSet<>(roles), r.get(USERS.IS_DISABLED));
}
Aggregations