use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreQueryManager method createOrUpdate.
public OperationResult createOrUpdate(String orgName, String storeName, JsonStoreQueryRequest entry) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
UUID queryId = entry.id();
String queryName = entry.name();
String text = entry.text();
validateQuery(text);
if (queryId == null && queryName != null) {
queryId = queryDao.getId(store.id(), queryName);
}
if (queryId == null) {
policyManager.checkEntity(org.getId(), null, EntityType.JSON_STORE_QUERY, EntityAction.CREATE, null, PolicyUtils.jsonStoreQueryToMap(org, store, queryName, text));
queryDao.insert(store.id(), queryName, text);
addAuditLog(AuditAction.CREATE, org.getId(), store.id(), queryName, null, text);
return OperationResult.CREATED;
} else {
policyManager.checkEntity(org.getId(), null, EntityType.JSON_STORE_QUERY, EntityAction.UPDATE, null, PolicyUtils.jsonStoreQueryToMap(org, store, queryName, text));
JsonStoreQueryEntry prevEntry = queryDao.get(queryId);
String prevText = prevEntry.text();
if (Objects.equals(text, prevText)) {
// no changes
return OperationResult.ALREADY_EXISTS;
}
queryDao.update(queryId, text);
addAuditLog(AuditAction.UPDATE, org.getId(), store.id(), queryName, prevEntry.text(), text);
return OperationResult.UPDATED;
}
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreQueryManager method exec.
public List<Object> exec(String orgName, String storeName, String queryName, Map<String, Object> params) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
return execDao.exec(store.id(), queryName, params);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreQueryManager method exec.
public List<Object> exec(String orgName, String storeName, String text, int maxLimit) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
return execDao.execSql(store.id(), text, null, maxLimit);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreQueryManager method list.
public List<JsonStoreQueryEntry> list(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 queryDao.list(store.id(), offset, limit, filter);
}
use of com.walmartlabs.concord.server.org.OrganizationEntry in project concord by walmartlabs.
the class JsonStoreQueryManager method delete.
public void delete(String orgName, String storeName, String queryName) {
OrganizationEntry org = orgManager.assertAccess(orgName, true);
JsonStoreEntry store = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
UUID id = queryDao.getId(store.id(), queryName);
if (id == null) {
throw new ValidationErrorsException("Query not found: " + queryName);
}
queryDao.delete(store.id(), queryName);
addAuditLog(AuditAction.DELETE, org.getId(), store.id(), queryName);
}
Aggregations