use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class ProjectProcessResource method list.
@GET
@ApiOperation("List processes for the specified project")
@Path("/{orgName}/project/{projectName}/process")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
@Deprecated
public List<ProcessEntry> list(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @PathParam("projectName") @ConcordKey String projectName, @ApiParam @QueryParam("status") ProcessStatus processStatus, @ApiParam @QueryParam("afterCreatedAt") OffsetDateTimeParam afterCreatedAt, @ApiParam @QueryParam("beforeCreatedAt") OffsetDateTimeParam beforeCreatedAt, @ApiParam @QueryParam("limit") @DefaultValue(DEFAULT_LIST_LIMIT) int limit, @ApiParam @QueryParam("offset") @DefaultValue("0") int offset) {
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);
}
ProcessFilter filter = ProcessFilter.builder().projectId(projectId).status(processStatus).afterCreatedAt(unwrap(afterCreatedAt)).beforeCreatedAt(unwrap(beforeCreatedAt)).limit(limit).offset(offset).build();
return queueDao.list(filter);
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException 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.sdk.ConcordApplicationException in project concord by walmartlabs.
the class UserManager method disable.
public void disable(UUID userId) {
if (userDao.isDisabled(userId).orElseThrow(() -> new ConcordApplicationException("User not found: " + userId))) {
// the account is already disabled, nothing to do
return;
}
userDao.disable(userId);
auditLog.add(AuditObject.USER, AuditAction.UPDATE).field("userId", userId).changes(describeStatusChange(false), describeStatusChange(true)).log();
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class UserResource method updateUserRoles.
@POST
@ApiOperation("Update the list of roles for the existing user")
@Path("/{username}/roles")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Validate
public GenericOperationResult updateUserRoles(@ApiParam @PathParam("username") @Size(max = UserEntry.MAX_USERNAME_LENGTH) String username, @ApiParam @Valid UpdateUserRolesRequest req) {
assertAdmin();
// TODO: type from request
UserType type = UserPrincipal.assertCurrent().getType();
// TODO: userDomain from request
String userDomain = null;
UUID id = userManager.getId(username, userDomain, type).orElseThrow(() -> new ConcordApplicationException("User not found: " + username, Status.NOT_FOUND));
userDao.updateRoles(id, req.getRoles());
return new GenericOperationResult(OperationResult.UPDATED);
}
use of com.walmartlabs.concord.server.sdk.ConcordApplicationException in project concord by walmartlabs.
the class UserResource method findByUsername.
/**
* Finds an existing user by username.
*
* @param username
* @return
*/
@GET
@ApiOperation("Find a user")
@Path("/{username}")
@Produces(MediaType.APPLICATION_JSON)
@Validate
public UserEntry findByUsername(@PathParam("username") @Size(max = UserEntry.MAX_USERNAME_LENGTH) @NotNull String username) {
assertAdmin();
UUID id = userManager.getId(username, null, null).orElseThrow(() -> new ConcordApplicationException("User not found: " + username, Status.NOT_FOUND));
return userDao.get(id);
}
Aggregations