Search in sources :

Example 1 with RepositoryValidationResponse

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());
}
Also used : RepositoryValidationResponse(com.walmartlabs.concord.server.repository.RepositoryValidationResponse) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) UUID(java.util.UUID) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

RepositoryValidationResponse (com.walmartlabs.concord.server.repository.RepositoryValidationResponse)1 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)1 ApiOperation (io.swagger.annotations.ApiOperation)1 UUID (java.util.UUID)1