SAP Cloud SDK (Java) 在 SuccessFactors 元数据加载时抛出命名错误异常

SAP Cloud SDK (Java) throws naming error exception on SuccessFactors metadata load

由于 Cloud SDK 抛出异常,我无法继续。云 SDK 的 EdmNamedImpl class 由于 SF 元数据 属性 名称不正确而引发错误。 SF 实体的 属性 名称是 "goto-url",因此由于 PATTER_VALID_NAME 匹配器不接受字段名称中的连字符。我尝试了很多方法,但无法解决此异常。我想 Cloud SDK 要么应该提供一种方法来抑制名称验证,要么提供一种方法来传递本地元数据文件的路径以执行 FluentHelper 的方法。

我构造查询的方式是:

new DefaultAPISuccessFactorsService().withServicePath("<host>/odata/v2").getAllUser().execute(PASSING_SF_DEST_HERE);

执行时,框架在执行实际查询之前从 SF 读取元数据,但元数据读取失败。请参阅下面的代码片段,其中抛出了异常:

这是 Maven 依赖关系树:

[INFO] +- com.sap.cds:cds-starter-spring-boot-odata:jar:1.3.0:compile
[INFO] |  +- com.sap.cds:cds-framework-spring-boot:jar:1.3.0:runtime
[INFO] |  |  +- com.sap.cds:cds-adapter-api:jar:1.3.0:runtime
[INFO] |  |  +- org.springframework:spring-context:jar:5.2.3.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-expression:jar:5.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:5.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:5.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-jdbc:jar:5.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-web:jar:5.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-webmvc:jar:5.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.2.3.RELEASE:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.3.RELEASE:compile
[INFO] |  +- com.sap.cds:cds-adapter-odata-v4:jar:1.3.0:runtime
[INFO] |  |  +- com.sap.cds:cds4j-multitenant:jar:1.7.0:runtime
[INFO] |  |  \- com.sap.cds.repackaged:odata-v4-lib:jar:1.3.0:runtime
[INFO] |  |     +- javax.servlet:javax.servlet-api:jar:4.0.1:runtime
[INFO] |  |     +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.10.2:runtime
[INFO] |  |     |  +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.10.2:runtime
[INFO] |  |     |  |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:runtime
[INFO] |  |     |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.1:runtime
[INFO] |  |     |  +- org.codehaus.woodstox:stax2-api:jar:4.2:runtime
[INFO] |  |     |  \- com.fasterxml.woodstox:woodstox-core:jar:6.0.3:runtime
[INFO] |  |     \- com.fasterxml:aalto-xml:jar:1.2.1:runtime
[INFO] |  +- org.springframework.boot:spring-boot-starter-web:jar:2.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-json:jar:2.2.3.RELEASE:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.10.2:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.2:compile
[INFO] |  |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.10.2:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.3.RELEASE:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.30:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.30:compile
[INFO] |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.30:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-starter-validation:jar:2.2.3.RELEASE:compile
[INFO] |  |     +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] |  |     \- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile
[INFO] |  |        +- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
[INFO] |  |        \- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter-jdbc:jar:2.2.3.RELEASE:compile
[INFO] |     \- com.zaxxer:HikariCP:jar:3.4.2:compile
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.2.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.2.3.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] |  |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  |  +- org.springframework:spring-core:jar:5.2.3.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-jcl:jar:5.2.3.RELEASE:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.25:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.2.3.RELEASE:compile
[INFO] |  \- org.aspectj:aspectjweaver:jar:1.9.5:compile
[INFO] +- com.sap.cds:cds-feature-cloudfoundry:jar:1.3.0:compile
[INFO] |  +- com.sap.cds:cds-feature-api:jar:1.3.0:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.2:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] +- com.sap.cds:cds-services-api:jar:1.3.0:compile
[INFO] |  \- com.sap.cds:cds4j-api:jar:1.7.0:compile
[INFO] +- com.sap.cds:cds-services-impl:jar:1.3.0:runtime
[INFO] |  +- com.sap.cds:cds-services-utils:jar:1.3.0:runtime
[INFO] |  +- com.sap.cds:cds4j-runtime:jar:1.7.0:compile
[INFO] |  |  \- com.jayway.jsonpath:json-path:jar:2.4.0:compile
[INFO] |  |     \- net.minidev:json-smart:jar:2.3:compile
[INFO] |  |        \- net.minidev:accessors-smart:jar:1.2:compile
[INFO] |  |           \- org.ow2.asm:asm:jar:5.0.4:compile
[INFO] |  \- com.sap.cds:cds4j-tx:jar:1.7.0:runtime
[INFO] +- com.sap.cds:cds-feature-xsuaa:jar:1.3.0:compile
[INFO] +- com.sap.cloud.security.xsuaa:xsuaa-spring-boot-starter:jar:2.6.2:compile
[INFO] |  +- com.sap.cloud.security.xsuaa:spring-xsuaa:jar:2.6.2:compile
[INFO] |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.12.1:compile
[INFO] |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.12.1:compile
[INFO] |  |  +- com.sap.cloud.security.xsuaa:api:jar:2.6.2:compile
[INFO] |  |  +- com.sap.cloud.security.xsuaa:token-client:jar:2.6.2:compile
[INFO] |  |  +- com.github.ben-manes.caffeine:caffeine:jar:2.8.0:compile
[INFO] |  |  |  \- org.checkerframework:checker-qual:jar:2.10.0:compile
[INFO] |  |  \- commons-io:commons-io:jar:2.6:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-security:jar:2.2.3.RELEASE:compile
[INFO] |  |  +- org.springframework.security:spring-security-config:jar:5.2.1.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-web:jar:5.2.1.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-oauth2-jose:jar:5.2.1.RELEASE:compile
[INFO] |  |  +- com.nimbusds:nimbus-jose-jwt:jar:7.8:compile
[INFO] |  |  |  \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] |  |  +- org.springframework.security:spring-security-core:jar:5.2.1.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-oauth2-core:jar:5.2.1.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-oauth2-resource-server:jar:5.2.1.RELEASE:compile
[INFO] +- com.sap.cds:cds-feature-hana:jar:1.3.0:compile
[INFO] |  \- com.sap.cloud.db.jdbc:ngdbc:jar:2.4.67:compile
[INFO] +- org.xerial:sqlite-jdbc:jar:3.28.0:compile
[INFO] +- com.sap.cloud.sdk.cloudplatform:scp-cf:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:auditlog-scp-cf:jar:3.21.0:compile
[INFO] |  |  \- com.sap.cloud.sdk.cloudplatform:auditlog:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:caching:jar:3.21.0:compile
[INFO] |  |  +- com.sap.cloud.sdk.cloudplatform:security:jar:3.21.0:compile
[INFO] |  |  \- com.sap.cloud.sdk.cloudplatform:tenant:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core-scp-cf:jar:3.21.0:compile
[INFO] |  |  \- com.auth0:java-jwt:jar:3.10.3:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp-cf:jar:3.21.0:compile
[INFO] |  |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp:jar:3.21.0:compile
[INFO] |  |  +- com.sap.cloud.sdk.cloudplatform:resilience:jar:3.21.0:compile
[INFO] |  |  \- com.sap.cloud.sdk.frameworks:resilience4j:jar:3.21.0:runtime
[INFO] |  |     +- io.github.resilience4j:resilience4j-circuitbreaker:jar:1.4.0:runtime
[INFO] |  |     |  \- io.github.resilience4j:resilience4j-core:jar:1.4.0:runtime
[INFO] |  |     +- io.github.resilience4j:resilience4j-bulkhead:jar:1.4.0:runtime
[INFO] |  |     +- io.github.resilience4j:resilience4j-timelimiter:jar:1.4.0:runtime
[INFO] |  |     +- io.github.resilience4j:resilience4j-cache:jar:1.4.0:runtime
[INFO] |  |     |  \- javax.cache:cache-api:jar:1.1.1:runtime
[INFO] |  |     \- io.github.resilience4j:resilience4j-retry:jar:1.4.0:runtime
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:security-scp-cf:jar:3.21.0:compile
[INFO] |  |  +- com.sap.cloud.security:java-security:jar:2.6.2:compile
[INFO] |  |  \- com.sap.cloud.security:java-api:jar:2.6.2:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:servlet:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:tenant-scp-cf:jar:3.21.0:compile
[INFO] |  \- com.sap.cloud.sdk.cloudplatform:metering:jar:3.21.0:compile
[INFO] +- com.sap.cloud.sdk.datamodel:odata-core:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.sdk.datamodel:odata-client:jar:3.21.0:compile
[INFO] |  |  \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:3.21.0:compile
[INFO] |  |  \- com.sap.cloud.sdk.quality:common:jar:3.21.0:compile
[INFO] |  |     \- org.apache.commons:commons-csv:jar:1.8:compile
[INFO] |  +- com.sap.cloud.sdk.datamodel:fluent-result:jar:3.21.0:compile
[INFO] |  +- com.sap.cloud.servicesdk:odatav2-connectivity-sdk3:jar:1.39.0:compile
[INFO] |  |  +- com.sap.cloud.servicesdk:jacksonutil-sdk3:jar:1.39.0:compile
[INFO] |  |  +- org.json:json:jar:20190722:compile
[INFO] |  |  \- com.sap.cloud.servicesdk.prov:api:jar:1.39.0:compile
[INFO] |  |     +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] |  |     \- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] |  |        \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] |  +- com.sap.cloud.servicesdk:odata-v2-lib:jar:1.39.0:compile
[INFO] |  |  \- com.sap.cloud.servicesdk:developer_license:jar:1.39.0:compile
[INFO] |  +- org.slf4j:jcl-over-slf4j:jar:1.7.30:runtime
[INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  +- com.google.guava:guava:jar:29.0-jre:compile
[INFO] |  |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  |  \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] |  +- org.jsoup:jsoup:jar:1.13.1:compile
[INFO] |  +- org.apache.commons:commons-text:jar:1.8:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.8.6:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.10.2:compile
[INFO] |  +- com.mikesamuel:json-sanitizer:jar:1.2.0:compile
[INFO] |  +- joda-time:joda-time:jar:2.10.5:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.13:compile
[INFO] |  +- io.vavr:vavr:jar:0.10.2:compile
[INFO] |  |  \- io.vavr:vavr-match:jar:0.10.2:compile
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] |  \- com.sap.cloud.sdk.quality:odata-querylistener:jar:3.21.0:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.10:provided
[INFO] +- javax.inject:javax.inject:jar:1:provided
[INFO] +- org.modelmapper:modelmapper:jar:2.3.7:compile
[INFO] \- org.springframework.boot:spring-boot-starter-cache:jar:2.2.3.RELEASE:compile
[INFO]    \- org.springframework:spring-context-support:jar:5.2.3.RELEASE:compile
[INFO] ------------------------------------------------------------------------

不幸的是,我目前看不到解决这个问题的简单方法。 SDK 本身在内部使用另一个库来执行 OData 2.0 请求。图书馆执行元数据请求并在发出实际请求之前对其进行处理。

但是,如 this answer 中所述,连字符在实体标识符中是不合法的。所以这在 SuccessFactors 方面更像是一个问题。

编辑:

有一个测试版 API 不依赖于元数据请求,但需要您手动 assemble 请求:

ODataRequestRead request =
            new ODataRequestRead("<host>/odata/v2", "Users", "", ODataProtocol.V2);
HttpClient client = HttpClientAccessor.getHttpClient(destination);

ODataRequestResult result = request.execute(client);
List<User> users = result.asList(User.class);

但是 API 是完全测试版,需要手动操作并且不支持某些功能。例如。此处未从响应中提取 ETag。所以我建议只有当你真的需要它工作并且可以接受功能差距和不稳定时才使用它 API.