Example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId.

Prototype

public long getScopeGroupId() 

Source Link

Document

Returns the ID of the scoped or sub-scoped active group (e.g.

Usage

From source file:com.liferay.blogs.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();//from  w ww . ja  v  a  2  s.  c  om

    if (user.isDefaultUser()) {
        return false;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    try {
        if (!BlogsPermission.contains(permissionChecker, themeDisplay.getScopeGroupId(),
                ActionKeys.PERMISSIONS)) {

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

    return true;
}

From source file:com.liferay.blogs.web.internal.upload.ImageBlogsUploadFileEntryHandler.java

License:Open Source License

protected FileEntry addFileEntry(String fileName, String contentType, InputStream inputStream,
        ThemeDisplay themeDisplay) throws PortalException {

    Folder folder = blogsLocalService.addAttachmentsFolder(themeDisplay.getUserId(),
            themeDisplay.getScopeGroupId());

    String uniqueFileName = PortletFileRepositoryUtil.getUniqueFileName(themeDisplay.getScopeGroupId(),
            folder.getFolderId(), fileName);

    return PortletFileRepositoryUtil.addPortletFileEntry(themeDisplay.getScopeGroupId(),
            themeDisplay.getUserId(), BlogsEntry.class.getName(), 0, BlogsConstants.SERVICE_NAME,
            folder.getFolderId(), inputStream, uniqueFileName, contentType, true);
}

From source file:com.liferay.blogs.web.internal.upload.TempImageBlogsUploadFileEntryHandler.java

License:Open Source License

@Override
protected FileEntry addFileEntry(String fileName, String contentType, InputStream inputStream,
        ThemeDisplay themeDisplay) throws PortalException {

    String uniqueFileName = _uniqueFileNameProvider.provide(fileName,
            curFileName -> _exists(themeDisplay, curFileName));

    return TempFileEntryUtil.addTempFileEntry(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(),
            _TEMP_FOLDER_NAME, uniqueFileName, inputStream, contentType);
}

From source file:com.liferay.blogs.web.internal.upload.TempImageBlogsUploadFileEntryHandler.java

License:Open Source License

private boolean _exists(ThemeDisplay themeDisplay, String curFileName) {
    try {/*w w w.  jav a 2s.  c  o  m*/
        if (TempFileEntryUtil.getTempFileEntry(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(),
                _TEMP_FOLDER_NAME, curFileName) != null) {

            return true;
        }

        return false;
    } catch (PortalException pe) {
        if (_log.isDebugEnabled()) {
            _log.debug(pe, pe);
        }

        return false;
    }
}

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;//from w  w w .  j  a v  a2s  . c o  m

    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);//from  www  .  ja v a 2s  .  com

    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.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";
    }//from w w  w  .j av 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  ww. j  a  v a  2 s .  c o 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();
}