Example usage for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil toXML

List of usage examples for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil toXML

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet PortletPreferencesFactoryUtil toXML.

Prototype

public static String toXML(PortletPreferences portletPreferences) 

Source Link

Usage

From source file:com.liferay.journal.search.test.JournalIndexerTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();//from   www.j  a  v  a  2s .c  om

    CompanyThreadLocal.setCompanyId(TestPropsValues.getCompanyId());

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext();

    serviceContext.setCompanyId(TestPropsValues.getCompanyId());

    ServiceTestUtil.setUser(TestPropsValues.getUser());

    PortalPreferences portalPreferenceces = PortletPreferencesFactoryUtil
            .getPortalPreferences(TestPropsValues.getUserId(), true);

    _originalPortalPreferencesXML = PortletPreferencesFactoryUtil.toXML(portalPreferenceces);

    portalPreferenceces.setValue("", "indexAllArticleVersionsEnabled", "true");
    portalPreferenceces.setValue("", "expireAllArticleVersionsEnabled", "true");

    PortalPreferencesLocalServiceUtil.updatePreferences(TestPropsValues.getCompanyId(),
            PortletKeys.PREFS_OWNER_TYPE_COMPANY, PortletPreferencesFactoryUtil.toXML(portalPreferenceces));
}

From source file:com.liferay.journal.service.test.JournalArticleIndexVersionsTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    CompanyThreadLocal.setCompanyId(TestPropsValues.getCompanyId());

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext();

    serviceContext.setCompanyId(TestPropsValues.getCompanyId());

    _group = GroupTestUtil.addGroup();/*w w  w. j  a v a2s. c  om*/

    User user = TestPropsValues.getUser();

    user.setCompanyId(TestPropsValues.getCompanyId());

    ServiceTestUtil.setUser(user);

    PortalPreferences portalPreferences = PortletPreferencesFactoryUtil
            .getPortalPreferences(TestPropsValues.getUserId(), true);

    _originalPortalPreferencesXML = PortletPreferencesFactoryUtil.toXML(portalPreferences);

    portalPreferences.setValue("", "expireAllArticleVersionsEnabled", "true");
    portalPreferences.setValue("", "indexAllArticleVersionsEnabled", "false");

    PortalPreferencesLocalServiceUtil.updatePreferences(TestPropsValues.getCompanyId(),
            PortletKeys.PREFS_OWNER_TYPE_COMPANY, PortletPreferencesFactoryUtil.toXML(portalPreferences));
}

From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    setUpDDMFormXSDDeserializer();// w w w.  ja  v a 2s .c om

    CompanyThreadLocal.setCompanyId(TestPropsValues.getCompanyId());

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext();

    serviceContext.setCompanyId(TestPropsValues.getCompanyId());

    _group = GroupTestUtil.addGroup();

    _article = JournalTestUtil.addArticle(_group.getGroupId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            "Version 1", "This is a test article.");

    ServiceTestUtil.setUser(TestPropsValues.getUser());

    PortalPreferences portalPreferenceces = PortletPreferencesFactoryUtil
            .getPortalPreferences(TestPropsValues.getUserId(), true);

    _originalPortalPreferencesXML = PortletPreferencesFactoryUtil.toXML(portalPreferenceces);

    portalPreferenceces.setValue("", "expireAllArticleVersionsEnabled", "true");

    PortalPreferencesLocalServiceUtil.updatePreferences(TestPropsValues.getCompanyId(),
            PortletKeys.PREFS_OWNER_TYPE_COMPANY, PortletPreferencesFactoryUtil.toXML(portalPreferenceces));
}

From source file:com.liferay.layout.admin.web.internal.upgrade.v_1_0_1.UpgradeLayoutType.java

License:Open Source License

protected String getPortletPreferences(long groupId, String articleId) throws Exception {

    if (Validator.isNull(articleId)) {
        return null;
    }/*from   www. j av a2s .c  o m*/

    long resourcePrimKey = getResourcePrimKey(groupId, articleId);

    PortletPreferences portletPreferences = new PortletPreferencesImpl();

    portletPreferences.setValue("articleId", articleId);

    long assetEntryId = getAssetEntryId(resourcePrimKey);

    portletPreferences.setValue("assetEntryId", String.valueOf(assetEntryId));

    portletPreferences.setValue("groupId", String.valueOf(groupId));

    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
}

From source file:com.liferay.site.navigation.breadcrumb.web.internal.upgrade.v1_0_0.UpgradePortletPreferences.java

License:Open Source License

@Override
protected String upgradePreferences(long companyId, long ownerId, int ownerType, long plid, String portletId,
        String xml) throws Exception {

    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML(companyId, ownerId, ownerType,
            plid, portletId, xml);/*  w w  w  . jav  a 2  s .  com*/

    upgradeDisplayStyle(portletPreferences);

    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
}

From source file:com.liferay.user.notification.event.service.UserNotificationEventCustomServiceWrapper.java

License:Open Source License

protected void storeUserNotificationEventsCount(long userId, int deliveryType) {

    if (deliveryType != UserNotificationDeliveryConstants.TYPE_WEBSITE) {
        return;//from w  w w .ja  v  a 2 s.  c o m
    }

    PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(userId, true);

    long userNotificationEventsCount = GetterUtil.getLong(
            portalPreferences.getValue(UserNotificationEvent.class.getName(), "userNotificationEventsCount"));

    portalPreferences.setValue(UserNotificationEvent.class.getName(), "userNotificationEventsCount",
            String.valueOf(++userNotificationEventsCount));

    PortalPreferencesLocalServiceUtil.updatePreferences(userId, PortletKeys.PREFS_OWNER_TYPE_USER,
            PortletPreferencesFactoryUtil.toXML(portalPreferences));
}

From source file:com.liferay.wiki.internal.upgrade.v1_0_0.UpgradePortletPreferences.java

License:Open Source License

@Override
protected String upgradePreferences(long companyId, long ownerId, int ownerType, long plid, String portletId,
        String xml) throws Exception {

    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML(companyId, ownerId, ownerType,
            plid, portletId, xml);//from  ww w .j a  va2 s  .c o  m

    upgradeEmailSignature(portletPreferences, "emailPageAddedBody", "emailPageAddedSignature");
    upgradeEmailSignature(portletPreferences, "emailPageUpdatedBody", "emailPageUpdatedSignature");

    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
}