Search in sources :

Example 1 with XmlException

use of com.enonic.xp.xml.XmlException in project xp by enonic.

the class AbstractGetAdminToolDescriptorCommand method parseXml.

protected void parseXml(final Resource resource, final AdminToolDescriptor.Builder builder) {
    try {
        final XmlAdminToolDescriptorParser parser = new XmlAdminToolDescriptorParser();
        parser.builder(builder);
        parser.source(resource.readString());
        parser.parse();
    } catch (final Exception e) {
        throw new XmlException(e, "Could not load admin app descriptor [" + resource.getUrl() + "]: " + e.getMessage());
    }
}
Also used : XmlException(com.enonic.xp.xml.XmlException) XmlException(com.enonic.xp.xml.XmlException)

Example 2 with XmlException

use of com.enonic.xp.xml.XmlException in project xp by enonic.

the class LayoutDescriptorLoader method parseXml.

private void parseXml(final Resource resource, final LayoutDescriptor.Builder builder) {
    try {
        final XmlLayoutDescriptorParser parser = new XmlLayoutDescriptorParser();
        parser.builder(builder);
        parser.currentApplication(resource.getKey().getApplicationKey());
        parser.source(resource.readString());
        parser.parse();
    } catch (final Exception e) {
        throw new XmlException(e, "Could not load layout descriptor [" + resource.getUrl() + "]: " + e.getMessage());
    }
}
Also used : XmlLayoutDescriptorParser(com.enonic.xp.xml.parser.XmlLayoutDescriptorParser) XmlException(com.enonic.xp.xml.XmlException) XmlException(com.enonic.xp.xml.XmlException)

Example 3 with XmlException

use of com.enonic.xp.xml.XmlException in project xp by enonic.

the class PartDescriptorLoader method parseXml.

private void parseXml(final Resource resource, final PartDescriptor.Builder builder) {
    try {
        final XmlPartDescriptorParser parser = new XmlPartDescriptorParser();
        parser.builder(builder);
        parser.currentApplication(resource.getKey().getApplicationKey());
        parser.source(resource.readString());
        parser.parse();
    } catch (final Exception e) {
        throw new XmlException(e, "Could not load part descriptor [" + resource.getUrl() + "]: " + e.getMessage());
    }
}
Also used : XmlPartDescriptorParser(com.enonic.xp.xml.parser.XmlPartDescriptorParser) XmlException(com.enonic.xp.xml.XmlException) XmlException(com.enonic.xp.xml.XmlException)

Example 4 with XmlException

use of com.enonic.xp.xml.XmlException in project xp by enonic.

the class NodeImporter method processNodeSource.

private Node processNodeSource(final VirtualFile nodeFolder, final ProcessNodeSettings.Builder processNodeSettings) {
    final VirtualFile nodeSource = this.exportReader.getNodeSource(nodeFolder);
    final CharSource nodeCharSource;
    try {
        nodeCharSource = transformer == null ? nodeSource.getCharSource() : CharSource.wrap(this.transformer.transform(nodeSource.getCharSource()));
    } catch (Exception e) {
        throw new ImportNodeException("Error during XSLT pre-processing for node in '" + nodeSource.getUrl() + "'", e);
    }
    final Node.Builder newNodeBuilder = Node.create();
    try {
        final XmlNodeParser parser = new XmlNodeParser();
        parser.builder(newNodeBuilder);
        parser.source(nodeCharSource);
        parser.parse();
    } catch (final Exception e) {
        throw new XmlException(e, "Could not load source node [" + nodeSource.getUrl() + "]: ", e);
    }
    final Node newNode = newNodeBuilder.build();
    final NodePath importNodePath = NodeImportPathResolver.resolveNodeImportPath(nodeFolder, this.exportRoot, this.importRoot);
    final ImportNodeResult importNodeResult = importNode(nodeFolder, processNodeSettings, newNode, importNodePath);
    if (nodeImportListener != null) {
        nodeImportListener.nodeImported(1L);
    }
    if (importNodeResult.isPreExisting()) {
        result.updated(importNodeResult.getNode().path());
    } else {
        result.added(importNodeResult.getNode().path());
    }
    return importNodeResult.getNode();
}
Also used : VirtualFile(com.enonic.xp.vfs.VirtualFile) CharSource(com.google.common.io.CharSource) ImportNodeException(com.enonic.xp.export.ImportNodeException) XmlException(com.enonic.xp.xml.XmlException) Node(com.enonic.xp.node.Node) ImportNodeResult(com.enonic.xp.node.ImportNodeResult) XmlNodeParser(com.enonic.xp.core.impl.export.xml.XmlNodeParser) ImportNodeException(com.enonic.xp.export.ImportNodeException) XmlException(com.enonic.xp.xml.XmlException) NodePath(com.enonic.xp.node.NodePath)

Example 5 with XmlException

use of com.enonic.xp.xml.XmlException in project xp by enonic.

the class MacroDescriptorServiceImpl method parseXml.

private void parseXml(final Resource resource, final MacroDescriptor.Builder builder) {
    try {
        final XmlMacroDescriptorParser parser = new XmlMacroDescriptorParser();
        parser.builder(builder);
        parser.currentApplication(resource.getKey().getApplicationKey());
        parser.source(resource.readString());
        parser.parse();
    } catch (final Exception e) {
        throw new XmlException(e, "Could not load macro descriptor [" + resource.getUrl() + "]: " + e.getMessage());
    }
}
Also used : XmlException(com.enonic.xp.xml.XmlException) XmlMacroDescriptorParser(com.enonic.xp.xml.parser.XmlMacroDescriptorParser) XmlException(com.enonic.xp.xml.XmlException)

Aggregations

XmlException (com.enonic.xp.xml.XmlException)7 XmlNodeParser (com.enonic.xp.core.impl.export.xml.XmlNodeParser)1 ImportNodeException (com.enonic.xp.export.ImportNodeException)1 ImportNodeResult (com.enonic.xp.node.ImportNodeResult)1 Node (com.enonic.xp.node.Node)1 NodePath (com.enonic.xp.node.NodePath)1 VirtualFile (com.enonic.xp.vfs.VirtualFile)1 XmlIdProviderDescriptorParser (com.enonic.xp.xml.parser.XmlIdProviderDescriptorParser)1 XmlLayoutDescriptorParser (com.enonic.xp.xml.parser.XmlLayoutDescriptorParser)1 XmlMacroDescriptorParser (com.enonic.xp.xml.parser.XmlMacroDescriptorParser)1 XmlPageDescriptorParser (com.enonic.xp.xml.parser.XmlPageDescriptorParser)1 XmlPartDescriptorParser (com.enonic.xp.xml.parser.XmlPartDescriptorParser)1 CharSource (com.google.common.io.CharSource)1