/** * Return the set of Obligations associated with the current result indexed by ObligationId. * * @return a Map of String, Obligation pairs * @throws PepException */ public Map<String, Obligation> getObligations() throws PepException { assertValidResult(); HashMap<String, Obligation> obligations = new HashMap<String, Obligation>(); if (!(this.currentResult instanceof AzResult)) { this.log.warn("getObligations() method not supported on " + "PepRequest.OPERATION.QUERY"); return obligations; } AzResult azResult = (AzResult) this.currentResult; AzObligations azObligations = azResult.getAzObligations(); if (azObligations != null) { if (log.isTraceEnabled()) log.trace("process azObligations"); Iterator<AzEntity<AzCategoryIdObligation>> obligationsIt = azObligations.iterator(); while (obligationsIt.hasNext()) { AzEntity<AzCategoryIdObligation> azObligation = obligationsIt.next(); if (log.isTraceEnabled()) log.trace("read and wrap next azObligation"); Obligation obligation = this.getResponseFactory().getObligationFactory().createObject(azObligation); String name = obligation.getAzEntity().getAzEntityId(); if (log.isTraceEnabled()) log.trace("\n\tput wrapped Obligation: ObligationId = " + name); obligations.put(name, obligation); } } else { if (log.isTraceEnabled()) log.trace("No Obligations returned in PepResponse"); } return obligations; }
/** * TBD: Some old helper methods below: probably should be removed and replaced by clean logging * capabilities. * * @param azResult * @param log */ static void printObligations(AzResult azResult, Log log) { Iterator<AzEntity<AzCategoryIdObligation>> itOb = azResult.getAzObligations().iterator(); log.debug(" TestAzAPI: itOb.hasNext() = " + itOb.hasNext()); while (itOb.hasNext()) { AzEntity<AzCategoryIdObligation> azObligation = itOb.next(); Iterator<AzAttribute<?>> itAttr = azObligation.getAzAttributeMixedSet().iterator(); log.debug(" TestAzAPI: itAttr.hasNext() = " + itAttr.hasNext()); while (itAttr.hasNext()) { printAttributeData(itAttr.next(), "Obligation attribute: ", log); } } }