Deleted IORuntimeException in favour of UncheckedIOException

This commit is contained in:
Sebastian Stenzel
2015-10-29 11:26:28 +01:00
parent b5160cddb9
commit 289ac55ccd
5 changed files with 14 additions and 45 deletions

View File

@@ -1,31 +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
******************************************************************************/
package org.cryptomator.webdav.exceptions;
import java.io.IOException;
public class IORuntimeException extends RuntimeException {
private static final long serialVersionUID = -4713080133052143303L;
public IORuntimeException(IOException cause) {
super(cause);
}
@Override
public String getMessage() {
return getCause().getMessage();
}
@Override
public String getLocalizedMessage() {
return getCause().getLocalizedMessage();
}
}

View File

@@ -9,6 +9,7 @@
package org.cryptomator.webdav.jackrabbit;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
@@ -38,7 +39,6 @@ import org.apache.jackrabbit.webdav.property.DavPropertySet;
import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
import org.apache.jackrabbit.webdav.property.PropEntry;
import org.cryptomator.crypto.Cryptor;
import org.cryptomator.webdav.exceptions.IORuntimeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -213,7 +213,7 @@ abstract class AbstractEncryptedNode implements DavResource {
this.move((AbstractEncryptedNode) dest);
} catch (IOException e) {
LOG.error("Error moving file from " + this.getResourcePath() + " to " + dest.getResourcePath());
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
} else {
throw new IllegalArgumentException("Unsupported resource type: " + dest.getClass().getName());
@@ -229,7 +229,7 @@ abstract class AbstractEncryptedNode implements DavResource {
this.copy((AbstractEncryptedNode) dest, shallow);
} catch (IOException e) {
LOG.error("Error copying file from " + this.getResourcePath() + " to " + dest.getResourcePath());
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
} else {
throw new IllegalArgumentException("Unsupported resource type: " + dest.getClass().getName());

View File

@@ -1,6 +1,7 @@
package org.cryptomator.webdav.jackrabbit;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
@@ -23,7 +24,6 @@ import org.apache.jackrabbit.webdav.DavSession;
import org.apache.jackrabbit.webdav.lock.LockManager;
import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
import org.cryptomator.crypto.Cryptor;
import org.cryptomator.webdav.exceptions.IORuntimeException;
import org.eclipse.jetty.http.HttpHeader;
public class CryptoResourceFactory implements DavResourceFactory, FileConstants {
@@ -191,7 +191,7 @@ public class CryptoResourceFactory implements DavResourceFactory, FileConstants
final String encryptedFilename = filenameTranslator.getEncryptedFilename(cleartextFilename);
return parent.resolve(encryptedFilename);
} catch (IOException e) {
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}
@@ -208,7 +208,7 @@ public class CryptoResourceFactory implements DavResourceFactory, FileConstants
final String encryptedFilename = filenameTranslator.getEncryptedDirFileName(cleartextFilename);
return parent.resolve(encryptedFilename);
} catch (IOException e) {
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}
@@ -242,7 +242,7 @@ public class CryptoResourceFactory implements DavResourceFactory, FileConstants
Files.createDirectories(result);
return result;
} catch (IOException e) {
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}

View File

@@ -10,6 +10,7 @@ package org.cryptomator.webdav.jackrabbit;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
@@ -51,7 +52,6 @@ import org.cryptomator.crypto.Cryptor;
import org.cryptomator.crypto.exceptions.DecryptFailedException;
import org.cryptomator.crypto.exceptions.EncryptFailedException;
import org.cryptomator.webdav.exceptions.DavRuntimeException;
import org.cryptomator.webdav.exceptions.IORuntimeException;
import org.eclipse.jetty.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +78,7 @@ class EncryptedDir extends AbstractEncryptedNode implements FileConstants {
try {
directoryId = filenameTranslator.getDirectoryId(filePath, false);
} catch (IOException e) {
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}
return directoryId;
@@ -187,7 +187,7 @@ class EncryptedDir extends AbstractEncryptedNode implements FileConstants {
Files.setLastModifiedTime(filePath, FileTime.from(Instant.now()));
} catch (IOException e) {
LOG.error("Failed to create file.", e);
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}
@@ -223,7 +223,7 @@ class EncryptedDir extends AbstractEncryptedNode implements FileConstants {
return new DavResourceIteratorImpl(result);
} catch (IOException e) {
LOG.error("Exception during getMembers.", e);
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
} catch (DavException e) {
LOG.error("Exception during getMembers.", e);
throw new DavRuntimeException(e);
@@ -263,7 +263,7 @@ class EncryptedDir extends AbstractEncryptedNode implements FileConstants {
} catch (FileNotFoundException e) {
// no-op
} catch (IOException e) {
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}

View File

@@ -10,6 +10,7 @@ package org.cryptomator.webdav.jackrabbit;
import java.io.EOFException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.channels.FileChannel;
import java.nio.channels.OverlappingFileLockException;
import java.nio.file.AtomicMoveNotSupportedException;
@@ -30,7 +31,6 @@ import org.apache.jackrabbit.webdav.property.DavPropertyName;
import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
import org.cryptomator.crypto.Cryptor;
import org.cryptomator.crypto.exceptions.MacAuthenticationFailedException;
import org.cryptomator.webdav.exceptions.IORuntimeException;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.slf4j.Logger;
@@ -65,7 +65,7 @@ class EncryptedFile extends AbstractEncryptedNode implements FileConstants {
// don't add content length DAV property
} catch (IOException e) {
LOG.error("Error reading filesize " + filePath.toString(), e);
throw new IORuntimeException(e);
throw new UncheckedIOException(e);
}
}
this.contentLength = contentLength;