mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-04 23:27:21 +00:00
Refactor reveal call stack to apply facade pattern.
This commit is contained in:
@@ -53,12 +53,22 @@ public class DokanyVolume extends AbstractVolume {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reveal(Revealer r) throws VolumeException {
|
||||
public void reveal(RevealerFacade r) throws VolumeException {
|
||||
try {
|
||||
mount.reveal(r);
|
||||
mount.reveal(p -> {
|
||||
try {
|
||||
r.reveal(p);
|
||||
} catch (VolumeException e) {
|
||||
throw new RevealException(e);
|
||||
}
|
||||
});
|
||||
} catch (RevealException e) {
|
||||
LOG.debug("Revealing the vault in file manger failed: " + e.getMessage());
|
||||
throw new VolumeException(e);
|
||||
if (e.getCause() instanceof VolumeException) {
|
||||
throw (VolumeException) e.getCause();
|
||||
} else {
|
||||
throw new VolumeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,12 +73,22 @@ public class FuseVolume extends AbstractVolume {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reveal(Revealer r) throws VolumeException {
|
||||
public void reveal(RevealerFacade r) throws VolumeException {
|
||||
try {
|
||||
mount.reveal(r);
|
||||
mount.reveal(p -> {
|
||||
try {
|
||||
r.reveal(p);
|
||||
} catch (VolumeException e) {
|
||||
throw new RevealException(e);
|
||||
}
|
||||
});
|
||||
} catch (RevealException e) {
|
||||
LOG.debug("Revealing the vault in file manger failed: " + e.getMessage());
|
||||
throw new VolumeException(e);
|
||||
if (e.getCause() instanceof VolumeException) {
|
||||
throw (VolumeException) e.getCause();
|
||||
} else {
|
||||
throw new VolumeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public class Vault {
|
||||
}
|
||||
}
|
||||
|
||||
public void reveal(Volume.Revealer vaultRevealer) throws VolumeException {
|
||||
public void reveal(Volume.RevealerFacade vaultRevealer) throws VolumeException {
|
||||
volume.reveal(vaultRevealer);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.cryptomator.common.vaults;
|
||||
import org.cryptomator.common.mountpoint.InvalidMountPointException;
|
||||
import org.cryptomator.common.settings.VolumeImpl;
|
||||
import org.cryptomator.cryptofs.CryptoFileSystem;
|
||||
import org.cryptomator.frontend.fuse.mount.Revealer;
|
||||
import org.cryptomator.frontend.webdav.mount.Mounter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
@@ -38,9 +36,10 @@ public interface Volume {
|
||||
|
||||
/**
|
||||
* TODO: refactor, such that this method accepts a (new) interface revealer and document that it could be ignored.
|
||||
*
|
||||
* @throws VolumeException
|
||||
*/
|
||||
void reveal(Revealer revealer) throws VolumeException;
|
||||
void reveal(RevealerFacade revealer) throws VolumeException;
|
||||
|
||||
void unmount() throws VolumeException;
|
||||
|
||||
@@ -85,10 +84,10 @@ public interface Volume {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to bundle the different revealer interfaces in the used nio-adapters
|
||||
*/
|
||||
interface Revealer extends org.cryptomator.frontend.fuse.mount.Revealer, org.cryptomator.frontend.dokany.Revealer, Mounter.Revealer{
|
||||
@FunctionalInterface
|
||||
interface RevealerFacade {
|
||||
|
||||
void reveal(Path p) throws VolumeException;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -73,12 +73,22 @@ public class WebDavVolume implements Volume {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reveal(Revealer r) throws VolumeException {
|
||||
public void reveal(RevealerFacade r) throws VolumeException {
|
||||
try {
|
||||
mount.reveal(r);
|
||||
mount.reveal(p -> {
|
||||
try {
|
||||
r.reveal(p);
|
||||
} catch (VolumeException e) {
|
||||
throw new Mounter.RevealException(e);
|
||||
}
|
||||
});
|
||||
} catch (Mounter.RevealException e) {
|
||||
LOG.debug("Revealing the vault in file manger failed: " + e.getMessage());
|
||||
throw new VolumeException(e);
|
||||
if (e.getCause() instanceof VolumeException) {
|
||||
throw (VolumeException) e.getCause();
|
||||
} else {
|
||||
throw new VolumeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user