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.google.mail.groups.hook.listeners.RoleModelListener.java

License:Open Source License

protected List<User> getUsers(Object classPK, String associationClassName, Object associationClassPK)
        throws PortalException {

    Role role = RoleLocalServiceUtil.getRole((Long) classPK);

    String roleName = role.getName();

    if (!roleName.equals(PortletPropsValues.EMAIL_LARGE_GROUP_ROLE)) {
        return null;
    }//from  w  w  w .  j a v a 2s .c om

    if (associationClassName.equals(Group.class.getName())) {
        LinkedHashMap<String, Object> userParams = new LinkedHashMap<String, Object>();

        userParams.put("inherit", Boolean.TRUE);
        userParams.put("usersGroups", associationClassPK);

        return UserLocalServiceUtil.search(role.getCompanyId(), null, WorkflowConstants.STATUS_APPROVED,
                userParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null);
    }

    if (associationClassName.equals(Organization.class.getName())) {
        return UserLocalServiceUtil.getOrganizationUsers((Long) associationClassPK);
    }

    if (associationClassName.equals(User.class.getName())) {
        return Arrays.asList(UserLocalServiceUtil.getUser((Long) associationClassPK));
    }

    if (associationClassName.equals(UserGroup.class.getName())) {
        return UserLocalServiceUtil.getUserGroupUsers((Long) associationClassPK);
    }

    return new ArrayList<User>();
}

From source file:com.liferay.google.mail.groups.util.GoogleMailGroupsUtil.java

License:Open Source License

public static void checkLargeGroup(Group group) throws PortalException {
    if ((PortletPropsValues.EMAIL_LARGE_GROUP_SIZE < 0)
            || Validator.isNull(PortletPropsValues.EMAIL_LARGE_GROUP_ROLE)) {

        return;/*  w w w  .j a v a  2  s.c o m*/
    }

    String whoCanPostMessage = null;

    boolean largeGroup = isLargeGroup(group);

    LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();

    params.put("inherit", Boolean.TRUE);
    params.put("usersGroups", group.getGroupId());

    int count = UserLocalServiceUtil.searchCount(group.getCompanyId(), null, WorkflowConstants.STATUS_APPROVED,
            params);

    if (!largeGroup && (count >= PortletPropsValues.EMAIL_LARGE_GROUP_SIZE)) {

        ExpandoValueLocalServiceUtil.addValue(group.getCompanyId(), Group.class.getName(),
                ExpandoTableConstants.DEFAULT_TABLE_NAME, "googleMailGroupsLargeGroup", group.getGroupId(),
                true);

        whoCanPostMessage = "ALL_MANAGERS_CAN_POST";

        updateGroupManagers(group);
    } else if (largeGroup && (count < PortletPropsValues.EMAIL_LARGE_GROUP_SIZE)) {

        ExpandoValue expandoValue = ExpandoValueLocalServiceUtil.getValue(group.getCompanyId(),
                Group.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, "googleMailGroupsLargeGroup",
                group.getGroupId());

        expandoValue.setBoolean(false);

        ExpandoValueLocalServiceUtil.updateExpandoValue(expandoValue);

        whoCanPostMessage = "ANYONE_CAN_POST";
    } else {
        return;
    }

    String groupEmailAddress = getGroupEmailAddress(group);

    Groups groups = GoogleGroupssettingsUtil.getGroups(groupEmailAddress);

    if (groups == null) {
        return;
    }

    groups.setWhoCanPostMessage(whoCanPostMessage);

    GoogleGroupssettingsUtil.updateGroups(groupEmailAddress, groups);
}

From source file:com.liferay.google.mail.groups.util.GoogleMailGroupsUtil.java

License:Open Source License

public static void syncGroups() throws Exception {
    ActionableDynamicQuery actionableDynamicQuery = new GroupActionableDynamicQuery() {

        @Override// ww w  .j  ava  2s.  c o  m
        protected void performAction(Object object) throws PortalException {
            Group group = (Group) object;

            if (!isSync(group)) {
                return;
            }

            List<String> groupMemberEmailAddresses = new ArrayList<String>();
            Members members = null;

            String groupEmailAddress = getGroupEmailAddress(group);

            if (GoogleDirectoryUtil.getGroup(groupEmailAddress) == null) {
                try {
                    GoogleDirectoryUtil.addGroup(group.getDescriptiveName(), groupEmailAddress);
                } catch (Exception e) {
                    _log.error("Unable to add Google group for " + group.getDescriptiveName(), e);

                    return;
                }
            } else {
                members = GoogleDirectoryUtil.getGroupMembers(groupEmailAddress);
            }

            if ((members != null) && (members.getMembers() != null)) {
                for (Member member : members.getMembers()) {
                    groupMemberEmailAddresses.add(member.getEmail());
                }
            }

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

            LinkedHashMap<String, Object> userParams = new LinkedHashMap<String, Object>();

            userParams.put("inherit", Boolean.TRUE);
            userParams.put("usersGroups", new Long(group.getGroupId()));

            List<User> users = UserLocalServiceUtil.search(group.getCompanyId(), null,
                    WorkflowConstants.STATUS_APPROVED, userParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    (OrderByComparator) null);

            for (User user : users) {
                emailAddresses.add(getUserEmailAddress(user));
            }

            for (String groupMemberEmailAddress : groupMemberEmailAddresses) {

                if (emailAddresses.contains(groupMemberEmailAddress)) {
                    continue;
                }

                try {
                    GoogleDirectoryUtil.deleteGroupMember(groupEmailAddress, groupMemberEmailAddress);
                } catch (Exception e) {
                    StringBundler sb = new StringBundler(4);

                    sb.append("Unable to delete ");
                    sb.append(groupMemberEmailAddress);
                    sb.append(" from Google group ");
                    sb.append(groupEmailAddress);

                    _log.error(sb.toString(), e);
                }
            }

            for (String emailAddress : emailAddresses) {
                if (groupMemberEmailAddresses.contains(emailAddress)) {
                    continue;
                }

                try {
                    GoogleDirectoryUtil.addGroupMember(groupEmailAddress, emailAddress);
                } catch (Exception e) {
                    StringBundler sb = new StringBundler(4);

                    sb.append("Unable to add ");
                    sb.append(emailAddress);
                    sb.append(" to Google group ");
                    sb.append(groupEmailAddress);

                    _log.error(sb.toString(), e);
                }
            }

            checkLargeGroup(group);
        }
    };

    actionableDynamicQuery.performActions();
}

From source file:com.liferay.grow.wiki.helper.service.impl.WikiHelperServiceImpl.java

License:Open Source License

@Override
public JSONObject getChildWikiPages(long nodeId, String title) throws PortalException {

    JSONObject childWikiPagesJSONObject = JSONFactoryUtil.createJSONObject();

    try {/*from  w  ww .  j a  v  a  2  s .c  o m*/
        WikiPage wikiPage = _wikiPageLocalService.getPage(nodeId, title);

        long childPagesCount = _wikiPageLocalService.getChildrenCount(wikiPage.getNodeId(), true,
                wikiPage.getTitle());

        childWikiPagesJSONObject.put("childPagesCount", childPagesCount);

        List<WikiPage> childPages = _wikiPageLocalService.getChildren(wikiPage.getNodeId(), true,
                wikiPage.getTitle(), WorkflowConstants.STATUS_APPROVED, 0, 60,
                new PageModifiedDateComparator());

        JSONArray childPagesJSONArray = JSONFactoryUtil.createJSONArray();

        for (WikiPage childPage : childPages) {
            childPagesJSONArray.put(getWikiPageJSONObject(childPage));
        }

        childWikiPagesJSONObject.put("childPages", childPagesJSONArray);
    } catch (Exception e) {
        _log.error("Cannot create childWikiPagesJSONObject ", e);
    }

    return childWikiPagesJSONObject;
}

From source file:com.liferay.invitation.invite.members.util.InviteMembersUserHelper.java

License:Open Source License

public List<User> getAvailableUsers(long companyId, long groupId, String keywords, int start, int end)
        throws Exception {

    LinkedHashMap usersParams = new LinkedHashMap();

    usersParams.put("usersInvited",
            new CustomSQLParam(CustomSQLUtil.get(getClass(),
                    "com.liferay.portal.service.persistence.UserFinder." + "filterByUsersGroupsGroupId"),
                    groupId));//from  www.j  a v  a 2  s . c  o  m

    return _userLocalService.search(companyId, keywords, WorkflowConstants.STATUS_APPROVED, usersParams, start,
            end, new UserFirstNameComparator(true));
}

From source file:com.liferay.invitation.invite.members.util.InviteMembersUserHelper.java

License:Open Source License

public int getAvailableUsersCount(long companyId, long groupId, String keywords) throws Exception {

    LinkedHashMap usersParams = new LinkedHashMap();

    usersParams.put("usersInvited",
            new CustomSQLParam(CustomSQLUtil.get(getClass(),
                    "com.liferay.portal.service.persistence.UserFinder." + "filterByUsersGroupsGroupId"),
                    groupId));/*from w  ww .j a  va2 s.c  om*/

    return _userLocalService.searchCount(companyId, keywords, WorkflowConstants.STATUS_APPROVED, usersParams);
}

From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

@Override
protected Iterable<JournalArticle> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    List<JournalArticle> journalArticles = new ArrayList<>();

    long companyId = CompanyThreadLocal.getCompanyId();
    long groupId = atomRequestContext.getLongParameter("groupId");

    if ((companyId <= 0) || (groupId <= 0)) {
        return journalArticles;
    }/*ww w  .  j  a v  a 2s  . c o  m*/

    List<Long> folderIds = Collections.emptyList();
    long classNameId = 0;
    String keywords = null;
    Double version = null;
    String ddmStructureKey = null;
    String ddmTemplateKey = null;
    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;

    OrderByComparator<JournalArticle> obc = new ArticleVersionComparator();

    int count = _journalArticleService.searchCount(companyId, groupId, folderIds, classNameId, keywords,
            version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    journalArticles = _journalArticleService.search(companyId, groupId, folderIds, classNameId, keywords,
            version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate,
            atomPager.getStart(), atomPager.getEnd() + 1, obc);

    return journalArticles;
}

From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

@Override
protected JournalArticle doPostEntry(String title, String summary, String content, Date date,
        AtomRequestContext atomRequestContext) throws Exception {

    long groupId = atomRequestContext.getLongParameter("groupId");
    long folderId = 0;
    long classNameId = 0;
    long classPK = 0;
    String articleId = StringPool.BLANK;
    boolean autoArticleId = true;

    Locale locale = LocaleUtil.getDefault();

    Map<Locale, String> titleMap = new HashMap<>();

    titleMap.put(locale, title);/*from   w ww  .ja v a2 s . co m*/

    Map<Locale, String> descriptionMap = new HashMap<>();

    String ddmStructureKey = null;
    String ddmTemplateKey = null;
    String layoutUuid = null;

    Calendar cal = Calendar.getInstance();

    cal.setTime(date);

    int displayDateMonth = cal.get(Calendar.MONTH);
    int displayDateDay = cal.get(Calendar.DAY_OF_MONTH);
    int displayDateYear = cal.get(Calendar.YEAR);
    int displayDateHour = cal.get(Calendar.HOUR_OF_DAY);
    int displayDateMinute = cal.get(Calendar.MINUTE);

    int expirationDateMonth = 0;
    int expirationDateDay = 0;
    int expirationDateYear = 0;
    int expirationDateHour = 0;
    int expirationDateMinute = 0;
    boolean neverExpire = true;
    int reviewDateMonth = 0;
    int reviewDateDay = 0;
    int reviewDateYear = 0;
    int reviewDateHour = 0;
    int reviewDateMinute = 0;
    boolean neverReview = true;
    boolean indexable = true;
    String articleURL = StringPool.BLANK;

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(false);
    serviceContext.setAddGuestPermissions(false);
    serviceContext.setScopeGroupId(groupId);

    JournalArticle journalArticle = _journalArticleService.addArticle(groupId, folderId, classNameId, classPK,
            articleId, autoArticleId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey,
            layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute,
            expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour,
            expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour,
            reviewDateMinute, neverReview, indexable, articleURL, serviceContext);

    double version = journalArticle.getVersion();

    int status = WorkflowConstants.STATUS_APPROVED;

    journalArticle = _journalArticleService.updateStatus(groupId, journalArticle.getArticleId(), version,
            status, articleURL, serviceContext);

    return journalArticle;
}

From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

@Override
protected void doPutEntry(JournalArticle journalArticle, String title, String summary, String content,
        Date date, AtomRequestContext atomRequestContext) throws Exception {

    long groupId = journalArticle.getGroupId();
    long folderId = journalArticle.getFolderId();
    String articleId = journalArticle.getArticleId();
    double version = journalArticle.getVersion();

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setScopeGroupId(groupId);

    journalArticle = _journalArticleService.updateArticle(groupId, folderId, articleId, version, content,
            serviceContext);//w ww  .  ja  v a2  s  .com

    int status = WorkflowConstants.STATUS_APPROVED;
    String articleURL = StringPool.BLANK;

    _journalArticleService.updateStatus(groupId, journalArticle.getArticleId(), journalArticle.getVersion(),
            status, articleURL, serviceContext);
}

From source file:com.liferay.journal.content.web.internal.exportimport.portlet.preferences.processor.JournalContentExportImportPortletPreferencesProcessor.java

License:Open Source License

@Override
public PortletPreferences processExportPortletPreferences(PortletDataContext portletDataContext,
        PortletPreferences portletPreferences) throws PortletDataException {

    String portletId = portletDataContext.getPortletId();

    try {//w w  w  . ja v a 2 s . c o m
        portletDataContext.addPortletPermissions(JournalPermission.RESOURCE_NAME);
    } catch (PortalException pe) {
        throw new PortletDataException("Unable to export portlet permissions", pe);
    }

    String articleId = portletPreferences.getValue("articleId", null);

    if (articleId == null) {
        if (_log.isDebugEnabled()) {
            _log.debug("No article ID found in preferences of portlet " + portletId);
        }

        return portletPreferences;
    }

    long articleGroupId = GetterUtil.getLong(portletPreferences.getValue("groupId", StringPool.BLANK));

    if (articleGroupId <= 0) {
        if (_log.isWarnEnabled()) {
            _log.warn("No group ID found in preferences of portlet " + portletId);
        }

        return portletPreferences;
    }

    Group group = _groupLocalService.fetchGroup(articleGroupId);

    if (ExportImportThreadLocal.isStagingInProcess() && !group.isStagedPortlet(JournalPortletKeys.JOURNAL)) {

        if (_log.isDebugEnabled()) {
            _log.debug("Web content is not staged in the site " + group.getName());
        }

        return portletPreferences;
    }

    long previousScopeGroupId = portletDataContext.getScopeGroupId();

    if (articleGroupId != previousScopeGroupId) {
        portletDataContext.setScopeGroupId(articleGroupId);
    }

    JournalArticle article = null;

    article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId,
            WorkflowConstants.STATUS_APPROVED);

    if (article == null) {
        article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId,
                WorkflowConstants.STATUS_EXPIRED);
    }

    if (article == null) {
        if (_log.isWarnEnabled()) {
            _log.warn("Portlet " + portletId + " refers to an invalid article ID " + articleId);
        }

        portletDataContext.setScopeGroupId(previousScopeGroupId);

        return portletPreferences;
    }

    if (!MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.PORTLET_DATA)
            && MergeLayoutPrototypesThreadLocal.isInProgress()) {

        portletDataContext.setScopeGroupId(previousScopeGroupId);

        return portletPreferences;
    }

    StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, portletId, article);

    String defaultDDMTemplateKey = article.getDDMTemplateKey();
    String preferenceDDMTemplateKey = portletPreferences.getValue("ddmTemplateKey", null);

    if (Validator.isNotNull(defaultDDMTemplateKey) && Validator.isNotNull(preferenceDDMTemplateKey)
            && !defaultDDMTemplateKey.equals(preferenceDDMTemplateKey)) {

        try {
            DDMTemplate ddmTemplate = _ddmTemplateLocalService.fetchTemplate(article.getGroupId(),
                    _portal.getClassNameId(DDMStructure.class), preferenceDDMTemplateKey, true);

            if (ddmTemplate == null) {
                ddmTemplate = _ddmTemplateLocalService.getTemplate(article.getGroupId(),
                        _portal.getClassNameId(DDMStructure.class), defaultDDMTemplateKey, true);

                portletPreferences.setValue("ddmTemplateKey", defaultDDMTemplateKey);
            }

            StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, article, ddmTemplate,
                    PortletDataContext.REFERENCE_TYPE_STRONG);
        } catch (PortalException | ReadOnlyException e) {
            throw new PortletDataException("Unable to export referenced article template", e);
        }
    }

    portletDataContext.setScopeGroupId(previousScopeGroupId);

    return portletPreferences;
}