Search in sources :

Example 1 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class Serialization method save.

/**
 * @param project
 * @param root
 * @param format
 * @throws ProjectSaveException
 */
public static void save(final Project project, final Path root) throws ProjectSaveException {
    Objects.requireNonNull(project);
    Objects.requireNonNull(root);
    try {
        new YamlSerializer().serializeProjectTo(project, root);
    } catch (final WriteException e) {
        throw new ProjectSaveException(root, e);
    }
}
Also used : WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) YamlSerializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlSerializer) ProjectSaveException(com.developmentontheedge.be5.metadata.exception.ProjectSaveException)

Example 2 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

public void serialize(final PageCustomizations customizations) throws WriteException {
    this.fileSystem = new ProjectFileSystem(customizations.getProject());
    new CustomizationSerializer().serialize(customizations.getModule());
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)

Example 3 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

private List<Object> serialize(final FreemarkerCatalog scripts, Function<String, Path> getPath, final boolean serializeReferencedFiles) throws WriteException {
    List<Object> paths = list();
    for (final FreemarkerScript script : scripts.getScripts()) {
        try {
            String relativePath = script.getRelativePath(scripts);
            if (serializeReferencedFiles) {
                final Path scriptFile = getPath.apply(relativePath);
                if (!Files.exists(scriptFile.getParent()))
                    Files.createDirectories(scriptFile.getParent());
                if (!script.isLoaded())
                    continue;
                write(scriptFile, script);
                script.setLinkedFile(scriptFile);
            }
            paths.add(relativePath);
        } catch (final Exception e) {
            throw new WriteException(script, e);
        }
    }
    return paths;
}
Also used : Path(java.nio.file.Path) WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) FreemarkerScript(com.developmentontheedge.be5.metadata.model.FreemarkerScript) ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) WriteException(com.developmentontheedge.be5.metadata.exception.WriteException)

Example 4 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

public void serialize(final Daemons daemons) throws WriteException {
    this.fileSystem = new ProjectFileSystem(daemons.getProject());
    new DaemonsSerializer().serialize(daemons);
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)

Example 5 with WriteException

use of com.developmentontheedge.be5.metadata.exception.WriteException in project be5 by DevelopmentOnTheEdge.

the class YamlSerializer method serialize.

public void serialize(final SecurityCollection security) throws WriteException {
    this.fileSystem = new ProjectFileSystem(security.getProject());
    new SecuritySerializer().serialize(security);
}
Also used : ProjectFileSystem(com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)

Aggregations

ProjectFileSystem (com.developmentontheedge.be5.metadata.serialization.ProjectFileSystem)9 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)4 IOException (java.io.IOException)3 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 ProjectSaveException (com.developmentontheedge.be5.metadata.exception.ProjectSaveException)1 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)1 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)1 Module (com.developmentontheedge.be5.metadata.model.Module)1 SourceFile (com.developmentontheedge.be5.metadata.model.SourceFile)1 SourceFileCollection (com.developmentontheedge.be5.metadata.model.SourceFileCollection)1 YamlSerializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlSerializer)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Path (java.nio.file.Path)1