use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class ProjectManager method get.
public ProjectEntry get(String orgName, String projectName) {
OrganizationEntry org = orgManager.assertAccess(orgName, false);
UUID projectId = projectDao.getId(org.getId(), projectName);
if (projectId == null) {
throw new ConcordApplicationException("Project not found: " + projectName, Response.Status.NOT_FOUND);
}
return get(projectId);
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class PolicyResource method list.
@GET
@ApiOperation(value = "List policies, optionally filtering by organization, project and/or user links", responseContainer = "list", response = PolicyEntry.class)
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public List<PolicyEntry> list(@ApiParam @QueryParam("orgName") @ConcordKey String orgName, @ApiParam @QueryParam("projectName") @ConcordKey String projectName, @ApiParam @QueryParam("userName") @ConcordKey String userName, @ApiParam @QueryParam("userDomain") String userDomain, @ApiParam @QueryParam("userType") UserType userType) {
if (orgName == null && projectName == null && userName == null) {
return policyManager.list();
}
UUID orgId = null;
if (orgName != null) {
orgId = orgDao.getId(orgName);
if (orgId == null) {
throw new ConcordApplicationException("Organization not found: " + orgName, Status.BAD_REQUEST);
}
}
UUID projectId = null;
if (projectName != null) {
if (orgId == null) {
throw new ConcordApplicationException("Organization name is required", Status.BAD_REQUEST);
}
projectId = projectDao.getId(orgId, projectName);
if (projectId == null) {
throw new ConcordApplicationException("Project not found: " + projectName, Status.BAD_REQUEST);
}
}
UUID userId = null;
if (userName != null) {
if (userType == null) {
userType = UserPrincipal.assertCurrent().getType();
}
userId = assertUser(userName, userDomain, userType);
}
PolicyEntry e = policyManager.getLinked(orgId, projectId, userId);
if (e == null) {
return Collections.emptyList();
}
// TODO consider returning multiple entries?
return Collections.singletonList(e);
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class PolicyResource method delete.
@DELETE
@ApiOperation("Delete an existing policy")
@Path("/{policyName}")
@Produces(MediaType.APPLICATION_JSON)
public GenericOperationResult delete(@ApiParam @PathParam("policyName") @ConcordKey String policyName) {
assertAdmin();
UUID id = policyManager.getId(policyName);
if (id == null) {
throw new ConcordApplicationException("Policy not found: " + policyName, Status.NOT_FOUND);
}
policyManager.delete(id);
auditLog.add(AuditObject.POLICY, AuditAction.DELETE).field("policyId", id).field("name", policyName).log();
return new GenericOperationResult(OperationResult.DELETED);
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class RepositoryResource method validateRepository.
/**
* Validate a repository.
*/
@POST
@ApiOperation("Validate an existing repository")
@Path("/{orgName}/project/{projectName}/repository/{repositoryName}/validate")
@Produces(MediaType.APPLICATION_JSON)
public RepositoryValidationResponse validateRepository(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @PathParam("projectName") @ConcordKey String projectName, @ApiParam @PathParam("repositoryName") @ConcordKey String repositoryName) {
UUID orgId = orgManager.assertAccess(orgName, true).getId();
UUID projectId = projectDao.getId(orgId, projectName);
if (projectId == null) {
throw new ConcordApplicationException("Project not found: " + projectName, Status.NOT_FOUND);
}
accessManager.assertAccess(projectId, ResourceAccessLevel.READER, true);
UUID repoId = repositoryDao.getId(projectId, repositoryName);
if (repoId == null) {
throw new ConcordApplicationException("Repository not found: " + repositoryName, Status.NOT_FOUND);
}
ProjectValidator.Result result = projectRepositoryManager.validateRepository(projectId, repositoryDao.get(projectId, repoId));
return new RepositoryValidationResponse(result.isValid(), OperationResult.VALIDATED, result.getErrors(), result.getWarnings());
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class RepositoryResource method delete.
@DELETE
@ApiOperation("Delete an existing repository")
@Path("/{orgName}/project/{projectName}/repository/{repositoryName}")
@Produces(MediaType.APPLICATION_JSON)
public GenericOperationResult delete(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @PathParam("projectName") @ConcordKey String projectName, @ApiParam @PathParam("repositoryName") @ConcordKey String repositoryName) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
UUID projectId = projectDao.getId(org.getId(), projectName);
if (projectId == null) {
throw new ConcordApplicationException("Project not found: " + projectName, Status.NOT_FOUND);
}
projectRepositoryManager.delete(projectId, repositoryName);
return new GenericOperationResult(OperationResult.DELETED);
}
Aggregations