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);
}
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);
}
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());
}
}
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;
}
}
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);
}
Aggregations