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; } }
/** * Creates a new {@code ODataFesParser}. */ public ODataFesParser() { this.urlEscaper = new PercentEscaper("-_.*", false); this.odata = new ODataImpl(); this.csdlProvider = new ObservationCsdlEdmProvider(); this.edm = new EdmProviderImpl(this.csdlProvider); // >=4.2.0 this.parser = new Parser(this.edm, this.odata); // >=4.0.0 <4.2.0 // this.parser = new Parser(); }
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); } } }
executeIdOption(query, odRequest, odResponse); } 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); } }
ensureLastSegment(typeCastSegment, 2, numberOfSegments); contextType = resourcePathParser.parseDollarEntityTypeCast(typeCastSegment); contextUriInfo = (UriInfoImpl) new Parser(edm, odata). parseUri("/" + idOptionText, query, fragment, baseUri); contextUriInfo.setEntityTypeCast((EdmEntityType) contextType); contextUriInfo = (UriInfoImpl) new Parser(edm, odata). parseUri("/" + idOptionText, query, fragment, baseUri);
ensureLastSegment(typeCastSegment, 2, numberOfSegments); contextType = resourcePathParser.parseDollarEntityTypeCast(typeCastSegment); contextUriInfo = (UriInfoImpl) new Parser(edm, odata). parseUri("/" + idOptionText, query, fragment, baseUri); contextUriInfo.setEntityTypeCast((EdmEntityType) contextType); contextUriInfo = (UriInfoImpl) new Parser(edm, odata). parseUri("/" + idOptionText, query, fragment, baseUri);
uriInfo = new Parser(serviceMetadata.getEdm(), odata) .parseUri(request.getRawODataPath(), request.getRawQueryPath(), null, request.getRawBaseUri()); } catch (final ODataLibraryException e) {
uriInfo = new Parser(serviceMetadata.getEdm(), odata) .parseUri(request.getRawODataPath(), request.getRawQueryPath(), null, request.getRawBaseUri()); } catch (final ODataLibraryException e) {