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.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.java

License:Open Source License

protected void convertExtraSettings(DLFileEntry dlFileEntry, DLFileVersion dlFileVersion, String[] keys)
        throws PortalException, SystemException {

    UnicodeProperties extraSettingsProperties = dlFileVersion.getExtraSettingsProperties();

    ExpandoBridge expandoBridge = dlFileVersion.getExpandoBridge();

    convertExtraSettings(extraSettingsProperties, expandoBridge, keys);

    dlFileVersion.setExtraSettingsProperties(extraSettingsProperties);

    dlFileVersionPersistence.update(dlFileVersion, false);

    int status = dlFileVersion.getStatus();

    if ((status == WorkflowConstants.STATUS_APPROVED)
            && (DLUtil.compareVersions(dlFileEntry.getVersion(), dlFileVersion.getVersion()) <= 0)) {

        reindex(dlFileEntry);// w  w w  . j  a v a2s . co m
    }
}

From source file:com.liferay.portlet.documentlibrary.service.impl.DLFileShortcutLocalServiceImpl.java

License:Open Source License

public DLFileShortcut addFileShortcut(long userId, long groupId, long folderId, long toFileEntryId,
        ServiceContext serviceContext) throws PortalException, SystemException {

    // File shortcut

    User user = userPersistence.findByPrimaryKey(userId);
    folderId = getFolderId(user.getCompanyId(), folderId);
    Date now = new Date();

    validate(user, toFileEntryId);//  ww  w  . jav  a 2  s  . c o m

    long fileShortcutId = counterLocalService.increment();

    DLFileShortcut fileShortcut = dlFileShortcutPersistence.create(fileShortcutId);

    fileShortcut.setUuid(serviceContext.getUuid());
    fileShortcut.setGroupId(groupId);
    fileShortcut.setCompanyId(user.getCompanyId());
    fileShortcut.setUserId(user.getUserId());
    fileShortcut.setUserName(user.getFullName());
    fileShortcut.setCreateDate(serviceContext.getCreateDate(now));
    fileShortcut.setModifiedDate(serviceContext.getModifiedDate(now));
    fileShortcut.setFolderId(folderId);
    fileShortcut.setToFileEntryId(toFileEntryId);
    fileShortcut.setStatus(WorkflowConstants.STATUS_APPROVED);
    fileShortcut.setStatusByUserId(userId);
    fileShortcut.setStatusByUserName(user.getFullName());
    fileShortcut.setStatusDate(now);

    dlFileShortcutPersistence.update(fileShortcut, false);

    // Resources

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

        addFileShortcutResources(fileShortcut, serviceContext.isAddGroupPermissions(),
                serviceContext.isAddGuestPermissions());
    } else {
        addFileShortcutResources(fileShortcut, serviceContext.getGroupPermissions(),
                serviceContext.getGuestPermissions());
    }

    // Folder

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        DLFolder dlFolder = dlFolderPersistence.findByPrimaryKey(folderId);

        dlFolder.setLastPostDate(fileShortcut.getModifiedDate());

        dlFolderPersistence.update(dlFolder, false);
    }

    // Asset

    FileEntry fileEntry = dlAppLocalService.getFileEntry(toFileEntryId);

    copyAssetTags(fileEntry, serviceContext);

    updateAsset(userId, fileShortcut, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());

    return fileShortcut;
}

From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java

License:Open Source License

@Override
public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception {

    int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS),
            WorkflowConstants.STATUS_APPROVED);

    if (status != WorkflowConstants.STATUS_ANY) {
        contextQuery.addRequiredTerm(Field.STATUS, status);
    }/* w  w  w . j  av  a  2s .c  o m*/

    long[] folderIds = searchContext.getFolderIds();

    if ((folderIds != null) && (folderIds.length > 0)) {
        if (folderIds[0] == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
            return;
        }

        BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

        for (long folderId : folderIds) {
            try {
                DLFolderServiceUtil.getFolder(folderId);
            } catch (Exception e) {
                continue;
            }

            folderIdsQuery.addTerm(Field.FOLDER_ID, folderId);
        }

        contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST);
    }
}

From source file:com.liferay.portlet.dynamicdatalists.action.ExportRecordSetAction.java

License:Open Source License

@Override
public void serveResource(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
    HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);

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

    long recordSetId = ParamUtil.getLong(resourceRequest, "recordSetId");

    DDLRecordSet recordSet = DDLRecordSetServiceUtil.getRecordSet(recordSetId);

    String fileExtension = ParamUtil.getString(resourceRequest, "fileExtension");

    String fileName = recordSet.getName(themeDisplay.getLocale()) + CharPool.PERIOD + fileExtension;

    DDLExportFormat exportFormat = DDLExportFormat.parse(fileExtension);

    DDLExporter exporter = DDLExporterFactory.getDDLExporter(exportFormat);

    byte[] bytes = exporter.export(recordSetId, WorkflowConstants.STATUS_APPROVED);

    String contentType = MimeTypesUtil.getContentType(fileName);

    ServletResponseUtil.sendFile(request, response, fileName, bytes, contentType);
}

From source file:com.liferay.portlet.dynamicdatalists.service.impl.DDLRecordLocalServiceImpl.java

License:Open Source License

public void updateAsset(long userId, DDLRecord record, DDLRecordVersion recordVersion, long[] assetCategoryIds,
        String[] assetTagNames, Locale locale) throws PortalException, SystemException {

    boolean addDraftAssetEntry = false;

    if ((recordVersion != null) && !recordVersion.isApproved()) {
        String version = recordVersion.getVersion();

        if (!version.equals(DDLRecordConstants.VERSION_DEFAULT)) {
            int approvedRecordVersionsCount = ddlRecordVersionPersistence.countByR_S(record.getRecordId(),
                    WorkflowConstants.STATUS_APPROVED);

            if (approvedRecordVersionsCount > 0) {
                addDraftAssetEntry = true;
            }//from w ww. j a  v a 2 s .  com
        }
    }

    boolean visible = false;

    if ((recordVersion != null) && !recordVersion.isApproved()) {
        visible = false;
    }

    DDLRecordSet recordSet = record.getRecordSet();

    String title = LanguageUtil.format(locale, "new-record-for-list-x", recordSet.getName(locale));

    if (addDraftAssetEntry) {
        assetEntryLocalService.updateEntry(userId, record.getGroupId(), DDLRecordConstants.getClassName(),
                recordVersion.getRecordVersionId(), record.getUuid(), 0, assetCategoryIds, assetTagNames, false,
                null, null, null, null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0,
                null, false);
    } else {
        assetEntryLocalService.updateEntry(userId, record.getGroupId(), DDLRecordConstants.getClassName(),
                record.getRecordId(), record.getUuid(), 0, assetCategoryIds, assetTagNames, visible, null, null,
                null, null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0, null,
                false);
    }
}

From source file:com.liferay.portlet.dynamicdatalists.service.impl.DDLRecordLocalServiceImpl.java

License:Open Source License

public DDLRecord updateStatus(long userId, long recordVersionId, int status, ServiceContext serviceContext)
        throws PortalException, SystemException {

    // Record version

    User user = userPersistence.findByPrimaryKey(userId);

    DDLRecordVersion recordVersion = ddlRecordVersionPersistence.findByPrimaryKey(recordVersionId);

    recordVersion.setStatus(status);/*from w ww  .  ja v  a  2s  . c o m*/
    recordVersion.setStatusByUserId(user.getUserId());
    recordVersion.setStatusByUserName(user.getFullName());
    recordVersion.setStatusDate(new Date());

    ddlRecordVersionPersistence.update(recordVersion, false);

    // Record

    DDLRecord record = ddlRecordPersistence.findByPrimaryKey(recordVersion.getRecordId());

    if (status == WorkflowConstants.STATUS_APPROVED) {
        if (DLUtil.compareVersions(record.getVersion(), recordVersion.getVersion()) <= 0) {

            record.setDDMStorageId(recordVersion.getDDMStorageId());
            record.setVersion(recordVersion.getVersion());
            record.setRecordSetId(recordVersion.getRecordSetId());
            record.setDisplayIndex(recordVersion.getDisplayIndex());
            record.setVersion(recordVersion.getVersion());
            record.setVersionUserId(recordVersion.getUserId());
            record.setVersionUserName(recordVersion.getUserName());
            record.setModifiedDate(recordVersion.getCreateDate());

            ddlRecordPersistence.update(record, false);
        }
    } else {
        if (record.getVersion().equals(recordVersion.getVersion())) {
            String newVersion = DDLRecordConstants.VERSION_DEFAULT;

            List<DDLRecordVersion> approvedRecordVersions = ddlRecordVersionPersistence
                    .findByR_S(record.getRecordId(), WorkflowConstants.STATUS_APPROVED);

            if (!approvedRecordVersions.isEmpty()) {
                newVersion = approvedRecordVersions.get(0).getVersion();
            }

            record.setVersion(newVersion);

            ddlRecordPersistence.update(record, false);
        }
    }

    return record;
}

From source file:com.liferay.portlet.journal.action.GetArticleAction.java

License:Open Source License

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    try {/*from w w w .  j  a  v a 2  s  .  c o  m*/
        long groupId = ParamUtil.getLong(request, "groupId");
        String articleId = ParamUtil.getString(request, "articleId");

        String languageId = LanguageUtil.getLanguageId(request);

        JournalArticle article = JournalArticleServiceUtil.getLatestArticle(groupId, articleId,
                WorkflowConstants.STATUS_APPROVED);

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

        Map<String, String> tokens = JournalUtil.getTokens(groupId, themeDisplay);

        String xml = article.getContentByLocale(languageId);

        Document doc = SAXReaderUtil.read(xml);

        Element root = doc.getRootElement();

        addProcessingInstructions(doc, request, themeDisplay, article);

        JournalUtil.addAllReservedEls(root, tokens, article, languageId);

        xml = DDMXMLUtil.formatXML(doc);

        String contentType = ContentTypes.TEXT_XML_UTF8;

        String fileName = null;
        byte[] bytes = xml.getBytes();

        ServletResponseUtil.sendFile(request, response, fileName, bytes, contentType);

        return null;
    } catch (Exception e) {
        PortalUtil.sendError(e, request, response);

        return null;
    }
}

From source file:com.liferay.portlet.journal.action.GetArticlesAction.java

License:Open Source License

protected List<JournalArticle> getArticles(HttpServletRequest request) throws Exception {

    long companyId = PortalUtil.getCompanyId(request);
    long groupId = ParamUtil.getLong(request, "groupId");
    String articleId = null;/*from ww w  . j a v  a  2 s.c  o m*/
    Double version = null;
    String title = null;
    String description = null;
    String content = null;
    String type = ParamUtil.getString(request, "type");
    String[] structureIds = StringUtil.split(ParamUtil.getString(request, "structureId"));
    String[] templateIds = StringUtil.split(ParamUtil.getString(request, "templateId"));

    Date displayDateGT = null;

    String displayDateGTParam = ParamUtil.getString(request, "displayDateGT");

    if (Validator.isNotNull(displayDateGTParam)) {
        DateFormat displayDateGTFormat = DateUtil.getISOFormat(displayDateGTParam);

        displayDateGT = GetterUtil.getDate(displayDateGTParam, displayDateGTFormat);
    }

    if (_log.isDebugEnabled()) {
        _log.debug("displayDateGT is " + displayDateGT);
    }

    Date displayDateLT = null;

    String displayDateLTParam = ParamUtil.getString(request, "displayDateLT");

    if (Validator.isNotNull(displayDateLTParam)) {
        DateFormat displayDateLTFormat = DateUtil.getISOFormat(displayDateLTParam);

        displayDateLT = GetterUtil.getDate(displayDateLTParam, displayDateLTFormat);
    }

    if (displayDateLT == null) {
        displayDateLT = new Date();
    }

    if (_log.isDebugEnabled()) {
        _log.debug("displayDateLT is " + displayDateLT);
    }

    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;
    boolean andOperator = true;
    int start = 0;
    int end = ParamUtil.getInteger(request, "delta", 5);
    String orderBy = ParamUtil.getString(request, "orderBy");
    String orderByCol = ParamUtil.getString(request, "orderByCol", orderBy);
    String orderByType = ParamUtil.getString(request, "orderByType");
    boolean orderByAsc = orderByType.equals("asc");

    OrderByComparator obc = new ArticleModifiedDateComparator(orderByAsc);

    if (orderByCol.equals("display-date")) {
        obc = new ArticleDisplayDateComparator(orderByAsc);
    }

    return JournalArticleServiceUtil.search(companyId, groupId, 0, articleId, version, title, description,
            content, type, structureIds, templateIds, displayDateGT, displayDateLT, status, reviewDate,
            andOperator, start, end, obc);
}

From source file:com.liferay.portlet.journal.action.GetLatestArticleContentAction.java

License:Open Source License

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    try {//from   w  w  w.j a  v a2  s  .  c o  m
        long groupId = ParamUtil.getLong(request, "groupId");
        String articleId = ParamUtil.getString(request, "articleId");

        String languageId = LanguageUtil.getLanguageId(request);

        JournalArticle article = JournalArticleServiceUtil.getLatestArticle(groupId, articleId,
                WorkflowConstants.STATUS_APPROVED);

        String fileName = "content.xml";
        byte[] bytes = article.getContentByLocale(languageId).getBytes();

        ServletResponseUtil.sendFile(request, response, fileName, bytes, ContentTypes.TEXT_XML_UTF8);

        return null;
    } catch (Exception e) {
        PortalUtil.sendError(e, request, response);

        return null;
    }
}

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

License:Open Source License

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

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

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

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

    long classNameId = 0;
    String keywords = null;
    Double version = null;
    String type = atomRequestContext.getParameter("type", "general");
    String structureId = null;
    String templateId = null;
    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;

    OrderByComparator obc = new ArticleVersionComparator();

    int count = JournalArticleLocalServiceUtil.searchCount(companyId, groupId, classNameId, keywords, version,
            type, structureId, templateId, displayDateGT, displayDateLT, status, reviewDate);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    journalArticles = JournalArticleLocalServiceUtil.search(companyId, groupId, classNameId, keywords, version,
            type, structureId, templateId, displayDateGT, displayDateLT, status, reviewDate,
            atomPager.getStart(), atomPager.getEnd() + 1, obc);

    return journalArticles;
}