Example usage for com.liferay.portal.kernel.security.permission ActionKeys VIEW

List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys VIEW

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission ActionKeys VIEW.

Prototype

String VIEW

To view the source code for com.liferay.portal.kernel.security.permission ActionKeys VIEW.

Click Source Link

Usage

From source file:com.liferay.site.util.GroupSearchProvider.java

License:Open Source License

protected boolean isFilterManageableGroups(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (permissionChecker.isCompanyAdmin()) {
        return false;
    }//from  w  w  w  .  j av  a2  s  .  c  o m

    if (GroupPermissionUtil.contains(permissionChecker, ActionKeys.VIEW)) {
        return false;
    }

    return true;
}

From source file:com.liferay.social.activity.customizer.interpreter.CustomWikiActivityInterpreter.java

License:Open Source License

@Override
protected boolean hasPermissions(PermissionChecker permissionChecker, SocialActivity activity, String actionId,
        ServiceContext serviceContext) throws Exception {

    if (!WikiPagePermissionChecker.contains(permissionChecker, activity.getClassPK(), ActionKeys.VIEW)) {

        return false;
    }/* w ww . java2  s . co  m*/

    int activityType = activity.getType();

    if (activityType == WikiActivityKeys.UPDATE_PAGE) {
        WikiPageResource pageResource = _wikiPageResourceLocalService.getPageResource(activity.getClassPK());

        double version = GetterUtil.getDouble(activity.getExtraDataValue("version"));

        WikiPage page = _wikiPageLocalService.getPage(pageResource.getNodeId(), pageResource.getTitle(),
                version);

        if (!page.isApproved() && !WikiPagePermissionChecker.contains(permissionChecker, activity.getClassPK(),
                ActionKeys.UPDATE)) {

            return false;
        }
    }

    return true;
}

From source file:com.liferay.social.activity.service.test.SocialActivityServiceTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();//from w w  w.  jav a  2 s. c o m
    _user = UserTestUtil.addUser();

    RoleTestUtil.addResourcePermission(RoleConstants.GUEST, DLPermission.RESOURCE_NAME,
            ResourceConstants.SCOPE_GROUP, String.valueOf(_group.getGroupId()), ActionKeys.VIEW);
}

From source file:com.liferay.social.activity.service.test.SocialActivityServiceTest.java

License:Open Source License

@After
public void tearDown() throws Exception {
    RoleTestUtil.removeResourcePermission(RoleConstants.GUEST, DLPermission.RESOURCE_NAME,
            ResourceConstants.SCOPE_GROUP, String.valueOf(_group.getGroupId()), ActionKeys.VIEW);

    SocialActivityHierarchyEntryThreadLocal.clear();
}

From source file:com.liferay.sync.internal.model.listener.ResourcePermissionModelListener.java

License:Open Source License

@Override
public void onBeforeCreate(ResourcePermission resourcePermission) throws ModelListenerException {

    SyncDLObject syncDLObject = getSyncDLObject(resourcePermission);

    if (syncDLObject == null) {
        return;//ww w. j av  a  2  s. c  o m
    }

    if (resourcePermission.hasActionId(ActionKeys.VIEW)) {
        updateSyncDLObject(syncDLObject);
    }
}

From source file:com.liferay.sync.internal.model.listener.ResourcePermissionModelListener.java

License:Open Source License

@Override
public void onBeforeRemove(ResourcePermission resourcePermission) throws ModelListenerException {

    SyncDLObject syncDLObject = getSyncDLObject(resourcePermission);

    if (syncDLObject == null) {
        return;//  w  w  w .ja  v  a 2 s.co  m
    }

    if (resourcePermission.hasActionId(ActionKeys.VIEW)) {
        Date date = new Date();

        syncDLObject.setModifiedTime(date.getTime());
        syncDLObject.setLastPermissionChangeDate(date);

        syncDLObjectLocalService.updateSyncDLObject(syncDLObject);
    }
}

From source file:com.liferay.sync.internal.model.listener.ResourcePermissionModelListener.java

License:Open Source License

@Override
public void onBeforeUpdate(ResourcePermission resourcePermission) throws ModelListenerException {

    SyncDLObject syncDLObject = getSyncDLObject(resourcePermission);

    if (syncDLObject == null) {
        return;//from   ww w. ja  v a 2s.  co m
    }

    ResourcePermission originalResourcePermission = resourcePermissionLocalService
            .fetchResourcePermission(resourcePermission.getResourcePermissionId());

    if (originalResourcePermission.hasActionId(ActionKeys.VIEW)
            && !resourcePermission.hasActionId(ActionKeys.VIEW)) {

        Date date = new Date();

        syncDLObject.setModifiedTime(date.getTime());
        syncDLObject.setLastPermissionChangeDate(date);

        syncDLObjectLocalService.updateSyncDLObject(syncDLObject);
    } else if (!originalResourcePermission.hasActionId(ActionKeys.VIEW)
            && resourcePermission.hasActionId(ActionKeys.VIEW)) {

        updateSyncDLObject(syncDLObject);
    }
}

From source file:com.liferay.training.space.gradebook.service.impl.AssignmentServiceImpl.java

License:Open Source License

public Assignment getAssignment(long assignmentId) throws PortalException {
    Assignment assignment = assignmentLocalService.getAssignment(assignmentId);

    AssignmentPermissionChecker.check(getPermissionChecker(), assignment.getGroupId(),
            assignment.getAssignmentId(), ActionKeys.VIEW);

    return assignment;
}

From source file:com.liferay.trash.service.impl.TrashEntryServiceImpl.java

License:Open Source License

/**
 * Deletes the trash entries with the matching group ID considering
 * permissions./*  ww w.  j  av a2 s  .  c  om*/
 *
 * @param groupId the primary key of the group
 */
@Override
@Transactional(noRollbackFor = { TrashPermissionException.class })
public void deleteEntries(long groupId) throws PortalException {
    boolean throwTrashPermissionException = false;

    List<TrashEntry> entries = trashEntryPersistence.findByGroupId(groupId);

    PermissionChecker permissionChecker = getPermissionChecker();

    for (TrashEntry entry : entries) {
        entry = trashEntryPersistence.fetchByPrimaryKey(entry.getEntryId());

        if (entry == null) {
            continue;
        }

        try {
            TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(entry.getClassName());

            if (!trashHandler.hasTrashPermission(permissionChecker, 0, entry.getClassPK(), ActionKeys.VIEW)) {

                continue;
            }

            deleteEntry(entry);
        } catch (TrashPermissionException tpe) {

            // LPS-52675

            if (_log.isDebugEnabled()) {
                _log.debug(tpe, tpe);
            }

            throwTrashPermissionException = true;
        } catch (Exception e) {
            _log.error(e, e);
        }
    }

    if (throwTrashPermissionException) {
        throw new TrashPermissionException(TrashPermissionException.EMPTY_TRASH);
    }
}

From source file:com.liferay.trash.service.impl.TrashEntryServiceImpl.java

License:Open Source License

protected List<TrashEntry> filterEntries(List<TrashEntry> entries) throws PrincipalException {

    List<TrashEntry> filteredEntries = new ArrayList<>();

    PermissionChecker permissionChecker = getPermissionChecker();

    for (TrashEntry entry : entries) {
        String className = entry.getClassName();
        long classPK = entry.getClassPK();

        try {/*from   w  w w  .j  av  a2s .c o  m*/
            TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

            if (trashHandler.hasTrashPermission(permissionChecker, 0, classPK, ActionKeys.VIEW)) {

                filteredEntries.add(entry);
            }
        } catch (Exception e) {
            _log.error(e, e);
        }
    }

    return filteredEntries;
}