List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH
int STATUS_IN_TRASH
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH.
Click Source Link
From source file:com.liferay.adaptive.media.document.library.web.internal.optimizer.DLAMImageOptimizer.java
License:Open Source License
private void _optimize(long companyId, String configurationEntryUuid, int total, AtomicInteger atomicCounter) { ActionableDynamicQuery actionableDynamicQuery = _dlFileEntryLocalService.getActionableDynamicQuery(); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override/*from w w w . ja v a2 s. co m*/ public void addCriteria(DynamicQuery dynamicQuery) { Property companyIdProperty = PropertyFactoryUtil.forName("companyId"); dynamicQuery.add(companyIdProperty.eq(companyId)); Property groupIdProperty = PropertyFactoryUtil.forName("groupId"); Property repositoryIdProperty = PropertyFactoryUtil.forName("repositoryId"); dynamicQuery.add(groupIdProperty.eqProperty(repositoryIdProperty)); Property mimeTypeProperty = PropertyFactoryUtil.forName("mimeType"); dynamicQuery.add(mimeTypeProperty.in(_amImageMimeTypeProvider.getSupportedMimeTypes())); DynamicQuery dlFileVersionDynamicQuery = _dlFileVersionLocalService.dynamicQuery(); dlFileVersionDynamicQuery.setProjection( ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("fileEntryId"))); dlFileVersionDynamicQuery.add(companyIdProperty.eq(companyId)); dlFileVersionDynamicQuery.add(groupIdProperty.eqProperty(repositoryIdProperty)); dlFileVersionDynamicQuery .add(mimeTypeProperty.in(_amImageMimeTypeProvider.getSupportedMimeTypes())); Property statusProperty = PropertyFactoryUtil.forName("status"); dlFileVersionDynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_IN_TRASH)); Property fileEntryIdProperty = PropertyFactoryUtil.forName("fileEntryId"); dynamicQuery.add(fileEntryIdProperty.notIn(dlFileVersionDynamicQuery)); } }); actionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DLFileEntry>() { @Override public void performAction(DLFileEntry dlFileEntry) throws PortalException { FileEntry fileEntry = new LiferayFileEntry(dlFileEntry); try { _amImageProcessor.process(fileEntry.getFileVersion(), configurationEntryUuid); _sendStatusMessage(atomicCounter.incrementAndGet(), total); } catch (PortalException pe) { _log.error("Unable to process file entry " + fileEntry.getFileEntryId(), pe); } } }); try { actionableDynamicQuery.performActions(); } catch (PortalException pe) { _log.error(pe, pe); } }
From source file:com.liferay.adaptive.media.image.internal.handler.AMImageRequestHandler.java
License:Open Source License
private Optional<Tuple<FileVersion, AMImageAttributeMapping>> _interpretPath(String pathInfo) { try {/* w w w . ja v a2 s .c o m*/ Optional<Tuple<FileVersion, Map<String, String>>> fileVersionPropertiesTupleOptional = _pathInterpreter .interpretPath(pathInfo); if (!fileVersionPropertiesTupleOptional.isPresent()) { return Optional.empty(); } Tuple<FileVersion, Map<String, String>> fileVersionMapTuple = fileVersionPropertiesTupleOptional.get(); FileVersion fileVersion = fileVersionMapTuple.first; if (fileVersion.getStatus() == WorkflowConstants.STATUS_IN_TRASH) { return Optional.empty(); } Map<String, String> properties = fileVersionMapTuple.second; AMAttribute<Object, Long> contentLengthAMAttribute = AMAttribute.getContentLengthAMAttribute(); properties.put(contentLengthAMAttribute.getName(), String.valueOf(fileVersion.getSize())); AMAttribute<Object, String> contentTypeAMAttribute = AMAttribute.getContentTypeAMAttribute(); properties.put(contentTypeAMAttribute.getName(), fileVersion.getMimeType()); AMAttribute<Object, String> fileNameAMAttribute = AMAttribute.getFileNameAMAttribute(); properties.put(fileNameAMAttribute.getName(), fileVersion.getFileName()); AMImageAttributeMapping amImageAttributeMapping = AMImageAttributeMapping.fromProperties(properties); return Optional.of(Tuple.of(fileVersion, amImageAttributeMapping)); } catch (AMRuntimeException | NumberFormatException e) { _log.error(e); return Optional.empty(); } }
From source file:com.liferay.blogs.internal.search.BlogsEntryIndexer.java
License:Open Source License
protected void reindexEntries(long companyId) throws PortalException { final IndexableActionableDynamicQuery indexableActionableDynamicQuery = _blogsEntryLocalService .getIndexableActionableDynamicQuery(); indexableActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override/* w ww.ja va2s.c om*/ public void addCriteria(DynamicQuery dynamicQuery) { Property displayDateProperty = PropertyFactoryUtil.forName("displayDate"); dynamicQuery.add(displayDateProperty.lt(new Date())); Property statusProperty = PropertyFactoryUtil.forName("status"); Integer[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }; dynamicQuery.add(statusProperty.in(statuses)); } }); indexableActionableDynamicQuery.setCompanyId(companyId); indexableActionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<BlogsEntry>() { @Override public void performAction(BlogsEntry entry) { try { Document document = getDocument(entry); indexableActionableDynamicQuery.addDocuments(document); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to index blogs entry " + entry.getEntryId(), pe); } } } }); indexableActionableDynamicQuery.setSearchEngineId(getSearchEngineId()); indexableActionableDynamicQuery.performActions(); }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
/** * Moves the blogs entry to the recycle bin. Social activity counters for * this entry get disabled.//from w ww . jav a 2 s . co m * * @param userId the primary key of the user moving the blogs entry * @param entry the blogs entry to be moved * @return the moved blogs entry */ @Indexable(type = IndexableType.REINDEX) @Override public BlogsEntry moveEntryToTrash(long userId, BlogsEntry entry) throws PortalException { // Entry if (entry.isInTrash()) { throw new TrashEntryException(); } int oldStatus = entry.getStatus(); if (oldStatus == WorkflowConstants.STATUS_PENDING) { entry.setStatus(WorkflowConstants.STATUS_DRAFT); blogsEntryPersistence.update(entry); } entry = updateStatus(userId, entry.getEntryId(), WorkflowConstants.STATUS_IN_TRASH, new ServiceContext()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", entry.getTitle()); SocialActivityManagerUtil.addActivity(userId, entry, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); // Workflow if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(entry.getCompanyId(), entry.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId()); } return entry; }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override//from ww w . j a va 2s. c o m public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { // Entry User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId); int oldStatus = entry.getStatus(); if ((status == WorkflowConstants.STATUS_APPROVED) && now.before(entry.getDisplayDate())) { status = WorkflowConstants.STATUS_SCHEDULED; } entry.setStatus(status); entry.setStatusByUserId(user.getUserId()); entry.setStatusByUserName(user.getFullName()); entry.setStatusDate(serviceContext.getModifiedDate(now)); if ((status == WorkflowConstants.STATUS_APPROVED) && Validator.isNull(entry.getUrlTitle())) { entry.setUrlTitle(getUniqueUrlTitle(entryId, entry.getGroupId(), entry.getTitle())); } blogsEntryPersistence.update(entry); // Statistics blogsStatsUserLocalService.updateStatsUser(entry.getGroupId(), entry.getUserId(), entry.getDisplayDate()); AssetEntry assetEntry = assetEntryLocalService.fetchEntry(BlogsEntry.class.getName(), entryId); if ((assetEntry == null) || (assetEntry.getPublishDate() == null)) { serviceContext.setCommand(Constants.ADD); } JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", entry.getTitle()); if (status == WorkflowConstants.STATUS_APPROVED) { // Asset assetEntryLocalService.updateEntry(BlogsEntry.class.getName(), entryId, entry.getDisplayDate(), null, true, true); // Social if ((oldStatus != WorkflowConstants.STATUS_IN_TRASH) && (oldStatus != WorkflowConstants.STATUS_SCHEDULED)) { if (serviceContext.isCommandUpdate()) { SocialActivityManagerUtil.addActivity(user.getUserId(), entry, BlogsActivityKeys.UPDATE_ENTRY, extraDataJSONObject.toString(), 0); } else { SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), entry, BlogsActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), 0); } } // Trash if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) { if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { CommentManagerUtil.restoreDiscussionFromTrash(BlogsEntry.class.getName(), entryId); } trashEntryLocalService.deleteEntry(BlogsEntry.class.getName(), entryId); } if (oldStatus != WorkflowConstants.STATUS_IN_TRASH) { // Subscriptions notifySubscribers(userId, entry, serviceContext, workflowContext); // Ping String[] trackbacks = (String[]) serviceContext.getAttribute("trackbacks"); Boolean pingOldTrackbacks = ParamUtil.getBoolean(serviceContext, "pingOldTrackbacks"); pingGoogle(entry, serviceContext); pingPingback(entry, serviceContext); pingTrackbacks(entry, trackbacks, pingOldTrackbacks, serviceContext); } } else { // Asset assetEntryLocalService.updateVisible(BlogsEntry.class.getName(), entryId, false); // Social if ((status == WorkflowConstants.STATUS_SCHEDULED) && (oldStatus != WorkflowConstants.STATUS_IN_TRASH)) { if (serviceContext.isCommandUpdate()) { SocialActivityManagerUtil.addActivity(user.getUserId(), entry, BlogsActivityKeys.UPDATE_ENTRY, extraDataJSONObject.toString(), 0); } else { SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), entry, BlogsActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), 0); } } // Trash if (status == WorkflowConstants.STATUS_IN_TRASH) { if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { CommentManagerUtil.moveDiscussionToTrash(BlogsEntry.class.getName(), entryId); } trashEntryLocalService.addTrashEntry(userId, entry.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId(), entry.getUuid(), null, oldStatus, null, null); } else if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) { if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { CommentManagerUtil.restoreDiscussionFromTrash(BlogsEntry.class.getName(), entryId); } trashEntryLocalService.deleteEntry(BlogsEntry.class.getName(), entryId); } } return entry; }
From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
@Override public List<BlogsEntry> getCompanyEntries(long companyId, Date displayDate, int status, int max) throws PortalException { List<BlogsEntry> entries = new ArrayList<>(); boolean listNotExhausted = true; QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(status, false, 0, 0, new EntryDisplayDateComparator()); if (status == WorkflowConstants.STATUS_ANY) { queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true); }//from w w w .ja v a2s . co m while ((entries.size() < max) && listNotExhausted) { queryDefinition.setEnd(queryDefinition.getStart() + max); List<BlogsEntry> entryList = blogsEntryLocalService.getCompanyEntries(companyId, displayDate, queryDefinition); queryDefinition.setStart(queryDefinition.getStart() + max); listNotExhausted = (entryList.size() == max); for (BlogsEntry entry : entryList) { if (entries.size() >= max) { break; } if (BlogsEntryPermission.contains(getPermissionChecker(), entry, ActionKeys.VIEW)) { entries.add(entry); } } } return entries; }
From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
@Override public List<BlogsEntry> getGroupEntries(long groupId, Date displayDate, int status, int start, int end) { if (status == WorkflowConstants.STATUS_ANY) { return blogsEntryPersistence.filterFindByG_LtD_NotS(groupId, displayDate, WorkflowConstants.STATUS_IN_TRASH, start, end); } else {/*from w w w .j a v a 2s. c o m*/ return blogsEntryPersistence.filterFindByG_LtD_S(groupId, displayDate, status, start, end); } }
From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
@Override public List<BlogsEntry> getGroupEntries(long groupId, int status, int start, int end) { if (status == WorkflowConstants.STATUS_ANY) { return blogsEntryPersistence.filterFindByG_NotS(groupId, WorkflowConstants.STATUS_IN_TRASH, start, end); } else {/*ww w. j a va2 s.c o m*/ return blogsEntryPersistence.filterFindByG_S(groupId, status, start, end); } }
From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
@Override public List<BlogsEntry> getGroupEntries(long groupId, int status, int start, int end, OrderByComparator<BlogsEntry> obc) { if (status == WorkflowConstants.STATUS_ANY) { return blogsEntryPersistence.filterFindByG_NotS(groupId, WorkflowConstants.STATUS_IN_TRASH, start, end, obc);/*from w ww .ja v a 2 s . c om*/ } else { return blogsEntryPersistence.filterFindByG_S(groupId, status, start, end, obc); } }
From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
@Override public int getGroupEntriesCount(long groupId, Date displayDate, int status) { if (status == WorkflowConstants.STATUS_ANY) { return blogsEntryPersistence.filterCountByG_LtD_NotS(groupId, displayDate, WorkflowConstants.STATUS_IN_TRASH); } else {/*from ww w.ja v a 2 s . c om*/ return blogsEntryPersistence.filterCountByG_LtD_S(groupId, displayDate, status); } }