public static FileSystem newInstance(io.vertx.core.file.FileSystem arg) { return arg != null ? new FileSystem(arg) : null; } }
/** * Change the permissions on the file represented by <code>path</code> to <code>perms</code>, asynchronously. * <p> * The permission String takes the form rwxr-x--- as * specified <a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>. * @param path the path to the file * @param perms the permissions string * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxChmod} instead */ @Deprecated() public Observable<Void> chmodObservable(String path, String perms) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); chmod(path, perms, handler.toHandler()); return handler; }
/** * Change the ownership on the file represented by <code>path</code> to <code>user</code> and {code group}, asynchronously. * @param path the path to the file * @param user the user name, <code>null</code> will not change the user name * @param group the user group, <code>null</code> will not change the user group name * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxChown} instead */ @Deprecated() public Observable<Void> chownObservable(String path, String user, String group) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); chown(path, user, group, handler.toHandler()); return handler; }
private Observable<DeployApplicationRequest> removeRunFile(DeployApplicationRequest deployApplicationRequest) { deployApplicationRequest.setRunning(false); return rxVertx.fileSystem().rxExists(config.getRunDir() + moduleIdToStop) .toObservable() .flatMap(exists -> { if (exists) { LOG.info("[{} - {}]: Removing runfile for application with applicationId '{}'.", LogConstants.DEPLOY_REQUEST, deployApplicationRequest.getId(), moduleIdToStop); return rxVertx.fileSystem().rxDelete(config.getRunDir() + moduleIdToStop) .toObservable() .flatMap(x -> just(deployApplicationRequest)); } else { return just(deployApplicationRequest); } }); }
public Observable<Boolean> cleanup() { List<String> runningApplications = new ProcessUtils(config).listModules(); FileSystem fs = new io.vertx.rxjava.core.Vertx(vertx).fileSystem(); return fs.rxReadDir(config.getRunDir()) .toObservable() .flatMapIterable(x -> x) .flatMap(s -> just(Pattern.compile("/").splitAsStream(s).reduce((a, b) -> b).orElse(""))) .filter(s -> !s.isEmpty() && !runningApplications.contains(s)) .flatMap(file -> fs.rxDelete(config.getRunDir() + file).toObservable()) .toList() .flatMap(x -> just(Boolean.TRUE).doOnError(t -> LOG.error("error"))) .onErrorReturn(x -> { LOG.error("Error during cleanup of run files {}", x.getMessage()); return Boolean.FALSE; }); }
private Observable<DeployApplicationRequest> registerApplication(DeployApplicationRequest deployApplicationRequest) { io.vertx.rxjava.core.Vertx rxVertx = new io.vertx.rxjava.core.Vertx(vertx); return rxVertx.fileSystem() .rxExists(config.getRunDir() + deployApplicationRequest.getModuleId()) .toObservable() .flatMap(exists -> { if (!exists) { return rxVertx.fileSystem().rxCreateFile(config.getRunDir() + deployApplicationRequest.getModuleId()) .toObservable() .flatMap(x -> just(deployApplicationRequest)); } else { return just(deployApplicationRequest); } }); }
Observable<DeployApplicationRequest> readServiceDefaults(DeployApplicationRequest request) { Properties serviceProperties = new Properties(); String path = deployConfig.getServiceConfigLocation() + request.getGroupId() + ":" + request.getArtifactId(); return rxVertx.fileSystem().rxExists(path) .toObservable() .filter(Boolean.TRUE::equals) .map(x -> path) .switchIfEmpty(rxVertx.fileSystem().rxExists(path.replace(":", "~")) .toObservable() .filter(Boolean.TRUE::equals) .rxReadFile(location) .toObservable() .flatMap(buffer -> {
.setWrite(true) .setTruncateExisting(true); return fs.rxOpen(archivePath, openOptions) .flatMap(file -> { return doDownload(downloadUrl, file)
/** * Download and extract Elasticsearch to a given location. If the destination * exists already this method does nothing. * @param downloadUrl the URL to the ZIP file containing Elasticsearch * @param destPath the path to the destination folder where the downloaded ZIP * file should be extracted to * @param strip <code>true</code> if the first path element of all items in the * ZIP file should be stripped away. * @return a single emitting the path to the extracted Elasticsearch */ public Single<String> download(String downloadUrl, String destPath, boolean strip) { FileSystem fs = vertx.fileSystem(); return fs.rxExists(destPath) .flatMap(exists -> { if (exists) { return Single.just(destPath); } return downloadNoCheck(downloadUrl, destPath, strip); }); }
/** * Creates an empty file with the specified <code>path</code>, asynchronously. * @param path path to the file * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxCreateFile} instead */ @Deprecated() public Observable<Void> createFileObservable(String path) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); createFile(path, handler.toHandler()); return handler; }
/** * Copy a file from the path <code>from</code> to path <code>to</code>, asynchronously. * @param from the path to copy from * @param to the path to copy to * @param options options describing how the file should be copied * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxCopy} instead */ @Deprecated() public Observable<Void> copyObservable(String from, String to, CopyOptions options) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); copy(from, to, options, handler.toHandler()); return handler; }
/** * Copy a file from the path <code>from</code> to path <code>to</code>, asynchronously. * <p> * If <code>recursive</code> is <code>true</code> and <code>from</code> represents a directory, then the directory and its contents * will be copied recursively to the destination <code>to</code>. * <p> * The copy will fail if the destination if the destination already exists. * @param from the path to copy from * @param to the path to copy to * @param recursive * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxCopyRecursive} instead */ @Deprecated() public Observable<Void> copyRecursiveObservable(String from, String to, boolean recursive) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); copyRecursive(from, to, recursive, handler.toHandler()); return handler; }
/** * Change the permissions on the file represented by <code>path</code> to <code>perms</code>, asynchronously.<p> * The permission String takes the form rwxr-x--- as * specified in {<a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>}. * <p> * If the file is directory then all contents will also have their permissions changed recursively. Any directory permissions will * be set to <code>dirPerms</code>, whilst any normal file permissions will be set to <code>perms</code>. * @param path the path to the file * @param perms the permissions string * @param dirPerms the directory permissions * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxChmodRecursive} instead */ @Deprecated() public Observable<Void> chmodRecursiveObservable(String path, String perms, String dirPerms) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); chmodRecursive(path, perms, dirPerms, handler.toHandler()); return handler; }
return fs.rxOpen(path, openOptions) .flatMap(file -> { ObservableFuture<ImportResult> o = RxHelper.observableFuture();
/** * Creates an empty file with the specified <code>path</code> and permissions <code>perms</code>, asynchronously. * @param path path to the file * @param perms the permissions string * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxCreateFile} instead */ @Deprecated() public Observable<Void> createFileObservable(String path, String perms) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); createFile(path, perms, handler.toHandler()); return handler; }
/** * Copy a file from the path <code>from</code> to path <code>to</code>, asynchronously. * @param from the path to copy from * @param to the path to copy to * @param options options describing how the file should be copied * @return a reference to this, so the API can be used fluently */ public Single<Void> rxCopy(String from, String to, CopyOptions options) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { copy(from, to, options, fut); })); }
/** * Copy a file from the path <code>from</code> to path <code>to</code>, asynchronously. * <p> * If <code>recursive</code> is <code>true</code> and <code>from</code> represents a directory, then the directory and its contents * will be copied recursively to the destination <code>to</code>. * <p> * The copy will fail if the destination if the destination already exists. * @param from the path to copy from * @param to the path to copy to * @param recursive * @return a reference to this, so the API can be used fluently */ public Single<Void> rxCopyRecursive(String from, String to, boolean recursive) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { copyRecursive(from, to, recursive, fut); })); }
/** * Change the permissions on the file represented by <code>path</code> to <code>perms</code>, asynchronously.<p> * The permission String takes the form rwxr-x--- as * specified in {<a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>}. * <p> * If the file is directory then all contents will also have their permissions changed recursively. Any directory permissions will * be set to <code>dirPerms</code>, whilst any normal file permissions will be set to <code>perms</code>. * @param path the path to the file * @param perms the permissions string * @param dirPerms the directory permissions * @return a reference to this, so the API can be used fluently */ public Single<Void> rxChmodRecursive(String path, String perms, String dirPerms) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { chmodRecursive(path, perms, dirPerms, fut); })); }
/** * Creates an empty file with the specified <code>path</code>, asynchronously. * @param path path to the file * @return a reference to this, so the API can be used fluently */ public Single<Void> rxCreateFile(String path) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { createFile(path, fut); })); }