@Override public ProcessNode load(final Path path) { try { final String content = ioService.readAllString(Paths.convert(path)); return BpmnPersistence.getInstance().unmarshal(content); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public Path save( final Path path, final ProcessNode content, final Metadata metadata, final String comment) { try { ioService.write( Paths.convert(path), BpmnPersistence.getInstance().marshal(content), MetadataFactory.makeMetadata(metadata), CommentedOptionFactory.makeCommentedOption(identity, sessionInfo, comment)); return path; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@PostConstruct public void setup() { try { fileSystem = ioService.newFileSystem( URI.create("default://bpmn"), new HashMap<String, Object>() { { put("init", Boolean.TRUE); put("internal", Boolean.TRUE); } }); } catch (final FileSystemAlreadyExistsException e) { fileSystem = ioService.getFileSystem(URI.create("default://bpmn")); } this.root = fileSystem.getRootDirectories().iterator().next(); ioService.write( root.resolve("file1.bpmn"), BpmnPersistence.getInstance().marshal(new ProcessNode())); }
@Override public Path create( final Path context, final String fileName, final ProcessNode content, final String comment) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName); final Path newPath = Paths.convert(nioPath); if (ioService.exists(nioPath)) { throw new FileAlreadyExistsException(nioPath.toString()); } ioService.write( nioPath, BpmnPersistence.getInstance().marshal(content), CommentedOptionFactory.makeCommentedOption(identity, sessionInfo, comment)); return newPath; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }