Example usage for com.liferay.portal.kernel.trash TrashHandler isInTrashContainer

List of usage examples for com.liferay.portal.kernel.trash TrashHandler isInTrashContainer

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.trash TrashHandler isInTrashContainer.

Prototype

public default boolean isInTrashContainer(long classPK) throws PortalException 

Source Link

Document

Returns true if the model entity with the primary key is in a container that is in the Recycle Bin.

Usage

From source file:com.liferay.trash.internal.TrashHelperImpl.java

License:Open Source License

@Override
public PortletURL getViewContentURL(HttpServletRequest request, String className, long classPK)
        throws PortalException {

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    if (trashHandler.isInTrashContainer(classPK)) {
        com.liferay.trash.kernel.model.TrashEntry trashEntry = trashHandler.getTrashEntry(classPK);

        className = trashEntry.getClassName();
        classPK = trashEntry.getClassPK();

        trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);
    }//from w w w . ja  v a2s  .c  o m

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    if (trashRenderer == null) {
        return null;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletURL portletURL = PortletProviderUtil.getPortletURL(request, TrashEntry.class.getName(),
            PortletProvider.Action.VIEW);

    portletURL.setParameter("mvcPath", "/view_content.jsp");
    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    TrashEntry trashEntry = _trashEntryLocalService.getEntry(className, classPK);

    if (trashEntry.getRootEntry() != null) {
        portletURL.setParameter("className", className);
        portletURL.setParameter("classPK", String.valueOf(classPK));
    } else {
        portletURL.setParameter("trashEntryId", String.valueOf(trashEntry.getEntryId()));
    }

    portletURL.setParameter("showAssetMetadata", Boolean.TRUE.toString());

    return portletURL;
}

From source file:com.liferay.trash.web.internal.portlet.configuration.icon.RestoreRootTrashPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    TrashDisplayContext trashDisplayContext = new TrashDisplayContext(
            _portal.getHttpServletRequest(portletRequest), null);

    TrashEntry trashEntry = trashDisplayContext.getTrashEntry();

    if (trashEntry == null) {
        return false;
    }//from w ww .  ja v  a2s. c  o m

    TrashHandler trashHandler = trashDisplayContext.getTrashHandler();

    if (trashHandler == null) {
        return false;
    }

    try {
        if (!trashHandler.isRestorable(trashEntry.getClassPK())) {
            return false;
        }

        if (trashHandler.isInTrashContainer(trashEntry.getClassPK())) {
            return false;
        }
    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:com.liferay.trash.web.internal.portlet.configuration.icon.RestoreTrashPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    TrashDisplayContext trashDisplayContext = new TrashDisplayContext(
            _portal.getHttpServletRequest(portletRequest), null);

    TrashHandler trashHandler = trashDisplayContext.getTrashHandler();

    if (trashHandler == null) {
        return false;
    }//w w w  . j a v a 2s  .  com

    if (!trashHandler.isMovable()) {
        return false;
    }

    if (trashHandler.isContainerModel()) {
        return false;
    }

    TrashEntry trashEntry = trashDisplayContext.getTrashEntry();

    if (trashEntry != null) {
        try {
            if (!trashHandler.isRestorable(trashEntry.getClassPK())) {
                return false;
            }

            if (!trashHandler.isInTrashContainer(trashEntry.getClassPK())) {
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    }

    return true;
}