public List<LayerType> getTextLayers() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(TEXT_LAYERS); if (tmp != null) { List<LayerType> layers = new ArrayList<>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof LayerType) { layers.add((LayerType) abstractField); } else { throw new BadFieldValueException("Layer expected and " + abstractField.getClass().getName() + " found."); } } return layers; } return null; }
private void checkThumbnails(PreflightContext ctx, XMPMetadata metadata) { XMPBasicSchema xmp = metadata.getXMPBasicSchema(); if (xmp == null) { return; } List<ThumbnailType> tbProp; try { tbProp = xmp.getThumbnailsProperty(); } catch (BadFieldValueException e) { // should not happen here because it would have happened in XmpParser already addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, e.getMessage(), e)); return; } if (tbProp == null) { return; } for (ThumbnailType tb : tbProp) { checkThumbnail(tb, ctx); } }
public List<JobType> getJobs() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(JOB_REF); if (tmp != null) { List<JobType> layers = new ArrayList<>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof JobType) { layers.add((JobType) abstractField); } else { throw new BadFieldValueException("Job expected and " + abstractField.getClass().getName() + " found."); } } return layers; } return null; }
private void checkThumbnails(PreflightContext ctx, XMPMetadata metadata) { XMPBasicSchema xmp = metadata.getXMPBasicSchema(); if (xmp == null) { return; } List<ThumbnailType> tbProp; try { tbProp = xmp.getThumbnailsProperty(); } catch (BadFieldValueException e) { // should not happen here because it would have happened in XmpParser already addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, e.getMessage(), e)); return; } if (tbProp == null) { return; } for (ThumbnailType tb : tbProp) { checkThumbnail(tb, ctx); } }
/** * Get list of Thumbnails * * @return List of all thumbnails properties defined * @throws BadFieldValueException * if one thumbnail is not thumbnail type */ public List<ThumbnailType> getThumbnailsProperty() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(THUMBNAILS); if (tmp != null) { List<ThumbnailType> thumbs = new ArrayList<>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof ThumbnailType) { thumbs.add((ThumbnailType) abstractField); } else { throw new BadFieldValueException("Thumbnail expected and " + abstractField.getClass().getName() + " found."); } } return thumbs; } return null; }
private void checkThumbnails(PreflightContext ctx, XMPMetadata metadata) { XMPBasicSchema xmp = metadata.getXMPBasicSchema(); if (xmp == null) { return; } List<ThumbnailType> tbProp; try { tbProp = xmp.getThumbnailsProperty(); } catch (BadFieldValueException e) { // should not happen here because it would have happened in XmpParser already addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_METADATA_FORMAT, e.getMessage(), e)); return; } if (tbProp == null) { return; } for (ThumbnailType tb : tbProp) { checkThumbnail(tb, ctx); } }
public AbstractStructuredType instanciateStructuredType(Types type, String propertyName) throws BadFieldValueException { try { Class<? extends AbstractStructuredType> propertyTypeClass = type.getImplementingClass().asSubclass( AbstractStructuredType.class); Constructor<? extends AbstractStructuredType> construct = propertyTypeClass .getDeclaredConstructor(XMPMetadata.class); AbstractStructuredType tmp = construct.newInstance(metadata); tmp.setPropertyName(propertyName); return tmp; } catch (InvocationTargetException | IllegalArgumentException | InstantiationException | IllegalAccessException | SecurityException | NoSuchMethodException e) { throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); } }
/** * Set the PDF/A conformance level * * @param value * The conformance level value to set * @throws BadFieldValueException * If Conformance Value not 'A', 'B' or 'U' (PDF/A-2 and PDF/A-3) */ public void setConformance(String value) throws BadFieldValueException { if (value.equals("A") || value.equals("B") || value.equals("U")) { TextType conf = createTextType(CONFORMANCE, value); addProperty(conf); } else { throw new BadFieldValueException( "The property given not seems to be a PDF/A conformance level (must be A, B or U)"); } }
/** * Set the PDF/A conformance level * * @param conf * The conformance level property to set * @throws BadFieldValueException * If Conformance Value not 'A', 'B' or 'U' (PDF/A-2 and PDF/A-3) */ public void setConformanceProperty(TextType conf) throws BadFieldValueException { String value = conf.getStringValue(); if (value.equals("A") || value.equals("B") || value.equals("U")) { addProperty(conf); } else { throw new BadFieldValueException( "The property given not seems to be a PDF/A conformance level (must be A, B or U)"); } }
/** * Set the RDF 'about' attribute * * @param about * the well-formed attribute * @throws BadFieldValueException * Bad Attribute name (not corresponding to about attribute) */ public void setAbout(Attribute about) throws BadFieldValueException { if (XmpConstants.RDF_NAMESPACE.equals(about.getNamespace()) && XmpConstants.ABOUT_NAME.equals(about.getName())) { setAttribute(about); return; } throw new BadFieldValueException("Attribute 'about' must be named 'rdf:about' or 'about'"); }
throw new BadFieldValueException("No descriptor found for " + name);
/** * Get an AbstractField list corresponding to the content of an array * property. * * @param name The property name whitout namespace. * @return List of properties contained in the array property. * @throws BadFieldValueException If the property with the requested name isn't an array. */ public List<AbstractField> getUnqualifiedArrayList(String name) throws BadFieldValueException { ArrayProperty array = null; for (AbstractField child : getAllProperties()) { if (child.getPropertyName().equals(name)) { if (child instanceof ArrayProperty) { array = (ArrayProperty) child; break; } throw new BadFieldValueException("Property asked is not an array"); } } if (array != null) { return new ArrayList<>(array.getContainer().getAllProperties()); } return null; }
throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); throw new BadFieldValueException("Failed to instanciate structured type : " + type, e);
public List<LayerType> getTextLayers() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(TEXT_LAYERS); if (tmp != null) { List<LayerType> layers = new ArrayList<LayerType>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof LayerType) { layers.add((LayerType) abstractField); } else { throw new BadFieldValueException("Layer expected and " + abstractField.getClass().getName() + " found."); } } return layers; } return null; }
public List<JobType> getJobs() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(JOB_REF); if (tmp != null) { List<JobType> layers = new ArrayList<>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof JobType) { layers.add((JobType) abstractField); } else { throw new BadFieldValueException("Job expected and " + abstractField.getClass().getName() + " found."); } } return layers; } return null; }
public List<JobType> getJobs() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(JOB_REF); if (tmp != null) { List<JobType> layers = new ArrayList<JobType>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof JobType) { layers.add((JobType) abstractField); } else { throw new BadFieldValueException("Job expected and " + abstractField.getClass().getName() + " found."); } } return layers; } return null; }
public List<LayerType> getTextLayers() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(TEXT_LAYERS); if (tmp != null) { List<LayerType> layers = new ArrayList<>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof LayerType) { layers.add((LayerType) abstractField); } else { throw new BadFieldValueException("Layer expected and " + abstractField.getClass().getName() + " found."); } } return layers; } return null; }
/** * Get list of Thumbnails * * @return List of all thumbnails properties defined * @throws BadFieldValueException * if one thumbnail is not thumbnail type */ public List<ThumbnailType> getThumbnailsProperty() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(THUMBNAILS); if (tmp != null) { List<ThumbnailType> thumbs = new ArrayList<>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof ThumbnailType) { thumbs.add((ThumbnailType) abstractField); } else { throw new BadFieldValueException("Thumbnail expected and " + abstractField.getClass().getName() + " found."); } } return thumbs; } return null; }
public AbstractStructuredType instanciateStructuredType(Types type, String propertyName) throws BadFieldValueException { try { Class<? extends AbstractStructuredType> propertyTypeClass = type.getImplementingClass().asSubclass( AbstractStructuredType.class); Constructor<? extends AbstractStructuredType> construct = propertyTypeClass .getDeclaredConstructor(XMPMetadata.class); AbstractStructuredType tmp = construct.newInstance(metadata); tmp.setPropertyName(propertyName); return tmp; } catch (InvocationTargetException | IllegalArgumentException | InstantiationException | IllegalAccessException | SecurityException | NoSuchMethodException e) { throw new BadFieldValueException("Failed to instanciate structured type : " + type, e); } }
/** * Get list of Thumbnails * * @return List of all thumbnails properties defined * @throws BadFieldValueException * if one thumbnail is not thumbnail type */ public List<ThumbnailType> getThumbnailsProperty() throws BadFieldValueException { List<AbstractField> tmp = getUnqualifiedArrayList(THUMBNAILS); if (tmp != null) { List<ThumbnailType> thumbs = new ArrayList<ThumbnailType>(); for (AbstractField abstractField : tmp) { if (abstractField instanceof ThumbnailType) { thumbs.add((ThumbnailType) abstractField); } else { throw new BadFieldValueException("Thumbnail expected and " + abstractField.getClass().getName() + " found."); } } return thumbs; } return null; }