Example usage for com.liferay.portal.kernel.exception TrashPermissionException EMPTY_TRASH

List of usage examples for com.liferay.portal.kernel.exception TrashPermissionException EMPTY_TRASH

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.exception TrashPermissionException EMPTY_TRASH.

Prototype

int EMPTY_TRASH

To view the source code for com.liferay.portal.kernel.exception TrashPermissionException EMPTY_TRASH.

Click Source Link

Usage

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./*  w  ww  .j  a va 2  s . c o  m*/
 *
 * @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

/**
 * Deletes the trash entries with the primary keys.
 *
 * @param entryIds the primary keys of the trash entries
 *///w ww . ja v a 2 s  . c om
@Override
@Transactional(noRollbackFor = { TrashPermissionException.class })
public void deleteEntries(long[] entryIds) throws PortalException {
    boolean throwTrashPermissionException = false;

    for (long entryId : entryIds) {
        try {
            deleteEntry(entryId);
        } catch (TrashPermissionException tpe) {

            // LPS-52675

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

            throwTrashPermissionException = true;
        }
    }

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