zipf.close();
return 0;
}
// Process components
JhoveBase jhoveBase;
try {
jhoveBase = new JhoveBase();
jhoveBase.init(_je.getConfigFile(),
_je.getSaxClass());
} catch (JhoveException excptn) {
repInfo.setValid(false);
repInfo.setWellFormed(false);
repInfo.setMessage(new ErrorMessage("Can't instance engine to analyze package parts. Cause : " +
excptn.getMessage()));
zipf.close();
return 0;
}
for (Iterator iter = elementList.iterator(); iter.hasNext();) {
ManifestEntry mnfe = (ManifestEntry) iter.next();
/*
* If the size field is set then the data is
* encrypted, therefore we can't process it. If the
* type equals application/binary (not a IANA
* registered one!) then the data is skipped as
* application specific.
*/
if (mnfe.size != 0) {
StringBuffer tmp = new StringBuffer("Warning, part ");
tmp.append(mnfe.fullPath);
tmp.append(" is encrypted, validation skipped.");
repInfo.setMessage(new InfoMessage(tmp.toString()));
}
else if (mimeTypeMap.get(mnfe.mediaType) != null &&
! mnfe.fullPath.equals(SKIP_ROOT)) {
String subDocName;
int idxof = mnfe.fullPath.indexOf("/");
if (idxof<1) {
subDocName= mnfe.fullPath.substring(0, idxof);
}
else {
subDocName = mnfe.fullPath;
}
RepInfo subDoc = new RepInfo(subDocName);
subDoc.setModule(this);
subDoc.setFormat("ODF");
subDoc.setProfile((String)mimeTypeMap.get(mnfe.mediaType));
subDoc.setMimeType(mnfe.mediaType);
subDoc.setValid(true);
subDoc.setWellFormed(true);
subDoc.setConsistent(true);
repInfo.putEmbeddedRepInfo(subDocName, subDoc);
}
else if ( mnfe.mediaType.equals("") ||
mnfe.mediaType.equals(SKIP_TYPE) ||
mnfe.mediaType.startsWith(SKIP_APP)) {
}
else {
ZipEntry part = zipf.getEntry(mnfe.fullPath);
if (part==null) {
// Manifest holds information of "virtual"
// file entries, like Configurations2 (a directory)
break;
}
// good for processing
if (! part.isDirectory() &&
part.getSize() > 0) {
String partFileName = dumpPart(part, zipf);
if (mnfe.mediaType.equals(XRNG_TYPE)) {
if (! jd.doValidation(getResource(SCHEMA_OPENDOCUMENT),
partFileName,
errorStream)) {
NullHandler nullHandler = new NullHandler();
try {
jhoveBase.dispatch(_app,
null,
null,
nullHandler,
null,
new String[] {partFileName});
String partDocName;
int idxofp = mnfe.fullPath.indexOf("/");
if (idxofp<1) {
partDocName = mnfe.fullPath;
}
else {
partDocName= mnfe.fullPath.substring(0, idxofp-1);
}
RepInfo current = repInfo.getEmbeddedRepInfo(partDocName);
if (current==null) {
current=repInfo;
}
for (Iterator iter2 = nullHandler.getRepInfos(); iter2.hasNext();) {
if ( ((RepInfo)iter2.next()).getWellFormed() != RepInfo.TRUE) {
repInfo.setValid(false);
}
}
if (repInfo.getValid() == RepInfo.TRUE && ! alreadyNonPreservable) {
alreadyNonPreservable=true;
repInfo.setProfile((String)mimeTypeMap.get(repInfo.getMimeType()));
}
else {
StringBuffer buf = new StringBuffer("Invalid ODF Package, component ");
buf.append(mnfe.fullPath);
buf.append(" failed both Relaxed NG and normal XML validation therefore" );
buf.append(" is not well formed.");
repInfo.setValid(false);
repInfo.setMessage(new ErrorMessage(buf.toString()));
}
} catch (Exception excptn) {
StringBuffer buf = new StringBuffer("Invalid ODF Package, component ");
buf.append(mnfe.fullPath);
buf.append(" failed both Relaxed NG and normal XML validation " );
buf.append(" due this error: ");
buf.append(excptn.getMessage());
repInfo.setValid(false);
repInfo.setMessage(new ErrorMessage(buf.toString()));
}
}
if (mnfe.fullPath.equals(META_FILE)) {
MetaHandler metaHandler = new MetaHandler(repInfo);
parser.setContentHandler (metaHandler);
try {
parser.parse (partFileName);
} catch (SAXException excptn) {
repInfo.setValid(false);
repInfo.setMessage(new ErrorMessage("malformed meta.xml: " +
excptn.getMessage()));
}
}
}
else if (mnfe.mediaType.startsWith(IMG_TYPE)) {
// For the files in the Picture directory
NullHandler nullHandler = new NullHandler();
try {
jhoveBase.dispatch(_app,
null,
null,
nullHandler,
null,
new String[] {partFileName});