Java Code Examples for org.apache.commons.collections.CollectionUtils#size()
The following examples show how to use
org.apache.commons.collections.CollectionUtils#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoleServiceBase.java From rice with Educational Community License v2.0 | 5 votes |
protected String getKimAttributeId(String kimTypeId, String attributeName) { Collection<KimAttributeBo> attributeData = getAttributeByName(attributeName); String kimAttributeId = null; if (CollectionUtils.isNotEmpty(attributeData)) { if (CollectionUtils.size(attributeData) == 1) { kimAttributeId = attributeData.iterator().next().getId(); } else { kimAttributeId = getCorrectAttributeId(kimTypeId, attributeName, attributeData); } } return kimAttributeId; }
Example 2
Source File: XUserREST.java From ranger with Apache License 2.0 | 4 votes |
/** * Implements the traditional search functionalities for XUsers * * @param request * @return */ @GET @Path("/users") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_X_USERS + "\")") public VXUserList searchXUsers(@Context HttpServletRequest request) { String UserRoleParamName = RangerConstants.ROLE_USER; SearchCriteria searchCriteria = searchUtil.extractCommonCriterias( request, xUserService.sortFields); String userName = null; if (request.getUserPrincipal() != null){ userName = request.getUserPrincipal().getName(); } searchUtil.extractString(request, searchCriteria, "name", "User name",null); searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null); searchUtil.extractInt(request, searchCriteria, "userSource", "User Source"); searchUtil.extractInt(request, searchCriteria, "isVisible", "User Visibility"); searchUtil.extractInt(request, searchCriteria, "status", "User Status"); List<String> userRolesList = searchUtil.extractStringList(request, searchCriteria, "userRoleList", "User Role List", "userRoleList", null, null); searchUtil.extractRoleString(request, searchCriteria, "userRole", "Role", null); if (CollectionUtils.isNotEmpty(userRolesList) && CollectionUtils.size(userRolesList) == 1 && userRolesList.get(0).equalsIgnoreCase(UserRoleParamName)) { if (!(searchCriteria.getParamList().containsKey("name"))) { searchCriteria.addParam("name", userName); } else if ((searchCriteria.getParamList().containsKey("name")) && userName!= null && userName.contains((String) searchCriteria.getParamList().get("name"))) { searchCriteria.addParam("name", userName); } } UserSessionBase userSession = ContextUtil.getCurrentUserSession(); if (userSession != null && userSession.getLoginId() != null) { VXUser loggedInVXUser = xUserService.getXUserByUserName(userSession .getLoginId()); if (loggedInVXUser != null) { if (loggedInVXUser.getUserRoleList().size() == 1 && loggedInVXUser.getUserRoleList().contains( RangerConstants.ROLE_USER)) { logger.info("Logged-In user having user role will be able to fetch his own user details."); if (!searchCriteria.getParamList().containsKey("name")) { searchCriteria.addParam("name", loggedInVXUser.getName()); }else if(searchCriteria.getParamList().containsKey("name") && !stringUtil.isEmpty(searchCriteria.getParamValue("name").toString()) && !searchCriteria.getParamValue("name").toString().equalsIgnoreCase(loggedInVXUser.getName())){ throw restErrorUtil.create403RESTException("Logged-In user is not allowed to access requested user data."); } } } } return xUserMgr.searchXUsers(searchCriteria); }
Example 3
Source File: TestPolicyEngine.java From ranger with Apache License 2.0 | 4 votes |
public static boolean compare(RangerTagEnricher me, RangerTagEnricher other) { boolean ret; if (me.getEnrichedServiceTags() == null || other == null || other.getEnrichedServiceTags() == null) { return false; } if (me.getEnrichedServiceTags().getServiceResourceTrie() != null && other.getEnrichedServiceTags().getServiceResourceTrie() != null) { ret = me.getEnrichedServiceTags().getServiceResourceTrie().size() == other.getEnrichedServiceTags().getServiceResourceTrie().size(); if (ret && me.getEnrichedServiceTags().getServiceResourceTrie().size() > 0) { for (Map.Entry<String, RangerResourceTrie<RangerServiceResourceMatcher>> entry : me.getEnrichedServiceTags().getServiceResourceTrie().entrySet()) { ret = compareSubtree(entry.getValue(), other.getEnrichedServiceTags().getServiceResourceTrie().get(entry.getKey())); if (!ret) { break; } } } } else { ret = me.getEnrichedServiceTags().getServiceResourceTrie() == other.getEnrichedServiceTags().getServiceResourceTrie(); } if (ret) { // Compare mappings ServiceTags myServiceTags = me.getEnrichedServiceTags().getServiceTags(); ServiceTags otherServiceTags = other.getEnrichedServiceTags().getServiceTags(); ret = StringUtils.equals(myServiceTags.getServiceName(), otherServiceTags.getServiceName()) && //myServiceTags.getTagVersion().equals(otherServiceTags.getTagVersion()) && myServiceTags.getTags().size() == otherServiceTags.getTags().size() && myServiceTags.getServiceResources().size() == otherServiceTags.getServiceResources().size() && myServiceTags.getResourceToTagIds().size() == otherServiceTags.getResourceToTagIds().size(); if (ret) { for (RangerServiceResource serviceResource : myServiceTags.getServiceResources()) { Long serviceResourceId = serviceResource.getId(); List<Long> myTagsForResource = myServiceTags.getResourceToTagIds().get(serviceResourceId); List<Long> otherTagsForResource = otherServiceTags.getResourceToTagIds().get(serviceResourceId); ret = CollectionUtils.size(myTagsForResource) == CollectionUtils.size(otherTagsForResource); if (ret && CollectionUtils.size(myTagsForResource) > 0) { ret = myTagsForResource.size() == CollectionUtils.intersection(myTagsForResource, otherTagsForResource).size(); } } } } return ret; }
Example 4
Source File: Result.java From alf.io with GNU General Public License v3.0 | 4 votes |
public ErrorCode getFirstErrorOrNull() { if(isSuccess() || CollectionUtils.size(errors) == 0) { return null; } return errors.get(0); }
Example 5
Source File: AgendaEditorMaintainable.java From rice with Educational Community License v2.0 | 4 votes |
/** * Retrieve a list of {@link RemotableAttributeField}s for the parameters (if any) required by the resolver for * the selected term in the proposition that is under edit. */ public List<RemotableAttributeField> retrieveTermParameters(View view, Object model, Container container) { List<RemotableAttributeField> results = new ArrayList<RemotableAttributeField>(); AgendaEditor agendaEditor = getAgendaEditor(model); // Figure out which rule is being edited RuleBo rule = agendaEditor.getAgendaItemLine().getRule(); if (null != rule) { // Figure out which proposition is being edited Tree<RuleTreeNode, String> propositionTree = rule.getPropositionTree(); Node<RuleTreeNode, String> editedPropositionNode = findEditedProposition(propositionTree.getRootElement()); if (editedPropositionNode != null) { PropositionBo propositionBo = editedPropositionNode.getData().getProposition(); if (StringUtils.isEmpty(propositionBo.getCompoundOpCode()) && CollectionUtils.size( propositionBo.getParameters()) > 0) { // Get the term ID; if it is a new parameterized term, it will have a special prefix PropositionParameterBo param = propositionBo.getParameters().get(0); if (StringUtils.isNotBlank(param.getValue()) && param.getValue().startsWith(KrmsImplConstants.PARAMETERIZED_TERM_PREFIX)) { String termSpecId = param.getValue().substring( KrmsImplConstants.PARAMETERIZED_TERM_PREFIX.length()); TermResolverDefinition simplestResolver = getSimplestTermResolver(termSpecId, rule.getNamespace()); // Get the parameters and build RemotableAttributeFields if (simplestResolver != null) { List<String> parameterNames = new ArrayList<String>(simplestResolver.getParameterNames()); Collections.sort(parameterNames); // make param order deterministic for (String parameterName : parameterNames) { // TODO: also allow for DD parameters if there are matching type attributes RemotableTextInput.Builder controlBuilder = RemotableTextInput.Builder.create(); controlBuilder.setSize(64); RemotableAttributeField.Builder builder = RemotableAttributeField.Builder.create( parameterName); builder.setRequired(true); builder.setDataType(DataType.STRING); builder.setControl(controlBuilder); builder.setLongLabel(parameterName); builder.setShortLabel(parameterName); builder.setMinLength(Integer.valueOf(1)); builder.setMaxLength(Integer.valueOf(64)); results.add(builder.build()); } } } } } } return results; }