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


Java ODataVersion类代码示例

本文整理汇总了Java中org.odata4j.core.ODataVersion的典型用法代码示例。如果您正苦于以下问题:Java ODataVersion类的具体用法?Java ODataVersion怎么用?Java ODataVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createOEntityFromRequest

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * リクエストボディReaderからOEntityを生成する.
 * @param keyPropNames エンティティキーを作成するためのプロパティの名前のリスト
 * @param reader リクエストボディ
 * @return OEntity
 */
private OEntity createOEntityFromRequest(List<String> keyPropNames,
        EdmDataServices metadata,
        Reader reader,
        String entitySetNameParam) {
    OEntityKey keyDummy = null;

    if (keyPropNames.size() == 1) {
        // single-unnamed value
        keyDummy = OEntityKey.create("");
    }
    // TODO multiple-named valueの実装

    OEntity entity = null;

    // ODataVersion.V2だと、おそらくバグのためJSONパースが動かないため、強制的にV1としてリクエストをパースする。
    entity = convertFromString(reader, MediaType.APPLICATION_JSON_TYPE, ODataVersion.V1, metadata,
            entitySetNameParam, keyDummy);

    return entity;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:27,代码来源:AbstractODataResource.java

示例2: getPostResponseBuilder

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * POST用のレスポンスビルダーを作成する.
 * @param ent OEntity
 * @param outputFormat Content-Type
 * @param responseStr レスポンスボディ
 * @param resUriInfo レスポンスのUriInfo
 * @param key レスポンスのエンティティキー
 * @return レスポンスビルダー
 */
protected ResponseBuilder getPostResponseBuilder(
        OEntity ent,
        MediaType outputFormat,
        String responseStr,
        UriInfo resUriInfo,
        String key) {
    ResponseBuilder rb = Response.status(HttpStatus.SC_CREATED).entity(responseStr).type(outputFormat)
            .header(HttpHeaders.LOCATION, resUriInfo.getBaseUri().toASCIIString()
                    + getEntitySetName() + key)
            .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);

    // 応答にETAGを付与
    if (ent instanceof OEntityWrapper) {
        OEntityWrapper oew2 = (OEntityWrapper) ent;
        String etag = oew2.getEtag();
        if (etag != null) {
            rb = rb.header(HttpHeaders.ETAG, "W/\"" + etag + "\"");
        }
    }
    return rb;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:31,代码来源:AbstractODataResource.java

示例3:

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * BoxNameを省略してRoleを削除した場合データが削除できること.
 */
@Test
public void BoxNameを省略してRoleを削除した場合データが削除できること() {
    try {
        CellCtlUtils.createRole(cellName, testRoleName);
    } finally {
        TResponse res = Http.request("role-delete-without-delete.txt")
                .with("token", AbstractCase.MASTER_TOKEN_NAME)
                .with("cellPath", cellName)
                .with("rolename", testRoleName)
                .returns()
                .statusCode(HttpStatus.SC_NO_CONTENT);

        // レスポンスヘッダーのチェック
        // DataServiceVersion
        res.checkHeader(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:21,代码来源:RoleDeleteTest.java

示例4: deleteExtRole

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * 指定されたボックス名にリンクされたExtRole情報を削除する.
 * @param relationName リレーション名
 * @param relationBoxName リレーションボックス名
 */
private void deleteExtRole(
        String relationName,
        String relationBoxName) {
    TResponse res = Http.request("cell/extRole/extRole-delete.txt")
            .with("token", AbstractCase.MASTER_TOKEN_NAME)
            .with("cellPath", cellName)
            .with("extRoleName", PersoniumCoreUtils.encodeUrlComp(testExtRoleName))
            .with("relationName", relationName)
            .with("relationBoxName", relationBoxName)
            .returns()
            .statusCode(HttpStatus.SC_NO_CONTENT);

    // レスポンスヘッダーのチェック
    // DataServiceVersion
    res.checkHeader(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:22,代码来源:ExtRoleDeleteTest.java

示例5:

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * BoxNameを省略してRelationを削除した場合データが削除できること.
 */
@Test
public void BoxNameを省略してRelationを削除した場合データが削除できること() {
    try {
        CellCtlUtils.createRelation(cellName, testRelationName);
    } finally {
        TResponse res = Http.request("relation-delete-without-boxname.txt")
                .with("token", AbstractCase.MASTER_TOKEN_NAME)
                .with("cellPath", cellName)
                .with("relationname", testRelationName)
                .returns()
                .statusCode(HttpStatus.SC_NO_CONTENT);

        // レスポンスヘッダーのチェック
        // DataServiceVersion
        res.checkHeader(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:21,代码来源:RelationDeleteTest.java

示例6: createAssociationEnd

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * AssociationEndの削除のテスト.
 */
@Test
public final void AssociationEndの削除のテスト() {
    // AssociationEnd作成
    createAssociationEnd();

    // AssociationEndの削除
    TResponse res = Http.request("box/odatacol/schema/assocend/delete.txt")
            .with("cell", "testcell1")
            .with("box", "box1")
            .with("collection", "setodata")
            .with("token", PersoniumUnitConfig.getMasterToken())
            .with("name", ASSOCIATION_END_NAME)
            .with("entityTypeName", ENTITY_TYPE_NAME)
            .with("ifMatch", "*")
            .returns()
            .statusCode(HttpStatus.SC_NO_CONTENT)
            .debug();

    // レスポンスヘッダーのチェック
    // DataServiceVersion
    res.checkHeader(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:26,代码来源:AssociationEndDeleteTest.java

示例7: getRequestEntity

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
protected OEntity getRequestEntity(HttpHeaders httpHeaders, UriInfo uriInfo, InputStream payload, EdmDataServices metadata, String entitySetName, OEntityKey entityKey) throws UnsupportedEncodingException {
  // TODO validation of MaxDataServiceVersion against DataServiceVersion
  // see spec [ms-odata] section 1.7

  ODataVersion version = InternalUtil.getDataServiceVersion(httpHeaders.getRequestHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));
  FormatParser<Entry> parser = FormatParserFactory.getParser(Entry.class, httpHeaders.getMediaType(),
      new Settings(version, metadata, entitySetName, entityKey, null, false));

  String charset = httpHeaders.getMediaType().getParameters().get("charset");
  if (charset == null) {
    charset = ODataConstants.Charsets.Upper.ISO_8859_1; // from HTTP 1.1
  }

  Entry entry = parser.parse(new BufferedReader(
      new InputStreamReader(payload, charset)));

  return entry.getEntity();
}
 
开发者ID:teiid,项目名称:oreva,代码行数:19,代码来源:BaseResource.java

示例8: getResult

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
private Object getResult(ODataVersion version, Reader reader, FormatType formatType) {
  if (function.getReturnType() == null) {
   return null;
  }

    FormatParser<? extends OObject> parser = FormatParserFactory.getParser(
        function.getReturnType().isSimple() ? OSimpleObject.class : EdmType.getInstanceType(function.getReturnType()),
        getClient().getFormatType(),
        new Settings(version, 
            getMetadata(), 
            function.getEntitySet() != null ? function.getEntitySet().getName() : null, 
            null, // entitykey
            null, // fcMapping
            true, // isResponse 
            function.getReturnType(), 
            function)
        );
		  
  OObject object = parser.parse(reader);

  return object;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:23,代码来源:ConsumerFunctionCallRequest.java

示例9: parseLinks

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * Parses the links.
 *
 * @param reader the reader
 * @return the iterable 
 */
@SuppressWarnings("unchecked")
public static Iterable<SingleLink> parseLinks(Reader reader) {
  EdmProperty.Builder ctPropBuilder = EdmProperty.newBuilder("url").setType(EdmSimpleType.STRING);
  List<EdmProperty.Builder> complexTypeBuilder = new ArrayList<EdmProperty.Builder>();
  complexTypeBuilder.add(ctPropBuilder);

  EdmComplexType.Builder ctBuilder = new EdmComplexType.Builder().addProperties(complexTypeBuilder).setName("urlLinks");
  EdmComplexType uriCtType = ctBuilder.build();
  Settings s = new Settings(ODataVersion.V3, null, null, null, null, true, new EdmCollectionType(CollectionKind.Collection, uriCtType));
  JsonLiteCollectionFormatParser jsonLiteCollectionFormatParser = new JsonLiteCollectionFormatParser(s);
  OCollection<OComplexObject> linkCollection = (OCollection<OComplexObject>)jsonLiteCollectionFormatParser.parse(reader);

  List<SingleLink> rt = new ArrayList<SingleLink>();
  for (OComplexObject obj : linkCollection) {
    rt.add(SingleLinks.create(obj.getProperty("url", String.class).getValue()));
  }

  return rt;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:26,代码来源:JsonLiteSingleLinkFormatParser.java

示例10: parseFunctionFeed

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * Function parsing will be handled in separate story. 
 *
 * @param reader the reader
 * @return the o collection<? extends o object>
 */
protected OCollection<? extends OObject> parseFunctionFeed(Reader reader) {
  EdmEntitySet entitySet = this.metadata.getEdmEntitySet((EdmEntityType) returnType.getItemType());

  Settings settings = new Settings(
      // someone really needs to spend some time on service version negotiation....
      ODataVersion.V3,
      this.metadata,
      entitySet.getName(),
      this.entityKey,
      null, // feed customization mapping
      this.isResponse,
      this.returnType.getItemType());

  JsonLiteFeedFormatParser parser = new JsonLiteFeedFormatParser(settings);
  JsonFeed feed = parser.parse(reader);
  OCollection.Builder<OObject> c = newCollectionBuilder();
  for (Entry e : feed.getEntries()) {
    c.add(e.getEntity());
  }
  return c.build();

  //return null;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:30,代码来源:JsonLiteCollectionFormatParser.java

示例11: parseLinks

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
public static Iterable<SingleLink> parseLinks(Reader reader) {
  EdmProperty.Builder ctPropBuilder = EdmProperty.newBuilder("uri").setType(EdmSimpleType.STRING);
  List<EdmProperty.Builder> complexTypeBuilder = new ArrayList<EdmProperty.Builder>();
  complexTypeBuilder.add(ctPropBuilder);

  EdmComplexType.Builder ctBuilder = new EdmComplexType.Builder().addProperties(complexTypeBuilder).setName("uriLinks");
  EdmComplexType uriCtType = ctBuilder.build();
  Settings s = new Settings(ODataVersion.V2, null, null, null, null, true, new EdmCollectionType(CollectionKind.Collection, uriCtType));
  OCollection<OComplexObject> linkCollection = (OCollection<OComplexObject>) new JsonCollectionFormatParser(s).parse(reader);

  List<SingleLink> rt = new ArrayList<SingleLink>();
  for (OComplexObject obj : linkCollection) {
    rt.add(SingleLinks.create(obj.getProperty("uri", String.class).getValue()));
  }

  return rt;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:18,代码来源:JsonSingleLinkFormatParser.java

示例12: parseFunctionFeed

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
protected OCollection<? extends OObject> parseFunctionFeed(Reader reader) {

    // entitySetName is a function
    // this really reveals a fundamental flaw in the parsers being driven by EdmEntitySets
    // instead of EdmEntityTypes.

    EdmEntitySet entitySet = this.metadata.getEdmEntitySet((EdmEntityType) returnType.getItemType());

    Settings settings = new Settings(
        // someone really needs to spend some time on service version negotiation....
        ODataVersion.V2,
        this.metadata,
        entitySet.getName(),
        this.entityKey,
        null, // feed customization mapping
        this.isResponse,
        this.returnType.getItemType());

    JsonFeedFormatParser parser = new JsonFeedFormatParser(settings);
    JsonFeed feed = parser.parse(reader);
    OCollection.Builder<OObject> c = newCollectionBuilder();
    for (Entry e : feed.getEntries()) {
      c.add(e.getEntity());
    }
    return c.build();
  }
 
开发者ID:teiid,项目名称:oreva,代码行数:27,代码来源:JsonCollectionFormatParser.java

示例13: createDataServices

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
private static EdmDataServices.Builder createDataServices(final String edmNs,
        final EdmEntityType.Builder[] typeList,
        final EdmAssociation.Builder[] assocs,
        final EdmComplexType.Builder[] complexList) {
    // EntitySet の Map
    Map<String, EdmEntitySet.Builder> setMap = new HashMap<String, EdmEntitySet.Builder>();
    for (EdmEntityType.Builder type : typeList) {
        setMap.put(type.getName(), type2set(type));
    }

    // AssociationSetは機械的に定義
    EdmAssociationSet.Builder[] assocSets = assoc2set(setMap, assocs);

    // EntityContainerは機械的に定義
    EdmEntityContainer.Builder ec = EdmEntityContainer.newBuilder()
            .setName(edmNs).setIsDefault(true)
            .addEntitySets(Enumerable.create(setMap.values()).toList())
            .addAssociationSets(Enumerable.create(assocSets).toList());

    // Schemaは機械的に定義
    EdmSchema.Builder schema = EdmSchema.newBuilder().addEntityTypes(Enumerable.create(typeList).toList())
            .addAssociations(Enumerable.create(assocs).toList()).setNamespace(edmNs).addEntityContainers(ec);
    if (complexList != null) {
        schema.addComplexTypes(Enumerable.create(complexList).toList());
    }

    EdmDataServices.Builder ret = EdmDataServices.newBuilder()
            .addNamespaces(Enumerable.create(Common.P_NAMESPACE).toList())
            .addSchemas(schema).setVersion(ODataVersion.V2);
    return ret;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:32,代码来源:CtlSchema.java

示例14: changeMessageStatus

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * 受信メッセージステータスを変更する.
 * @param reader リクエストボディ
 * @param key メッセージId
 * @return response情報
 */
protected Response changeMessageStatus(Reader reader, String key) {

    JSONObject body;
    body = ResourceUtils.parseBodyAsJSON(reader);

    String status = (String) body.get(ReceivedMessage.MESSAGE_COMMAND);
    // ステータスのチェック
    if (!ReceivedMessage.STATUS_UNREAD.equals(status)
            && !ReceivedMessage.STATUS_READ.equals(status)
            && !ReceivedMessage.STATUS_APPROVED.equals(status)
            && !ReceivedMessage.STATUS_REJECTED.equals(status)) {
        throw PersoniumCoreException.OData.REQUEST_FIELD_FORMAT_ERROR.params(ReceivedMessage.MESSAGE_COMMAND);
    }

    // EdmEntitySetの取得
    EdmEntitySet edmEntitySet = getOdataProducer().getMetadata()
            .getEdmEntitySet(ReceivedMessagePort.EDM_TYPE_NAME);

    // OEntityKeyの作成
    OEntityKey oEntityKey;
    try {
        oEntityKey = OEntityKey.parse("('" + key + "')");
    } catch (IllegalArgumentException e) {
        throw PersoniumCoreException.OData.ENTITY_KEY_PARSE_ERROR.reason(e);
    }

    // ステータス更新、及び関係登録/削除をProducerに依頼
    String etag = ((CellCtlODataProducer) getOdataProducer()).changeStatusAndUpdateRelation(
            edmEntitySet, oEntityKey, status);

    return Response.noContent()
            .header(HttpHeaders.ETAG, ODataResource.renderEtagHeader(etag))
            .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString)
            .build();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:42,代码来源:MessageODataResource.java

示例15: mypass

import org.odata4j.core.ODataVersion; //导入依赖的package包/类
/**
 * パスワードの変更をする.
 * @return ODataEntityResourceクラスのオブジェクト
 */
@WriteAPI
@PUT
public Response mypass() {
    // アクセス制御
    this.accessContext.checkMyLocalToken(cell, this.davRsCmp.getAcceptableAuthScheme());
    // セルローカルトークンからパスワード変更するAccount名を取得する
    this.key = this.accessContext.getSubject();
    String[] keyName;
    keyName = this.key.split("#");
    this.keyString = "('" + keyName[1] + "')";

    try {
        this.oEntityKey = OEntityKey.parse(this.keyString);
    } catch (IllegalArgumentException e) {
        throw PersoniumCoreException.OData.ENTITY_KEY_PARSE_ERROR.reason(e);
    }

    // Accountのスキーマ情報を取得する
    PersoniumODataProducer producer = ModelFactory.ODataCtl.cellCtl(accessContext.getCell());
    EdmEntitySet esetAccount = producer.getMetadata().getEdmEntitySet(Account.EDM_TYPE_NAME);

    // パスワードの変更をProducerに依頼
    producer.updatePassword(esetAccount, this.oEntityKey, this.pCredHeader);

    // レスポンス返却
    return Response.noContent()
            .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString)
            .build();
}
 
开发者ID:personium,项目名称:personium-core,代码行数:34,代码来源:PasswordResource.java


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