Search in sources :

Example 1 with MCRVFSContent

use of org.mycore.common.content.MCRVFSContent in project mycore by MyCoRe-Org.

the class MCRFileCollection method readAdditionalData.

private void readAdditionalData() throws IOException {
    FileObject src = VFS.getManager().resolveFile(fo, dataFile);
    if (!src.exists()) {
        LOGGER.warn("Metadata file is missing, repairing metadata...");
        data = new Element("collection");
        new Document(data);
        repairMetadata();
    }
    try {
        data = new MCRVFSContent(src).asXML().getRootElement();
    } catch (JDOMException | SAXException e) {
        throw new IOException(e);
    }
}
Also used : Element(org.jdom2.Element) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException) MCRVFSContent(org.mycore.common.content.MCRVFSContent) SAXException(org.xml.sax.SAXException)

Example 2 with MCRVFSContent

use of org.mycore.common.content.MCRVFSContent in project mycore by MyCoRe-Org.

the class MCRCategLinkServiceImplTest method loadWorldClassification.

private void loadWorldClassification() throws URISyntaxException, MCRException, SAXParseException, IOException {
    URL worlClassUrl = this.getClass().getResource(WORLD_CLASS_RESOURCE_NAME);
    Document xml = MCRXMLParserFactory.getParser().parseXML(new MCRVFSContent(worlClassUrl));
    category = MCRXMLTransformer.getCategory(xml);
}
Also used : Document(org.jdom2.Document) URL(java.net.URL) MCRVFSContent(org.mycore.common.content.MCRVFSContent)

Example 3 with MCRVFSContent

use of org.mycore.common.content.MCRVFSContent in project mycore by MyCoRe-Org.

the class MCRCStoreVFS method doRetrieveMCRContent.

protected MCRContent doRetrieveMCRContent(MCRFile file) throws IOException {
    FileObject targetObject = fsManager.resolveFile(getBase(), file.getStorageID());
    MCRVFSContent content = new MCRVFSContent(targetObject);
    content.setName(file.getName());
    return content;
}
Also used : FileObject(org.apache.commons.vfs2.FileObject) MCRVFSContent(org.mycore.common.content.MCRVFSContent)

Example 4 with MCRVFSContent

use of org.mycore.common.content.MCRVFSContent in project mycore by MyCoRe-Org.

the class MCRCategoryDAOImplTest method loadClassificationResource.

public static MCRCategory loadClassificationResource(String resourceName) throws SAXParseException, IOException, URISyntaxException {
    URL classResourceUrl = MCRCategoryDAOImplTest.class.getResource(resourceName);
    Document xml = MCRXMLParserFactory.getParser().parseXML(new MCRVFSContent(classResourceUrl));
    return MCRXMLTransformer.getCategory(xml);
}
Also used : Document(org.jdom2.Document) URL(java.net.URL) MCRVFSContent(org.mycore.common.content.MCRVFSContent)

Example 5 with MCRVFSContent

use of org.mycore.common.content.MCRVFSContent in project mycore by MyCoRe-Org.

the class MCRCategoryImplTest method loadWorldClassification.

/**
 * @throws URISyntaxException
 * @throws SAXParseException
 * @throws MCRException
 */
private void loadWorldClassification() throws URISyntaxException, MCRException, SAXParseException, IOException {
    URL worlClassUrl = this.getClass().getResource(WORLD_CLASS_RESOURCE_NAME);
    Document xml = MCRXMLParserFactory.getParser().parseXML(new MCRVFSContent(worlClassUrl));
    category = MCRCategoryImpl.wrapCategory(MCRXMLTransformer.getCategory(xml), null, null);
    category.calculateLeftRightAndLevel(1, 0);
}
Also used : Document(org.jdom2.Document) URL(java.net.URL) MCRVFSContent(org.mycore.common.content.MCRVFSContent)

Aggregations

MCRVFSContent (org.mycore.common.content.MCRVFSContent)7 Document (org.jdom2.Document)5 URL (java.net.URL)3 FileObject (org.apache.commons.vfs2.FileObject)2 IOException (java.io.IOException)1 Element (org.jdom2.Element)1 JDOMException (org.jdom2.JDOMException)1 SAXException (org.xml.sax.SAXException)1