List of usage examples for com.liferay.portal.kernel.service ServiceContext getAttributes
public Map<String, Serializable> getAttributes()
From source file:com.liferay.exportimport.system.event.test.SystemEventTest.java
License:Open Source License
public long doTestRemoteStaging() throws Exception { setPortalProperty("TUNNELING_SERVLET_SHARED_SECRET", "F0E1D2C3B4A5968778695A4B3C2D1E0F"); setPortalProperty("TUNNELING_SERVLET_SHARED_SECRET_HEX", true); _stagingGroup = GroupTestUtil.addGroup(); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(_stagingGroup.getGroupId()); Map<String, Serializable> attributes = serviceContext.getAttributes(); attributes.putAll(ExportImportConfigurationParameterMapFactory.buildParameterMap()); attributes.put(PortletDataHandlerKeys.PORTLET_CONFIGURATION_ALL, new String[] { Boolean.FALSE.toString() }); attributes.put(PortletDataHandlerKeys.PORTLET_DATA_ALL, new String[] { Boolean.FALSE.toString() }); int serverPort = PortalUtil.getPortalServerPort(false); String pathContext = PortalUtil.getPathContext(); ServiceTestUtil.setUser(TestPropsValues.getUser()); StagingLocalServiceUtil.enableRemoteStaging(TestPropsValues.getUserId(), _stagingGroup, false, false, "localhost", serverPort, pathContext, false, _liveGroup.getGroupId(), serviceContext); _exportImportConfiguration = ExportImportConfigurationFactory .buildDefaultRemotePublishingExportImportConfiguration(TestPropsValues.getUser(), _stagingGroup.getGroupId(), false, "localhost", serverPort, pathContext, false, _liveGroup.getGroupId()); JournalArticle journalArticle = JournalTestUtil.addArticle(_stagingGroup.getGroupId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID); StagingUtil.publishLayouts(TestPropsValues.getUserId(), _exportImportConfiguration); List<JournalArticle> articles = JournalArticleLocalServiceUtil.getArticles(_liveGroup.getGroupId()); Assert.assertEquals(articles.toString(), 1, articles.size()); JournalArticleLocalServiceUtil.deleteArticle(_stagingGroup.getGroupId(), journalArticle.getArticleId(), new ServiceContext()); SystemEvent systemEvent = SystemEventLocalServiceUtil.fetchSystemEvent(_stagingGroup.getGroupId(), ClassNameLocalServiceUtil.getClassNameId(JournalArticle.class), journalArticle.getResourcePrimKey(), SystemEventConstants.TYPE_DELETE); Assert.assertNotNull(systemEvent);//from w w w .java2s .co m GroupUtil.clearCache(); StagingUtil.publishLayouts(TestPropsValues.getUserId(), _exportImportConfiguration); Assert.assertEquals(0, JournalArticleLocalServiceUtil.getArticlesCount(_liveGroup.getGroupId())); journalArticle = articles.get(0); return journalArticle.getResourcePrimKey(); }
From source file:com.liferay.staging.test.StagingImplTest.java
License:Open Source License
protected void enableLocalStaging(boolean branching) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); Map<String, Serializable> attributes = serviceContext.getAttributes(); attributes.putAll(ExportImportConfigurationParameterMapFactory.buildParameterMap()); if (branching) { serviceContext.setSignedIn(true); }/*from ww w. jav a2 s .com*/ ServiceContextThreadLocal.pushServiceContext(serviceContext); enableLocalStaging(branching, serviceContext); ServiceContextThreadLocal.popServiceContext(); if (!branching) { return; } UnicodeProperties typeSettingsProperties = _group.getTypeSettingsProperties(); Assert.assertTrue(GetterUtil.getBoolean(typeSettingsProperties.getProperty("branchingPrivate"))); Assert.assertTrue(GetterUtil.getBoolean(typeSettingsProperties.getProperty("branchingPublic"))); Group stagingGroup = _group.getStagingGroup(); LayoutSetBranch layoutSetBranch = LayoutSetBranchLocalServiceUtil.fetchLayoutSetBranch( stagingGroup.getGroupId(), false, LayoutSetBranchConstants.MASTER_BRANCH_NAME); Assert.assertNotNull(layoutSetBranch); layoutSetBranch = LayoutSetBranchLocalServiceUtil.fetchLayoutSetBranch(stagingGroup.getGroupId(), true, LayoutSetBranchConstants.MASTER_BRANCH_NAME); Assert.assertNotNull(layoutSetBranch); }
From source file:com.liferay.staging.test.StagingImplTest.java
License:Open Source License
protected void enableLocalStagingWithContent(boolean stageJournal, boolean stageAssetCategories, boolean branching) throws Exception { // Layouts/*ww w. j a va 2s . c om*/ LayoutTestUtil.addLayout(_group); LayoutTestUtil.addLayout(_group); // Create content JournalArticle journalArticle = JournalTestUtil.addArticle(_group.getGroupId(), "Title", "content"); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); Map<String, String[]> parameters = ExportImportConfigurationParameterMapFactory.buildParameterMap(); parameters.put( PortletDataHandlerKeys.PORTLET_CONFIGURATION + StringPool.UNDERLINE + JournalPortletKeys.JOURNAL, new String[] { String.valueOf(stageJournal) }); parameters.put(PortletDataHandlerKeys.PORTLET_CONFIGURATION_ALL, new String[] { Boolean.FALSE.toString() }); parameters.put(PortletDataHandlerKeys.PORTLET_DATA + StringPool.UNDERLINE + JournalPortletKeys.JOURNAL, new String[] { String.valueOf(stageJournal) }); parameters.put(PortletDataHandlerKeys.PORTLET_DATA_ALL, new String[] { Boolean.FALSE.toString() }); parameters.put(PortletDataHandlerKeys.PORTLET_SETUP + StringPool.UNDERLINE + JournalPortletKeys.JOURNAL, new String[] { String.valueOf(stageJournal) }); serviceContext.setAttribute(StagingUtil.getStagedPortletId(JournalPortletKeys.JOURNAL), stageJournal); Map<String, Serializable> attributes = serviceContext.getAttributes(); attributes.putAll(parameters); enableLocalStaging(branching, serviceContext); Group stagingGroup = _group.getStagingGroup(); // Update content in staging JournalArticle stagingJournalArticle = JournalArticleLocalServiceUtil .getArticleByUrlTitle(stagingGroup.getGroupId(), journalArticle.getUrlTitle()); stagingJournalArticle = JournalTestUtil.updateArticle(stagingJournalArticle, "Title2", stagingJournalArticle.getContent()); // Publish to live StagingUtil.publishLayouts(TestPropsValues.getUserId(), stagingGroup.getGroupId(), _group.getGroupId(), false, parameters); // Retrieve content from live after publishing journalArticle = JournalArticleLocalServiceUtil.getArticle(_group.getGroupId(), journalArticle.getArticleId()); if (stageJournal) { for (Locale locale : _locales) { Assert.assertEquals(journalArticle.getTitle(locale), stagingJournalArticle.getTitle(locale)); } } else { for (Locale locale : _locales) { Assert.assertNotEquals(journalArticle.getTitle(locale), stagingJournalArticle.getTitle(locale)); } } }
From source file:de.hofuniversity.iisys.liferay.workflows.LoggingTaskManager.java
License:Open Source License
private void logServiceContext(ServiceContext serviceContext, String indent) { if (serviceContext != null) { fLogger.println(indent + "command: " + serviceContext.getCommand()); try {//from ww w . j av a 2 s . com fLogger.println(indent + "guestOrUserId: " + serviceContext.getGuestOrUserId()); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } fLogger.println(indent + "workflowAction: " + serviceContext.getWorkflowAction()); fLogger.println(indent + "attributes:"); logMap(serviceContext.getAttributes(), indent + "\t"); } }