static UriInfo buildUriInfo(URI uri, String baseUri, ServiceMetadata serviceMetadata, OData odata) throws URISyntaxException, UriParserException, UriValidationException { URI servicePath = new URI(baseUri); String path = servicePath.getPath(); String rawPath = uri.getPath(); int e = rawPath.indexOf(path); if (-1 == e) { rawPath = uri.getPath(); } else { rawPath = rawPath.substring(e+path.length()); } return new Parser(serviceMetadata.getEdm(), odata).parseUri(rawPath, uri.getQuery(), null, baseUri); }
@Override public UriResourceEntitySet parseEntityId(final Edm edm, final String entityId, final String rawServiceRoot) throws DeserializerException { String oDataPath = entityId; if (rawServiceRoot != null && entityId.startsWith(rawServiceRoot)) { oDataPath = entityId.substring(rawServiceRoot.length()); } oDataPath = oDataPath.startsWith("/") ? oDataPath : "/" + oDataPath; try { final List<UriResource> uriResourceParts = new Parser(edm, new ODataImpl()).parseUri(oDataPath, null, null, rawServiceRoot).getUriResourceParts(); if (uriResourceParts.size() == 1 && uriResourceParts.get(0).getKind() == UriResourceKind.entitySet) { final UriResourceEntitySet entityUriResource = (UriResourceEntitySet) uriResourceParts.get(0); return entityUriResource; } throw new DeserializerException("Invalid entity binding link", MessageKeys.INVALID_ENTITY_BINDING_LINK, entityId); } catch (final ODataLibraryException e) { throw new DeserializerException("Invalid entity binding link", e, MessageKeys.INVALID_ENTITY_BINDING_LINK, entityId); } } }
@Override public UriResourceEntitySet parseEntityId(final Edm edm, final String entityId, final String rawServiceRoot) throws DeserializerException { String oDataPath = entityId; if (rawServiceRoot != null && entityId.startsWith(rawServiceRoot)) { oDataPath = entityId.substring(rawServiceRoot.length()); } oDataPath = oDataPath.startsWith("/") ? oDataPath : "/" + oDataPath; try { final List<UriResource> uriResourceParts = new Parser(edm, new ODataImpl()).parseUri(oDataPath, null, null, rawServiceRoot).getUriResourceParts(); if (uriResourceParts.size() == 1 && uriResourceParts.get(0).getKind() == UriResourceKind.entitySet) { final UriResourceEntitySet entityUriResource = (UriResourceEntitySet) uriResourceParts.get(0); return entityUriResource; } throw new DeserializerException("Invalid entity binding link", MessageKeys.INVALID_ENTITY_BINDING_LINK, entityId); } catch (final ODataLibraryException e) { throw new DeserializerException("Invalid entity binding link", e, MessageKeys.INVALID_ENTITY_BINDING_LINK, entityId); } } }
public DataRequest parseLink(URI uri) throws UriParserException, UriValidationException { String path = "/"; URI servicePath = URI.create(getODataRequest().getRawBaseUri()); path = servicePath.getPath(); String rawPath = uri.getPath(); int e = rawPath.indexOf(path); if (-1 == e) { rawPath = uri.getPath(); } else { rawPath = rawPath.substring(e+path.length()); } UriInfo reqUriInfo = new Parser(serviceMetadata.getEdm(), odata).parseUri(rawPath, uri.getQuery(), null, getODataRequest().getRawBaseUri()); ServiceDispatcher dispatcher = new ServiceDispatcher(odata, serviceMetadata, null, customContentType); dispatcher.visit(reqUriInfo); dispatcher.request.setUriInfo(reqUriInfo); return (DataRequest)dispatcher.request; } }
public DataRequest parseLink(URI uri) throws UriParserException, UriValidationException { String path = "/"; URI servicePath = URI.create(getODataRequest().getRawBaseUri()); path = servicePath.getPath(); String rawPath = uri.getPath(); int e = rawPath.indexOf(path); if (-1 == e) { rawPath = uri.getPath(); } else { rawPath = rawPath.substring(e+path.length()); } UriInfo reqUriInfo = new Parser(serviceMetadata.getEdm(), odata).parseUri(rawPath, uri.getQuery(), null, getODataRequest().getRawBaseUri()); ServiceDispatcher dispatcher = new ServiceDispatcher(odata, serviceMetadata, null, customContentType); dispatcher.visit(reqUriInfo); dispatcher.request.setUriInfo(reqUriInfo); return (DataRequest)dispatcher.request; } }
public Query parse(String rawPath, String baseUri) throws TeiidException { try { rawPath = rawPath.replace("$root", ""); UriInfo uriInfo = new Parser(serviceMetadata.getEdm(), odata).parseUri(rawPath, null, null, baseUri); ODataSQLBuilder visitor = new ODataSQLBuilder(odata, metadata, prepared, aliasedGroups, baseURI, serviceMetadata) { public void visit(OrderByOption option) { //no implicit ordering now. } }; visitor.nameGenerator = nameGenerator; visitor.visit(uriInfo); return visitor.selectQuery(); } catch (UriParserException e) { throw new TeiidException(e); } catch (UriValidationException e) { throw new TeiidException(e); } } }
@Override public Filter<?> decode(String objectToDecode) throws DecodingException { LOG.debug("Parsing filter: {}", objectToDecode); if (objectToDecode == null || objectToDecode.isEmpty()) { return null; } try { String encode = urlEscaper.escape(checkForGeoFitler(objectToDecode)); // >=4.4.0 UriInfo parseUri = parser.parseUri(PATH, "$filter=" + encode, FRAGMENT, BASE_URI); // >=4.2.0 <4.4.0 // UriInfo parseUri = parser.parseUri(PATH, "$filter=" + encode, // FRAGMENT); // >=4.0.0 <4.2.0 // UriInfo parseUri = parser.parseUri(PATH, "$filter=" + encode, // FRAGMENT, this.edm); return parseUri.getFilterOption().getExpression().accept(new ExpressionGenerator()) .accept(new RenamingVisitor(csdlProvider::mapProperty)).accept(new FilterGenerator()); } catch (ODataException ex) { throw new DecodingException(ex); } }
} else { UriInfo uriInfo = new Parser(this.metadata.getEdm(), odata) .parseUri(path, query, null, odRequest.getRawBaseUri());
public void execute(ODataRequest odRequest, ODataResponse odResponse) { ContentType contentType = ContentType.JSON; try { contentType = ContentNegotiator.doContentNegotiation(null, odRequest, this.customContentSupport, RepresentationType.ERROR); String path = odRequest.getRawODataPath(); String query = odRequest.getRawQueryPath(); if(path.indexOf("$entity") != -1) { executeIdOption(query, odRequest, odResponse); } else { UriInfo uriInfo = new Parser(this.metadata.getEdm(), odata) .parseUri(path, query, null, odRequest.getRawBaseUri()); contentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), odRequest, this.customContentSupport, RepresentationType.ERROR); internalExecute(uriInfo, odRequest, odResponse); } } catch(ODataLibraryException e) { handleException(e, contentType, odRequest, odResponse); } catch(ODataApplicationException e) { handleException(e, contentType, odRequest, odResponse); } }
contextType = resourcePathParser.parseDollarEntityTypeCast(typeCastSegment); contextUriInfo = (UriInfoImpl) new Parser(edm, odata). parseUri("/" + idOptionText, query, fragment, baseUri); contextUriInfo.setEntityTypeCast((EdmEntityType) contextType); } else if (numberOfSegments == 1) { parseUri("/" + idOptionText, query, fragment, baseUri);
contextType = resourcePathParser.parseDollarEntityTypeCast(typeCastSegment); contextUriInfo = (UriInfoImpl) new Parser(edm, odata). parseUri("/" + idOptionText, query, fragment, baseUri); contextUriInfo.setEntityTypeCast((EdmEntityType) contextType); } else if (numberOfSegments == 1) { parseUri("/" + idOptionText, query, fragment, baseUri);
try { uriInfo = new Parser(serviceMetadata.getEdm(), odata) .parseUri(request.getRawODataPath(), request.getRawQueryPath(), null, request.getRawBaseUri()); } catch (final ODataLibraryException e) { debugger.stopRuntimeMeasurement(measurementUriParser);
try { uriInfo = new Parser(serviceMetadata.getEdm(), odata) .parseUri(request.getRawODataPath(), request.getRawQueryPath(), null, request.getRawBaseUri()); } catch (final ODataLibraryException e) { debugger.stopRuntimeMeasurement(measurementUriParser);