if (metadata != null)
{
// Filters are forbidden in a XMP stream
if (metadata.getFilters() != null && !metadata.getFilters().isEmpty())
{
this.fContainer.push(new ValidationError(ERROR_SYNTAX_STREAM_INVALID_FILTER,
"Filter specified in font file metadata dictionnary"));
return;
}
byte[] mdAsBytes = getMetaDataStreamAsBytes(metadata);
try
{
DomXmpParser xmpBuilder = new DomXmpParser();
XMPMetadata xmpMeta = xmpBuilder.parse(mdAsBytes);
FontMetaDataValidation fontMDval = new FontMetaDataValidation();
List<ValidationError> ve = new ArrayList<ValidationError>();
fontMDval.analyseFontName(xmpMeta, fontDescriptor, ve);
fontMDval.analyseRights(xmpMeta, fontDescriptor, ve);
this.fContainer.push(ve);
}
catch (XmpParsingException e)
{
if (e.getErrorType() == ErrorType.NoValueType)
{
this.fContainer.push(new ValidationError(ERROR_METADATA_UNKNOWN_VALUETYPE, e.getMessage()));
}
else if (e.getErrorType() == ErrorType.XpacketBadEnd)
{
this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_XPACKET,
"Unable to parse font metadata due to : " + e.getMessage()));
}
else
{
this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT, e.getMessage()));
}
}
}
}
catch (IllegalStateException e)
{
this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_UNKOWN,
"The Metadata entry doesn't reference a stream object"));
}
}