Example usage for com.liferay.portal.kernel.service.persistence GroupUtil clearCache

List of usage examples for com.liferay.portal.kernel.service.persistence GroupUtil clearCache

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service.persistence GroupUtil clearCache.

Prototype

public static void clearCache() 

Source Link

Usage

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);/*ww w .ja  v a  2 s  .c o m*/

    GroupUtil.clearCache();

    StagingUtil.publishLayouts(TestPropsValues.getUserId(), _exportImportConfiguration);

    Assert.assertEquals(0, JournalArticleLocalServiceUtil.getArticlesCount(_liveGroup.getGroupId()));

    journalArticle = articles.get(0);

    return journalArticle.getResourcePrimKey();
}