use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class ProjectManager method createOrUpdate.
public ProjectOperationResult createOrUpdate(DSLContext tx, String orgName, ProjectEntry entry) {
entry = normalize(entry);
OrganizationEntry org = orgManager.assertAccess(orgName, true);
UUID projectId = entry.getId();
if (projectId == null) {
assertName(entry);
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();
} else {
update(tx, projectId, entry);
return ProjectOperationResult.builder().result(OperationResult.UPDATED).projectId(projectId).build();
}
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class PolicyResource method assertLink.
private PolicyLink assertLink(String policyName, String orgName, String projectName, String userName, String domain, UserType userType) {
UUID policyId = policyManager.getId(policyName);
if (policyId == null) {
throw new ConcordApplicationException("Policy not found: " + policyName, Status.NOT_FOUND);
}
UUID orgId = null;
if (orgName != null) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
orgId = org.getId();
}
UUID projectId = null;
if (projectName != null) {
if (orgId != null) {
projectId = assertProject(orgId, projectName);
} else {
throw new ConcordApplicationException("Organization name is required", Status.BAD_REQUEST);
}
}
if (projectId != null) {
// projectId is enough to make a proper reference
orgId = null;
}
UUID userId = null;
if (userName != null && userType != null) {
userId = assertUser(userName, domain, userType);
}
return new PolicyLink(policyId, orgId, projectId, userId);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreDataManager method createOrUpdate.
public OperationResult createOrUpdate(String orgName, String storeName, String itemPath, Object data) {
if (data == null) {
throw new ValidationErrorsException("JSON Store entries cannot be null.");
}
// we expect all entries to be proper JSON objects
if (!(data instanceof Map)) {
throw new ValidationErrorsException("All JSON Store entries must be valid JSON objects. Got: " + data.getClass());
}
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.WRITER, true);
String jsonData = objectMapper.toString(data);
policyManager.checkEntity(org.getId(), null, EntityType.JSON_STORE_ITEM, EntityAction.UPDATE, null, PolicyUtils.jsonStoreItemToMap(org, store, itemPath, jsonData));
Long currentItemSize = storeDataDao.getItemSize(store.id(), itemPath);
assertStorageDataPolicy(org.getId(), store.id(), currentItemSize == null ? 0 : currentItemSize, jsonData);
storeDataDao.upsert(store.id(), itemPath, jsonData);
addAuditLog(currentItemSize != null ? AuditAction.UPDATE : AuditAction.CREATE, org.getId(), store.id(), itemPath);
return currentItemSize != null ? OperationResult.UPDATED : OperationResult.CREATED;
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreDataManager method delete.
public boolean delete(String orgName, String storeName, String itemPath) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.WRITER, true);
boolean deleted = storeDataDao.delete(store.id(), itemPath);
if (deleted) {
addAuditLog(AuditAction.DELETE, org.getId(), store.id(), itemPath);
}
return deleted;
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreDataManager method getItem.
public Object getItem(String orgName, String storeName, String itemPath) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
return storeDataDao.get(store.id(), itemPath);
}
Aggregations