@Override protected UriParser getUriParser(final Edm edm) { return new UriParserImpl(edm); }
@Override public UriInfo parseAll(final List<PathSegment> pathSegments, final Map<String, List<String>> allQueryParameters) throws UriSyntaxException, UriNotMatchingException, EdmException { this.pathSegments = copyPathSegmentList(pathSegments); systemQueryOptions = new HashMap<SystemQueryOption, String>(); otherQueryParameters = new HashMap<String, String>(); uriResult = new UriInfoImpl(); preparePathSegments(); handleResourcePath(); distributeQueryParameters(allQueryParameters); checkSystemQueryOptionsCompatibility(); handleSystemQueryOptions(); handleOtherQueryParameters(); return uriResult; }
private void handleResourcePath() throws UriSyntaxException, UriNotMatchingException, EdmException { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI0); } else { currentPathSegment = pathSegments.remove(0); final String decodedPath = percentDecode(currentPathSegment); if ("$metadata".equals(decodedPath)) { ensureLastSegment(); uriResult.setUriType(UriType.URI8); } else if ("$batch".equals(decodedPath)) { ensureLastSegment(); uriResult.setUriType(UriType.URI9); } else { handleNormalInitialSegment(); } } }
@Override public UriInfo parseUri(Edm edm, List<PathSegment> pathSegments, Map<String, List<String>> queryParameters) throws UriSyntaxException, UriNotMatchingException, EdmException { return new UriParserImpl(edm).parseAll(pathSegments, queryParameters); }
@SuppressWarnings("deprecation") @Override public UriInfo parseUriWithStrictFilter(Edm edm, List<PathSegment> pathSegments, Map<String, String> queryParameters, boolean strictFilter) throws UriSyntaxException, UriNotMatchingException, EdmException { return new UriParserImpl(edm).parse(pathSegments, queryParameters, strictFilter);//NOSONAR }
final String navigationPropertyName = percentDecode(matcher.group(1)); final String keyPredicateName = matcher.group(2); final String emptyParentheses = matcher.group(3); handlePropertyPath((EdmProperty) property); break; addNavigationSegment(keyPredicateName, navigationProperty); checkCount(); if (!uriResult.isCount()) { throw new UriSyntaxException(UriSyntaxException.INVALIDSEGMENT.addContent(currentPathSegment)); handleNavigationPathOptions();
private void handleNavigationPathOptions() throws UriSyntaxException, UriNotMatchingException, EdmException { currentPathSegment = pathSegments.remove(0); final String decodedPath = percentDecode(currentPathSegment); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI16); // Count of multiple entities is handled elsewhere } else if ("$value".equals(decodedPath)) { if (uriResult.getTargetEntitySet().getEntityType().hasStream()) { ensureLastSegment(); uriResult.setUriType(UriType.URI17); uriResult.setValue(true); } else { throw new UriSyntaxException(UriSyntaxException.NOMEDIARESOURCE); } } else if ("$links".equals(decodedPath)) { uriResult.setLinks(true); if (pathSegments.isEmpty()) { throw new UriSyntaxException(UriSyntaxException.MUSTNOTBELASTSEGMENT.addContent(currentPathSegment)); } currentPathSegment = pathSegments.remove(0); handleNavigationProperties(); } else { handleNavigationProperties(); } }
private void handleEntitySet(final EdmEntitySet entitySet, final String keyPredicate) throws UriSyntaxException, UriNotMatchingException, EdmException { final EdmEntityType entityType = entitySet.getEntityType(); uriResult.setTargetType(entityType); uriResult.setTargetEntitySet(entitySet); if (keyPredicate == null) { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI1); } else { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI15); } else { throw new UriSyntaxException(UriSyntaxException.ENTITYSETINSTEADOFENTITY.addContent(entitySet.getName())); } } } else { uriResult.setKeyPredicates(parseKey(keyPredicate, entityType)); if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI2); } else { handleNavigationPathOptions(); } } }
private void handleNormalInitialSegment() throws UriSyntaxException, UriNotMatchingException, EdmException { final Matcher matcher = INITIAL_SEGMENT_PATTERN.matcher(currentPathSegment); if (!matcher.matches()) { throw new UriNotMatchingException(UriNotMatchingException.MATCHPROBLEM.addContent(currentPathSegment)); } final String entityContainerName = percentDecode(matcher.group(1)); final String segmentName = percentDecode(matcher.group(2)); final String keyPredicate = matcher.group(3); final String emptyParentheses = matcher.group(4); final EdmEntityContainer entityContainer = entityContainerName == null ? edm.getDefaultEntityContainer() : edm.getEntityContainer(entityContainerName); if (entityContainer == null) { throw new UriNotMatchingException(UriNotMatchingException.CONTAINERNOTFOUND.addContent(entityContainerName)); } uriResult.setEntityContainer(entityContainer); final EdmEntitySet entitySet = entityContainer.getEntitySet(segmentName); if (entitySet != null) { uriResult.setStartEntitySet(entitySet); handleEntitySet(entitySet, keyPredicate); } else { final EdmFunctionImport functionImport = entityContainer.getFunctionImport(segmentName); if (functionImport == null) { throw new UriNotMatchingException(UriNotMatchingException.NOTFOUND.addContent(segmentName)); } uriResult.setFunctionImport(functionImport); handleFunctionImport(functionImport, emptyParentheses, keyPredicate); } }
} else { currentPathSegment = percentDecode(pathSegments.remove(0)); switch (type.getKind()) { case SIMPLE: if ("$value".equals(percentDecode(currentPathSegment))) { ensureLastSegment(); uriResult.setValue(true); if (uriResult.getPropertyPath().size() == 1) { handlePropertyPath(nextProperty); break;
handleEntitySet(functionImport.getEntitySet(), keyPredicate); return; if (uriResult.getUriType() == UriType.URI14) { currentPathSegment = pathSegments.remove(0); if ("$value".equals(percentDecode(currentPathSegment))) { uriResult.setValue(true); } else { ensureLastSegment();
private void handleNavigationPathOptions() throws UriSyntaxException, UriNotMatchingException, EdmException { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI16); // Count of multiple entities is handled elsewhere } else if ("$value".equals(currentPathSegment)) { if (uriResult.getTargetEntitySet().getEntityType().hasStream()) { ensureLastSegment(); uriResult.setUriType(UriType.URI17); uriResult.setValue(true); } else { throw new UriSyntaxException(UriSyntaxException.NOMEDIARESOURCE); } } else if ("$links".equals(currentPathSegment)) { uriResult.setLinks(true); if (pathSegments.isEmpty()) { throw new UriSyntaxException(UriSyntaxException.MUSTNOTBELASTSEGMENT.addContent(currentPathSegment)); } currentPathSegment = pathSegments.remove(0); handleNavigationProperties(); } else { handleNavigationProperties(); } }
private void handleResourcePath() throws UriSyntaxException, UriNotMatchingException, EdmException { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI0); } else { currentPathSegment = pathSegments.remove(0); if ("$metadata".equals(currentPathSegment)) { ensureLastSegment(); uriResult.setUriType(UriType.URI8); } else if ("$batch".equals(currentPathSegment)) { ensureLastSegment(); uriResult.setUriType(UriType.URI9); } else { handleNormalInitialSegment(); } } }
handleEntitySet(functionImport.getEntitySet(), keyPredicate); return; ensureLastSegment();
private EdmLiteral parseLiteral(final String value, final EdmSimpleType expectedType) throws UriSyntaxException { EdmLiteral literal; try { literal = simpleTypeFacade.parseUriLiteral(value); } catch (EdmLiteralException e) { throw convertEdmLiteralException(e); } if (expectedType.isCompatible(literal.getType())) { return literal; } else { throw new UriSyntaxException(UriSyntaxException.INCOMPATIBLELITERAL.addContent(value, expectedType)); } }
final String navigationPropertyName = percentDecode(matcher.group(1)); final String keyPredicateName = matcher.group(2); final String emptyParentheses = matcher.group(3); handlePropertyPath((EdmProperty) property); break; addNavigationSegment(keyPredicateName, navigationProperty); checkCount(); if (!uriResult.isCount()) { throw new UriSyntaxException(UriSyntaxException.INVALIDSEGMENT.addContent(currentPathSegment)); handleNavigationPathOptions();
private void handleNavigationPathOptions() throws UriSyntaxException, UriNotMatchingException, EdmException { currentPathSegment = pathSegments.remove(0); final String decodedPath = percentDecode(currentPathSegment); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI16); // Count of multiple entities is handled elsewhere } else if ("$value".equals(decodedPath)) { if (uriResult.getTargetEntitySet().getEntityType().hasStream()) { ensureLastSegment(); uriResult.setUriType(UriType.URI17); uriResult.setValue(true); } else { throw new UriSyntaxException(UriSyntaxException.NOMEDIARESOURCE); } } else if ("$links".equals(decodedPath)) { uriResult.setLinks(true); if (pathSegments.isEmpty()) { throw new UriSyntaxException(UriSyntaxException.MUSTNOTBELASTSEGMENT.addContent(currentPathSegment)); } currentPathSegment = pathSegments.remove(0); handleNavigationProperties(); } else { handleNavigationProperties(); } }
private void handleEntitySet(final EdmEntitySet entitySet, final String keyPredicate) throws UriSyntaxException, UriNotMatchingException, EdmException { final EdmEntityType entityType = entitySet.getEntityType(); uriResult.setTargetType(entityType); uriResult.setTargetEntitySet(entitySet); if (keyPredicate == null) { if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI1); } else { currentPathSegment = pathSegments.remove(0); checkCount(); if (uriResult.isCount()) { uriResult.setUriType(UriType.URI15); } else { throw new UriSyntaxException(UriSyntaxException.ENTITYSETINSTEADOFENTITY.addContent(entitySet.getName())); } } } else { uriResult.setKeyPredicates(parseKey(keyPredicate, entityType)); if (pathSegments.isEmpty()) { uriResult.setUriType(UriType.URI2); } else { handleNavigationPathOptions(); } } }
private void handleNormalInitialSegment() throws UriSyntaxException, UriNotMatchingException, EdmException { final Matcher matcher = INITIAL_SEGMENT_PATTERN.matcher(currentPathSegment); if (!matcher.matches()) { throw new UriNotMatchingException(UriNotMatchingException.MATCHPROBLEM.addContent(currentPathSegment)); } final String entityContainerName = percentDecode(matcher.group(1)); final String segmentName = percentDecode(matcher.group(2)); final String keyPredicate = matcher.group(3); final String emptyParentheses = matcher.group(4); final EdmEntityContainer entityContainer = entityContainerName == null ? edm.getDefaultEntityContainer() : edm.getEntityContainer(entityContainerName); if (entityContainer == null) { throw new UriNotMatchingException(UriNotMatchingException.CONTAINERNOTFOUND.addContent(entityContainerName)); } uriResult.setEntityContainer(entityContainer); final EdmEntitySet entitySet = entityContainer.getEntitySet(segmentName); if (entitySet != null) { uriResult.setStartEntitySet(entitySet); handleEntitySet(entitySet, keyPredicate); } else { final EdmFunctionImport functionImport = entityContainer.getFunctionImport(segmentName); if (functionImport == null) { throw new UriNotMatchingException(UriNotMatchingException.NOTFOUND.addContent(segmentName)); } uriResult.setFunctionImport(functionImport); handleFunctionImport(functionImport, emptyParentheses, keyPredicate); } }
} else { currentPathSegment = percentDecode(pathSegments.remove(0)); switch (type.getKind()) { case SIMPLE: if ("$value".equals(percentDecode(currentPathSegment))) { ensureLastSegment(); uriResult.setValue(true); if (uriResult.getPropertyPath().size() == 1) { handlePropertyPath(nextProperty); break;