List of usage examples for com.liferay.portal.atom AtomUtil getUser
public static User getUser(AtomRequestContext atomRequestContext)
From source file:com.liferay.portlet.journal.atom.JournalArticleAtomCollectionProvider.java
License:Open Source License
@Override protected JournalArticle doPostEntry(String title, String summary, String content, Date date, AtomRequestContext atomRequestContext) throws Exception { User user = AtomUtil.getUser(atomRequestContext); long groupId = atomRequestContext.getLongParameter("groupId"); long classNameId = 0; long classPK = 0; String articleId = StringPool.BLANK; boolean autoArticleId = true; Locale locale = LocaleUtil.getDefault(); Map<Locale, String> titleMap = new HashMap<Locale, String>(); titleMap.put(locale, title);//from w w w . j a v a 2 s . c o m Map<Locale, String> descriptionMap = new HashMap<Locale, String>(); String type = atomRequestContext.getParameter("type", "general"); String structureId = null; String templateId = 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 = JournalArticleServiceUtil.addArticle(groupId, classNameId, classPK, articleId, autoArticleId, titleMap, descriptionMap, content, type, structureId, templateId, 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 = JournalArticleLocalServiceUtil.updateStatus(user.getUserId(), groupId, journalArticle.getArticleId(), version, status, articleURL, serviceContext); return journalArticle; }
From source file:com.liferay.portlet.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 { User user = AtomUtil.getUser(atomRequestContext); long groupId = journalArticle.getGroupId(); String articleId = journalArticle.getArticleId(); double version = journalArticle.getVersion(); ServiceContext serviceContext = new ServiceContext(); serviceContext.setScopeGroupId(groupId); journalArticle = JournalArticleServiceUtil.updateArticle(groupId, articleId, version, content, serviceContext);/* w ww .j a v a2 s .c o m*/ int status = WorkflowConstants.STATUS_APPROVED; String articleURL = StringPool.BLANK; JournalArticleLocalServiceUtil.updateStatus(user.getUserId(), groupId, journalArticle.getArticleId(), journalArticle.getVersion(), status, articleURL, serviceContext); }