本文整理汇总了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;
}
示例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;
}
示例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");
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}