use of xades4j.xml.bind.xades.XmlCommitmentTypeQualifiersListType in project xades4j by luisgoncalves.
the class FromXmlCommitmentTypeConverter method convertFromObjectTree.
@Override
public void convertFromObjectTree(XmlSignedDataObjectPropertiesType xmlProps, QualifyingPropertiesDataCollector propertyDataCollector) throws PropertyUnmarshalException {
List<XmlCommitmentTypeIndicationType> xmlCommitments = xmlProps.getCommitmentTypeIndication();
if (xmlCommitments.isEmpty()) {
return;
}
for (XmlCommitmentTypeIndicationType xmlCommitment : xmlCommitments) {
List<String> objsRefs = xmlCommitment.getObjectReference();
Object allDataObjs = xmlCommitment.getAllSignedDataObjects();
if (objsRefs.isEmpty()) {
// Should be AllSignedDataObjects.
objsRefs = null;
if (null == allDataObjs) {
throw new PropertyUnmarshalException("ObjectReference or AllSignedDataObjects have to be present", CommitmentTypePropertyBase.PROP_NAME);
}
} else if (allDataObjs != null) {
throw new PropertyUnmarshalException("Both ObjectReference and AllSignedDataObjects are present", CommitmentTypePropertyBase.PROP_NAME);
}
CommitmentTypeData commTypeData = new CommitmentTypeData(xmlCommitment.getCommitmentTypeId().getIdentifier().getValue(), xmlCommitment.getCommitmentTypeId().getDescription());
commTypeData.setObjReferences(objsRefs);
XmlCommitmentTypeQualifiersListType xmlQualifiers = xmlCommitment.getCommitmentTypeQualifiers();
if (xmlQualifiers != null) {
Collection qualifiers = new ArrayList();
for (XmlAnyType xmlQualifier : xmlQualifiers.getCommitmentTypeQualifier()) {
if (!xmlQualifier.getContent().isEmpty()) {
if (xmlQualifier.getContent().size() > 1) {
throw new PropertyUnmarshalException("Qualifiers with multiple children are not support", CommitmentTypePropertyBase.PROP_NAME);
}
qualifiers.add(xmlQualifier.getContent().get(0));
}
}
commTypeData.setQualifiers(qualifiers);
}
propertyDataCollector.addCommitmentType(commTypeData);
}
}
use of xades4j.xml.bind.xades.XmlCommitmentTypeQualifiersListType in project xades4j by luisgoncalves.
the class ToXmlCommitmentTypeConverter method convertIntoObjectTree.
@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlSignedPropertiesType xmlProps, Document doc) {
CommitmentTypeData commitmentTypeData = (CommitmentTypeData) propData;
// Create the JAXB CommitmentTypeIndication and add it to SignedDataObjectProperties.
XmlCommitmentTypeIndicationType xmlCommitmentTypeProp = new XmlCommitmentTypeIndicationType();
xmlProps.getSignedDataObjectProperties().getCommitmentTypeIndication().add(xmlCommitmentTypeProp);
XmlIdentifierType xmlIdentifier = new XmlIdentifierType();
xmlIdentifier.setValue(commitmentTypeData.getUri());
XmlObjectIdentifierType xmlObjectId = new XmlObjectIdentifierType();
xmlObjectId.setDescription(commitmentTypeData.getDescription());
xmlObjectId.setIdentifier(xmlIdentifier);
xmlCommitmentTypeProp.setCommitmentTypeId(xmlObjectId);
Collection<String> refsUris = commitmentTypeData.getObjReferences();
if (null == refsUris) {
xmlCommitmentTypeProp.setAllSignedDataObjects();
} else {
xmlCommitmentTypeProp.getObjectReference().addAll(refsUris);
}
Collection qualifiers = commitmentTypeData.getQualifiers();
if (!qualifiers.isEmpty()) {
XmlCommitmentTypeQualifiersListType xmlQualifiers = new XmlCommitmentTypeQualifiersListType();
for (Object q : qualifiers) {
XmlAnyType xmlQualifier = new XmlAnyType();
xmlQualifier.getContent().add(q);
xmlQualifiers.getCommitmentTypeQualifier().add(xmlQualifier);
}
xmlCommitmentTypeProp.setCommitmentTypeQualifiers(xmlQualifiers);
}
}
Aggregations