我遵循@PaulBastide的建議,並創建了一個SubCommunityService類,當前只包含一個創建方法。它包裝了社區服務而不是繼承它,因爲我發現它是可取的。下面是要重新使用它的情況下,代碼:
public class SubCommunityService {
private final CommunityService communityService;
public SubCommunityService(CommunityService communityService) {
this.communityService = communityService;
}
public Community createCommunity(Community community, String superCommunityId) throws ClientServicesException {
Object constructCreateRequestBody = community.constructCreateRequestBody();
ClientService clientService = communityService.getEndpoint().getClientService();
String entityType = CommunityEntity.COMMUNITY.getCommunityEntityType();
Map<String, String> params = new HashMap<>();
params.put("communityUuid", superCommunityId);
String postUrl = communityService.resolveCommunityUrl(entityType,
CommunityType.SUBCOMMUNITIES.getCommunityType(), params);
String newCommunityUrl = (String) clientService.post(postUrl, null, constructCreateRequestBody,
ClientService.FORMAT_CONNECTIONS_OUTPUT);
String communityId = newCommunityUrl.substring(newCommunityUrl.indexOf("communityUuid=")
+ "communityUuid=".length());
community.setCommunityUuid(communityId);
return community;
}
}
我不知道,但是我會問馬尼什迴應 –
你應該讓GitHub上發佈請求 - https://開頭github.com/OpenNTF/SocialSDK/issues?state=open –
https://github.com/OpenNTF/SocialSDK/issues/706 –