mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-24 19:46:56 -04: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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class VaultService {
|
||||
|
||||
private final ExecutorService executorService;
|
||||
|
||||
private AtomicReference<Volume.Revealer> vaultRevealer;
|
||||
private AtomicReference<Volume.RevealerFacade> vaultRevealer;
|
||||
|
||||
@Inject
|
||||
public VaultService(ExecutorService executorService) {
|
||||
@@ -37,7 +37,7 @@ public class VaultService {
|
||||
executorService.execute(createRevealTask(vault));
|
||||
}
|
||||
|
||||
public void setVaultRevealer(Volume.Revealer revealer){
|
||||
public void setVaultRevealer(Volume.RevealerFacade revealer) {
|
||||
this.vaultRevealer.set(revealer);
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ public class VaultService {
|
||||
private static class RevealVaultTask extends Task<Vault> {
|
||||
|
||||
private final Vault vault;
|
||||
private final Volume.Revealer revealer;
|
||||
private final Volume.RevealerFacade revealer;
|
||||
|
||||
/**
|
||||
* @param vault The vault to lock
|
||||
* @param revealer The object to use to show the vault content to the user.
|
||||
*/
|
||||
public RevealVaultTask(Vault vault, Volume.Revealer revealer) {
|
||||
public RevealVaultTask(Vault vault, Volume.RevealerFacade revealer) {
|
||||
this.vault = vault;
|
||||
this.revealer = revealer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user