use of org.apache.xmpbox.type.ArrayProperty in project pdfbox by apache.
the class XMPSchema method internalAddBagValue.
private void internalAddBagValue(String qualifiedBagName, String bagValue) {
ArrayProperty bag = (ArrayProperty) getAbstractProperty(qualifiedBagName);
TextType li = createTextType(XmpConstants.LIST_NAME, bagValue);
if (bag != null) {
bag.getContainer().addProperty(li);
} else {
ArrayProperty newBag = createArrayProperty(qualifiedBagName, Cardinality.Bag);
newBag.getContainer().addProperty(li);
addProperty(newBag);
}
}
use of org.apache.xmpbox.type.ArrayProperty in project pdfbox by apache.
the class XMPSchema method addUnqualifiedSequenceValue.
/**
* Add a new value to a sequence property.
*
* @param simpleSeqName
* The name of the sequence property without the namespace prefix
* @param seqValue
* The value to add to the sequence.
*/
public void addUnqualifiedSequenceValue(String simpleSeqName, String seqValue) {
ArrayProperty seq = (ArrayProperty) getAbstractProperty(simpleSeqName);
TextType li = createTextType(XmpConstants.LIST_NAME, seqValue);
if (seq != null) {
seq.getContainer().addProperty(li);
} else {
ArrayProperty newSeq = createArrayProperty(simpleSeqName, Cardinality.Seq);
newSeq.getContainer().addProperty(li);
addProperty(newSeq);
}
}
use of org.apache.xmpbox.type.ArrayProperty in project pdfbox by apache.
the class XMPSchemaTest method testArrayList.
@Test
public void testArrayList() throws Exception {
XMPMetadata meta = XMPMetadata.createXMPMetadata();
ArrayProperty newSeq = meta.getTypeMapping().createArrayProperty(null, "nsSchem", "seqType", Cardinality.Seq);
TypeMapping tm = meta.getTypeMapping();
TextType li1 = tm.createText(null, "rdf", "li", "valeur1");
TextType li2 = tm.createText(null, "rdf", "li", "valeur2");
newSeq.getContainer().addProperty(li1);
newSeq.getContainer().addProperty(li2);
schem.addProperty(newSeq);
List<AbstractField> list = schem.getUnqualifiedArrayList("seqType");
Assert.assertTrue(list.contains(li1));
Assert.assertTrue(list.contains(li2));
}
use of org.apache.xmpbox.type.ArrayProperty in project pdfbox by apache.
the class FontMetaDataValidation method analyseRights.
/**
* If XMP MetaData are present, they must have followings information :
* <UL>
* <li>dc:rights
* <li>Marked (with the value true)
* <li>Owner
* <li>UsageTerms
* </UL>
*
* @param metadata
* XMPMetaData of the Font File Stream
* @param fontDesc
* The FontDescriptor dictionary
* @param ve
* the list of validation error to update if the validation fails
* @return true if the analysis found no problems, false if it did.
*/
public boolean analyseRights(XMPMetadata metadata, PDFontDescriptor fontDesc, List<ValidationError> ve) {
DublinCoreSchema dc = metadata.getDublinCoreSchema();
if (dc != null) {
ArrayProperty copyrights = dc.getRightsProperty();
if (copyrights == null || copyrights.getContainer() == null || copyrights.getContainer().getAllProperties().isEmpty()) {
ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_PROPERTY_MISSING, "CopyRights is missing from the XMP information (dc:rights) of the Font File Stream."));
return false;
}
}
XMPRightsManagementSchema rights = metadata.getXMPRightsManagementSchema();
if (rights != null) {
BooleanType marked = rights.getMarkedProperty();
if (marked != null && !marked.getValue()) {
ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_PROPERTY_MISSING, "the XMP information (xmpRights:Marked) is invalid for the Font File Stream."));
return false;
}
/*
* rights.getUsageTerms() & rights.getOwnerValue() should be present but it is only a recommendation : may
* be it should be useful to append a Warning if these entries are missing.
*/
}
return true;
}
use of org.apache.xmpbox.type.ArrayProperty in project pdfbox by apache.
the class DomXmpParser method manageArray.
private void manageArray(XMPMetadata xmp, Element property, PropertyType type, ComplexPropertyContainer container) throws XmpParsingException {
TypeMapping tm = xmp.getTypeMapping();
String prefix = property.getPrefix();
String name = property.getLocalName();
String namespace = property.getNamespaceURI();
Element bagOrSeq = DomHelper.getUniqueElementChild(property);
// ensure this is the good type of array
if (bagOrSeq == null) {
// not an array
String whatFound = "nothing";
if (property.getFirstChild() != null) {
whatFound = property.getFirstChild().getClass().getName();
}
throw new XmpParsingException(ErrorType.Format, "Invalid array definition, expecting " + type.card() + " and found " + whatFound + " [prefix=" + prefix + "; name=" + name + "]");
}
if (!bagOrSeq.getLocalName().equals(type.card().name())) {
// not the good array type
throw new XmpParsingException(ErrorType.Format, "Invalid array type, expecting " + type.card() + " and found " + bagOrSeq.getLocalName() + " [prefix=" + prefix + "; name=" + name + "]");
}
ArrayProperty array = tm.createArrayProperty(namespace, prefix, name, type.card());
container.addProperty(array);
List<Element> lis = DomHelper.getElementChildren(bagOrSeq);
for (Element element : lis) {
QName propertyQName = new QName(element.getLocalName());
AbstractField ast = parseLiElement(xmp, propertyQName, element, type.type());
if (ast != null) {
array.addProperty(ast);
}
}
}
Aggregations