use of com.walmartlabs.concord.server.repository.RepositoryValidationResponse 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());
}
Aggregations