Example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Prototype

String THEME_DISPLAY

To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.

Click Source Link

Usage

From source file:com.liferay.bookmarks.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static BookmarksFolder getFolder(HttpServletRequest request) throws Exception {

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

    long folderId = ParamUtil.getLong(request, "folderId");

    BookmarksFolder folder = null;/* w  w w. ja v a2s  . c  om*/

    if ((folderId > 0) && (folderId != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID)) {

        folder = BookmarksFolderServiceUtil.getFolder(folderId);

        if (folder.isInTrash()) {
            throw new NoSuchFolderException("{folderId=" + folderId + "}");
        }
    } else {
        BookmarksResourcePermissionChecker.check(themeDisplay.getPermissionChecker(),
                themeDisplay.getScopeGroupId(), ActionKeys.VIEW);
    }

    return folder;
}

From source file:com.liferay.bookmarks.web.internal.portlet.action.EditEntryMVCActionCommand.java

License:Open Source License

protected BookmarksEntry updateEntry(ActionRequest actionRequest) throws Exception {

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

    long entryId = ParamUtil.getLong(actionRequest, "entryId");

    long groupId = themeDisplay.getScopeGroupId();
    long folderId = ParamUtil.getLong(actionRequest, "folderId");
    String name = ParamUtil.getString(actionRequest, "name");
    String url = ParamUtil.getString(actionRequest, "url");
    String description = ParamUtil.getString(actionRequest, "description");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(BookmarksEntry.class.getName(),
            actionRequest);//  w  w  w  .  j a  v  a2 s  . co  m

    BookmarksEntry entry = null;

    if (entryId <= 0) {

        // Add entry

        entry = _bookmarksEntryService.addEntry(groupId, folderId, name, url, description, serviceContext);
    } else {

        // Update entry

        entry = _bookmarksEntryService.updateEntry(entryId, groupId, folderId, name, url, description,
                serviceContext);
    }

    return entry;
}

From source file:com.liferay.bookmarks.web.internal.portlet.action.EditFolderMVCActionCommand.java

License:Open Source License

protected void subscribeFolder(ActionRequest actionRequest) throws Exception {

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

    long folderId = ParamUtil.getLong(actionRequest, "folderId");

    _bookmarksFolderService.subscribeFolder(themeDisplay.getScopeGroupId(), folderId);
}

From source file:com.liferay.bookmarks.web.internal.portlet.action.EditFolderMVCActionCommand.java

License:Open Source License

protected void unsubscribeFolder(ActionRequest actionRequest) throws Exception {

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

    long folderId = ParamUtil.getLong(actionRequest, "folderId");

    _bookmarksFolderService.unsubscribeFolder(themeDisplay.getScopeGroupId(), folderId);
}

From source file:com.liferay.bookmarks.web.internal.portlet.action.FindEntryAction.java

License:Open Source License

@Override
public String execute(StrutsAction originalStrutsAction, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

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

    long entryId = ParamUtil.getLong(request, "entryId");

    response.sendRedirect(themeDisplay.getPathMain() + "/bookmarks/open_entry?entryId=" + entryId);

    return null;//from w ww .ja  v  a  2  s  .  c om
}

From source file:com.liferay.bookmarks.web.internal.portlet.configuration.icon.DeleteFolderPortletConfigurationIcon.java

License:Open Source License

@Override
public String getMessage(PortletRequest portletRequest) {
    String key = "delete";

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

    if (isTrashEnabled(themeDisplay.getScopeGroupId())) {
        key = "move-to-the-recycle-bin";
    }//w w w.ja  v a  2 s  .  c  o  m

    return LanguageUtil.get(getResourceBundle(themeDisplay.getLocale()), key);
}

From source file:com.liferay.bookmarks.web.internal.portlet.configuration.icon.DeleteFolderPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    PortletURL deleteURL = PortalUtil.getControlPanelPortletURL(portletRequest,
            BookmarksPortletKeys.BOOKMARKS_ADMIN, PortletRequest.ACTION_PHASE);

    deleteURL.setParameter(ActionRequest.ACTION_NAME, "/bookmarks/edit_folder");

    String cmd = Constants.DELETE;

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

    if (isTrashEnabled(themeDisplay.getScopeGroupId())) {
        cmd = Constants.MOVE_TO_TRASH;/*from   w w w  . j  a  v  a 2 s. co  m*/
    }

    deleteURL.setParameter(Constants.CMD, cmd);

    PortletURL parentFolderURL = PortalUtil.getControlPanelPortletURL(portletRequest,
            BookmarksPortletKeys.BOOKMARKS_ADMIN, PortletRequest.RENDER_PHASE);

    BookmarksFolder folder = null;

    try {
        folder = ActionUtil.getFolder(portletRequest);
    } catch (Exception e) {
        return null;
    }

    long parentFolderId = folder.getParentFolderId();

    if (parentFolderId == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        parentFolderURL.setParameter("mvcRenderCommandName", "/bookmarks/view");
    } else {
        parentFolderURL.setParameter("mvcRenderCommandName", "/bookmarks/view_folder");
        parentFolderURL.setParameter("folderId", String.valueOf(parentFolderId));
    }

    deleteURL.setParameter("redirect", parentFolderURL.toString());

    deleteURL.setParameter("folderId", String.valueOf(folder.getFolderId()));

    return deleteURL.toString();
}

From source file:com.liferay.bookmarks.web.internal.portlet.configuration.icon.DeleteFolderPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {//  w w  w.  j  av a2  s . c  o  m
        BookmarksFolder folder = ActionUtil.getFolder(portletRequest);

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

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

        if (BookmarksFolderPermissionChecker.contains(themeDisplay.getPermissionChecker(), folder,
                ActionKeys.DELETE)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.bookmarks.web.internal.portlet.configuration.icon.EditFolderPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {//from   w  w  w.  j a  v a2 s  .c o  m
        BookmarksFolder folder = ActionUtil.getFolder(portletRequest);

        if (folder.getFolderId() == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            return false;
        }

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

        if (BookmarksFolderPermissionChecker.contains(themeDisplay.getPermissionChecker(), folder,
                ActionKeys.UPDATE)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.bookmarks.web.internal.portlet.configuration.icon.FolderPermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    String url = StringPool.BLANK;

    try {//from  w  w  w.j  ava2s . c  o m
        BookmarksFolder folder = ActionUtil.getFolder(portletRequest);

        String modelResource = BookmarksFolder.class.getName();
        String modelResourceDescription = folder.getName();
        String resourcePrimKey = String.valueOf(folder.getFolderId());

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

        url = PermissionsURLTag.doTag(StringPool.BLANK, modelResource, modelResourceDescription, null,
                resourcePrimKey, LiferayWindowState.POP_UP.toString(), null, themeDisplay.getRequest());
    } catch (Exception e) {
    }

    return url;
}