List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId
public long getScopeGroupId()
From source file:ca.efendi.datafeeds.web.internal.portlet.action.ActionUtil.java
License:Apache License
public static List<FtpSubscription> getFtpSubscriptions(final RenderRequest request) { final ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); final long groupId = themeDisplay.getScopeGroupId(); List<FtpSubscription> tempResults; try {//from ww w .j a v a 2s .c o m tempResults = FtpSubscriptionLocalServiceUtil.getAllFtpSubscriptions(groupId); } catch (final SystemException se) { tempResults = Collections.EMPTY_LIST; } return tempResults; }
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsAdminPortlet.java
License:Apache License
/** * @param request//from w w w . jav a 2s . c o m * @return */ public FtpSubscription ftpSubscriptionFromRequest(final ActionRequest request) { final ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(THEME_DISPLAY); long ftpSubscriptionId = ParamUtil.getLong(request, "ftpSubscriptionId"); final FtpSubscription ftpSubscription = _ftpSubscriptionLocalService.createFtpSubscription(0); ftpSubscription.setFtpSubscriptionId(ParamUtil.getInteger(request, "ftpSubscriptionId")); _log.warn("ftpSubscriptionId:" + ftpSubscription.getFtpSubscriptionId()); ftpSubscription.setCompanyId(themeDisplay.getCompanyId()); ftpSubscription.setGroupId(themeDisplay.getScopeGroupId()); ftpSubscription.setUserId(themeDisplay.getUser().getUserId()); ftpSubscription.setUserName(themeDisplay.getUser().getFullName()); final Date now = new Date(); ftpSubscription.setCreateDate(now); ftpSubscription.setModifiedDate(now); // _log.warn("ftpSubscriptionId:" + ParamUtil.getInteger(request, // "ftpSubscriptionId")); ftpSubscription.setFtpHost(ParamUtil.getString(request, "ftpHost")); ftpSubscription.setFtpUser(ParamUtil.getString(request, "ftpUser")); ftpSubscription.setFtpPassword(ParamUtil.getString(request, "ftpPassword")); ftpSubscription.setFtpFolder(ParamUtil.getString(request, "ftpFolder")); ftpSubscription.setFtpDatafeedName(ParamUtil.getString(request, "ftpDatafeedName")); ftpSubscription.setFtpFile(ParamUtil.getString(request, "ftpFile")); ftpSubscription.setFtpDatafeedDescription(ParamUtil.getString(request, "ftpDatafeedDescription")); return ftpSubscription; }
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected MBMessage updateMessage(final ActionRequest actionRequest) throws Exception { final ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); final String className = ParamUtil.getString(actionRequest, "className"); final long classPK = ParamUtil.getLong(actionRequest, "classPK"); final String permissionClassName = ParamUtil.getString(actionRequest, "permissionClassName"); final long permissionClassPK = ParamUtil.getLong(actionRequest, "permissionClassPK"); final long permissionOwnerId = ParamUtil.getLong(actionRequest, "permissionOwnerId"); final long messageId = ParamUtil.getLong(actionRequest, "messageId"); final long threadId = ParamUtil.getLong(actionRequest, "threadId"); final long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId"); final String subject = ParamUtil.getString(actionRequest, "subject"); final String body = ParamUtil.getString(actionRequest, "body"); final ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest);/* ww w. ja va2s . com*/ final MBMessage message = null; /* * if (messageId <= 0) { message = * MBMessageServiceUtil.addDiscussionMessage( * serviceContext.getScopeGroupId(), className, classPK, * permissionClassName, permissionClassPK, permissionOwnerId, threadId, * parentMessageId, subject, body, serviceContext); } else { message = * MBMessageServiceUtil.updateDiscussionMessage( className, classPK, * permissionClassName, permissionClassPK, permissionOwnerId, messageId, * subject, body, serviceContext); } */ // Subscription final boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe"); if (subscribe) { SubscriptionLocalServiceUtil.addSubscription(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK); } return message; }
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected void subscribeToComments(final ActionRequest actionRequest, final boolean subscribe) throws Exception { final ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); final String className = ParamUtil.getString(actionRequest, "className"); final long classPK = ParamUtil.getLong(actionRequest, "classPK"); if (subscribe) { SubscriptionLocalServiceUtil.addSubscription(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK);//from w ww . ja v a2 s.co m } else { SubscriptionLocalServiceUtil.deleteSubscription(themeDisplay.getUserId(), className, classPK); } }
From source file:ch.inofix.referencemanager.web.internal.portlet.ReferenceManagerPortlet.java
License:Apache License
/** * /*from w w w . j a va 2s.com*/ * @param actionRequest * @param actionResponse * @since 1.0.0 * @throws Exception */ public void importBibTeXFile(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); File file = uploadPortletRequest.getFile("file"); String fileName = file.getName(); long userId = themeDisplay.getUserId(); long groupId = themeDisplay.getScopeGroupId(); boolean privateLayout = themeDisplay.getLayout().isPrivateLayout(); String servletContextName = request.getSession().getServletContext().getServletContextName(); String[] servletContextNames = new String[] { servletContextName }; Map<String, String[]> parameterMap = new HashMap<String, String[]>(actionRequest.getParameterMap()); parameterMap.put("servletContextNames", servletContextNames); if (Validator.isNotNull(file)) { String message = PortletUtil.translate("upload-successfull-import-will-finish-in-a-separate-thread"); ServiceContext serviceContext = ServiceContextFactory.getInstance(Reference.class.getName(), uploadPortletRequest); _referenceService.importReferencesInBackground(userId, fileName, groupId, privateLayout, parameterMap, file, serviceContext); SessionMessages.add(actionRequest, "request_processed", message); } else { SessionErrors.add(actionRequest, "file-not-found"); } }
From source file:com.liferay.akismet.hook.action.AkismetEditDiscussionAction.java
License:Open Source License
protected void checkPermission(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isCompanyAdmin()) { return;//from w w w .j a v a 2 s . co m } if (permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) { return; } throw new PrincipalException(); }
From source file:com.liferay.announcements.web.internal.display.context.DefaultAnnouncementsDisplayContext.java
License:Open Source License
@Override public boolean isTabs1Visible() { String portletName = _announcementsRequestHelper.getPortletName(); ThemeDisplay themeDisplay = _announcementsRequestHelper.getThemeDisplay(); try {/* ww w .ja va2 s. co m*/ if (!portletName.equals(AnnouncementsPortletKeys.ALERTS) || (portletName.equals(AnnouncementsPortletKeys.ALERTS) && PortletPermissionUtil .hasControlPanelAccessPermission(_announcementsRequestHelper.getPermissionChecker(), themeDisplay.getScopeGroupId(), AnnouncementsPortletKeys.ANNOUNCEMENTS_ADMIN))) { return true; } } catch (PortalException pe) { _log.error(pe, pe); } return false; }
From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java
License:Open Source License
public String getAddButtonURL() throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); long groupId = getGroupId(); if (groupId == 0) { groupId = themeDisplay.getScopeGroupId(); }/*from w w w. ja va2s .c om*/ LiferayPortletRequest liferayPortletRequest = PortalUtil.getLiferayPortletRequest(_renderRequest); LiferayPortletResponse liferayPortletResponse = PortalUtil.getLiferayPortletResponse(_renderResponse); AssetRendererFactory assetRendererFactory = getAssetRendererFactory(); PortletURL addPortletURL = null; if (assetRendererFactory.isSupportsClassTypes() && (getSubtypeSelectionId() > 0)) { addPortletURL = _assetHelper.getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId, getTypeSelection(), getSubtypeSelectionId(), null, null, getPortletURL().toString()); } else { addPortletURL = _assetHelper.getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId, getTypeSelection(), 0, null, null, getPortletURL().toString()); } if (addPortletURL == null) { return StringPool.BLANK; } addPortletURL.setParameter("groupId", String.valueOf(groupId)); return HttpUtil.addParameter(addPortletURL.toString(), "refererPlid", themeDisplay.getPlid()); }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public SearchContainer getCategoriesSearchContainer() throws PortalException { if (_categoriesSearchContainer != null) { return _categoriesSearchContainer; }// ww w . j ava 2 s. c om SearchContainer categoriesSearchContainer = new SearchContainer(_renderRequest, getIteratorURL(), null, "there-are-no-categories"); if (Validator.isNull(getKeywords())) { if (isShowCategoriesAddButton()) { categoriesSearchContainer .setEmptyResultsMessageCssClass("there-are-no-categories.-you-can-add-a-category-by-" + "clicking-the-plus-button-on-the-bottom-right-corner"); categoriesSearchContainer .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { categoriesSearchContainer.setSearch(true); } categoriesSearchContainer.setOrderByCol(getOrderByCol()); boolean orderByAsc = false; String orderByType = getOrderByType(); if (orderByType.equals("asc")) { orderByAsc = true; } OrderByComparator<AssetCategory> orderByComparator = new AssetCategoryCreateDateComparator(orderByAsc); categoriesSearchContainer.setOrderByComparator(orderByComparator); categoriesSearchContainer.setOrderByType(orderByType); EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse); StringBundler sb = new StringBundler(7); sb.append("^(?!.*"); sb.append(_renderResponse.getNamespace()); sb.append("redirect).*(/vocabulary/"); sb.append(getVocabularyId()); sb.append("/category/"); sb.append(getCategoryId()); sb.append(")"); emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString()); categoriesSearchContainer.setRowChecker(emptyOnClickRowChecker); List<AssetCategory> categories = null; int categoriesCount = 0; ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); long scopeGroupId = themeDisplay.getScopeGroupId(); if (Validator.isNotNull(getKeywords())) { AssetCategoryDisplay assetCategoryDisplay = null; Sort sort = null; if (isFlattenedNavigationAllowed()) { sort = new Sort("leftCategoryId", Sort.INT_TYPE, orderByAsc); } else { sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc); } assetCategoryDisplay = AssetCategoryServiceUtil.searchCategoriesDisplay(new long[] { scopeGroupId }, getKeywords(), new long[] { getVocabularyId() }, new long[0], categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), sort); categoriesCount = assetCategoryDisplay.getTotal(); categoriesSearchContainer.setTotal(categoriesCount); categories = assetCategoryDisplay.getCategories(); } else if (isFlattenedNavigationAllowed()) { AssetCategory category = getCategory(); if (Validator.isNull(category)) { categoriesCount = AssetCategoryServiceUtil .getVocabularyCategoriesCount(themeDisplay.getScopeGroupId(), getVocabularyId()); categories = AssetCategoryServiceUtil.getVocabularyCategories(getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), new AssetCategoryLeftCategoryIdComparator(orderByAsc)); } else { categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount( themeDisplay.getScopeGroupId(), category.getCategoryId(), getVocabularyId()); categories = AssetCategoryServiceUtil.getVocabularyCategories(category.getCategoryId(), getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), new AssetCategoryLeftCategoryIdComparator(orderByAsc)); } categoriesSearchContainer.setTotal(categoriesCount); } else { categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount(scopeGroupId, getCategoryId(), getVocabularyId()); categoriesSearchContainer.setTotal(categoriesCount); categories = AssetCategoryServiceUtil.getVocabularyCategories(scopeGroupId, getCategoryId(), getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), categoriesSearchContainer.getOrderByComparator()); } categoriesSearchContainer.setResults(categories); _categoriesSearchContainer = categoriesSearchContainer; return _categoriesSearchContainer; }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public String getSelectCategoryURL() throws Exception { if (_selectCategoryURL != null) { return _selectCategoryURL; }//from ww w .j ava 2 s. c o m ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); List<AssetVocabulary> vocabularies = AssetVocabularyServiceUtil .getGroupVocabularies(themeDisplay.getScopeGroupId()); PortletURL selectCategoryURL = PortletProviderUtil.getPortletURL(_request, AssetCategory.class.getName(), PortletProvider.Action.BROWSE); selectCategoryURL.setParameter("allowedSelectVocabularies", Boolean.TRUE.toString()); selectCategoryURL.setParameter("eventName", _renderResponse.getNamespace() + "selectCategory"); selectCategoryURL.setParameter("singleSelect", Boolean.TRUE.toString()); selectCategoryURL.setParameter("vocabularyIds", ListUtil.toString(vocabularies, AssetVocabulary.VOCABULARY_ID_ACCESSOR)); selectCategoryURL.setWindowState(LiferayWindowState.POP_UP); _selectCategoryURL = selectCategoryURL.toString(); return _selectCategoryURL; }