List of usage examples for com.liferay.portal.kernel.service ServiceContext clone
@Override
public Object clone()
From source file:com.liferay.blogs.test.util.BlogsTestUtil.java
License:Open Source License
public static BlogsEntry addEntryWithWorkflow(long userId, String title, boolean approved, ServiceContext serviceContext) throws Exception { boolean workflowEnabled = WorkflowThreadLocal.isEnabled(); try {//www . ja v a 2 s. co m WorkflowThreadLocal.setEnabled(true); Calendar displayCalendar = CalendarFactoryUtil.getCalendar(2012, 1, 1); serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); BlogsEntry entry = BlogsEntryLocalServiceUtil.addEntry(userId, title, RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), displayCalendar.getTime(), true, true, new String[0], StringPool.BLANK, null, null, serviceContext); if (approved) { return updateStatus(entry, serviceContext); } return entry; } finally { WorkflowThreadLocal.setEnabled(workflowEnabled); } }
From source file:com.liferay.bookmarks.util.test.BookmarksTestUtil.java
License:Open Source License
public static BookmarksEntry addEntry(String name, long folderId, boolean approved, ServiceContext serviceContext) throws Exception { boolean workflowEnabled = WorkflowThreadLocal.isEnabled(); try {/* w w w . j ava 2 s. c o m*/ WorkflowThreadLocal.setEnabled(true); String url = "http://www.liferay.com"; String description = "This is a test entry."; serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); BookmarksEntry entry = BookmarksEntryServiceUtil.addEntry(serviceContext.getScopeGroupId(), folderId, name, url, description, serviceContext); serviceContext.setCommand(Constants.ADD); serviceContext.setLayoutFullURL("http://localhost"); if (approved) { entry.setStatus(WorkflowConstants.STATUS_APPROVED); entry = BookmarksEntryServiceUtil.updateEntry(entry.getEntryId(), serviceContext.getScopeGroupId(), entry.getFolderId(), entry.getName(), entry.getUrl(), entry.getUrl(), serviceContext); } return entry; } finally { WorkflowThreadLocal.setEnabled(workflowEnabled); } }
From source file:com.liferay.calendar.test.util.CalendarBookingTestUtil.java
License:Open Source License
public static CalendarBooking addRegularCalendarBookingWithWorkflow(User user, Calendar calendar, ServiceContext serviceContext) throws PortalException { boolean workflowEnabled = WorkflowThreadLocal.isEnabled(); try {/* www . j a v a 2 s . c om*/ WorkflowThreadLocal.setEnabled(true); serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); return addRegularCalendarBooking(user, calendar, serviceContext); } finally { WorkflowThreadLocal.setEnabled(workflowEnabled); } }
From source file:com.liferay.journal.test.util.JournalTestUtil.java
License:Open Source License
public static JournalArticle addArticle(long groupId, long folderId, long classNameId, String articleId, boolean autoArticleId, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, Map<Locale, String> contentMap, String layoutUuid, Locale defaultLocale, Date expirationDate, boolean workflowEnabled, boolean approved, ServiceContext serviceContext) throws Exception { String content = DDMStructureTestUtil.getSampleStructuredContent(contentMap, LocaleUtil.toLanguageId(defaultLocale)); DDMForm ddmForm = DDMStructureTestUtil.getSampleDDMForm(_locales, defaultLocale); long ddmGroupId = GetterUtil.getLong(serviceContext.getAttribute("ddmGroupId"), groupId); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(ddmGroupId, JournalArticle.class.getName(), ddmForm, defaultLocale);/* ww w . ja v a 2s. c o m*/ DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(ddmGroupId, ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class)); boolean neverExpire = true; int expirationDateDay = 0; int expirationDateMonth = 0; int expirationDateYear = 0; int expirationDateHour = 0; int expirationDateMinute = 0; if (expirationDate != null) { neverExpire = false; Calendar expirationCal = CalendarFactoryUtil.getCalendar(TestPropsValues.getUser().getTimeZone()); expirationCal.setTime(expirationDate); expirationDateMonth = expirationCal.get(Calendar.MONTH); expirationDateDay = expirationCal.get(Calendar.DATE); expirationDateYear = expirationCal.get(Calendar.YEAR); expirationDateHour = expirationCal.get(Calendar.HOUR_OF_DAY); expirationDateMinute = expirationCal.get(Calendar.MINUTE); } Calendar displayCal = CalendarFactoryUtil.getCalendar(TestPropsValues.getUser().getTimeZone()); int displayDateDay = displayCal.get(Calendar.DATE); int displayDateMonth = displayCal.get(Calendar.MONTH); int displayDateYear = displayCal.get(Calendar.YEAR); int displayDateHour = displayCal.get(Calendar.HOUR_OF_DAY); int displayDateMinute = displayCal.get(Calendar.MINUTE); if (workflowEnabled) { serviceContext = (ServiceContext) serviceContext.clone(); if (approved) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } } return JournalArticleLocalServiceUtil.addArticle(serviceContext.getUserId(), groupId, folderId, classNameId, 0, articleId, autoArticleId, JournalArticleConstants.VERSION_DEFAULT, titleMap, descriptionMap, content, ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, 0, 0, 0, 0, 0, true, true, false, null, null, null, null, serviceContext); }
From source file:com.liferay.journal.test.util.JournalTestUtil.java
License:Open Source License
public static JournalArticle updateArticle(long userId, JournalArticle article, Map<Locale, String> titleMap, String content, boolean workflowEnabled, boolean approved, ServiceContext serviceContext) throws Exception { if (workflowEnabled) { serviceContext = (ServiceContext) serviceContext.clone(); if (approved) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else {//from w w w . j a v a 2 s . c om serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } } 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(TestPropsValues.getUser().getTimeZone()); displayCal.setTime(displayDate); displayDateMonth = displayCal.get(Calendar.MONTH); displayDateDay = displayCal.get(Calendar.DATE); displayDateYear = displayCal.get(Calendar.YEAR); displayDateHour = displayCal.get(Calendar.HOUR_OF_DAY); displayDateMinute = displayCal.get(Calendar.MINUTE); } serviceContext.setCommand(Constants.UPDATE); serviceContext.setLayoutFullURL("http://localhost"); return JournalArticleLocalServiceUtil.updateArticle(userId, article.getGroupId(), article.getFolderId(), article.getArticleId(), article.getVersion(), titleMap, article.getDescriptionMap(), content, article.getDDMStructureKey(), article.getDDMTemplateKey(), article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, 0, 0, 0, 0, 0, true, 0, 0, 0, 0, 0, true, article.getIndexable(), article.isSmallImage(), article.getSmallImageURL(), null, null, null, serviceContext); }
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 {/* w ww. j av a 2 s . c om*/ 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.wiki.ratings.test.WikiPageRatingsTest.java
License:Open Source License
@Override protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext) throws Exception { serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); return WikiNodeLocalServiceUtil.addNode(TestPropsValues.getUserId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); }
From source file:com.liferay.wiki.search.test.WikiPageSearchTest.java
License:Open Source License
@Override protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext) throws Exception { serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.STATUS_APPROVED); return WikiNodeLocalServiceUtil.addNode(TestPropsValues.getUserId(), getSearchKeywords(), getSearchKeywords(), serviceContext); }
From source file:com.liferay.wiki.trash.test.WikiNodeTrashHandlerTest.java
License:Open Source License
@Override protected BaseModel<?> addBaseModelWithWorkflow(BaseModel<?> parentBaseModel, ServiceContext serviceContext) throws Exception { serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); return WikiNodeLocalServiceUtil.addNode(TestPropsValues.getUserId(), _NODE_NAME, RandomTestUtil.randomString(), serviceContext); }
From source file:com.liferay.wiki.util.test.WikiPageTrashHandlerTestUtil.java
License:Open Source License
public static BaseModel<?> addBaseModelWithWorkflow(BaseModel<?> parentBaseModel, boolean approved, ServiceContext serviceContext) throws Exception { serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); return WikiTestUtil.addPage(TestPropsValues.getUserId(), serviceContext.getScopeGroupId(), (Long) parentBaseModel.getPrimaryKeyObj(), getSearchKeywords(), approved); }