List of usage examples for com.liferay.portal.kernel.util ListUtil remove
public static <E> List<E> remove(List<E> list, List<? extends E> remove)
From source file:com.inikah.slayer.model.impl.ProfileImpl.java
License:Open Source License
public List<KeyValuePair> getLanguagesSpokenLeft() { List<KeyValuePair> itemsOnLeft = getLanguagesSpokenForFilter(); return ListUtil.remove(itemsOnLeft, getLanguagesSpokenRight()); }
From source file:com.liferay.content.targeting.hook.CTAssetVocabularyServiceImpl.java
License:Open Source License
@Override public AssetVocabularyDisplay getGroupVocabulariesDisplay(long groupId, String name, int start, int end, boolean addDefaultVocabulary, OrderByComparator obc) throws PortalException, SystemException { AssetVocabularyDisplay vocabularyDisplay = super.getGroupVocabulariesDisplay(groupId, name, start, end, addDefaultVocabulary, obc);// ww w . ja v a 2 s. c om List<AssetVocabulary> vocabularies = vocabularyDisplay.getVocabularies(); AssetVocabulary vocabulary = null; try { vocabulary = AssetVocabularyLocalServiceUtil.getGroupVocabulary(groupId, UserSegmentUtil.getAssetVocabularyName()); } catch (NoSuchVocabularyException nsve) { return vocabularyDisplay; } List<AssetVocabulary> removes = new ArrayList<AssetVocabulary>(); removes.add(vocabulary); vocabularyDisplay.setVocabularies(ListUtil.remove(vocabularies, removes)); return vocabularyDisplay; }
From source file:com.liferay.content.targeting.rule.role.OrganizationRoleRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context, Map<String, String> values) { long roleId = 0; long organizationId = 0; if (!values.isEmpty()) { roleId = GetterUtil.getLong(values.get("roleId")); organizationId = GetterUtil.getLong(values.get("organizationId")); } else if (ruleInstance != null) { String typeSettings = ruleInstance.getTypeSettings(); try {/*ww w . jav a 2 s.co m*/ JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings); roleId = jsonObj.getLong("roleId"); organizationId = jsonObj.getLong("organizationId"); } catch (JSONException jse) { } } context.put("roleId", roleId); context.put("organizationId", organizationId); Company company = (Company) context.get("company"); List<Role> roles = new ArrayList<Role>(); try { roles = RoleLocalServiceUtil.getRoles(company.getCompanyId(), new int[] { RoleConstants.TYPE_ORGANIZATION }); Role role = RoleLocalServiceUtil.fetchRole(company.getCompanyId(), RoleConstants.ORGANIZATION_USER); List<Role> removeRoles = new ArrayList<Role>(); removeRoles.add(role); roles = ListUtil.remove(roles, removeRoles); } catch (SystemException e) { } context.put("roles", roles); List<Organization> organizations = new ArrayList<Organization>(); try { // See LPS-50218 organizations = OrganizationLocalServiceUtil.getOrganizations(company.getCompanyId(), OrganizationConstants.ANY_PARENT_ORGANIZATION_ID); } catch (SystemException e) { } context.put("organizations", organizations); if ((organizations == null) || organizations.isEmpty()) { boolean hasUsersAdminViewPermission = ContentTargetingContextUtil .hasControlPanelPortletViewPermission(context, PortletKeys.USERS_ADMIN); if (hasUsersAdminViewPermission) { context.put("usersAdminURL", ContentTargetingContextUtil.getControlPanelPortletURL(context, PortletKeys.USERS_ADMIN, null)); } } }
From source file:com.liferay.content.targeting.rule.role.SiteRoleRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context, Map<String, String> values) { long roleId = 0; long siteId = 0; if (!values.isEmpty()) { roleId = GetterUtil.getLong(values.get("roleId")); siteId = GetterUtil.getLong(values.get("siteId")); } else if (ruleInstance != null) { String typeSettings = ruleInstance.getTypeSettings(); try {/*w w w . j a va 2 s.c o m*/ JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings); roleId = jsonObj.getLong("roleId"); siteId = jsonObj.getLong("siteId"); } catch (JSONException jse) { } } context.put("roleId", roleId); context.put("siteId", siteId); Company company = (Company) context.get("company"); List<Role> roles = new ArrayList<Role>(); try { roles = RoleLocalServiceUtil.getRoles(company.getCompanyId(), new int[] { RoleConstants.TYPE_SITE }); Role role = RoleLocalServiceUtil.fetchRole(company.getCompanyId(), RoleConstants.SITE_MEMBER); List<Role> removeRoles = new ArrayList<Role>(); removeRoles.add(role); roles = ListUtil.remove(roles, removeRoles); } catch (SystemException e) { } context.put("roles", roles); List<Group> sites = new ArrayList<Group>(); try { sites = GroupServiceUtil.getGroups(company.getCompanyId(), GroupConstants.ANY_PARENT_GROUP_ID, true); } catch (Exception e) { } context.put("sites", sites); if ((sites == null) || sites.isEmpty()) { boolean hasSitesAdminViewPermission = ContentTargetingContextUtil .hasControlPanelPortletViewPermission(context, PortletKeys.SITES_ADMIN); if (hasSitesAdminViewPermission) { context.put("sitesAdminURL", ContentTargetingContextUtil.getControlPanelPortletURL(context, PortletKeys.SITES_ADMIN, null)); } } }
From source file:com.liferay.contenttargeting.rules.role.OrganizationRoleRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context) { long roleId = 0; long organizationId = 0; if (ruleInstance != null) { String typeSettings = ruleInstance.getTypeSettings(); try {//from w w w . ja v a 2s. c om JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings); roleId = jsonObj.getLong("roleId"); organizationId = jsonObj.getLong("organizationId"); } catch (JSONException jse) { } } context.put("roleId", roleId); context.put("organizationId", organizationId); Company company = (Company) context.get("company"); List<Role> roles = new ArrayList<Role>(); try { roles = RoleLocalServiceUtil.getRoles(company.getCompanyId(), new int[] { RoleConstants.TYPE_ORGANIZATION }); Role role = RoleLocalServiceUtil.fetchRole(company.getCompanyId(), RoleConstants.ORGANIZATION_USER); List<Role> removeRoles = new ArrayList<Role>(); removeRoles.add(role); roles = ListUtil.remove(roles, removeRoles); } catch (SystemException e) { } context.put("roles", roles); List<Organization> organizations = new ArrayList<Organization>(); try { organizations = OrganizationLocalServiceUtil.getOrganizations(company.getCompanyId(), OrganizationConstants.ANY_PARENT_ORGANIZATION_ID); } catch (SystemException e) { } context.put("organizations", organizations); }
From source file:com.liferay.contenttargeting.rules.role.SiteRoleRule.java
License:Open Source License
@Override protected void populateContext(RuleInstance ruleInstance, Map<String, Object> context) { long roleId = 0; long siteId = 0; if (ruleInstance != null) { String typeSettings = ruleInstance.getTypeSettings(); try {/*from w ww .j ava 2 s. c o m*/ JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings); roleId = jsonObj.getLong("roleId"); siteId = jsonObj.getLong("siteId"); } catch (JSONException jse) { } } context.put("roleId", roleId); context.put("siteId", siteId); Company company = (Company) context.get("company"); List<Role> roles = new ArrayList<Role>(); try { roles = RoleLocalServiceUtil.getRoles(company.getCompanyId(), new int[] { RoleConstants.TYPE_SITE }); Role role = RoleLocalServiceUtil.fetchRole(company.getCompanyId(), RoleConstants.SITE_MEMBER); List<Role> removeRoles = new ArrayList<Role>(); removeRoles.add(role); roles = ListUtil.remove(roles, removeRoles); } catch (SystemException e) { } context.put("roles", roles); List<Group> sites = new ArrayList<Group>(); try { sites = GroupLocalServiceUtil.getGroups(company.getCompanyId(), GroupConstants.ANY_PARENT_GROUP_ID, true); } catch (SystemException e) { } context.put("sites", sites); }
From source file:com.liferay.expando.taglib.servlet.taglib.CustomAttributesAvailableTag.java
License:Open Source License
@Override public int doStartTag() throws JspException { try {//from ww w .j a va 2 s . c o m HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long companyId = _companyId; if (companyId == 0) { companyId = themeDisplay.getCompanyId(); } ExpandoBridge expandoBridge = null; if (_classPK == 0) { expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId, _className); } else { expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId, _className, _classPK); } List<String> attributeNames = ListUtil.remove(Collections.list(expandoBridge.getAttributeNames()), ListUtil.fromString(_ignoreAttributeNames, StringPool.COMMA)); if (attributeNames.isEmpty()) { return SKIP_BODY; } if (_classPK == 0) { return EVAL_BODY_INCLUDE; } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); for (String attributeName : attributeNames) { Serializable value = expandoBridge.getAttribute(attributeName); if (Validator.isNull(value)) { continue; } UnicodeProperties properties = expandoBridge.getAttributeProperties(attributeName); boolean propertyHidden = GetterUtil .getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_HIDDEN)); boolean propertyVisibleWithUpdatePermission = GetterUtil .getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_VISIBLE_WITH_UPDATE_PERMISSION)); if (_editable && propertyVisibleWithUpdatePermission) { if (ExpandoColumnPermissionUtil.contains(permissionChecker, companyId, _className, ExpandoTableConstants.DEFAULT_TABLE_NAME, attributeName, ActionKeys.UPDATE)) { propertyHidden = false; } else { propertyHidden = true; } } if (!propertyHidden && ExpandoColumnPermissionUtil.contains(permissionChecker, companyId, _className, ExpandoTableConstants.DEFAULT_TABLE_NAME, attributeName, ActionKeys.VIEW)) { return EVAL_BODY_INCLUDE; } } return SKIP_BODY; } catch (Exception e) { throw new JspException(e); } finally { if (!ServerDetector.isResin()) { _className = null; _classPK = 0; _companyId = 0; _editable = false; _ignoreAttributeNames = null; } } }
From source file:com.liferay.social.activity.service.test.SocialRelationLocalServiceTest.java
License:Open Source License
@Test public void testGetMultipleGroups() throws Exception { User dlc3User = UserLocalServiceUtil.getUserByScreenName(TestPropsValues.getCompanyId(), "dlc3"); List<User> groupUsers = UserLocalServiceUtil.getGroupUsers(TestPropsValues.getGroupId()); GroupLocalServiceUtil.addUserGroup(dlc3User.getUserId(), TestPropsValues.getGroupId()); User dlc4User = UserLocalServiceUtil.getUserByScreenName(TestPropsValues.getCompanyId(), "dlc4"); GroupLocalServiceUtil.addUserGroup(dlc4User.getUserId(), TestPropsValues.getGroupId()); Set<Long> groupIds = SetUtil.intersect(dlc3User.getGroupIds(), dlc4User.getGroupIds()); List<User> users = UserLocalServiceUtil.searchSocial(TestPropsValues.getCompanyId(), ArrayUtil.toArray(groupIds.toArray(new Long[groupIds.size()])), "dlc", QueryUtil.ALL_POS, QueryUtil.ALL_POS);// w ww .ja va 2 s. c o m users = ListUtil.remove(users, groupUsers); Assert.assertEquals(users.toString(), 2, users.size()); GroupLocalServiceUtil.deleteUserGroup(dlc3User.getUserId(), TestPropsValues.getGroupId()); GroupLocalServiceUtil.deleteUserGroup(dlc4User.getUserId(), TestPropsValues.getGroupId()); }