Example usage for com.liferay.portal.kernel.service RoleLocalServiceUtil deleteRole

List of usage examples for com.liferay.portal.kernel.service RoleLocalServiceUtil deleteRole

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service RoleLocalServiceUtil deleteRole.

Prototype

public static com.liferay.portal.kernel.model.Role deleteRole(com.liferay.portal.kernel.model.Role role)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Deletes the role from the database.

Usage

From source file:com.liferay.document.library.service.test.DLCheckInCheckOutTest.java

License:Open Source License

@Test
public void testCancelCheckoutWithPermissionOverrideCheckout() throws Exception {

    Role role = RoleTestUtil.addRole("Overrider", RoleConstants.TYPE_REGULAR,
            DLFileEntryConstants.getClassName(), ResourceConstants.SCOPE_GROUP_TEMPLATE,
            String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID), ActionKeys.OVERRIDE_CHECKOUT);

    try {//from   w w  w  .j  a  v a2  s .c  o  m
        UserLocalServiceUtil.setRoleUsers(role.getRoleId(), new long[] { _overriderUser.getUserId() });

        FileEntry fileEntry = null;

        try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_authorUser)) {

            fileEntry = createFileEntry(StringUtil.randomString());

            DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext);
        }

        try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_overriderUser)) {

            DLAppServiceUtil.cancelCheckOut(fileEntry.getFileEntryId());

            fileEntry = DLAppServiceUtil.getFileEntry(fileEntry.getFileEntryId());

            Assert.assertFalse(fileEntry.isCheckedOut());
        }
    } finally {
        RoleLocalServiceUtil.deleteRole(role.getRoleId());
    }
}

From source file:com.liferay.document.library.service.test.DLCheckInCheckOutTest.java

License:Open Source License

@Test(expected = FileEntryLockException.MustOwnLock.class)
public void testCheckInWithPermissionOverrideCheckout() throws Exception {
    Role role = RoleTestUtil.addRole("Overrider", RoleConstants.TYPE_REGULAR,
            DLFileEntryConstants.getClassName(), ResourceConstants.SCOPE_GROUP_TEMPLATE,
            String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID), ActionKeys.OVERRIDE_CHECKOUT);

    try {// ww w.  j a  v  a  2s . c o  m
        UserLocalServiceUtil.setRoleUsers(role.getRoleId(), new long[] { _overriderUser.getUserId() });

        FileEntry fileEntry = null;

        try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_authorUser)) {

            fileEntry = createFileEntry(StringUtil.randomString());

            DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext);
        }

        try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_overriderUser)) {

            DLAppServiceUtil.checkInFileEntry(fileEntry.getFileEntryId(), false, StringPool.NULL,
                    _serviceContext);
        }
    } finally {
        RoleLocalServiceUtil.deleteRole(role.getRoleId());
    }
}

From source file:com.liferay.document.library.service.test.DLCheckInCheckOutTest.java

License:Open Source License

@Test(expected = FileEntryLockException.MustOwnLock.class)
public void testUpdateWithPermissionOverrideCheckout() throws Exception {
    Role role = RoleTestUtil.addRole("Overrider", RoleConstants.TYPE_REGULAR,
            DLFileEntryConstants.getClassName(), ResourceConstants.SCOPE_GROUP_TEMPLATE,
            String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID), ActionKeys.OVERRIDE_CHECKOUT);

    RoleTestUtil.addResourcePermission(role, DLFileEntryConstants.getClassName(),
            ResourceConstants.SCOPE_GROUP_TEMPLATE, String.valueOf(GroupConstants.DEFAULT_PARENT_GROUP_ID),
            ActionKeys.UPDATE);/*from www  .ja va  2 s  . c o  m*/

    try {
        UserLocalServiceUtil.setRoleUsers(role.getRoleId(), new long[] { _overriderUser.getUserId() });

        FileEntry fileEntry = null;

        try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_authorUser)) {

            fileEntry = createFileEntry(StringUtil.randomString());

            DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext);
        }

        try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_overriderUser)) {

            updateFileEntry(fileEntry.getFileEntryId());
        }
    } finally {
        RoleLocalServiceUtil.deleteRole(role.getRoleId());
    }
}

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularRoleServiceImpl.java

License:Open Source License

@Override
public Role deleteRole(long roleId) throws PortalException {

    _log.info("Deleting role with id: " + String.valueOf(roleId));

    _log.debug("    security check ...");

    RolePermissionUtil.check(getPermissionChecker(), roleId, ActionKeys.DELETE);

    _log.debug("    deleting role ...");

    return RoleLocalServiceUtil.deleteRole(roleId);
}