Fixing raw query
This commit is contained in:
parent
0ffca0008e
commit
fa503eb828
|
@ -170,7 +170,7 @@ public class DatabaseEnvironment {
|
||||||
DEFAULT_PASSWORDS.put(PermissionMode.WRITER, DEFAULT_CREATED_WRITER_USER_PASSWORD);
|
DEFAULT_PASSWORDS.put(PermissionMode.WRITER, DEFAULT_CREATED_WRITER_USER_PASSWORD);
|
||||||
DEFAULT_PASSWORDS.put(PermissionMode.READER, DEFAULT_CREATED_READER_USER_PASSWORD);
|
DEFAULT_PASSWORDS.put(PermissionMode.READER, DEFAULT_CREATED_READER_USER_PASSWORD);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Throwable e) {
|
||||||
logger.error("Unable to load properties from {}", PROPERTY_FILENAME);
|
logger.error("Unable to load properties from {}", PROPERTY_FILENAME);
|
||||||
throw new RuntimeException("Unable to load properties", e);
|
throw new RuntimeException("Unable to load properties", e);
|
||||||
}
|
}
|
||||||
|
@ -288,6 +288,8 @@ public class DatabaseEnvironment {
|
||||||
oDatabaseDocument.set(ATTRIBUTES.DATETIMEFORMAT, Element.DATETIME_PATTERN);
|
oDatabaseDocument.set(ATTRIBUTES.DATETIMEFORMAT, Element.DATETIME_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
// This code must be removed for OrientDB versions higher than 3.2.X
|
||||||
protected static void setRecordLevelSecurity(OMetadata oMetadata) {
|
protected static void setRecordLevelSecurity(OMetadata oMetadata) {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"Setting Record-level Security (see https://orientdb.org/docs/3.2.x/security/Database-Security.html#record-level-security-deprecated-in-v-31)");
|
"Setting Record-level Security (see https://orientdb.org/docs/3.2.x/security/Database-Security.html#record-level-security-deprecated-in-v-31)");
|
||||||
|
@ -383,6 +385,7 @@ public class DatabaseEnvironment {
|
||||||
logger.trace("Updated password for user {}", permissionMode.toString());
|
logger.trace("Updated password for user {}", permissionMode.toString());
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.trace("Unable to update password for user {}. {}", permissionMode.toString(), e.getMessage());
|
logger.trace("Unable to update password for user {}. {}", permissionMode.toString(), e.getMessage());
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,13 +68,19 @@ public class QueryImpl implements Query {
|
||||||
|
|
||||||
while(resultSet.hasNext()) {
|
while(resultSet.hasNext()) {
|
||||||
OResult oResult = resultSet.next();
|
OResult oResult = resultSet.next();
|
||||||
OElement element = ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JsonNode jsonNode = null;
|
JsonNode jsonNode = null;
|
||||||
if(raw) {
|
if(raw) {
|
||||||
jsonNode = Utility.toJsonNode(element, false);
|
if(oResult.isElement()) {
|
||||||
|
OElement element = ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
||||||
|
jsonNode = Utility.toJsonNode(element, false);
|
||||||
|
}else {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
jsonNode = mapper.readTree(oResult.toJSON());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
OElement element = ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
||||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument,
|
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument,
|
||||||
element);
|
element);
|
||||||
jsonNode = erManagement.serializeAsJsonNode();
|
jsonNode = erManagement.serializeAsJsonNode();
|
||||||
|
@ -83,7 +89,7 @@ public class QueryImpl implements Query {
|
||||||
|
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
||||||
element.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
oResult.toJSON(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,7 @@ public class Access extends BaseRest {
|
||||||
* <a href="https://orientdb.com/docs/last/Fetching-Strategies.html" target="_blank">
|
* <a href="https://orientdb.com/docs/last/Fetching-Strategies.html" target="_blank">
|
||||||
* https://orientdb.com/docs/last/Fetching-Strategies.html
|
* https://orientdb.com/docs/last/Fetching-Strategies.html
|
||||||
* </a>
|
* </a>
|
||||||
|
* @param raw request a raw response (not a Element based response)
|
||||||
* @return The JSON representation of the result
|
* @return The JSON representation of the result
|
||||||
* @throws InvalidQueryException if the query is invalid or not idempotent
|
* @throws InvalidQueryException if the query is invalid or not idempotent
|
||||||
*/
|
*/
|
||||||
|
@ -244,7 +245,7 @@ public class Access extends BaseRest {
|
||||||
@QueryParam(AccessPath.FETCH_PLAN_PARAM) @DefaultValue(AccessPath.DEFAULT_FETCH_PLAN_PARAM) String fetchPlan,
|
@QueryParam(AccessPath.FETCH_PLAN_PARAM) @DefaultValue(AccessPath.DEFAULT_FETCH_PLAN_PARAM) String fetchPlan,
|
||||||
@QueryParam(AccessPath.RAW_PARAM) @DefaultValue(AccessPath.DEFAULT_RAW_PARAM) Boolean raw)
|
@QueryParam(AccessPath.RAW_PARAM) @DefaultValue(AccessPath.DEFAULT_RAW_PARAM) Boolean raw)
|
||||||
throws InvalidQueryException {
|
throws InvalidQueryException {
|
||||||
logger.info("Requested query (fetch plan {}, limit : {}, Raw : raw):\n{}", fetchPlan, limit, query, raw);
|
logger.info("Requested query (fetch plan {}, limit {}, Raw {}):\n{}", fetchPlan, limit, raw, query);
|
||||||
CalledMethodProvider.instance.set("graphQuery");
|
CalledMethodProvider.instance.set("graphQuery");
|
||||||
|
|
||||||
checkHierarchicalMode();
|
checkHierarchicalMode();
|
||||||
|
|
Loading…
Reference in New Issue