@Override public PIPResponse getAttributes(PIPRequest pipRequest, PIPFinder pipFinder) throws PIPException { String pipRequestKey = generateKey(pipRequest); PIPResponse pipResponse = this.cache.get(pipRequestKey); if (pipResponse != null) { return pipResponse; } Attribute attributeMatch = this.findAttribute(pipRequest); if (attributeMatch == null) { return StdPIPResponse.PIP_RESPONSE_EMPTY; } /* * Iterate through the values and only return the ones that match the requested data type */ List<AttributeValue<?>> matchingValues = attributeMatch .getValues() .stream() .filter( attributeValue -> pipRequest.getDataTypeId().equals(attributeValue.getDataTypeId())) .collect(Collectors.toList()); if (matchingValues.size() > 0) { Attribute attributeResponse = new StdMutableAttribute( attributeMatch.getCategory(), attributeMatch.getAttributeId(), matchingValues, attributeMatch.getIssuer(), false); pipResponse = new StdPIPResponse(attributeResponse); this.cache.put(pipRequestKey, pipResponse); } return pipResponse; }
protected Attribute findAttribute(PIPRequest pipRequest) { Attribute attributeResult = null; Iterator<Attribute> iterAttributes = this.listAttributes.iterator(); while (attributeResult == null && iterAttributes.hasNext()) { Attribute attributeTest = iterAttributes.next(); if (pipRequest.getCategory().equals(attributeTest.getCategory()) && pipRequest.getAttributeId().equals(attributeTest.getAttributeId()) && (pipRequest.getIssuer() == null || pipRequest.getIssuer().equals(attributeTest.getIssuer()))) { attributeResult = attributeTest; } } return attributeResult; }