当前位置: 首页>>代码示例>>Java>>正文


Java EntityProvider.readMetadata方法代码示例

本文整理汇总了Java中org.apache.olingo.odata2.api.ep.EntityProvider.readMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java EntityProvider.readMetadata方法的具体用法?Java EntityProvider.readMetadata怎么用?Java EntityProvider.readMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.odata2.api.ep.EntityProvider的用法示例。


在下文中一共展示了EntityProvider.readMetadata方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readEdm

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
private Edm readEdm() throws EntityProviderException,
		IllegalStateException, IOException {

	// This is used for both setting the Edm and CSRF Token :)
	if (m_edm != null) {
		return m_edm;
	}

	String serviceUrl = new StringBuilder(getODataServiceUrl())
			.append(SEPARATOR).append(METADATA).toString();

	logger.info("Metadata url => " + serviceUrl);

	final HttpGet get = new HttpGet(serviceUrl);
	get.setHeader(AUTHORIZATION_HEADER, getAuthorizationHeader());
	get.setHeader(CSRF_TOKEN_HEADER, CSRF_TOKEN_FETCH);

	HttpResponse response = getHttpClient().execute(get);

	m_csrfToken = response.getFirstHeader(CSRF_TOKEN_HEADER).getValue();
	logger.info("CSRF token => " + m_csrfToken);

	m_edm = EntityProvider.readMetadata(response.getEntity().getContent(),
			false);
	return m_edm;
}
 
开发者ID:SAP,项目名称:C4CODATAAPIDEVGUIDE,代码行数:27,代码来源:ServiceTicketODataConsumer.java

示例2: readEdm

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
private Edm readEdm() throws EntityProviderException,
		IllegalStateException, IOException {

	// This is used for both setting the Edm and CSRF Token :)
	if (m_edm != null) {
		return m_edm;
	}

	String serviceUrl = new StringBuilder(getODataServiceURL())
			.append(SEPARATOR).append(METADATA).toString();

	logger.info("Metadata url => " + serviceUrl);

	final HttpGet get = new HttpGet(serviceUrl);
	get.setHeader(AUTHORIZATION_HEADER, getAuthorizationHeader());
	get.setHeader(CSRF_TOKEN_HEADER, CSRF_TOKEN_FETCH);

	HttpResponse response = getHttpClient().execute(get);
	if(response.getStatusLine().getStatusCode() != 200) {
		logger.severe(response.getStatusLine().toString());
	}

	m_csrfToken = response.getFirstHeader(CSRF_TOKEN_HEADER).getValue();
	logger.info("CSRF token => " + m_csrfToken);

	m_edm = EntityProvider.readMetadata(response.getEntity().getContent(),
			false);
	return m_edm;
}
 
开发者ID:SAP,项目名称:C4CODATAAPIDEVGUIDE,代码行数:30,代码来源:AccountAttachmentODataConsumer.java

示例3: setup

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
  InputStream metadataStream =
      ODataFilterExpressionParserTest.class.getClassLoader().getResourceAsStream("metadata.xml");
  try {
    edm = EntityProvider.readMetadata(metadataStream, true);
  } catch (EntityProviderException e) {
    fail("Not expected");
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:11,代码来源:ODataFilterExpressionParserTest.java

示例4: edmxReferences

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Test
public void edmxReferences() throws Exception {
  DataServices serviceMetadata = new DataServices();
  List<AnnotationElement> annoElements = new ArrayList<AnnotationElement>();
  annoElements.add(createElementWithoutInclude());
  annoElements.add(createElementWithInclude());
  serviceMetadata.setAnnotationElements(annoElements);
  serviceMetadata.setDataServiceVersion(ODataServiceVersion.V20);
  ODataResponse response = EntityProvider.writeMetadata(serviceMetadata, null);

  EntityProvider.readMetadata(response.getEntityAsStream(), false);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:13,代码来源:XmlMetadataConsumerTest.java

示例5: createEdm

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
private Edm createEdm() throws Exception {
  EdmProvider testProvider = new EdmTestProvider();
  ODataResponse response = EntityProvider.writeMetadata(testProvider.getSchemas(), null);
  InputStream in = (InputStream) response.getEntity();
  return EntityProvider.readMetadata(in, true);

}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:8,代码来源:EdmxProviderTest.java

示例6: readEdm

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
private Edm readEdm(String serviceUrl) throws IOException, ODataException {
	InputStream content = execute(serviceUrl + SEPARATOR + METADATA, APPLICATION_XML, GET);
	return EntityProvider.readMetadata(content, false);
}
 
开发者ID:sapmentors,项目名称:lemonaid,代码行数:5,代码来源:GenericODataClient.java

示例7: ODataClient

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
/**
 * Creates an OdataClient for the given service
 * and credentials (HTTP Basic authentication).
 * 
 * @param url an URL to an OData service, 
 *    does not have to be the root service URL.
 *    this parameter must follow this syntax :
 *    {@code odata://hostname:port/path/...}
 * @param username Username
 * @param password Password
 * 
 * @throws URISyntaxException when the {@code url} parameter is invalid.
 * @throws IOException when the OdataClient fails to contact the server 
 *    at {@code url}.
 * @throws ODataException when no OData service have been found at the 
 *    given url.
 */
public ODataClient(String url, String username, String password)
   throws URISyntaxException, IOException, ODataException
{
   this.username = username;
   this.password = password;
   
   // Find the service root URL and retrieve the Entity Data Model (EDM).
   URI uri = new URI (url);
   String metadata = "/$metadata";
   
   URI svc = null;
   Edm edm = null;
   
   String[] pathSegments = uri.getPath().split("/");
   StringBuilder sb = new StringBuilder();
   
   // for each possible service root URL.
   for (int i = 1; i < pathSegments.length; i++)
   {
      sb.append ('/').append (pathSegments[i]).append (metadata);
      svc = new URI (uri.getScheme (), uri.getAuthority (),
         sb.toString (), null, null);
      sb.delete (sb.length () - metadata.length (), sb.length ());
      
      // Test if `svc` is the service root URL.
      try
      {
         InputStream content = execute (svc.toString (),
            ContentType.APPLICATION_XML, "GET");
         
         edm = EntityProvider.readMetadata(content, false);
         svc = new URI (uri.getScheme (), uri.getAuthority (),
            sb.toString (), null, null);
         
         break;
      }
      catch (InterruptedException ex)
      {
         break;
      }
      catch (HttpException | EntityProviderException e)
      {
         LOGGER.debug ("URL not root "+svc, e);
      }
   }
   
   // no OData service have been found at the given URL.
   if (svc == null || edm == null)
      throw new ODataException ("No service found at "+url);
   
   this.serviceRoot = svc;
   this.serviceEDM  = edm;
   this.uriParser = RuntimeDelegate.getUriParser (edm);
}
 
开发者ID:SentinelDataHub,项目名称:DataHubSystem,代码行数:72,代码来源:ODataClient.java

示例8: loadEdm

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@BeforeClass
public static void loadEdm() throws EntityProviderException {
  edm = EntityProvider.readMetadata(JPALinkTest.class.getClassLoader().getResourceAsStream(
      "metadata.xml"), false);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:6,代码来源:JPALinkTest.java

示例9: getEdmInternal

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
private Edm getEdmInternal() throws IOException, ODataException, HttpException {
  HttpURLConnection connection = connect(METADATA, null, APPLICATION_XML, "GET");
  edm = EntityProvider.readMetadata((InputStream) connection.getContent(), false);
  return edm;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:6,代码来源:Client.java


注:本文中的org.apache.olingo.odata2.api.ep.EntityProvider.readMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。