public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) { this(metadata, namespaceURI, null, null); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { throw new IllegalArgumentException(" StructuredType annotation cannot be null"); } this.prefix = this.preferedPrefix; }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName) { super(metadata, propertyName); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { // init with parameters if (namespaceURI == null) { throw new IllegalArgumentException( "Both StructuredType annotation and namespace parameter cannot be null"); } this.namespace = namespaceURI; this.preferedPrefix = fieldPrefix; } this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix; }
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
if (!id.getPrefix().equals(stPdfaIdent.preferedPrefix())) if (metadata.getSchema(stPdfaIdent.preferedPrefix(), stBasic.namespace()) == null) ve.add(unexpectedPrefixFoundError(id.getPrefix(), stPdfaIdent.preferedPrefix(), PDFAIdentificationSchema.class.getName())); id = (PDFAIdentificationSchema) metadata.getSchema(stPdfaIdent.preferedPrefix(), stPdfaIdent.namespace());
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException { List<XMPSchema> schems = meta.getAllSchemas(); TypeMapping tm = meta.getTypeMapping(); StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class); for (XMPSchema xmpSchema : schems) { if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) { // ensure the prefix is the preferred one (cannot use other definition) if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) { throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'"); } // create schema and types PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema; ArrayProperty sp = pes.getSchemasProperty(); for (AbstractField af : sp.getAllProperties()) { if (af instanceof PDFASchemaType) { populatePDFASchemaType(meta, (PDFASchemaType) af, tm); } // TODO unmanaged ? } } } }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) { this(metadata, namespaceURI, null, null); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { throw new IllegalArgumentException(" StructuredType annotation cannot be null"); } this.prefix = this.preferedPrefix; }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI) { this(metadata, namespaceURI, null, null); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { throw new IllegalArgumentException(" StructuredType annotation cannot be null"); } this.prefix = this.preferedPrefix; }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName) { super(metadata, propertyName); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { // init with parameters if (namespaceURI == null) { throw new IllegalArgumentException( "Both StructuredType annotation and namespace parameter cannot be null"); } this.namespace = namespaceURI; this.preferedPrefix = fieldPrefix; } this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix; }
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
public AbstractStructuredType(XMPMetadata metadata, String namespaceURI, String fieldPrefix, String propertyName) { super(metadata, propertyName); StructuredType st = this.getClass().getAnnotation(StructuredType.class); if (st != null) { // init with annotation this.namespace = st.namespace(); this.preferedPrefix = st.preferedPrefix(); } else { // init with parameters if (namespaceURI == null) { throw new IllegalArgumentException( "Both StructuredType annotation and namespace parameter cannot be null"); } this.namespace = namespaceURI; this.preferedPrefix = fieldPrefix; } this.prefix = fieldPrefix == null ? this.preferedPrefix : fieldPrefix; }
private static void checkNamespaceDeclaration(Attr attr, Class<? extends AbstractStructuredType> clz) throws XmpParsingException { String prefix = attr.getLocalName(); String namespace = attr.getValue(); String cprefix = clz.getAnnotation(StructuredType.class).preferedPrefix(); String cnamespace = clz.getAnnotation(StructuredType.class).namespace(); // check extension if (cprefix.equals(prefix) && !cnamespace.equals(namespace)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } if (cnamespace.equals(namespace) && !cprefix.equals(prefix)) { throw new XmpParsingException(ErrorType.InvalidPdfaSchema, "Invalid PDF/A namespace definition"); } }
if (!id.getPrefix().equals(stPdfaIdent.preferedPrefix())) if (metadata.getSchema(stPdfaIdent.preferedPrefix(), stBasic.namespace()) == null) ve.add(unexpectedPrefixFoundError(id.getPrefix(), stPdfaIdent.preferedPrefix(), PDFAIdentificationSchema.class.getName())); id = (PDFAIdentificationSchema) metadata.getSchema(stPdfaIdent.preferedPrefix(), stPdfaIdent.namespace());
if (!id.getPrefix().equals(stPdfaIdent.preferedPrefix())) if (metadata.getSchema(stPdfaIdent.preferedPrefix(), stBasic.namespace()) == null) ve.add(unexpectedPrefixFoundError(id.getPrefix(), stPdfaIdent.preferedPrefix(), PDFAIdentificationSchema.class.getName())); id = (PDFAIdentificationSchema) metadata.getSchema(stPdfaIdent.preferedPrefix(), stPdfaIdent.namespace());
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException { List<XMPSchema> schems = meta.getAllSchemas(); TypeMapping tm = meta.getTypeMapping(); StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class); for (XMPSchema xmpSchema : schems) { if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) { // ensure the prefix is the preferred one (cannot use other definition) if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) { throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'"); } // create schema and types PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema; ArrayProperty sp = pes.getSchemasProperty(); for (AbstractField af : sp.getAllProperties()) { if (af instanceof PDFASchemaType) { populatePDFASchemaType(meta, (PDFASchemaType) af, tm); } // TODO unmanaged ? } } } }
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException { List<XMPSchema> schems = meta.getAllSchemas(); TypeMapping tm = meta.getTypeMapping(); StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class); for (XMPSchema xmpSchema : schems) { if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) { // ensure the prefix is the preferred one (cannot use other definition) if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) { throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'"); } // create schema and types PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema; ArrayProperty sp = pes.getSchemasProperty(); for (AbstractField af : sp.getAllProperties()) { if (af instanceof PDFASchemaType) { populatePDFASchemaType(meta, (PDFASchemaType) af, tm); } // TODO unmanaged ? } } } }