Example usage for com.liferay.portal.kernel.service PortalPreferencesLocalServiceUtil updatePortalPreferences

List of usage examples for com.liferay.portal.kernel.service PortalPreferencesLocalServiceUtil updatePortalPreferences

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service PortalPreferencesLocalServiceUtil updatePortalPreferences.

Prototype

public static com.liferay.portal.kernel.model.PortalPreferences updatePortalPreferences(
        com.liferay.portal.kernel.model.PortalPreferences portalPreferences) 

Source Link

Document

Updates the portal preferences in the database or adds it if it does not yet exist.

Usage

From source file:com.liferay.calendar.web.upgrade.v1_1_0.test.UpgradePortalPreferencesTest.java

License:Open Source License

@Test
public void testUpgradeCalendarColorPreferences() throws Exception {
    long calendarId = RandomTestUtil.randomLong();
    long color = RandomTestUtil.randomLong();

    String preferencesXML = getPreferences(_NAMESPACE_OLD_SESSION_CLICKS,
            "calendar-portlet-calendar-" + calendarId + "-color", color);

    _portalPreferences.setPreferences(preferencesXML);

    PortalPreferencesLocalServiceUtil.updatePortalPreferences(_portalPreferences);

    _upgradeProcess.upgrade();//from www .  j a  v  a2 s .  c  om

    PortalPreferences portalPreferences = reloadPortalPreferences(_portalPreferences);

    String value = getPreference(portalPreferences.getPreferences(), _NAMESPACE_NEW_SESSION_CLICKS,
            "com.liferay.calendar.web_calendar" + calendarId + "Color");

    Assert.assertEquals(String.valueOf(color), value);
}

From source file:com.liferay.calendar.web.upgrade.v1_1_0.test.UpgradePortalPreferencesTest.java

License:Open Source License

@Test
public void testUpgradeCalendarVisiblePreferences() throws Exception {
    long calendarId = RandomTestUtil.randomLong();
    boolean visible = RandomTestUtil.randomBoolean();

    String preferencesXML = getPreferences(_NAMESPACE_OLD_SESSION_CLICKS,
            "calendar-portlet-calendar-" + calendarId + "-visible", visible);

    _portalPreferences.setPreferences(preferencesXML);

    PortalPreferencesLocalServiceUtil.updatePortalPreferences(_portalPreferences);

    _upgradeProcess.upgrade();//from  w w  w . j  a  v  a2  s . c o m

    PortalPreferences portalPreferences = reloadPortalPreferences(_portalPreferences);

    String value = getPreference(portalPreferences.getPreferences(), _NAMESPACE_NEW_SESSION_CLICKS,
            "com.liferay.calendar.web_calendar" + calendarId + "Visible");

    Assert.assertEquals(String.valueOf(visible), value);
}

From source file:com.liferay.calendar.web.upgrade.v1_1_0.test.UpgradePortalPreferencesTest.java

License:Open Source License

@Test
public void testUpgradeColumnOptionsVisiblePreferences() throws Exception {
    boolean visible = RandomTestUtil.randomBoolean();

    String preferencesXML = getPreferences(_NAMESPACE_OLD_SESSION_CLICKS,
            "calendar-portlet-column-options-visible", visible);

    _portalPreferences.setPreferences(preferencesXML);

    PortalPreferencesLocalServiceUtil.updatePortalPreferences(_portalPreferences);

    _upgradeProcess.upgrade();//w w w  .  j av  a 2  s  . co m

    PortalPreferences portalPreferences = reloadPortalPreferences(_portalPreferences);

    String value = getPreference(portalPreferences.getPreferences(), _NAMESPACE_NEW_SESSION_CLICKS,
            "com.liferay.calendar.web_columnOptionsVisible");

    Assert.assertEquals(String.valueOf(visible), value);
}

From source file:com.liferay.calendar.web.upgrade.v1_1_0.test.UpgradePortalPreferencesTest.java

License:Open Source License

@Test
public void testUpgradeDefaultViewPreferences() throws Exception {
    String[] views = { "day", "month", "week", "agenda" };

    String view = views[RandomTestUtil.randomInt(0, views.length - 1)];

    String preferencesXML = getPreferences(_NAMESPACE_OLD_SESSION_CLICKS, "calendar-portlet-default-view",
            view);// ww w  .j av a2 s. c om

    _portalPreferences.setPreferences(preferencesXML);

    PortalPreferencesLocalServiceUtil.updatePortalPreferences(_portalPreferences);

    _upgradeProcess.upgrade();

    PortalPreferences portalPreferences = reloadPortalPreferences(_portalPreferences);

    String value = getPreference(portalPreferences.getPreferences(), _NAMESPACE_NEW_SESSION_CLICKS,
            "com.liferay.calendar.web_defaultView");

    Assert.assertEquals(view, value);
}

From source file:com.liferay.calendar.web.upgrade.v1_1_0.test.UpgradePortalPreferencesTest.java

License:Open Source License

@Test
public void testUpgradeOtherCalendarsPreferences() throws Exception {
    long otherCalendarId = RandomTestUtil.randomLong();

    String preferencesXML = getPreferences(_NAMESPACE_OLD_SESSION_CLICKS, "calendar-portlet-other-calendars",
            otherCalendarId);/*from   ww w .ja  v a2 s .co m*/

    _portalPreferences.setPreferences(preferencesXML);

    PortalPreferencesLocalServiceUtil.updatePortalPreferences(_portalPreferences);

    _upgradeProcess.upgrade();

    PortalPreferences portalPreferences = reloadPortalPreferences(_portalPreferences);

    String value = getPreference(portalPreferences.getPreferences(), _NAMESPACE_NEW_SESSION_CLICKS,
            "com.liferay.calendar.web_otherCalendars");

    Assert.assertEquals(String.valueOf(otherCalendarId), value);
}