f = new File(this.documentRootDir, path + extension);
}
if (!f.exists())
{
throw new PageNotFoundException("Document not found: " + path);
}
try
{
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbfactory.newDocumentBuilder();
org.w3c.dom.Document d = builder.parse(f);
Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
document = (Document) unmarshaller.unmarshal((org.w3c.dom.Node) d);
document.setId(path);
document.setPath(path);
AbstractBaseElement documentImpl = (AbstractBaseElement)document;
documentImpl.setHandlerFactory(handlerFactory);
documentImpl.setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
documentImpl.setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
}
catch (IOException e)
{
throw new PageNotFoundException("Could not load the file " + f.getAbsolutePath(), e);
}
catch (MarshalException e)
{
throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
}
catch (MappingException e)
{
throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
}
catch (ValidationException e)
{
throw new DocumentNotFoundException("Document " + f.getAbsolutePath() + " is not valid", e);
}
catch (SAXException e)
{
throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
}
catch (ParserConfigurationException e)
{
throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(), e);
}
if (document == null)
{