use of iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse in project open-ecard by ecsec.
the class CardRecognitionImpl method getCardInfoFromRepo.
@Override
public CardInfoType getCardInfoFromRepo(String type) {
CardInfoType cif = null;
// only do something when a repo is specified
if (cif == null && cifRepo != null) {
GetCardInfoOrACD req = new GetCardInfoOrACD();
req.setAction(ECardConstants.CIF.GET_SPECIFIED);
req.getCardTypeIdentifier().add(type);
GetCardInfoOrACDResponse res = getCifRepo().getCardInfoOrACD(req);
// checkout response if it contains our cardinfo
List<Serializable> cifs = res.getCardInfoOrCapabilityInfo();
for (Serializable next : cifs) {
if (next instanceof CardInfoType) {
return (CardInfoType) next;
}
}
}
return cif;
}
use of iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse in project open-ecard by ecsec.
the class CardRecognitionImpl method getCardInfos.
@Override
public List<CardInfoType> getCardInfos() {
// TODO: add caching
GetCardInfoOrACD req = new GetCardInfoOrACD();
req.setAction(ECardConstants.CIF.GET_OTHER);
GetCardInfoOrACDResponse res = getCifRepo().getCardInfoOrACD(req);
// checkout response if it contains our cardinfo
List<Serializable> cifs = res.getCardInfoOrCapabilityInfo();
ArrayList<CardInfoType> result = new ArrayList<>();
for (Serializable next : cifs) {
if (next instanceof CardInfoType) {
result.add((CardInfoType) next);
}
}
return result;
}
use of iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse in project open-ecard by ecsec.
the class LocalCifRepo method getCardInfoOrACD.
@Override
public GetCardInfoOrACDResponse getCardInfoOrACD(iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACD parameters) {
List<String> cardTypes = parameters.getCardTypeIdentifier();
ArrayList<CardInfoType> cifsResult = new ArrayList<>(cardTypes.size());
Result result = WSHelper.makeResultOK();
try {
if (ECardConstants.CIF.GET_SPECIFIED.equals(parameters.getAction())) {
ArrayList<String> missingTypes = new ArrayList<>();
for (String cardType : cardTypes) {
Document cif = cifs.get(cardType);
if (cif == null) {
missingTypes.add(cardType);
} else {
// marshal here to receive a copy of the CIF
cifsResult.add((CardInfoType) m.unmarshal(cif));
}
}
if (!missingTypes.isEmpty()) {
StringBuilder error = new StringBuilder("The following card types could not be found:");
for (String type : missingTypes) {
error.append("\n ").append(type);
}
result = WSHelper.makeResultError(ECardConstants.Minor.SAL.UNKNOWN_CARDTYPE, error.toString());
}
} else if (ECardConstants.CIF.GET_OTHER.equals(parameters.getAction())) {
HashMap<String, Document> cifsTmp = new HashMap<>();
cifsTmp.putAll(cifs);
for (String cardType : cardTypes) {
cifsTmp.remove(cardType);
}
for (Map.Entry<String, Document> e : cifsTmp.entrySet()) {
Document next = e.getValue();
cifsResult.add((CardInfoType) m.unmarshal(next));
}
} else {
result = WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR, "Given action is unsupported.");
}
GetCardInfoOrACDResponse res = WSHelper.makeResponse(GetCardInfoOrACDResponse.class, result);
res.getCardInfoOrCapabilityInfo().addAll(cifsResult);
return res;
} catch (WSMarshallerException ex) {
String msg = "Failed to unmarshal a CIF document.";
logger.error(msg, ex);
result = WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR, msg);
GetCardInfoOrACDResponse res = WSHelper.makeResponse(GetCardInfoOrACDResponse.class, result);
return res;
}
}
use of iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse in project open-ecard by ecsec.
the class TestLocalCif method testeGKCif.
@Test
public void testeGKCif() throws WSMarshallerException, IOException, SAXException {
LocalCifRepo repo = new LocalCifRepo(new JAXBMarshaller());
GetCardInfoOrACD req = new GetCardInfoOrACD();
req.setAction(ECardConstants.CIF.GET_SPECIFIED);
req.getCardTypeIdentifier().add("http://ws.gematik.de/egk/1.0.0");
GetCardInfoOrACDResponse res = repo.getCardInfoOrACD(req);
try {
WSHelper.checkResult(res);
} catch (WSException ex) {
Assert.fail("Local repo returned with error\n" + ex.getMessage());
}
Assert.assertEquals(1, res.getCardInfoOrCapabilityInfo().size());
}
use of iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse in project open-ecard by ecsec.
the class CardRecognitionImpl method getAllTypesFromRepo.
private List<String> getAllTypesFromRepo(org.openecard.ws.GetCardInfoOrACD repo) throws WSHelper.WSException {
// read list of all cifs from the repo
GetCardInfoOrACD req = new GetCardInfoOrACD();
req.setAction(ECardConstants.CIF.GET_OTHER);
GetCardInfoOrACDResponse res = repo.getCardInfoOrACD(req);
WSHelper.checkResult(res);
ArrayList<String> oids = new ArrayList<>();
for (Object cif : res.getCardInfoOrCapabilityInfo()) {
if (cif instanceof CardInfoType) {
String type = ((CardInfoType) cif).getCardType().getObjectIdentifier();
oids.add(type);
}
}
return oids;
}
Aggregations