Search in sources :

Example 1 with XMPRightsManagementSchema

use of org.apache.xmpbox.schema.XMPRightsManagementSchema 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;
}
Also used : ArrayProperty(org.apache.xmpbox.type.ArrayProperty) BooleanType(org.apache.xmpbox.type.BooleanType) ValidationError(org.apache.pdfbox.preflight.ValidationResult.ValidationError) DublinCoreSchema(org.apache.xmpbox.schema.DublinCoreSchema) XMPRightsManagementSchema(org.apache.xmpbox.schema.XMPRightsManagementSchema)

Example 2 with XMPRightsManagementSchema

use of org.apache.xmpbox.schema.XMPRightsManagementSchema in project pdfbox by apache.

the class XMPMetadata method createAndAddXMPRightsManagementSchema.

/**
 * Create and add a default XMP Rights Management Schema to this metadata.
 *
 * This method return the created schema to enter information.
 *
 * @return schema added in order to work on it
 */
public XMPRightsManagementSchema createAndAddXMPRightsManagementSchema() {
    XMPRightsManagementSchema rights = new XMPRightsManagementSchema(this);
    rights.setAboutAsSimple("");
    addSchema(rights);
    return rights;
}
Also used : XMPRightsManagementSchema(org.apache.xmpbox.schema.XMPRightsManagementSchema)

Aggregations

XMPRightsManagementSchema (org.apache.xmpbox.schema.XMPRightsManagementSchema)2 ValidationError (org.apache.pdfbox.preflight.ValidationResult.ValidationError)1 DublinCoreSchema (org.apache.xmpbox.schema.DublinCoreSchema)1 ArrayProperty (org.apache.xmpbox.type.ArrayProperty)1 BooleanType (org.apache.xmpbox.type.BooleanType)1