@Override
public void execute(CoreSession session) {
try {
SocialWorkspaceService socialWorkspaceService = Framework.getLocalService(SocialWorkspaceService.class);
SocialWorkspaceContainerDescriptor socialWorkspaceContainer = socialWorkspaceService.getSocialWorkspaceContainerDescriptor();
DocumentRef docRef = new PathRef(socialWorkspaceContainer.getPath());
if (!session.exists(docRef)) {
Path path = new Path(socialWorkspaceContainer.getPath());
String parentPath = path.removeLastSegments(1).toString();
String name = path.lastSegment();
DocumentModel container = session.createDocumentModel(
parentPath, name, SOCIAL_WORKSPACE_CONTAINER_TYPE);
container.setPropertyValue(DC_TITLE,
socialWorkspaceContainer.getTitle());
container.setPropertyValue(DC_DESCRIPTION,
socialWorkspaceContainer.getDescription());
session.createDocument(container);
}
} catch (ClientException e) {
throw new ClientRuntimeException(e);
}