Search in sources :

Example 6 with OrganizationEntry

use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.

the class RepositoryResource method createOrUpdate.

@POST
@ApiOperation("Creates a new repository or updates an existing one")
@Path("/{orgName}/project/{projectName}/repository")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public GenericOperationResult createOrUpdate(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @PathParam("projectName") @ConcordKey String projectName, @ApiParam @Valid RepositoryEntry entry) {
    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.createOrUpdate(projectId, entry);
    return new GenericOperationResult(entry.getId() == null ? OperationResult.CREATED : OperationResult.UPDATED);
}
Also used : GenericOperationResult(com.walmartlabs.concord.server.GenericOperationResult) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) UUID(java.util.UUID) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with OrganizationEntry

use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.

the class JsonStoreQueryManager method get.

public JsonStoreQueryEntry get(String orgName, String storeName, String queryName) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
    return queryDao.get(store.id(), queryName);
}
Also used : OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry)

Example 8 with OrganizationEntry

use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.

the class ConsoleService method testRepository.

@POST
@Path("/repository/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public boolean testRepository(RepositoryTestRequest req) {
    OrganizationEntry org = orgManager.assertAccess(null, req.getOrgName(), false);
    ProjectEntry project = projectAccessManager.assertAccess(org.getId(), null, req.getProjectName(), ResourceAccessLevel.READER, false);
    try {
        String secretName = secretDao.getName(req.getSecretId());
        repositoryManager.testConnection(project.getOrgId(), project.getId(), req.getUrl(), req.getBranch(), req.getCommitId(), req.getPath(), secretName);
        return true;
    } catch (InvalidRepositoryPathException e) {
        Map<String, String> m = new HashMap<>();
        m.put("message", "Repository validation error");
        m.put("level", "WARN");
        m.put("details", e.getMessage());
        throw new ConcordApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).entity(m).build());
    } catch (Exception e) {
        String msg;
        Throwable t = e;
        while (true) {
            msg = t.getMessage();
            t = t.getCause();
            if (t == null) {
                break;
            }
        }
        if (msg == null) {
            msg = "Repository test error";
        }
        throw new ConcordApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).entity(msg).build());
    }
}
Also used : ProjectEntry(com.walmartlabs.concord.server.org.project.ProjectEntry) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) InvalidRepositoryPathException(com.walmartlabs.concord.server.repository.InvalidRepositoryPathException) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) InvalidRepositoryPathException(com.walmartlabs.concord.server.repository.InvalidRepositoryPathException) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Example 9 with OrganizationEntry

use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.

the class ConsoleService method isStorageQueryExists.

@GET
@Path("/org/{orgName}/jsonstore/{storeName}/query/{queryName}/exists")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public boolean isStorageQueryExists(@PathParam("orgName") @ConcordKey String orgName, @PathParam("storeName") String storeName, @PathParam("queryName") String queryName) {
    try {
        OrganizationEntry org = orgManager.assertAccess(orgName, true);
        JsonStoreEntry storage = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
        return storageQueryDao.getId(storage.id(), queryName) != null;
    } catch (UnauthorizedException e) {
        return false;
    }
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Example 10 with OrganizationEntry

use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.

the class JsonStoreDataManager method listItems.

public List<String> listItems(String orgName, String storeName, int offset, int limit, String filter) {
    OrganizationEntry org = orgManager.assertAccess(orgName, true);
    JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
    return storeDataDao.listPath(store.id(), offset, limit, filter);
}
Also used : OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry)

Aggregations

OrganizationEntry (com.walmartlabs.concord.server.org.OrganizationEntry)36 ApiOperation (io.swagger.annotations.ApiOperation)12 UUID (java.util.UUID)12 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)8 UnauthorizedException (org.apache.shiro.authz.UnauthorizedException)6 GenericOperationResult (com.walmartlabs.concord.server.GenericOperationResult)5 JsonStoreEntry (com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry)5 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)5 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)3 UserPrincipal (com.walmartlabs.concord.server.security.UserPrincipal)3 Validate (org.sonatype.siesta.Validate)3 Map (java.util.Map)2 OperationResult (com.walmartlabs.concord.server.OperationResult)1 AuditObject (com.walmartlabs.concord.server.audit.AuditObject)1 RawPayloadMode (com.walmartlabs.concord.server.jooq.enums.RawPayloadMode)1 ResourceAccessLevel (com.walmartlabs.concord.server.org.ResourceAccessLevel)1 ProjectEntry (com.walmartlabs.concord.server.org.project.ProjectEntry)1 MetadataFilter (com.walmartlabs.concord.server.process.queue.ProcessFilter.MetadataFilter)1 InvalidRepositoryPathException (com.walmartlabs.concord.server.repository.InvalidRepositoryPathException)1 UserEntry (com.walmartlabs.concord.server.user.UserEntry)1