我一直在构建一个客户端来替换我们拥有的连接社交网站上的一些内容。我按照 Github repo 中的示例代码编写了一个 java 客户端:https ://github.com/OpenNTF/SocialSDK/tree/master/sdk/com.ibm.sbt.core.test/src/test/java/ com/ibm/sbt/services/客户端/连接/文件
并且还使用本教程作为参考来创建端点,然后将其传递给不同的服务。 http://bastide.org/2014/01/28/how-to-develop-a-simple-java-integration-with-the-ibm-social-business-toolkit-sdk/
需要明确的是,我在社区上发布内容,所以我使用 CommunityService 上传内容和 FileService 来更新社区文件。
此方法工作正常: fileservice.updateCommunityFile(iStream, fileId, title, communityLibraryId, params) 这在服务器上创建了多个版本,这不是我想要的。
但是,我想使用这个 - fileservice.updateFile(inputStream, file, params) 如果我在我的代码中使用上面的一个,它会导致以下错误:
Error updating the file
com.ibm.sbt.services.client.connections.files.FileServiceException: Error updating the file
at com.ibm.sbt.services.client.connections.files.FileService.updateFile(FileService.java:2686)
at sbt.sample.standalone.java.StandaloneDemo.ReplacePhoto(StandaloneDemo.java:332)
at sbt.sample.standalone.java.StandaloneDemo.main(StandaloneDemo.java:239)
Caused by: java.lang.IllegalStateException: SBT context is not initialized for the request
at com.ibm.commons.runtime.Context.get(Context.java:57)
at com.ibm.sbt.services.endpoints.BasicEndpoint.authenticate(BasicEndpoint.java:151)
at com.ibm.sbt.services.client.ClientService.forceAuthentication(ClientService.java:296)
at com.ibm.sbt.services.client.ClientService.processResponse(ClientService.java:1154)
at com.ibm.sbt.services.client.ClientService._xhr(ClientService.java:1072)
at com.ibm.sbt.services.client.ClientService.execRequest(ClientService.java:1037)
at com.ibm.sbt.services.client.ClientService.xhr(ClientService.java:1003)
at com.ibm.sbt.services.client.ClientService.put(ClientService.java:937)
at com.ibm.sbt.services.client.ClientService.put(ClientService.java:933)
at com.ibm.sbt.services.client.base.BaseService.updateData(BaseService.java:439)
at com.ibm.sbt.services.client.connections.files.FileService.updateFile(FileService.java:2683)
注意:我在程序中使用的用户是发布内容的社区管理员。此外,有什么方法可以在 sbtsdk api 中指定来替换其他文件而不创建其他版本?
我发现这很相似 - Liferay Portal & IBM SBT SDK: SBT context is not initialized for the request 但我不明白是否有任何解决方案。
谢谢。