Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Dec 19, 2016
1 parent ed10997 commit 5a3428d
Showing 1 changed file with 11 additions and 29 deletions.
40 changes: 11 additions & 29 deletions main/ui/src/main/java/org/cryptomator/ui/model/Vault.java
Expand Up @@ -15,7 +15,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;

import javax.inject.Inject;
Expand All @@ -39,21 +38,20 @@
import javafx.beans.binding.Binding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.ObservableList;

@PerVault
public class Vault {

private static final Logger LOG = LoggerFactory.getLogger(Vault.class);

@Deprecated
public static final String VAULT_FILE_EXTENSION = ".cryptomator";

private final VaultSettings vaultSettings;
private final WebDavServer server;
private final DeferredCloser closer;

private final BooleanProperty unlocked = new SimpleBooleanProperty();
private final BooleanProperty mounted = new SimpleBooleanProperty();

private final AtomicReference<CryptoFileSystem> cryptoFileSystem = new AtomicReference<>();

@Inject
Expand All @@ -79,16 +77,16 @@ private CryptoFileSystem createCryptoFileSystem(CharSequence passphrase) throws
}

public void create(CharSequence passphrase) throws IOException {
getCryptoFileSystem(passphrase);
// TODO and now?
// TODO overheadhunter/markuskreusch check (via cryptofs) if already existing? if not, just call:
getCryptoFileSystem(passphrase); // implicitly creates a non-existing vault
}

public void changePassphrase(CharSequence oldPassphrase, CharSequence newPassphrase) throws IOException, InvalidPassphraseException {
// TODO implement
// TODO overheadhunter/markuskreusch implement in cryptofs
}

public synchronized void activateFrontend(CharSequence passphrase) {
boolean launchSuccess = false;
boolean unlockSuccess = false;
boolean mountSuccess = false;
try {
FileSystem fs = getCryptoFileSystem(passphrase);
Expand All @@ -101,7 +99,7 @@ public synchronized void activateFrontend(CharSequence passphrase) {
} finally {
// unlocked is a observable property and should only be changed by the FX application thread
Platform.runLater(() -> {
unlocked.set(launchSuccess);
unlocked.set(unlockSuccess);
mounted.set(mountSuccess);
});
}
Expand All @@ -120,7 +118,7 @@ public synchronized void deactivateFrontend() throws Exception {
}

public synchronized void reveal() {
// TODO implement
// TODO overheadhunter implement mounting utility in webdav-nio-adapter
}

// ******************************************************************************
Expand All @@ -131,7 +129,7 @@ public VaultSettings getVaultSettings() {
return vaultSettings;
}

public synchronized String getWebDavUrl() {
public String getWebDavUrl() {
// TODO implement
return "http://localhost/not/implemented";
}
Expand All @@ -157,7 +155,7 @@ public Binding<String> displayablePath() {
* @return Directory name without preceeding path components and file extension
*/
public Binding<String> name() {
return EasyBind.map(vaultSettings.pathProperty(), p -> p.getFileName().toString());
return EasyBind.map(vaultSettings.pathProperty(), Path::getFileName).map(Path::toString);
}

public boolean doesVaultDirectoryExist() {
Expand All @@ -166,7 +164,7 @@ public boolean doesVaultDirectoryExist() {

public boolean isValidVaultDirectory() {
try {
return doesVaultDirectoryExist(); // TODO: && cryptoFileSystemFactory.isValidVaultStructure(getNioFileSystem());
return doesVaultDirectoryExist(); // TODO overheadhunter/markuskreusch: && CryptoFileSystemProvider.isValidVaultStructure(getPath());
} catch (UncheckedIOException e) {
return false;
}
Expand All @@ -188,16 +186,6 @@ public boolean isMounted() {
return mounted.get();
}

public ObservableList<String> getNamesOfResourcesWithInvalidMac() {
// TODO overheadhunter implement.
return null;
}

public Set<String> getWhitelistedResourcesWithInvalidMac() {
// TODO overheadhunter implement.
return null;
}

public long pollBytesRead() {
// TODO overheadhunter implement.
return 0l;
Expand All @@ -212,12 +200,6 @@ public String getMountName() {
return vaultSettings.getMountName();
}

/**
* sets the mount name while normalizing it
*
* @param mountName
* @throws IllegalArgumentException if the name is empty after normalization
*/
public void setMountName(String mountName) throws IllegalArgumentException {
if (StringUtils.isBlank(mountName)) {
throw new IllegalArgumentException("mount name is empty");
Expand Down

0 comments on commit 5a3428d

Please sign in to comment.