mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-30 19:56:00 +00:00
exception handling during mount/unmount/reveal operations
This commit is contained in:
+11
-26
@@ -4,9 +4,9 @@ import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend;
|
||||
import org.cryptomator.frontend.FrontendCreationFailedException;
|
||||
import org.cryptomator.frontend.webdav.mount.CommandFailedException;
|
||||
import org.cryptomator.frontend.webdav.mount.WebDavMount;
|
||||
import org.cryptomator.frontend.webdav.mount.WebDavMounterProvider;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
@@ -36,36 +36,21 @@ class WebDavFrontend implements Frontend {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mount(Map<MountParam, Optional<String>> mountParams) {
|
||||
try {
|
||||
mount = webdavMounterProvider.get().mount(uri, mountParams);
|
||||
return true;
|
||||
} catch (CommandFailedException e) {
|
||||
return false;
|
||||
public void mount(Map<MountParam, Optional<String>> mountParams) throws CommandFailedException {
|
||||
mount = webdavMounterProvider.get().mount(uri, mountParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unmount() throws CommandFailedException {
|
||||
if (mount != null) {
|
||||
mount.unmount();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unmount() {
|
||||
public void reveal() throws CommandFailedException {
|
||||
if (mount != null) {
|
||||
try {
|
||||
mount.unmount();
|
||||
} catch (CommandFailedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reveal() {
|
||||
if (mount != null) {
|
||||
try {
|
||||
mount.reveal();
|
||||
} catch (CommandFailedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
mount.reveal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Sebastian Stenzel
|
||||
* This file is licensed under the terms of the MIT license.
|
||||
* See the LICENSE.txt file for more info.
|
||||
*
|
||||
* Contributors:
|
||||
* Sebastian Stenzel - initial API and implementation
|
||||
* Markus Kreusch - Refactored WebDavMounter to use strategy pattern
|
||||
******************************************************************************/
|
||||
package org.cryptomator.frontend.webdav.mount;
|
||||
|
||||
public class CommandFailedException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 5784853630182321479L;
|
||||
|
||||
public CommandFailedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CommandFailedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -12,6 +12,7 @@ import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend.MountParam;
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend.MountParam;
|
||||
import org.cryptomator.frontend.webdav.mount.command.Script;
|
||||
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend.MountParam;
|
||||
import org.cryptomator.frontend.webdav.mount.command.Script;
|
||||
|
||||
|
||||
+2
@@ -8,6 +8,8 @@
|
||||
******************************************************************************/
|
||||
package org.cryptomator.frontend.webdav.mount;
|
||||
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
|
||||
/**
|
||||
* A mounted webdav share.
|
||||
*
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend.MountParam;
|
||||
|
||||
public interface WebDavMounter {
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend.MountParam;
|
||||
import org.cryptomator.frontend.webdav.mount.command.CommandResult;
|
||||
import org.cryptomator.frontend.webdav.mount.command.Script;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.cryptomator.frontend.webdav.mount.CommandFailedException;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.frontend.webdav.mount.CommandFailedException;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.cryptomator.frontend.webdav.mount.CommandFailedException;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
|
||||
final class FutureCommandResult implements Future<CommandResult>, Runnable {
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.cryptomator.frontend.webdav.mount.CommandFailedException;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
|
||||
public final class Script {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user