Fixed prepared query

This commit is contained in:
Luca Frosini 2021-07-07 17:36:10 +02:00
parent 6770823e29
commit 4ec7d40f7b
2 changed files with 12 additions and 6 deletions

View File

@ -537,7 +537,14 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
Iterable<?> references = null; Iterable<?> references = null;
if(referenceUUID != null) { if(referenceUUID != null) {
OElement element = ElementManagementUtility.getAnyElementByUUID(oDatabaseDocument, referenceUUID); OElement element = null;
try {
element = ElementManagementUtility.getAnyElementByUUID(oDatabaseDocument, referenceUUID);
}catch (ResourceRegistryException e) {
String error = String.format("No instace with UUID % exists", referenceUUID);
throw new InvalidQueryException(error);
}
if(element instanceof OVertex) { if(element instanceof OVertex) {
EntityManagement<?, ?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(), EntityManagement<?, ?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
oDatabaseDocument, (OVertex) element); oDatabaseDocument, (OVertex) element);
@ -547,8 +554,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
if(polymorphic && getOClass().isSubClassOf(referenceType)) { if(polymorphic && getOClass().isSubClassOf(referenceType)) {
// OK // OK
} else { } else {
String error = String.format("Referenced instace with UUID %s is not a %s", referenceUUID, String error = String.format("Referenced instace with UUID %s is not a %s", referenceUUID, referenceType);
referenceType);
throw new InvalidQueryException(error); throw new InvalidQueryException(error);
} }
} }
@ -558,7 +564,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
references = vertexes; references = vertexes;
} else { } else {
String error = String.format("Referenced instace with UUID %s is not an %s", referenceUUID, Entity.NAME); String error = String.format("Referenced instace with UUID %s is not a %s", referenceUUID, referenceType);
throw new InvalidQueryException(error); throw new InvalidQueryException(error);
} }

View File

@ -287,8 +287,8 @@ public class Access extends BaseRest {
/*@QueryParam(AccessPath._INCLUDE_RELATION_PARAM) @DefaultValue("false") Boolean includeRelation,*/ /*@QueryParam(AccessPath._INCLUDE_RELATION_PARAM) @DefaultValue("false") Boolean includeRelation,*/
@Context UriInfo uriInfo) throws ResourceRegistryException { @Context UriInfo uriInfo) throws ResourceRegistryException {
logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={}. Complete Request is {})", resourcetype, relationType, logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={}). Request URI is {})", resourcetype, relationType,
AccessPath._DIRECTION_PARAM, direction, referenceType, AccessPath._POLYMORPHIC_PARAM, polymorphic, uriInfo.getPath()); AccessPath._DIRECTION_PARAM, direction, referenceType, AccessPath._POLYMORPHIC_PARAM, polymorphic, uriInfo.getRequestUri());
CalledMethodProvider.instance.set("query"); CalledMethodProvider.instance.set("query");