Search in sources :

Example 1 with Space

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;
    }
}
Also used : Space(org.exoplatform.social.core.space.model.Space) Group(org.exoplatform.services.organization.Group) VersionNode(org.exoplatform.ecm.jcr.model.VersionNode) Node(javax.jcr.Node) DriveData(org.exoplatform.services.cms.drives.DriveData) ItemNotFoundException(javax.jcr.ItemNotFoundException) AccessDeniedException(javax.jcr.AccessDeniedException) PathNotFoundException(javax.jcr.PathNotFoundException) ConfigurationException(org.exoplatform.container.configuration.ConfigurationException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RepositoryException(javax.jcr.RepositoryException) NoSuchElementException(java.util.NoSuchElementException) MalformedURLException(java.net.MalformedURLException) ValueFormatException(javax.jcr.ValueFormatException)

Example 2 with Space

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;
}
Also used : Space(org.exoplatform.social.core.space.model.Space)

Example 3 with 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 "#";
    }
}
Also used : Space(org.exoplatform.social.core.space.model.Space)

Example 4 with Space

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);
}
Also used : Space(org.exoplatform.social.core.space.model.Space) Type(org.exoplatform.social.core.activity.model.ActivityStream.Type) ExoSocialActivity(org.exoplatform.social.core.activity.model.ExoSocialActivity) ActivityStream(org.exoplatform.social.core.activity.model.ActivityStream) AnalyticsUtils.getIdentity(org.exoplatform.analytics.utils.AnalyticsUtils.getIdentity) Identity(org.exoplatform.social.core.identity.model.Identity) StatisticData(org.exoplatform.analytics.model.StatisticData)

Example 5 with Space

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));
}
Also used : Space(org.exoplatform.social.core.space.model.Space)

Aggregations

Space (org.exoplatform.social.core.space.model.Space)777 Identity (org.exoplatform.social.core.identity.model.Identity)205 SpaceService (org.exoplatform.social.core.space.spi.SpaceService)105 ExoSocialActivity (org.exoplatform.social.core.activity.model.ExoSocialActivity)101 Test (org.junit.Test)75 ArrayList (java.util.ArrayList)70 SpaceFilter (org.exoplatform.social.core.space.SpaceFilter)61 ContainerResponse (org.exoplatform.services.rest.impl.ContainerResponse)53 HttpServletRequest (javax.servlet.http.HttpServletRequest)51 ExoSocialActivityImpl (org.exoplatform.social.core.activity.model.ExoSocialActivityImpl)49 RolesAllowed (javax.annotation.security.RolesAllowed)46 News (org.exoplatform.news.model.News)46 Response (javax.ws.rs.core.Response)44 MaxQueryNumber (org.exoplatform.social.core.test.MaxQueryNumber)43 MaxQueryNumber (org.exoplatform.social.core.jpa.test.MaxQueryNumber)36 SpaceEntity (org.exoplatform.social.core.chromattic.entity.SpaceEntity)31 IdentityManager (org.exoplatform.social.core.manager.IdentityManager)25 ConversationState (org.exoplatform.services.security.ConversationState)23 DeprecatedAPI (org.exoplatform.deprecation.DeprecatedAPI)22 Relationship (org.exoplatform.social.core.relationship.model.Relationship)22