final String containerName = referencedEntityName.substring(0, containerSeparator); referencedEntityName = referencedEntityName.substring(containerSeparator + 1); entityContainer = edm.getEntityContainer(containerName); if (entityContainer == null) { throw new IllegalArgumentException("EDM does not have entity container " + containerName); entityContainer = edm.getDefaultEntityContainer(); if (entityContainer == null) { throw new IllegalArgumentException("EDM does not have a default entity container"
public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
entitymetadata = edm.getDefaultEntityContainer().getEntitySet(getEntityName(entity)); } catch (EdmException e) { throw new ODataException(ODataExceptionType.METADATA_PARSING_FAILED,
public ODataEntry readEntry(String serviceUri, String contentType, String entitySetName, String keyValue, SystemQueryOptions options) throws IllegalStateException, IOException, EdmException, EntityProviderException { EdmEntityContainer entityContainer = readEdm() .getDefaultEntityContainer(); logger.info("Entity container is => " + entityContainer.getName()); String absolutUri = createUri(serviceUri, entitySetName, keyValue, options); InputStream content = executeGet(absolutUri, contentType); return EntityProvider.readEntry(contentType, entityContainer.getEntitySet(entitySetName), content, EntityProviderReadProperties.init().build()); }
final String containerName = referencedEntityName.substring(0, containerSeparator); referencedEntityName = referencedEntityName.substring(containerSeparator + 1); entityContainer = edm.getEntityContainer(containerName); if (entityContainer == null) { throw new IllegalArgumentException("EDM does not have entity container " + containerName); entityContainer = edm.getDefaultEntityContainer(); if (entityContainer == null) { throw new IllegalArgumentException("EDM does not have a default entity container"
private EdmEntitySet getTargetEntitySet(Edm edm, EdmEntitySet srcEtySet, EdmNavigationProperty navigationProp) throws EdmException, ODataException{ //Look for Target EntitySet Type based on Navigation Property --> Association --> AssociationSet EdmAssociationSet associationSet = null; associationSet = edm.getDefaultEntityContainer().getAssociationSet(srcEtySet, navigationProp ); if(associationSet == null){ throw new ODataException( ODataExceptionType.METADATA_PARSING_FAILED, "The association, referred by the navigation property "+ navigationProp.getName() + ", is not contained in an association set."); } EdmAssociationSetEnd end = null; if(navigationProp!= null){ end = associationSet.getEnd(navigationProp.getToRole()) ; return end.getEntitySet() ; } return null; } private String handleNavigation(String completeUrl, EdmEntityType entityType) throws EdmException, ODataException {
public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
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); } }
public ODataFeed readFeed(String serviceUri, String contentType, String entitySetName, SystemQueryOptions options) throws IllegalStateException, IOException, EntityProviderException, EdmException { Edm edm = readEdm(); EdmEntityContainer entityContainer = edm.getDefaultEntityContainer(); String absolutUri = createUri(serviceUri, entitySetName, null, options); InputStream content = executeGet(absolutUri, contentType); return EntityProvider.readFeed(contentType, entityContainer.getEntitySet(entitySetName), content, EntityProviderReadProperties.init().build()); }
public void writeServiceDocument(final Writer writer) throws EntityProviderException { EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
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); } }
public ODataCreateResult getResponseFromLocation(String completeUrl, String destinationName) throws ODataException { HttpResponse httpResponse = null; try { Edm edm = metadataCache.getEdm(completeUrl, getHttpClient(destinationName), destinationRelevantHeaders, errorHandler, cacheMetadata,metadataFilePath,cacheKey,isCacheRefresh); EdmEntitySet eSet = edm.getDefaultEntityContainer().getEntitySet(this.entitySet); HttpGet requestGet = new HttpGet(location); httpResponse = getHttpClient(destinationName).execute(requestGet); ODataConnectivityUtil.checkHttpStatus(httpResponse, errorHandler); EntityStream entityStream = new EntityStream(); entityStream.setContent(httpResponse.getEntity().getContent()); entityStream.setReadProperties(DeserializerProperties.init().build()); String contentType = "application/atom+xml"; if (!httpResponse.getFirstHeader("Content-Type").toString().contains(contentType)) contentType = "application/json"; ODataEntry deepInsResponse = ODataClient.newInstance().createDeserializer(contentType).readEntry(eSet, entityStream); return new ODataCreateResult(httpResponse, deepInsResponse.getProperties()); } catch (IOException e1) { HttpClientUtils.closeQuietly(httpResponse); throw new ODataException(null, "IOException", e1); } catch (EntityProviderException | EdmException e1) { HttpClientUtils.closeQuietly(httpResponse); throw new ODataException(ODataExceptionType.RESPONSE_DESERIALIZATION_FAILED, "Error during serialization of input payload. " + e1.getMessage(), e1); } finally { HttpClientUtils.closeQuietly(httpResponse); } } private boolean isNavigationFlow(){
public static void writeServiceDocument(final Writer writer, final Edm edm) throws EntityProviderException { final EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
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); } }
String keyPredicateString = null; try { entitySet = edm.getDefaultEntityContainer().getEntitySet(entitySetName); if (entitySet == null) throw new ODataException(ODataExceptionType.INVALID_ENTITY_NAME,
/** * @see MetadataProcessor */ @Override public ODataResponse readMetadata(final GetMetadataUriInfo uriInfo, final String contentType) throws ODataException { final EdmServiceMetadata edmServiceMetadata = getContext().getService().getEntityDataModel().getServiceMetadata(); return ODataResponse.status(HttpStatusCodes.OK) .header(ODataHttpHeaders.DATASERVICEVERSION, edmServiceMetadata.getDataServiceVersion()) .entity(edmServiceMetadata.getMetadata()).build(); }
eSet = edm.getDefaultEntityContainer().getEntitySet(entitySetName); if (eSet == null) throw new ODataException(ODataExceptionType.INVALID_ENTITY_NAME,
/** * @see MetadataProcessor */ @Override public ODataResponse readMetadata(final GetMetadataUriInfo uriInfo, final String contentType) throws ODataException { final EdmServiceMetadata edmServiceMetadata = getContext().getService().getEntityDataModel().getServiceMetadata(); return ODataResponse.status(HttpStatusCodes.OK) .header(ODataHttpHeaders.DATASERVICEVERSION, edmServiceMetadata.getDataServiceVersion()) .entity(edmServiceMetadata.getMetadata()).build(); }
String keyPredicateString; try { entitySet = edm.getDefaultEntityContainer().getEntitySet(entitySetName); if (entitySet == null) throw new ODataException(ODataExceptionType.INVALID_ENTITY_NAME, "No entity with name " + entitySetName + " in the OData service", null); entityType = edm.getDefaultEntityContainer().getEntitySet(entitySetName).getEntityType(); keyPredicateString = convertKeyValuesToString(this.keys, entityType); entity = ODataConnectivityUtil.addPropertiesToEntity(this.body, entityType);
/** * @see MetadataProcessor */ @Override public ODataResponse readMetadata(final GetMetadataUriInfo uriInfo, final String contentType) throws ODataException { final EdmServiceMetadata edmServiceMetadata = getContext().getService().getEntityDataModel().getServiceMetadata(); return ODataResponse.status(HttpStatusCodes.OK) .header(ODataHttpHeaders.DATASERVICEVERSION, edmServiceMetadata.getDataServiceVersion()) .entity(edmServiceMetadata.getMetadata()).build(); }