use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class AuditLogResource method getEffectiveOrgId.
private UUID getEffectiveOrgId(Map<String, String> details) {
UUID orgId = getUUID(details, "orgId");
String orgName = details.get("orgName");
if (orgId != null || orgName != null) {
OrganizationEntry org = orgManager.assertAccess(orgId, orgName, true);
return org.getId();
}
return null;
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class ProjectManager method update.
private void update(DSLContext tx, UUID projectId, ProjectEntry entry) {
ProjectEntry e = projectDao.get(projectId);
if (e == null) {
throw new ValidationErrorsException("Project not found: " + projectId);
}
UserEntry owner = getOwner(entry.getOwner(), null);
policyManager.checkEntity(e.getOrgId(), projectId, EntityType.PROJECT, EntityAction.UPDATE, owner, PolicyUtils.projectToMap(e.getOrgId(), e.getOrgName(), entry));
UUID currentOwnerId = e.getOwner() != null ? e.getOwner().id() : null;
UUID updatedOwnerId = owner != null ? owner.getId() : null;
ResourceAccessLevel level = ResourceAccessLevel.WRITER;
if (updatedOwnerId != null && !updatedOwnerId.equals(currentOwnerId)) {
level = ResourceAccessLevel.OWNER;
}
ProjectEntry prevEntry = accessManager.assertAccess(projectId, level, true);
UUID orgId = prevEntry.getOrgId();
OrganizationEntry organizationEntry = null;
if (entry.getOrgId() != null) {
organizationEntry = orgManager.assertAccess(entry.getOrgId(), true);
} else if (entry.getOrgName() != null) {
organizationEntry = orgManager.assertAccess(entry.getOrgName(), true);
}
UUID orgIdUpdate = organizationEntry != null ? organizationEntry.getId() : orgId;
RawPayloadMode rawPayloadMode = entry.getRawPayloadMode();
if (rawPayloadMode == null && entry.getAcceptsRawPayload() != null && entry.getAcceptsRawPayload()) {
rawPayloadMode = RawPayloadMode.ORG_MEMBERS;
}
if (!orgIdUpdate.equals(orgId)) {
secretDao.updateProjectScopeByProjectId(tx, orgId, projectId, null);
repositoryDao.clearSecretMappingByProjectId(tx, projectId);
}
projectDao.update(tx, orgIdUpdate, projectId, entry.getVisibility(), entry.getName(), entry.getDescription(), entry.getCfg(), rawPayloadMode, updatedOwnerId, entry.getMeta(), entry.getOutVariablesMode());
Map<String, RepositoryEntry> repos = entry.getRepositories();
if (repos != null) {
repositoryDao.deleteAll(tx, projectId);
repos.forEach((k, v) -> projectRepositoryManager.insert(tx, orgId, prevEntry.getOrgName(), projectId, prevEntry.getName(), v, false));
}
ProjectEntry newEntry = projectDao.get(tx, projectId);
Map<String, Object> changes = DiffUtils.compare(prevEntry, newEntry);
addAuditLog(AuditAction.UPDATE, prevEntry.getOrgId(), prevEntry.getOrgName(), prevEntry.getId(), prevEntry.getName(), changes);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class ProjectManager method get.
public ProjectEntry get(String orgName, String projectName) {
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);
}
return get(projectId);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class ProjectManager method createOrGet.
public ProjectOperationResult createOrGet(DSLContext tx, UUID orgId, ProjectEntry entry) {
entry = normalize(entry);
OrganizationEntry org = orgManager.assertAccess(tx, orgId, true);
UUID projectId = projectDao.getId(tx, org.getId(), entry.getName());
if (projectId == null) {
projectId = insert(tx, org.getId(), org.getName(), entry);
return ProjectOperationResult.builder().result(OperationResult.CREATED).projectId(projectId).build();
}
return ProjectOperationResult.builder().result(OperationResult.ALREADY_EXISTS).projectId(projectId).build();
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class RepositoryResource method delete.
@DELETE
@ApiOperation("Delete an existing repository")
@Path("/{orgName}/project/{projectName}/repository/{repositoryName}")
@Produces(MediaType.APPLICATION_JSON)
public GenericOperationResult delete(@ApiParam @PathParam("orgName") @ConcordKey String orgName, @ApiParam @PathParam("projectName") @ConcordKey String projectName, @ApiParam @PathParam("repositoryName") @ConcordKey String repositoryName) {
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.delete(projectId, repositoryName);
return new GenericOperationResult(OperationResult.DELETED);
}
Aggregations