List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_SAVE_DRAFT
int ACTION_SAVE_DRAFT
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_SAVE_DRAFT.
Click Source Link
From source file:com.liferay.message.boards.test.util.MBTestUtil.java
License:Open Source License
public static MBMessage addMessageWithWorkflow(long groupId, long categoryId, String subject, String body, boolean approved, ServiceContext serviceContext) throws Exception { boolean workflowEnabled = WorkflowThreadLocal.isEnabled(); try {//from w ww . jav a 2s. c o m WorkflowThreadLocal.setEnabled(true); serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); MBMessage message = MBMessageLocalServiceUtil.addMessage(serviceContext.getUserId(), RandomTestUtil.randomString(), groupId, categoryId, subject, body, serviceContext); if (approved) { return updateStatus(message, serviceContext); } return message; } finally { WorkflowThreadLocal.setEnabled(workflowEnabled); } }
From source file:com.liferay.message.boards.trash.test.MBCategoryTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { MBCategory category = MBCategoryLocalServiceUtil.getCategory(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { category = MBCategoryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), primaryKey, WorkflowConstants.STATUS_DRAFT); }//from w w w. j a va2s. co m return category; }
From source file:com.liferay.message.boards.trash.test.MBThreadTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { MBThread thread = MBThreadLocalServiceUtil.getThread(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { thread = MBThreadLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), primaryKey, WorkflowConstants.STATUS_DRAFT); }// w ww . j a va 2 s . co m return thread; }
From source file:com.liferay.message.boards.web.internal.portlet.action.EditMessageMVCActionCommand.java
License:Open Source License
protected String getRedirect(ActionRequest actionRequest, ActionResponse actionResponse, MBMessage message) { if (message == null) { String redirect = ParamUtil.getString(actionRequest, "redirect"); return redirect; }/*ww w. ja va 2 s .c om*/ int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_PUBLISH); if (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT) { return getSaveAndContinueRedirect(actionRequest, actionResponse, message); } else if (message == null) { return ParamUtil.getString(actionRequest, "redirect"); } ActionResponseImpl actionResponseImpl = (ActionResponseImpl) actionResponse; PortletURL portletURL = actionResponseImpl.createRenderURL(); portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_message"); portletURL.setParameter("messageId", String.valueOf(message.getMessageId())); return portletURL.toString(); }
From source file:com.liferay.portlet.blogs.lar.BlogsPortletDataHandlerImpl.java
License:Open Source License
protected void importEntry(PortletDataContext portletDataContext, Element entryElement, BlogsEntry entry) throws Exception { long userId = portletDataContext.getUserId(entry.getUserUuid()); String content = JournalPortletDataHandlerImpl.importReferencedContent(portletDataContext, entryElement, entry.getContent());//from www .ja va 2s .c o m entry.setContent(content); Calendar displayDateCal = CalendarFactoryUtil.getCalendar(); displayDateCal.setTime(entry.getDisplayDate()); int displayDateMonth = displayDateCal.get(Calendar.MONTH); int displayDateDay = displayDateCal.get(Calendar.DATE); int displayDateYear = displayDateCal.get(Calendar.YEAR); int displayDateHour = displayDateCal.get(Calendar.HOUR); int displayDateMinute = displayDateCal.get(Calendar.MINUTE); if (displayDateCal.get(Calendar.AM_PM) == Calendar.PM) { displayDateHour += 12; } boolean allowPingbacks = entry.isAllowPingbacks(); boolean allowTrackbacks = entry.isAllowTrackbacks(); String[] trackbacks = StringUtil.split(entry.getTrackbacks()); int status = entry.getStatus(); ServiceContext serviceContext = portletDataContext.createServiceContext(entryElement, entry, _NAMESPACE); if (status != WorkflowConstants.STATUS_APPROVED) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } String smallImageFileName = null; InputStream smallImageInputStream = null; try { String smallImagePath = entryElement.attributeValue("small-image-path"); if (entry.isSmallImage() && Validator.isNotNull(smallImagePath)) { smallImageFileName = String.valueOf(entry.getSmallImageId()).concat(StringPool.PERIOD) .concat(entry.getSmallImageType()); smallImageInputStream = portletDataContext.getZipEntryAsInputStream(smallImagePath); } BlogsEntry importedEntry = null; if (portletDataContext.isDataStrategyMirror()) { BlogsEntry existingEntry = BlogsEntryUtil.fetchByUUID_G(entry.getUuid(), portletDataContext.getScopeGroupId()); if (existingEntry == null) { serviceContext.setUuid(entry.getUuid()); importedEntry = BlogsEntryLocalServiceUtil.addEntry(userId, entry.getTitle(), entry.getDescription(), entry.getContent(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, entry.isSmallImage(), entry.getSmallImageURL(), smallImageFileName, smallImageInputStream, serviceContext); } else { importedEntry = BlogsEntryLocalServiceUtil.updateEntry(userId, existingEntry.getEntryId(), entry.getTitle(), entry.getDescription(), entry.getContent(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, entry.getSmallImage(), entry.getSmallImageURL(), smallImageFileName, smallImageInputStream, serviceContext); } } else { importedEntry = BlogsEntryLocalServiceUtil.addEntry(userId, entry.getTitle(), entry.getDescription(), entry.getContent(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, entry.getSmallImage(), entry.getSmallImageURL(), smallImageFileName, smallImageInputStream, serviceContext); } portletDataContext.importClassedModel(entry, importedEntry, _NAMESPACE); } finally { StreamUtil.cleanUp(smallImageInputStream); } }
From source file:com.liferay.portlet.blogs.lar.WordPressImporter.java
License:Open Source License
protected static void importEntry(PortletDataContext context, User defaultUser, Map<String, Long> userMap, DateFormat dateFormat, Element entryEl) throws PortalException, SystemException { String creator = entryEl.elementText(SAXReaderUtil.createQName("creator", _NS_DC)); Long userId = userMap.get(creator); if (userId == null) { userId = context.getUserId(null); }//from w w w . j ava2 s .c om String title = entryEl.elementTextTrim("title"); if (Validator.isNull(title)) { title = entryEl.elementTextTrim(SAXReaderUtil.createQName("post_name", _NS_WP)); } String content = entryEl.elementText(SAXReaderUtil.createQName("encoded", _NS_CONTENT)); content = content.replaceAll("\\n", "\n<br />"); // LPS-1425 if (Validator.isNull(content)) { content = "<br />"; } String dateText = entryEl.elementTextTrim(SAXReaderUtil.createQName("post_date_gmt", _NS_WP)); Date postDate = new Date(); try { postDate = dateFormat.parse(dateText); } catch (ParseException pe) { _log.warn("Parse " + dateText, pe); } Calendar cal = Calendar.getInstance(); cal.setTime(postDate); 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); String pingStatusText = entryEl.elementTextTrim(SAXReaderUtil.createQName("ping_status", _NS_WP)); boolean allowPingbacks = pingStatusText.equalsIgnoreCase("open"); boolean allowTrackbacks = allowPingbacks; String statusText = entryEl.elementTextTrim(SAXReaderUtil.createQName("status", _NS_WP)); int workflowAction = WorkflowConstants.ACTION_PUBLISH; if (statusText.equalsIgnoreCase("draft")) { workflowAction = WorkflowConstants.ACTION_SAVE_DRAFT; } String[] assetTagNames = null; String categoryText = entryEl.elementTextTrim("category"); if (Validator.isNotNull(categoryText)) { assetTagNames = new String[] { categoryText }; } ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setAssetTagNames(assetTagNames); serviceContext.setScopeGroupId(context.getGroupId()); serviceContext.setWorkflowAction(workflowAction); BlogsEntry entry = null; try { entry = BlogsEntryLocalServiceUtil.addEntry(userId, title, StringPool.BLANK, content, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, null, false, null, null, null, serviceContext); } catch (Exception e) { _log.error("Add entry " + title, e); return; } MBMessageDisplay messageDisplay = MBMessageLocalServiceUtil.getDiscussionMessageDisplay(userId, context.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED); Map<Long, Long> messageIdMap = new HashMap<Long, Long>(); List<Node> commentNodes = entryEl.selectNodes("wp:comment", "wp:comment_parent/text()"); for (Node commentNode : commentNodes) { Element commentEl = (Element) commentNode; importComment(context, defaultUser, messageDisplay, messageIdMap, entry, commentEl); } }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.java
License:Open Source License
protected String getNextVersion(DLFileEntry dlFileEntry, boolean majorVersion, int workflowAction) throws PortalException, SystemException { String version = dlFileEntry.getVersion(); try {/*from ww w. j a v a 2 s. com*/ DLFileVersion dlFileVersion = dlFileVersionLocalService .getLatestFileVersion(dlFileEntry.getFileEntryId(), true); version = dlFileVersion.getVersion(); } catch (NoSuchFileVersionException nsfve) { } if (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT) { majorVersion = false; } int[] versionParts = StringUtil.split(version, StringPool.PERIOD, 0); if (majorVersion) { versionParts[0]++; versionParts[1] = 0; } else { versionParts[1]++; } return versionParts[0] + StringPool.PERIOD + versionParts[1]; }
From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public int putResource(WebDAVRequest webDavRequest) throws WebDAVException { File file = null;//from ww w.java2s .co m try { HttpServletRequest request = webDavRequest.getHttpServletRequest(); String[] pathArray = webDavRequest.getPathArray(); long companyId = webDavRequest.getCompanyId(); long groupId = webDavRequest.getGroupId(); long parentFolderId = getParentFolderId(companyId, pathArray); String title = WebDAVUtil.getResourceName(pathArray); String description = StringPool.BLANK; String changeLog = StringPool.BLANK; ServiceContext serviceContext = ServiceContextFactory.getInstance(request); serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId)); serviceContext.setAddGuestPermissions(true); String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE), ContentTypes.APPLICATION_OCTET_STREAM); String extension = FileUtil.getExtension(title); file = FileUtil.createTempFile(extension); FileUtil.write(file, request.getInputStream()); if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) { contentType = MimeTypesUtil.getContentType(file, title); } try { FileEntry fileEntry = DLAppServiceUtil.getFileEntry(groupId, parentFolderId, title); if (!hasLock(fileEntry, webDavRequest.getLockUuid()) && (fileEntry.getLock() != null)) { return WebDAVUtil.SC_LOCKED; } long fileEntryId = fileEntry.getFileEntryId(); description = fileEntry.getDescription(); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(FileEntry.class.getName(), fileEntry.getFileEntryId()); serviceContext.setAssetTagNames(assetTagNames); DLAppServiceUtil.updateFileEntry(fileEntryId, title, contentType, title, description, changeLog, false, file, serviceContext); } catch (NoSuchFileEntryException nsfee) { if (file.length() == 0) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType, title, description, changeLog, file, serviceContext); } if (_log.isInfoEnabled()) { _log.info("Added " + StringUtil.merge(pathArray, StringPool.SLASH)); } return HttpServletResponse.SC_CREATED; } catch (PrincipalException pe) { return HttpServletResponse.SC_FORBIDDEN; } catch (NoSuchFolderException nsfe) { return HttpServletResponse.SC_CONFLICT; } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn(pe, pe); } return HttpServletResponse.SC_CONFLICT; } catch (Exception e) { throw new WebDAVException(e); } finally { FileUtil.delete(file); } }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
public static void importArticle(PortletDataContext portletDataContext, Element articleElement) throws Exception { String path = articleElement.attributeValue("path"); if (!portletDataContext.isPathNotProcessed(path)) { return;/*from w w w. ja v a 2 s.c o m*/ } JournalArticle article = (JournalArticle) portletDataContext.getZipEntryAsObject(path); prepareLanguagesForImport(article); long userId = portletDataContext.getUserId(article.getUserUuid()); JournalCreationStrategy creationStrategy = JournalCreationStrategyFactory.getInstance(); long authorId = creationStrategy.getAuthorUserId(portletDataContext, article); if (authorId != JournalCreationStrategy.USE_DEFAULT_USER_ID_STRATEGY) { userId = authorId; } User user = UserLocalServiceUtil.getUser(userId); String articleId = article.getArticleId(); boolean autoArticleId = false; Map<String, String> articleIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalArticle.class + ".articleId"); String newArticleId = articleIds.get(articleId); // ======= Start of change ============ if (Validator.isNotNull(newArticleId)) { // A sibling of a different version was already assigned a new // article id articleId = newArticleId; } // =======end of change================ String content = article.getContent(); content = importDLFileEntries(portletDataContext, articleElement, content); Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getScopeGroupId()); content = StringUtil.replace(content, "@data_handler_group_friendly_url@", group.getFriendlyURL()); content = importLinksToLayout(portletDataContext, content); article.setContent(content); String newContent = creationStrategy.getTransformedContent(portletDataContext, article); if (!StringUtils.equals(JournalCreationStrategy.ARTICLE_CONTENT_UNCHANGED, newContent)) { article.setContent(newContent); } Map<String, String> structureIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalStructure.class); String parentStructureId = MapUtil.getString(structureIds, article.getStructureId(), article.getStructureId()); Map<String, String> templateIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalTemplate.class); String parentTemplateId = MapUtil.getString(templateIds, article.getTemplateId(), article.getTemplateId()); Date displayDate = article.getDisplayDate(); int displayDateMonth = 0; int displayDateDay = 0; int displayDateYear = 0; int displayDateHour = 0; int displayDateMinute = 0; if (displayDate != null) { Calendar displayCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); displayCal.setTime(displayDate); displayDateMonth = displayCal.get(Calendar.MONTH); displayDateDay = displayCal.get(Calendar.DATE); displayDateYear = displayCal.get(Calendar.YEAR); displayDateHour = displayCal.get(Calendar.HOUR); displayDateMinute = displayCal.get(Calendar.MINUTE); if (displayCal.get(Calendar.AM_PM) == Calendar.PM) { displayDateHour += 12; } } Date expirationDate = article.getExpirationDate(); int expirationDateMonth = 0; int expirationDateDay = 0; int expirationDateYear = 0; int expirationDateHour = 0; int expirationDateMinute = 0; boolean neverExpire = true; if (expirationDate != null) { Calendar expirationCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); expirationCal.setTime(expirationDate); expirationDateMonth = expirationCal.get(Calendar.MONTH); expirationDateDay = expirationCal.get(Calendar.DATE); expirationDateYear = expirationCal.get(Calendar.YEAR); expirationDateHour = expirationCal.get(Calendar.HOUR); expirationDateMinute = expirationCal.get(Calendar.MINUTE); neverExpire = false; if (expirationCal.get(Calendar.AM_PM) == Calendar.PM) { expirationDateHour += 12; } } Date reviewDate = article.getReviewDate(); int reviewDateMonth = 0; int reviewDateDay = 0; int reviewDateYear = 0; int reviewDateHour = 0; int reviewDateMinute = 0; boolean neverReview = true; if (reviewDate != null) { Calendar reviewCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); reviewCal.setTime(reviewDate); reviewDateMonth = reviewCal.get(Calendar.MONTH); reviewDateDay = reviewCal.get(Calendar.DATE); reviewDateYear = reviewCal.get(Calendar.YEAR); reviewDateHour = reviewCal.get(Calendar.HOUR); reviewDateMinute = reviewCal.get(Calendar.MINUTE); neverReview = false; if (reviewCal.get(Calendar.AM_PM) == Calendar.PM) { reviewDateHour += 12; } } long structurePrimaryKey = 0; if (Validator.isNotNull(article.getStructureId())) { String structureUuid = articleElement.attributeValue("structure-uuid"); JournalStructure existingStructure = JournalStructureUtil.fetchByUUID_G(structureUuid, portletDataContext.getScopeGroupId()); if (existingStructure == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); existingStructure = JournalStructureUtil.fetchByUUID_G(structureUuid, companyGroupId); } if (existingStructure == null) { String newStructureId = structureIds.get(article.getStructureId()); if (Validator.isNotNull(newStructureId)) { existingStructure = JournalStructureUtil.fetchByG_S(portletDataContext.getScopeGroupId(), String.valueOf(newStructureId)); } if (existingStructure == null) { if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(); sb.append("Structure "); sb.append(article.getStructureId()); sb.append(" is missing for article "); sb.append(article.getArticleId()); sb.append(", skipping this article."); _log.warn(sb.toString()); } return; } } structurePrimaryKey = existingStructure.getPrimaryKey(); parentStructureId = existingStructure.getStructureId(); } if (Validator.isNotNull(article.getTemplateId())) { String templateUuid = articleElement.attributeValue("template-uuid"); JournalTemplate existingTemplate = JournalTemplateUtil.fetchByUUID_G(templateUuid, portletDataContext.getScopeGroupId()); if (existingTemplate == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); existingTemplate = JournalTemplateUtil.fetchByUUID_G(templateUuid, companyGroupId); } if (existingTemplate == null) { String newTemplateId = templateIds.get(article.getTemplateId()); if (Validator.isNotNull(newTemplateId)) { existingTemplate = JournalTemplateUtil.fetchByG_T(portletDataContext.getScopeGroupId(), newTemplateId); } if (existingTemplate == null) { if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(); sb.append("Template "); sb.append(article.getTemplateId()); sb.append(" is missing for article "); sb.append(article.getArticleId()); sb.append(", skipping this article."); _log.warn(sb.toString()); } return; } } parentTemplateId = existingTemplate.getTemplateId(); } File smallFile = null; String smallImagePath = articleElement.attributeValue("small-image-path"); if (article.isSmallImage() && Validator.isNotNull(smallImagePath)) { byte[] bytes = portletDataContext.getZipEntryAsByteArray(smallImagePath); smallFile = FileUtil.createTempFile(article.getSmallImageType()); FileUtil.write(smallFile, bytes); } Map<String, byte[]> images = new HashMap<String, byte[]>(); String imagePath = articleElement.attributeValue("image-path"); if (portletDataContext.getBooleanParameter(_NAMESPACE, "images") && Validator.isNotNull(imagePath)) { List<String> imageFiles = portletDataContext.getZipFolderEntries(imagePath); for (String imageFile : imageFiles) { String fileName = imageFile; if (fileName.contains(StringPool.SLASH)) { fileName = fileName.substring(fileName.lastIndexOf(CharPool.SLASH) + 1); } if (fileName.endsWith(".xml")) { continue; } int pos = fileName.lastIndexOf(CharPool.PERIOD); if (pos != -1) { fileName = fileName.substring(0, pos); } images.put(fileName, portletDataContext.getZipEntryAsByteArray(imageFile)); } } String articleURL = null; boolean addGroupPermissions = creationStrategy.addGroupPermissions(portletDataContext, article); boolean addGuestPermissions = creationStrategy.addGuestPermissions(portletDataContext, article); ServiceContext serviceContext = portletDataContext.createServiceContext(articleElement, article, _NAMESPACE); serviceContext.setAddGroupPermissions(addGroupPermissions); serviceContext.setAddGuestPermissions(addGuestPermissions); serviceContext.setAttribute("imported", Boolean.TRUE.toString()); if (article.getStatus() != WorkflowConstants.STATUS_APPROVED) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } JournalArticle importedArticle = null; String articleResourceUuid = articleElement.attributeValue("article-resource-uuid"); if (portletDataContext.isDataStrategyMirror()) { JournalArticleResource articleResource = JournalArticleResourceUtil.fetchByUUID_G(articleResourceUuid, portletDataContext.getScopeGroupId()); if (articleResource == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); articleResource = JournalArticleResourceUtil.fetchByUUID_G(articleResourceUuid, companyGroupId); } //Modification start if (articleResource == null) { articleResource = JournalArticleResourceUtil.fetchByG_A(portletDataContext.getScopeGroupId(), articleId); } //Modification end serviceContext.setUuid(articleResourceUuid); JournalArticle existingArticle = null; if (articleResource != null) { try { existingArticle = JournalArticleLocalServiceUtil.getLatestArticle( articleResource.getResourcePrimKey(), WorkflowConstants.STATUS_ANY, false); } catch (NoSuchArticleException nsae) { } } if (existingArticle == null) { existingArticle = JournalArticleUtil.fetchByG_A_V(portletDataContext.getScopeGroupId(), newArticleId, article.getVersion()); } if (existingArticle == null) { importedArticle = JournalArticleLocalServiceUtil.addArticle(userId, portletDataContext.getScopeGroupId(), article.getClassNameId(), structurePrimaryKey, articleId, autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId, parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL, serviceContext); } else { importedArticle = JournalArticleLocalServiceUtil.updateArticle(userId, existingArticle.getGroupId(), existingArticle.getArticleId(), existingArticle.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId, parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL, serviceContext); } } else { importedArticle = JournalArticleLocalServiceUtil.addArticle(userId, portletDataContext.getScopeGroupId(), article.getClassNameId(), structurePrimaryKey, articleId, autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId, parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL, serviceContext); } if (smallFile != null) { smallFile.delete(); } portletDataContext.importClassedModel(article, importedArticle, _NAMESPACE); if (Validator.isNull(newArticleId)) { articleIds.put(article.getArticleId(), importedArticle.getArticleId()); } Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); if (importedArticle.getGroupId() == companyGroup.getGroupId()) { portletDataContext.addCompanyReference(JournalArticle.class, articleId); } if (!articleId.equals(importedArticle.getArticleId())) { if (_log.isWarnEnabled()) { _log.warn("An article with the ID " + articleId + " already " + "exists. The new generated ID is " + importedArticle.getArticleId()); } } }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutsAction.java
License:Open Source License
protected void enableLayout(ActionRequest actionRequest) throws Exception { long incompleteLayoutRevisionId = ParamUtil.getLong(actionRequest, "incompleteLayoutRevisionId"); LayoutRevision incompleteLayoutRevision = LayoutRevisionLocalServiceUtil .getLayoutRevision(incompleteLayoutRevisionId); long layoutBranchId = ParamUtil.getLong(actionRequest, "layoutBranchId", incompleteLayoutRevision.getLayoutBranchId()); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); LayoutRevisionLocalServiceUtil.updateLayoutRevision(serviceContext.getUserId(), incompleteLayoutRevision.getLayoutRevisionId(), layoutBranchId, incompleteLayoutRevision.getName(), incompleteLayoutRevision.getTitle(), incompleteLayoutRevision.getDescription(), incompleteLayoutRevision.getKeywords(), incompleteLayoutRevision.getRobots(), incompleteLayoutRevision.getTypeSettings(), incompleteLayoutRevision.getIconImage(), incompleteLayoutRevision.getIconImageId(), incompleteLayoutRevision.getThemeId(), incompleteLayoutRevision.getColorSchemeId(), incompleteLayoutRevision.getWapThemeId(), incompleteLayoutRevision.getWapColorSchemeId(), incompleteLayoutRevision.getCss(), serviceContext); }