Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Prototype

int STATUS_APPROVED

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Click Source Link

Usage

From source file:com.liferay.knowledgebase.admin.util.AdminOpenSearchImpl.java

License:Open Source License

@Override
protected String getURL(ThemeDisplay themeDisplay, long groupId, Document result, PortletURL portletURL) {

    long resourcePrimKey = GetterUtil.getLong(result.get(Field.ENTRY_CLASS_PK));
    int status = WorkflowConstants.STATUS_APPROVED;

    WindowState windowState = portletURL.getWindowState();

    return KnowledgeBaseUtil.getKBArticleURL(themeDisplay.getPlid(), resourcePrimKey, status,
            themeDisplay.getPortalURL(), windowState.equals(LiferayWindowState.MAXIMIZED));
}

From source file:com.liferay.knowledgebase.admin.util.KBArticleIndexer.java

License:Open Source License

protected void reindexKBArticles(KBArticle kbArticle) throws Exception {

    // See KBArticlePermission#contains

    List<KBArticle> kbArticles = KBArticleLocalServiceUtil.getKBArticleAndAllDescendantKBArticles(
            kbArticle.getResourcePrimKey(), WorkflowConstants.STATUS_APPROVED, null);

    Collection<Document> documents = new ArrayList<>();

    for (KBArticle curKBArticle : kbArticles) {
        documents.add(getDocument(curKBArticle));
    }//w ww .ja v  a  2 s .c  om

    IndexWriterHelperUtil.updateDocuments(getSearchEngineId(), kbArticle.getCompanyId(), documents,
            isCommitImmediately());
}

From source file:com.liferay.knowledgebase.admin.util.KBArticleIndexer.java

License:Open Source License

protected void reindexKBArticles(long companyId) throws Exception {
    final IndexableActionableDynamicQuery indexableActionableDynamicQuery = KBArticleLocalServiceUtil
            .getIndexableActionableDynamicQuery();

    indexableActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override/* ww w  . ja va2  s. c  o  m*/
        public void addCriteria(DynamicQuery dynamicQuery) {
            Property property = PropertyFactoryUtil.forName("status");

            dynamicQuery.add(property.eq(WorkflowConstants.STATUS_APPROVED));
        }

    });
    indexableActionableDynamicQuery.setCompanyId(companyId);
    indexableActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<KBArticle>() {

                @Override
                public void performAction(KBArticle kbArticle) {
                    try {
                        Document document = getDocument(kbArticle);

                        indexableActionableDynamicQuery.addDocuments(document);
                    } catch (PortalException pe) {
                        if (_log.isWarnEnabled()) {
                            _log.warn("Unable to index knowledge base article " + kbArticle.getKbArticleId(),
                                    pe);
                        }
                    }
                }

            });
    indexableActionableDynamicQuery.setSearchEngineId(getSearchEngineId());

    indexableActionableDynamicQuery.performActions();
}

From source file:com.liferay.knowledgebase.article.portlet.ArticlePortlet.java

License:Open Source License

protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isSignedIn()) {
        return WorkflowConstants.STATUS_APPROVED;
    }/*from w ww.j  av  a 2  s.  co m*/

    String value = renderRequest.getParameter("status");
    int status = GetterUtil.getInteger(value);

    if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
        return WorkflowConstants.STATUS_APPROVED;
    }

    long resourcePrimKey = getResourcePrimKey(renderRequest);

    if (resourcePrimKey == 0) {
        return WorkflowConstants.STATUS_APPROVED;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {

        return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
    }

    return WorkflowConstants.STATUS_APPROVED;
}

From source file:com.liferay.knowledgebase.display.portlet.DisplayPortlet.java

License:Open Source License

protected KBArticle getKBFolderKBArticle(long groupId, long kbFolderId, String kbFolderUrlTitle)
        throws PortalException {

    if (Validator.isNotNull(kbFolderUrlTitle)) {
        KBFolder kbFolder = KBFolderServiceUtil.fetchKBFolderByUrlTitle(groupId, kbFolderId, kbFolderUrlTitle);

        if (kbFolder != null) {
            kbFolderId = kbFolder.getKbFolderId();
        }//from   ww  w  . j  a v  a  2  s  .  c  om
    }

    List<KBArticle> kbArticles = KBArticleServiceUtil.getKBArticles(groupId, kbFolderId,
            WorkflowConstants.STATUS_APPROVED, 0, 1, new KBArticlePriorityComparator(true));

    if (!kbArticles.isEmpty()) {
        return kbArticles.get(0);
    }

    List<KBFolder> kbFolders = KnowledgeBaseUtil.getAlternateRootKBFolders(groupId, kbFolderId);

    for (KBFolder kbFolder : kbFolders) {
        KBArticle kbArticle = getKBFolderKBArticle(groupId, kbFolder.getKbFolderId(), kbFolder.getUrlTitle());

        if (kbArticle != null) {
            return kbArticle;
        }
    }

    return null;
}

From source file:com.liferay.knowledgebase.display.portlet.DisplayPortlet.java

License:Open Source License

protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isSignedIn()) {
        return WorkflowConstants.STATUS_APPROVED;
    }/* w ww  .  j av a  2  s. c o m*/

    String statusString = renderRequest.getParameter("status");

    int status = GetterUtil.getInteger(statusString);

    if ((statusString != null) && (status == WorkflowConstants.STATUS_APPROVED)) {

        return WorkflowConstants.STATUS_APPROVED;
    }

    Tuple resourceTuple = getResourceTuple(renderRequest);

    long resourcePrimKey = (Long) resourceTuple.getObject(1);

    if (resourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        return WorkflowConstants.STATUS_APPROVED;
    }

    long resourceClassNameId = (Long) resourceTuple.getObject(0);

    long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName());

    if (resourceClassNameId == kbArticleClassNameId) {
        KBArticle kbArticle = KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey,
                WorkflowConstants.STATUS_ANY);

        if (kbArticle == null) {
            return WorkflowConstants.STATUS_APPROVED;
        }

        if (KBArticlePermission.contains(themeDisplay.getPermissionChecker(), resourcePrimKey,
                ActionKeys.UPDATE)) {

            return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
        }
    }

    return WorkflowConstants.STATUS_APPROVED;
}

From source file:com.liferay.knowledgebase.display.selector.KBArticleKBArticleSelector.java

License:Open Source License

@Override
public KBArticle findByResourcePrimKey(long groupId, String preferredKBFolderUrlTitle,
        long ancestorResourcePrimKey, long resourcePrimKey) throws PortalException {

    KBArticle ancestorKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(ancestorResourcePrimKey,
            WorkflowConstants.STATUS_APPROVED);

    if (ancestorKBArticle == null) {
        return null;
    }/*from  ww w. j  av a 2 s .  c om*/

    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(resourcePrimKey,
            WorkflowConstants.STATUS_APPROVED);

    return getClosestMatchingDescendantKBArticle(groupId, ancestorKBArticle, kbArticle);
}

From source file:com.liferay.knowledgebase.display.selector.KBArticleKBArticleSelector.java

License:Open Source License

@Override
public KBArticle findByUrlTitle(long groupId, String preferredKBFolderUrlTitle, long ancestorResourcePrimKey,
        String kbFolderUrlTitle, String urlTitle) throws PortalException {

    KBArticle ancestorKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(ancestorResourcePrimKey,
            WorkflowConstants.STATUS_APPROVED);

    if (ancestorKBArticle == null) {
        return null;
    }/*from w w w.  j  a  va2  s. com*/

    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchLatestKBArticleByUrlTitle(groupId,
            ancestorKBArticle.getKbFolderId(), urlTitle, WorkflowConstants.STATUS_APPROVED);

    return getClosestMatchingDescendantKBArticle(groupId, ancestorKBArticle, kbArticle);
}

From source file:com.liferay.knowledgebase.display.selector.KBFolderKBArticleSelector.java

License:Open Source License

@Override
public KBArticle findByResourcePrimKey(long groupId, String preferredKBFolderUrlTitle,
        long ancestorResourcePrimKey, long resourcePrimKey) throws PortalException {

    KBFolder ancestorKBFolder = _rootKBFolder;

    if (ancestorResourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        ancestorKBFolder = KBFolderLocalServiceUtil.fetchKBFolder(ancestorResourcePrimKey);

        if (ancestorKBFolder == null) {
            return null;
        }/*from  w  w w  . j  av a  2  s .  c  o m*/
    }

    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(resourcePrimKey,
            WorkflowConstants.STATUS_APPROVED);

    if ((kbArticle == null) || !isDescendant(kbArticle, ancestorKBFolder)) {
        return findClosestMatchingKBArticle(groupId, ancestorKBFolder, preferredKBFolderUrlTitle);
    }

    return kbArticle;
}

From source file:com.liferay.knowledgebase.hook.action.FindKBArticleAction.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 plid = ParamUtil.getLong(request, "plid");
    long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
    int status = ParamUtil.getInteger(request, "status", WorkflowConstants.STATUS_APPROVED);
    boolean maximized = ParamUtil.getBoolean(request, "maximized");

    KBArticle kbArticle = getKBArticle(resourcePrimKey, status);

    if (!isValidPlid(plid)) {
        plid = themeDisplay.getPlid();/*ww  w  . j  a v  a 2s.  co m*/
    }

    PortletURL portletURL = null;

    if (kbArticle == null) {
        portletURL = getDynamicPortletURL(plid, status, request);
    }

    if (status != WorkflowConstants.STATUS_APPROVED) {
        portletURL = getDynamicPortletURL(plid, status, request);
    }

    if (portletURL == null) {
        portletURL = getKBArticleURL(plid, false, kbArticle, request);
    }

    if (portletURL == null) {
        portletURL = getKBArticleURL(plid, true, kbArticle, request);
    }

    if (portletURL == null) {
        portletURL = getDynamicPortletURL(plid, status, request);
    }

    if (maximized) {
        portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
        portletURL.setPortletMode(PortletMode.VIEW);
    }

    response.sendRedirect(portletURL.toString());

    return null;
}