protected String contextPath;
@OperationMethod
public Blob run() throws Exception {
NuxeoPrincipal currentUser = (NuxeoPrincipal) session.getPrincipal();
SocialWorkspace socialWorkspace = socialWorkspaceService.getDetachedSocialWorkspace(
session, new PathRef(contextPath));
List<String> targets = relationshipService.getTargetsOfKind(
ActivityHelper.createDocumentActivityObject(
socialWorkspace.getDocument().getRepositoryName(),
socialWorkspace.getId()),
RelationshipKind.fromString("socialworkspace:members"));
if (targets.contains(ActivityHelper.createUserActivityObject(currentUser))) {
return buildResponse(socialWorkspace.getDocument(), Status.MEMBER);
} else if (socialWorkspace.isAdministratorOrMember(currentUser)) {
return buildResponse(socialWorkspace.getDocument(), Status.MEMBER);
} else {
String reqestStatus = socialWorkspace.getSubscriptionRequestStatus(currentUser);
if (reqestStatus == null) { // no subscrition requests
return buildResponse(socialWorkspace.getDocument(),
Status.NOT_MEMBER);
} else if (REQUEST_PENDING_STATE.equals(reqestStatus)) {
return buildResponse(socialWorkspace.getDocument(),
Status.REQUEST_PENDING);
} else if (REQUEST_ACCEPTED_STATE.equals(reqestStatus)) {
return buildResponse(socialWorkspace.getDocument(),
Status.REQUEST_ACCEPTED);
} else if (REQUEST_REJECTED_STATE.equals(reqestStatus)) {
return buildResponse(socialWorkspace.getDocument(),
Status.REQUEST_REJECTED);
} else {
return buildResponse(socialWorkspace.getDocument(),
Status.NOT_MEMBER);
}
}
}