Example usage for com.liferay.portal.kernel.util ParamUtil getLongValues

List of usage examples for com.liferay.portal.kernel.util ParamUtil getLongValues

Introduction

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

Prototype

public static long[] getLongValues(ServiceContext serviceContext, String param) 

Source Link

Document

Returns the service context parameter value as a long array.

Usage

From source file:ch.inofix.referencemanager.web.internal.portlet.ReferenceManagerPortlet.java

License:Apache License

/**
*
* @param actionRequest//ww w . j  ava 2s  .co m
* @param actionResponse
* @throws Exception
*/
protected void deleteReferences(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long[] referenceIds = ParamUtil.getLongValues(actionRequest, "deleteBibliographyIds");

    if (referenceId > 0) {
        referenceIds = new long[] { referenceId };
    }

    for (long id : referenceIds) {
        _referenceService.deleteReference(id);
    }

}

From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java

License:Open Source License

public void deleteDiscussionMBMessages(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

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

    checkMBMessagePermission(themeDisplay.getScopeGroupId());

    long[] mbMessageIds = ParamUtil.getLongValues(actionRequest, "deleteMBMessageIds");

    for (long mbMessageId : mbMessageIds) {
        MBMessageLocalServiceUtil.deleteDiscussionMessage(mbMessageId);
    }//from   ww  w .  j  a  v a  2  s.c  o m
}

From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java

License:Open Source License

public void deleteMBMessages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    checkMBMessagePermission(themeDisplay.getScopeGroupId());

    long[] mbMessageIds = ParamUtil.getLongValues(actionRequest, "deleteMBMessageIds");

    for (long mbMessageId : mbMessageIds) {
        MBMessageLocalServiceUtil.deleteMessage(mbMessageId);
    }/*from   w w w  . j  av  a2 s  .  c  om*/
}

From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java

License:Open Source License

public void markNotSpamMBMessages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    checkMBMessagePermission(themeDisplay.getScopeGroupId());

    long[] mbMessageIds = ParamUtil.getLongValues(actionRequest, "notSpamMBMessageIds");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    for (long mbMessageId : mbMessageIds) {
        MBMessage mbMessage = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), mbMessageId,
                WorkflowConstants.STATUS_APPROVED, serviceContext);

        if (AkismetUtil.isMessageBoardsEnabled(mbMessage.getCompanyId())) {
            AkismetUtil.submitHam(mbMessage);
        }// w ww  . j  ava  2 s. c om
    }
}

From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java

License:Open Source License

public void markNotSpamWikiPages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    checkWikiPagePermission(themeDisplay.getScopeGroupId());

    long[] wikiPageIds = ParamUtil.getLongValues(actionRequest, "notSpamWikiPageIds");

    List<String> wikiPageLinks = new ArrayList<String>();

    for (long wikiPageId : wikiPageIds) {
        WikiPage wikiPage = WikiPageLocalServiceUtil.getPageByPageId(wikiPageId);

        WikiPage latestVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(),
                wikiPage.getVersion(), false);

        String latestContent = null;

        if (latestVersionWikiPage != null) {
            latestContent = latestVersionWikiPage.getContent();
        }/* w w  w  . j a  v  a2 s .  c o m*/

        WikiPage previousVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(),
                wikiPage.getVersion(), true);

        String previousContent = null;

        if (previousVersionWikiPage != null) {
            previousContent = previousVersionWikiPage.getContent();
        }

        // Selected version

        wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED);
        wikiPage.setSummary(StringPool.BLANK);

        wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage);

        // Latest version

        if ((latestContent != null) && ((previousContent == null) || latestContent.equals(previousContent))) {

            ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

            WikiPageLocalServiceUtil.revertPage(themeDisplay.getUserId(), wikiPage.getNodeId(),
                    wikiPage.getTitle(), wikiPage.getVersion(), serviceContext);
        } else {
            StringBundler sb = new StringBundler(5);

            sb.append("<a href=\"");

            long plid = PortalUtil.getPlidFromPortletId(wikiPage.getGroupId(), PortletKeys.WIKI);

            LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.WIKI,
                    plid, PortletRequest.RENDER_PHASE);

            WikiNode wikiNode = wikiPage.getNode();

            liferayPortletURL.setParameter("struts_action", "/wiki/view");
            liferayPortletURL.setParameter("nodeName", wikiNode.getName());
            liferayPortletURL.setParameter("title", wikiPage.getTitle());
            liferayPortletURL.setParameter("version", String.valueOf(wikiPage.getVersion()));

            sb.append(liferayPortletURL.toString());
            sb.append("\" target=\"_blank\">");
            sb.append(HtmlUtil.escape(wikiPage.getTitle()));
            sb.append("</a>");

            wikiPageLinks.add(sb.toString());
        }

        // Akismet

        if (AkismetUtil.isWikiEnabled(wikiPage.getCompanyId())) {
            AkismetUtil.submitHam(wikiPage);
        }
    }

    if (!wikiPageLinks.isEmpty()) {
        SessionMessages.add(actionRequest, "anotherUserHasMadeChangesToThesePages",
                StringUtil.merge(wikiPageLinks, "<br />"));

        addSuccessMessage(actionRequest, actionResponse);

        super.sendRedirect(actionRequest, actionResponse);
    }
}

From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java

License:Open Source License

public void spamWikiPages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    checkWikiPagePermission(themeDisplay.getScopeGroupId());

    long[] wikiPageIds = ParamUtil.getLongValues(actionRequest, "spamWikiPageIds");

    for (long wikiPageId : wikiPageIds) {
        WikiPage wikiPage = WikiPageLocalServiceUtil.getPageByPageId(wikiPageId);

        wikiPage.setSummary(AkismetConstants.WIKI_PAGE_MARKED_AS_SPAM);

        WikiPageLocalServiceUtil.updateWikiPage(wikiPage);
    }//from  www. j  a v a2  s . co  m
}

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

License:Open Source License

protected void deleteEntry(ActionRequest actionRequest) throws Exception {
    long entryId = ParamUtil.getLong(actionRequest, "entryId");

    long[] deleteEntryIds = null;

    if (entryId > 0) {
        deleteEntryIds = new long[] { entryId };
    } else {/*from   ww w  . j  av  a2s  .com*/
        deleteEntryIds = ParamUtil.getLongValues(actionRequest, "rowIdsAnnouncementsEntry");
    }

    for (long deleteEntryId : deleteEntryIds) {
        _announcementsEntryService.deleteEntry(deleteEntryId);
    }
}

From source file:com.liferay.asset.categories.admin.web.internal.portlet.AssetCategoryAdminPortlet.java

License:Open Source License

public void deleteCategory(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long[] deleteCategoryIds = null;

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

    if (categoryId > 0) {
        deleteCategoryIds = new long[] { categoryId };
    } else {/*from w w w.  j  a  v a 2s .c  om*/
        deleteCategoryIds = ParamUtil.getLongValues(actionRequest, "rowIds");
    }

    _assetCategoryService.deleteCategories(deleteCategoryIds);
}

From source file:com.liferay.asset.categories.admin.web.internal.portlet.AssetCategoryAdminPortlet.java

License:Open Source License

public void deleteVocabulary(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long[] deleteVocabularyIds = null;

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

    if (vocabularyId > 0) {
        deleteVocabularyIds = new long[] { vocabularyId };
    } else {//from ww  w.ja  v  a  2  s .  c o  m
        deleteVocabularyIds = ParamUtil.getLongValues(actionRequest, "rowIds");
    }

    for (long deleteVocabularyId : deleteVocabularyIds) {
        _assetVocabularyService.deleteVocabulary(deleteVocabularyId);
    }
}

From source file:com.liferay.asset.tags.admin.web.internal.portlet.AssetTagsAdminPortlet.java

License:Open Source License

public void deleteTag(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long[] deleteTagIds = null;

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

    if (tagId > 0) {
        deleteTagIds = new long[] { tagId };
    } else {//from w  ww .  j ava 2  s .c  om
        deleteTagIds = ParamUtil.getLongValues(actionRequest, "rowIds");
    }

    for (long deleteTagId : deleteTagIds) {
        _assetTagService.deleteTag(deleteTagId);
    }
}