Example usage for com.liferay.portal.kernel.service GroupLocalServiceUtil updateGroup

List of usage examples for com.liferay.portal.kernel.service GroupLocalServiceUtil updateGroup

Introduction

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

Prototype

public static com.liferay.portal.kernel.model.Group updateGroup(com.liferay.portal.kernel.model.Group group) 

Source Link

Document

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

Usage

From source file:com.liferay.site.service.persistence.test.GroupLocalServiceTreeTest.java

License:Open Source License

@Override
protected TreeModel addTreeModel(TreeModel parentTreeModel) throws Exception {

    long parentGroupId = GroupConstants.DEFAULT_PARENT_GROUP_ID;

    if (parentTreeModel != null) {
        Group group = (Group) parentTreeModel;

        parentGroupId = group.getGroupId();
    }//from   w  w  w  .  j  a  va 2  s . c o  m

    Group group = GroupTestUtil.addGroup(parentGroupId);

    group.setTreePath(null);

    return GroupLocalServiceUtil.updateGroup(group);
}

From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java

License:Open Source License

@Test
public void testFindGroupByDescriptionWithSpaces() throws Exception {
    Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID);

    group.setDescription(RandomTestUtil.randomString() + StringPool.SPACE + RandomTestUtil.randomString());

    GroupLocalServiceUtil.updateGroup(group);

    LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>();

    groupParams.put("manualMembership", Boolean.TRUE);
    groupParams.put("site", Boolean.TRUE);

    Assert.assertEquals(1, GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null,
            group.getDescription(getLocale()), groupParams));

    GroupLocalServiceUtil.deleteGroup(group);
}

From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java

License:Open Source License

@Test
public void testFindGroupByNameWithSpaces() throws Exception {
    Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID);

    group.setName(RandomTestUtil.randomString() + StringPool.SPACE + RandomTestUtil.randomString());

    GroupLocalServiceUtil.updateGroup(group);

    LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>();

    groupParams.put("manualMembership", Boolean.TRUE);
    groupParams.put("site", Boolean.TRUE);

    Assert.assertEquals(1, GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null,
            group.getName(getLocale()), groupParams));

    GroupLocalServiceUtil.deleteGroup(group);
}

From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java

License:Open Source License

@Test
public void testInactiveGroups() throws Exception {
    _group = GroupTestUtil.addGroup();//from w  w  w  .  j  av  a 2 s  .c o  m

    LayoutTestUtil.addLayout(_group);

    _user = UserTestUtil.addGroupUser(_group, RoleConstants.USER);

    _group.setActive(false);

    GroupLocalServiceUtil.updateGroup(_group);

    List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS);

    Assert.assertFalse(groups + " contains " + _group, groups.contains(_group));
}

From source file:com.liferay.site.service.persistence.test.GroupServiceUserSitesGroupsTest.java

License:Open Source License

@Test
public void testInactiveOrganizationGroup() throws Exception {
    _user = UserTestUtil.addUser();//from  w ww.  j  a  va  2s . co  m

    Organization organization = OrganizationTestUtil.addOrganization(true);

    _organizations.addFirst(organization);

    UserLocalServiceUtil.addOrganizationUsers(organization.getOrganizationId(),
            new long[] { _user.getUserId() });

    Group group = organization.getGroup();

    LayoutTestUtil.addLayout(group);

    group = GroupLocalServiceUtil.getGroup(group.getGroupId());

    group.setActive(false);

    GroupLocalServiceUtil.updateGroup(group);

    List<Group> groups = GroupServiceUtil.getUserSitesGroups(_user.getUserId(), null, QueryUtil.ALL_POS);

    Assert.assertFalse(groups + " contains " + group, groups.contains(group));
}

From source file:com.liferay.trash.service.test.TrashEntryLocalServiceCheckEntriesTest.java

License:Open Source License

protected Group updateTrashEntriesMaxAge(Group group, int days) throws Exception {

    UnicodeProperties typeSettingsProperties = group.getParentLiveGroupTypeSettingsProperties();

    int companyTrashEntriesMaxAge = PrefsPropsUtil.getInteger(group.getCompanyId(),
            PropsKeys.TRASH_ENTRIES_MAX_AGE);

    if (days > 0) {
        days *= 1440;/*from   w ww.j ava 2s.  c o m*/
    } else {
        days = GetterUtil.getInteger(typeSettingsProperties.getProperty("trashEntriesMaxAge"),
                companyTrashEntriesMaxAge);
    }

    if (days != companyTrashEntriesMaxAge) {
        typeSettingsProperties.setProperty("trashEntriesMaxAge", String.valueOf(days));
    } else {
        typeSettingsProperties.remove("trashEntriesMaxAge");
    }

    group.setTypeSettingsProperties(typeSettingsProperties);

    return GroupLocalServiceUtil.updateGroup(group);
}

From source file:com.liferay.trash.test.util.TrashTestUtil.java

License:Open Source License

public static Group disableTrash(Group group) {
    UnicodeProperties typeSettingsProperties = group.getParentLiveGroupTypeSettingsProperties();

    typeSettingsProperties.setProperty("trashEnabled", StringPool.FALSE);

    group.setTypeSettingsProperties(typeSettingsProperties);

    return GroupLocalServiceUtil.updateGroup(group);
}