use of org.exoplatform.social.core.space.model.Space in project onlyoffice by exoplatform.
the class OnlyofficeEditorServiceImpl method getDisplayPath.
/**
* Gets display path.
*
* @param node the node
* @param userId the userId
* @return the display path
*/
protected String getDisplayPath(Node node, String userId) {
try {
DriveData driveData = documentService.getDriveOfNode(node.getPath());
List<String> elems = Arrays.asList(node.getPath().split("/"));
String parentFolder;
try {
parentFolder = node.getParent().getProperty("exo:title").getString();
} catch (Exception e) {
LOG.debug("Couldn't get exo:title from node parent. Node {}, message {}", node.getPath(), e.getMessage());
parentFolder = elems.get(elems.size() - 2);
}
String title = node.hasProperty("exo:title") ? node.getProperty("exo:title").getString() : elems.get(elems.size() - 1);
String drive = "";
if (driveData != null) {
String driveName = driveData.getName();
// User's documents
if (node.getPath().startsWith(usersPath)) {
drive = driveName;
// Shared document
if (!userId.equals(getUserId(node.getPath()))) {
Node symlink = getSymlink(node, userId);
if (symlink != null && !StringUtils.equals(symlink.getPath(), node.getPath())) {
return getDisplayPath(symlink, userId);
} else if (symlink == null) {
parentFolder = HIDDEN_FOLDER;
}
}
// Spaces's documents
} else if (driveName.startsWith(".spaces.")) {
String spacePrettyName = driveName.substring(driveName.lastIndexOf(".") + 1);
Space space = spaceService.getSpaceByPrettyName(spacePrettyName);
if (space != null) {
drive = "spaces/" + space.getDisplayName();
} else {
LOG.warn("Cannot find space by pretty name {}", spacePrettyName);
drive = spacePrettyName;
}
// Group's documents
} else if (driveName.startsWith(".platform.")) {
String groupId = driveName.replaceAll("\\.", "/");
Group group = organization.getGroupHandler().findGroupById(groupId);
if (group != null) {
drive = group.getLabel();
} else {
LOG.warn("Cannot find group by id {}", groupId);
drive = groupId;
}
} else {
drive = driveData.getName();
}
}
return drive + ":" + parentFolder + "/" + title;
} catch (Exception e) {
LOG.error("Error occured while creating display path", e);
return null;
}
}
use of org.exoplatform.social.core.space.model.Space in project kudos by Meeds-io.
the class SpaceServiceMock method getSpaceByPrettyName.
public Space getSpaceByPrettyName(String spacePrettyName) {
Space space = new Space();
space.setPrettyName(spacePrettyName);
space.setId(String.valueOf(spacePrettyName.charAt(spacePrettyName.length() - 1)));
space.setGroupId("/spaces/" + spacePrettyName);
return space;
}
use of org.exoplatform.social.core.space.model.Space in project perk-store by Meeds-io.
the class NotificationUtils method getSpaceAbsoluteURL.
public static String getSpaceAbsoluteURL(String id) {
Space space = getSpace(id);
if (space != null) {
String spaceUrlId = space.getGroupId().replace(SPACE_GROUP_PREFIX, "");
String currentDomain = CommonsUtils.getCurrentDomain();
if (!currentDomain.endsWith("/")) {
currentDomain += "/";
}
return currentDomain + "portal/g/:spaces:" + spaceUrlId;
} else {
return "#";
}
}
use of org.exoplatform.social.core.space.model.Space in project kudos by Meeds-io.
the class KudosSentListener method addEventStatistic.
private void addEventStatistic(Kudos kudos) {
long activityId = kudos.getActivityId();
long streamIdentityId = 0;
if (activityId <= 0 && (StringUtils.equals("ACTIVITY", kudos.getEntityType()) || StringUtils.equals("COMMENT", kudos.getEntityType()))) {
activityId = Long.parseLong(kudos.getEntityId());
}
StatisticData statisticData = new StatisticData();
if (activityId > 0) {
ExoSocialActivity activity = getActivityManager().getActivity(RDBMSActivityStorageImpl.COMMENT_PREFIX + activityId);
if (activity == null) {
activity = getActivityManager().getActivity(String.valueOf(activityId));
}
if (activity != null) {
ExoSocialActivity parentActivity = getActivityManager().getParentActivity(activity);
if (parentActivity != null) {
activity = parentActivity;
}
}
Identity streamIdentity = null;
if (activity != null) {
ActivityStream activityStream = activity.getActivityStream();
if (activityStream != null) {
Type type = activityStream.getType();
boolean isSpace = type == Type.SPACE;
String streamProviderId = isSpace ? SpaceIdentityProvider.NAME : OrganizationIdentityProvider.NAME;
String streamRemoteId = activityStream.getPrettyId();
try {
streamIdentity = getIdentity(streamProviderId, streamRemoteId);
} catch (Exception e) {
LOG.debug("Can't retrieve identity with providerId {} and remoteId {}. Attempt to retrieve it as Identity technical ID", streamProviderId, streamRemoteId, e);
streamIdentity = getIdentity(activityStream.getId());
}
}
}
if (streamIdentity != null) {
streamIdentityId = Long.parseLong(streamIdentity.getId());
if (StringUtils.equals(streamIdentity.getProviderId(), SpaceIdentityProvider.NAME)) {
Space space = getSpaceService().getSpaceByPrettyName(streamIdentity.getRemoteId());
addSpaceStatistics(statisticData, space);
}
}
}
statisticData.setModule("social");
statisticData.setSubModule("kudos");
statisticData.setOperation("sendKudos");
statisticData.setUserId(Long.parseLong(kudos.getSenderIdentityId()));
statisticData.addParameter("activityId", activityId);
statisticData.addParameter("streamIdentityId", streamIdentityId);
statisticData.addParameter("kudosId", kudos.getTechnicalId());
statisticData.addParameter("senderId", kudos.getSenderIdentityId());
statisticData.addParameter("receiverId", kudos.getReceiverIdentityId());
statisticData.addParameter("entityId", kudos.getEntityId());
statisticData.addParameter("entityType", kudos.getEntityType());
statisticData.addParameter("parentEntityId", kudos.getParentEntityId());
statisticData.addParameter("receiverType", kudos.getReceiverType());
statisticData.addParameter("messageLength", kudos.getMessage().length());
statisticData.addParameter("duration", kudos.getTimeInSeconds());
AnalyticsUtils.addStatisticData(statisticData);
}
use of org.exoplatform.social.core.space.model.Space in project kudos by Meeds-io.
the class KudosService method isAuthorizedOnKudosModule.
/**
* Check if user is authorized to send/receive Kudos
*
* @param username username to check
* @return true if authorised else return false
*/
public boolean isAuthorizedOnKudosModule(String username) {
if (StringUtils.isBlank(username)) {
return false;
}
String accessPermission = getAccessPermission();
if (StringUtils.isBlank(accessPermission)) {
return true;
}
Space space = getSpace(accessPermission);
// Disable kudos for users not member of the permitted space members
return spaceService.isSuperManager(username) || (space != null && spaceService.isMember(space, username));
}
Aggregations