diff --git a/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java b/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java index 9ef252f6e3dafda864d22741f6df3e39b1edbf04..dca7be2e5bb26dadfd0f2661319562e34fd43db3 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java +++ b/bds/source/java/ch/systemsx/cisd/bds/AbstractDataStructure.java @@ -18,7 +18,6 @@ package ch.systemsx.cisd.bds; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.IStorage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Abstract superclass of classes implementing {@link IDataStructure}. @@ -47,7 +46,7 @@ abstract class AbstractDataStructure implements IDataStructure Version loadedVersion = Version.loadFrom(root); if (loadedVersion.isBackwardsCompatibleWith(getVersion()) == false) { - throw new UserFailureException("Version of loaded data structure is " + loadedVersion + throw new DataStructureException("Version of loaded data structure is " + loadedVersion + " which is not backward compatible with " + getVersion()); } } diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataStructureException.java b/bds/source/java/ch/systemsx/cisd/bds/DataStructureException.java new file mode 100644 index 0000000000000000000000000000000000000000..6682379e29f0f58931e2ad69588934b77aa41fd7 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/DataStructureException.java @@ -0,0 +1,45 @@ +/* + * Copyright 2007 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.bds; + +import ch.systemsx.cisd.bds.storage.StorageException; + +/** + * Exception thrown by manipulations of BDS data structures which can not be classified as {@link StorageException}. + * + * @author Franz-Josef Elmer + */ +public class DataStructureException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * Creates an instance with the specified message. + */ + public DataStructureException(String message) + { + super(message); + } + + /** + * Creates an instance with the specified message and throwable causing this exception. + */ + public DataStructureException(String message, Throwable cause) + { + super(message, cause); + } +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java b/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java index 9c628089e66d801bcc9e0abd6cc870960ddd8dac..e4b5baa0e31e39cab03774a3ea8e5adb42596e57 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/DataStructureFactory.java @@ -18,7 +18,6 @@ package ch.systemsx.cisd.bds; import ch.systemsx.cisd.bds.storage.IStorage; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Factory of data structures. @@ -39,7 +38,7 @@ public class DataStructureFactory * Returns the class of the object returned after invoking {@link #createDataStructure(IStorage, Version)}. * * @param version Version of the data structure. - * @throws UserFailureException if no data structure can be created for the specified version. + * @throws DataStructureException if no data structure can be created for the specified version. */ public static Class<? extends IDataStructure> getDataStructureClassFor(Version version) { @@ -52,7 +51,7 @@ public class DataStructureFactory * @param storage Storage behind the data structure. * @param version Version of the data structure to be created. * @throws EnvironmentFailureException found data structure class has not an appropriated constructor. - * @throws UserFailureException if no data structure can be created for the specified version. + * @throws DataStructureException if no data structure can be created for the specified version. */ public static IDataStructure createDataStructure(IStorage storage, Version version) { diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataStructureLoader.java b/bds/source/java/ch/systemsx/cisd/bds/DataStructureLoader.java index 1d8538b58ca24fc23a6784ea5352ca9842d03493..6c23fa41ac0abf2e82ff6abee0d84ee41ab210ce 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/DataStructureLoader.java +++ b/bds/source/java/ch/systemsx/cisd/bds/DataStructureLoader.java @@ -21,7 +21,6 @@ import java.io.File; import ch.systemsx.cisd.bds.storage.IStorage; import ch.systemsx.cisd.bds.storage.filesystem.FileStorage; import ch.systemsx.cisd.bds.storage.hdf5.HDF5Storage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Loader for {@link IDataStructure}s from the file system. @@ -58,7 +57,7 @@ public class DataStructureLoader File file = new File(baseDir, name); if (file.exists() == false) { - throw new UserFailureException("No container name '" + name + "' exists in " + baseDir.getAbsolutePath()); + throw new DataStructureException("No container name '" + name + "' exists in " + baseDir.getAbsolutePath()); } if (file.isDirectory()) { @@ -69,7 +68,7 @@ public class DataStructureLoader { return new HDF5Storage(hdf5File); } - throw new UserFailureException("Couldn't found appropriate container named '" + name + "' in " + throw new DataStructureException("Couldn't found appropriate container named '" + name + "' in " + baseDir.getAbsolutePath()); } diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java b/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java index 1a1567c122748e19ea2f521d91bc99545c4ca01f..072856244b6d2bb8eb328d152d0d0f5b86d1f55a 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java +++ b/bds/source/java/ch/systemsx/cisd/bds/DataStructureV1_0.java @@ -65,13 +65,13 @@ public class DataStructureV1_0 extends AbstractDataStructure * Returns the formated data. This method can be called only after method {@link #setFormat(Format)} has been * invoked. If the format is not known {@link UnknownFormat1_0} will be assumed. * - * @throws UserFailureException if this method has been invoked before the format has been set. + * @throws DataStructureException if this method has been invoked before the format has been set. */ public IFormattedData getFormatedData() { if (format == null) { - throw new UserFailureException("Couldn't create formated data because of undefined format."); + throw new DataStructureException("Couldn't create formated data because of undefined format."); } return FormatedDataFactory.createFormatedData(getMetaDataDirectory(), format, UnknownFormat1_0.UNKNOWN_1_0); } @@ -88,7 +88,7 @@ public class DataStructureV1_0 extends AbstractDataStructure /** * Returns the experiment identifier. * - * @throws UserFailureException if the experiment identifier hasn't be loaded nor hasn't be set by + * @throws DataStructureException if the experiment identifier hasn't be loaded nor hasn't be set by * {@link #setExperimentIdentifier(ExperimentIdentifier)}. */ public ExperimentIdentifier getExperimentIdentifier() @@ -108,7 +108,7 @@ public class DataStructureV1_0 extends AbstractDataStructure /** * Returns the processing type. * - * @throws UserFailureException if the processing type hasn't be loaded nor hasn't be set by + * @throws DataStructureException if the processing type hasn't be loaded nor hasn't be set by * {@link #setProcessingType(ProcessingType)}. */ public ProcessingType getProcessingType() @@ -136,28 +136,28 @@ public class DataStructureV1_0 extends AbstractDataStructure } @Override - public void save() throws UserFailureException + public void save() { if (getOriginalData().iterator().hasNext() == false) { - throw new UserFailureException("Empty original data directory."); + throw new DataStructureException("Empty original data directory."); } IDirectory metaDataDirectory = getMetaDataDirectory(); if (metaDataDirectory.tryToGetNode(Format.FORMAT_DIR) == null) { if (format == null) { - throw new UserFailureException("Unspecified format."); + throw new DataStructureException("Unspecified format."); } format.saveTo(metaDataDirectory); } if (metaDataDirectory.tryToGetNode(ExperimentIdentifier.FOLDER) == null) { - throw new UserFailureException("Unspecified experiment identifier."); + throw new DataStructureException("Unspecified experiment identifier."); } if (metaDataDirectory.tryToGetNode(ProcessingType.PROCESSING_TYPE) == null) { - throw new UserFailureException("Unspecified processing type."); + throw new DataStructureException("Unspecified processing type."); } super.save(); } diff --git a/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java b/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java index b624e68e3d4f31e815b638542176c112137115d9..5a66b75bca27e01502d594867dbe0ffff4a46d11 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java +++ b/bds/source/java/ch/systemsx/cisd/bds/ExperimentIdentifier.java @@ -17,7 +17,6 @@ package ch.systemsx.cisd.bds; import ch.systemsx.cisd.bds.storage.IDirectory; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Identifier of the experiment which corresponds to the data. This is an immutable but extendable value object class. @@ -35,7 +34,7 @@ public class ExperimentIdentifier /** * Loads the experiment identifier from the specified directory. * - * @throws UserFailureException if file missing. + * @throws DataStructureException if file missing. */ static ExperimentIdentifier loadFrom(IDirectory directory) { diff --git a/bds/source/java/ch/systemsx/cisd/bds/Factory.java b/bds/source/java/ch/systemsx/cisd/bds/Factory.java index fccbdd3e8a9bc8fccb55254a415e787f34170157..e700c940c5c5033876dbd45246979a39b62df516 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/Factory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/Factory.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * General purpose factory for versioned classes with one-argument constructors. @@ -51,7 +50,7 @@ class Factory<T> } if (v.getMinor() == 0) { - throw new UserFailureException("No class found for version " + version); + throw new DataStructureException("No class found for version " + version); } v = v.getPreviousMinorVersion(); } @@ -74,11 +73,11 @@ class Factory<T> return constructor.newInstance(new Object[] {argument}); } catch (InvocationTargetException ex) { - throw new UserFailureException("Couldn't create instance of " + clazz + " for version " + version, ex + throw new DataStructureException("Couldn't create instance of " + clazz + " for version " + version, ex .getCause()); } catch (Exception ex) { - throw new UserFailureException("Couldn't create instance of " + clazz + " for version " + version, ex); + throw new DataStructureException("Couldn't create instance of " + clazz + " for version " + version, ex); } } diff --git a/bds/source/java/ch/systemsx/cisd/bds/Format.java b/bds/source/java/ch/systemsx/cisd/bds/Format.java index 12b2b368e6bb866a0e3934188bc0f60272a5377f..06c5bcfd8b05ee85d5c04dc879cd9dbabab6ee5d 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/Format.java +++ b/bds/source/java/ch/systemsx/cisd/bds/Format.java @@ -19,7 +19,6 @@ package ch.systemsx.cisd.bds; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.IFile; import ch.systemsx.cisd.bds.storage.INode; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Inmutable value object of a versioned format. @@ -34,20 +33,20 @@ public class Format /** * Loads the format from the specified directory. * - * @throws UserFailureException if the format could be loaded. + * @throws DataStructureException if the format could be loaded. */ static Format loadFrom(IDirectory directory) { INode dir = directory.tryToGetNode(FORMAT_DIR); if (dir instanceof IDirectory == false) { - throw new UserFailureException("Not a directory: " + dir); + throw new DataStructureException("Not a directory: " + dir); } IDirectory formatDir = (IDirectory) dir; INode file = formatDir.tryToGetNode(FORMAT_CODE_FILE); if (file instanceof IFile == false) { - throw new UserFailureException("Not a plain file: " + file); + throw new DataStructureException("Not a plain file: " + file); } IFile codeFile = (IFile) file; String formatCode = codeFile.getStringContent().trim(); diff --git a/bds/source/java/ch/systemsx/cisd/bds/FormatedDataFactory.java b/bds/source/java/ch/systemsx/cisd/bds/FormatedDataFactory.java index ef32a8a41ddff64805aa3005b7bb76a9770fa732..42505187763c9eb3de59afabcd7604c84baddd0e 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/FormatedDataFactory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/FormatedDataFactory.java @@ -20,7 +20,6 @@ import java.util.HashMap; import java.util.Map; import ch.systemsx.cisd.bds.storage.IDirectory; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** @@ -75,7 +74,7 @@ class FormatedDataFactory { return getFactory(defaultFormat, null); } - throw new UserFailureException("Unknown format code: " + code); + throw new DataStructureException("Unknown format code: " + code); } return factory; } diff --git a/bds/source/java/ch/systemsx/cisd/bds/IDataStructure.java b/bds/source/java/ch/systemsx/cisd/bds/IDataStructure.java index 953cf557b84a8f05b61a20ac04cd5a4a14cadb32..c7dbd88c5ca54b2c3e80d763a9adb64a818ba8e4 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/IDataStructure.java +++ b/bds/source/java/ch/systemsx/cisd/bds/IDataStructure.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.bds; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Common interface of all data structures. @@ -28,7 +27,7 @@ public interface IDataStructure extends IHasVersion /** * Loads the data structure. */ - public void load() throws UserFailureException; + public void load(); /** * Saves the data structure. diff --git a/bds/source/java/ch/systemsx/cisd/bds/Utilities.java b/bds/source/java/ch/systemsx/cisd/bds/Utilities.java index 5b2ccfcdf6223b55d299d90bd91686f62a0fee97..bab9c8ae8ed5c340b5e4190c2301102ea5066644 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/Utilities.java +++ b/bds/source/java/ch/systemsx/cisd/bds/Utilities.java @@ -20,7 +20,6 @@ package ch.systemsx.cisd.bds; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.IFile; import ch.systemsx.cisd.bds.storage.INode; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Storage utility methods. @@ -32,7 +31,7 @@ public class Utilities /** * Returns a subdirectory from the specified directory. If it does not exist it will be created. * - * @throws UserFailureException if there is already a node named <code>name</code> but which isn't a directory. + * @throws DataStructureException if there is already a node named <code>name</code> but which isn't a directory. */ public static IDirectory getOrCreateSubDirectory(IDirectory directory, String name) { @@ -45,7 +44,7 @@ public class Utilities { return (IDirectory) node; } - throw new UserFailureException("There is already a node named '" + name + "' but which isn't a directory."); + throw new DataStructureException("There is already a node named '" + name + "' but which isn't a directory."); } /** @@ -53,18 +52,18 @@ public class Utilities * * @param directory Parent directory of the requested directory. * @param name Name of the requested directory. - * @throws UserFailureException if requested directory not found. + * @throws DataStructureException if requested directory not found. */ public static IDirectory getSubDirectory(IDirectory directory, String name) { INode node = directory.tryToGetNode(name); if (node == null) { - throw new UserFailureException("No directory named '" + name + "' found in " + directory); + throw new DataStructureException("No directory named '" + name + "' found in " + directory); } if (node instanceof IDirectory == false) { - throw new UserFailureException("Is not a directory: " + node); + throw new DataStructureException("Is not a directory: " + node); } return (IDirectory) node; } @@ -82,18 +81,18 @@ public class Utilities * * @param directory Directory of the requested file. * @param name Name of the file. - * @throws UserFailureException if the requested file does not exist. + * @throws DataStructureException if the requested file does not exist. */ public static String getString(IDirectory directory, String name) { INode node = directory.tryToGetNode(name); if (node == null) { - throw new UserFailureException("File '" + name + "' missing in " + directory); + throw new DataStructureException("File '" + name + "' missing in " + directory); } if (node instanceof IFile == false) { - throw new UserFailureException(node + " is not a file."); + throw new DataStructureException(node + " is not a file."); } IFile file = (IFile) node; return file.getStringContent(); diff --git a/bds/source/java/ch/systemsx/cisd/bds/Version.java b/bds/source/java/ch/systemsx/cisd/bds/Version.java index 88cd8c45c126a858784543a45580b990bcffa0f7..58918ab300e16d844fc0cf7e3efd61a94d1d48c6 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/Version.java +++ b/bds/source/java/ch/systemsx/cisd/bds/Version.java @@ -17,7 +17,6 @@ package ch.systemsx.cisd.bds; import ch.systemsx.cisd.bds.storage.IDirectory; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Immutable value object for the version of something. @@ -47,7 +46,7 @@ public final class Version return Integer.parseInt(value); } catch (NumberFormatException ex) { - throw new UserFailureException("Value of " + name + " version file is not a number: " + value); + throw new DataStructureException("Value of " + name + " version file is not a number: " + value); } } @@ -96,13 +95,13 @@ public final class Version /** * Returns the previous minor version. * - * @throws UserFailureException if minor version is 0. + * @throws DataStructureException if minor version is 0. */ public Version getPreviousMinorVersion() { if (minor == 0) { - throw new UserFailureException("There is no previous minor version of " + this); + throw new DataStructureException("There is no previous minor version of " + this); } return new Version(major, minor - 1); } diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java index bdafa8e4d38dbe388238567deded1dae2a2770f4..a943effb8a143e33ca2d353059652ee67f7a2e63 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/IDirectory.java @@ -18,9 +18,6 @@ package ch.systemsx.cisd.bds.storage; import java.io.File; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - /** * Node representing a directory. * @@ -40,9 +37,8 @@ public interface IDirectory extends INode, Iterable<INode> * * @param name Name of the new subdirectory. * @return the new subdirectory. - * @throws EnvironmentFailureException if the subdirectory cannot be created because of some other reason. */ - public IDirectory makeDirectory(String name) throws UserFailureException, EnvironmentFailureException; + public IDirectory makeDirectory(String name); /** * Adds the specified real file to this directory. The content of <code>file</code> will be copied. If it is a @@ -52,14 +48,12 @@ public interface IDirectory extends INode, Iterable<INode> * @return the new node. It will be a {@link ILink} if <code>file</code> is a symbolic link, a {@link IDirectory} * if <code>file</code> is a folder, or {@link IFile} if <code>file</code> is a plain file. */ - public INode addFile(final File file, final boolean move) throws UserFailureException, EnvironmentFailureException; + public INode addFile(final File file, final boolean move); /** * Removes given <var>node</var> from this directory. - * - * @throws EnvironmentFailureException if given <var>node</var> could be removed for some other reason. */ - public void removeNode(final INode node) throws UserFailureException, EnvironmentFailureException; + public void removeNode(final INode node); /** * Adds a plain file named <code>key</code> with content <code>value</code> to this directory. diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java b/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java index 56f81212f6682323e8939b78b9703fb87b31692c..b4cc3ea9fd641e514a55fa60034159fef0661ca1 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/INode.java @@ -18,9 +18,6 @@ package ch.systemsx.cisd.bds.storage; import java.io.File; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - /** * Abstraction of a node in a hierarchical data structure. * @@ -43,10 +40,6 @@ public interface INode * <p> * All descendants are also extracted. This is a copy operation. * </p> - * - * @throws UserFailureException if this or a descended node is a link referring to a node which is not this node or - * a descended node. - * @throws EnvironmentFailureException if extraction causes an IOException. */ - public void extractTo(final File directory) throws UserFailureException, EnvironmentFailureException; + public void extractTo(final File directory); } diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java b/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java index 98cf5ae759362c9b360f94223aa255af7fc5e1a9..ac018d8f4b1cc12b9b5055b8ef6daa8ddf299110 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/IStorage.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.bds.storage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * Abstraction of a hierarchical storage. @@ -33,9 +32,9 @@ public interface IStorage /** * Returns root directory of this storage. * - * @throws UserFailureException if invoked before {@link #mount()} or after {@link #unmount()}. + * @throws StorageException if invoked before {@link #mount()} or after {@link #unmount()}. */ - public IDirectory getRoot() throws UserFailureException; + public IDirectory getRoot(); /** * Unmounts this storage. May perform some finalization (e.g. make cached data persistent). diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/StorageException.java b/bds/source/java/ch/systemsx/cisd/bds/storage/StorageException.java new file mode 100644 index 0000000000000000000000000000000000000000..21534198779cd89560bc6560eeaa0c5bdd5bf870 --- /dev/null +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/StorageException.java @@ -0,0 +1,47 @@ +/* + * Copyright 2007 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.bds.storage; + +import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; + +/** + * Exception thrown if some problem occured during operations in the Storage API which can not be classified + * convincingly as an {@link EnvironmentFailureException}. + * + * @author Franz-Josef Elmer + */ +public class StorageException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * Creates an instance with the specified message. + */ + public StorageException(String message) + { + super(message); + } + + /** + * Creates an instance with the specified message and throwable causing this exception. + */ + public StorageException(String message, Throwable cause) + { + super(message, cause); + } + +} diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java index c257acf9b410b12d9c0e3d0c051a7f309745352e..435296f62c49eb0eedb2b7a3f6a5be878cd6c414 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/AbstractNode.java @@ -20,7 +20,7 @@ import java.io.File; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.INode; -import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.bds.storage.StorageException; /** * @author Franz-Josef Elmer @@ -33,11 +33,11 @@ abstract class AbstractNode implements INode { if (file == null) { - throw new UserFailureException("Unspecified file"); + throw new StorageException("Unspecified file"); } if (file.exists() == false) { - throw new UserFailureException("Non existing file " + file); + throw new StorageException("Non existing file " + file); } this.nodeFile = file; } diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java index 25e9c772aab9b1386961c333e9813b09b2cced5f..c694c78cbc22d8b267b56816f19f37d3eaf6e7cf 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java @@ -27,8 +27,8 @@ import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.IFile; import ch.systemsx.cisd.bds.storage.ILink; import ch.systemsx.cisd.bds.storage.INode; +import ch.systemsx.cisd.bds.storage.StorageException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.logging.Log4jSimpleLogger; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; @@ -49,7 +49,7 @@ class Directory extends AbstractNode implements IDirectory super(directory); if (directory.isDirectory() == false) { - throw new UserFailureException("Not a directory: " + directory.getAbsolutePath()); + throw new StorageException("Not a directory: " + directory.getAbsolutePath()); } } @@ -101,7 +101,7 @@ class Directory extends AbstractNode implements IDirectory { if (dir.isDirectory() == false) { - throw new UserFailureException("There already exists a file named '" + name + "' in directory " + this); + throw new StorageException("There already exists a file named '" + name + "' in directory " + this); } return new Directory(dir); } @@ -121,8 +121,7 @@ class Directory extends AbstractNode implements IDirectory return new File(file); } - public INode addFile(final java.io.File file, final boolean move) throws UserFailureException, - EnvironmentFailureException + public INode addFile(final java.io.File file, final boolean move) { final java.io.File newFile = new java.io.File(nodeFile, file.getName()); if (move) @@ -197,7 +196,7 @@ class Directory extends AbstractNode implements IDirectory } } - public final void removeNode(final INode node) throws UserFailureException, EnvironmentFailureException + public final void removeNode(final INode node) { assert node != null : "Node could not be null"; AbstractNode abstractNode = (AbstractNode) node; diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java index 4a51cd3692e8e5bb53a78c029fa23cc3a1980c55..fbde24c79ed03fa3f8b06d6a5686039737d4a1eb 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorage.java @@ -20,7 +20,7 @@ import java.io.File; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.IStorage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.bds.storage.StorageException; /** * Implementation of {@link IStorage} based on the file system. @@ -36,7 +36,7 @@ public class FileStorage implements IStorage /** * Creates an instance with the specified folder as the root directory. * - * @throws UserFailureException if <code>folder</code> does not exist or is not a directory in the file system. + * @throws StorageException if <code>folder</code> does not exist or is not a directory in the file system. */ public FileStorage(File folder) { @@ -47,7 +47,7 @@ public class FileStorage implements IStorage { if (mounted == false) { - throw new UserFailureException("Can not get root of an unmounted storage."); + throw new StorageException("Can not get root of an unmounted storage."); } return root; } diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java index 8a3f961e48b6496909eb8b0bb4245fcd950aeebc..9debc53f089778a22be6bb0ee282c4e13c4cac1f 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Link.java @@ -21,8 +21,6 @@ import java.io.File; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.ILink; import ch.systemsx.cisd.bds.storage.INode; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * @author Franz-Josef Elmer @@ -62,7 +60,7 @@ class Link implements ILink return reference; } - public void extractTo(final File directory) throws UserFailureException, EnvironmentFailureException + public void extractTo(final File directory) { // TODO Auto-generated method stub } diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java index 9359038b506db64759bd0b0fa0cedc8721f9c2f2..0ae75b1d5f9947a31d329faacfed2da6484cebff 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/NodeFactory.java @@ -44,7 +44,7 @@ class NodeFactory return new File(file); } catch (IOException ex) { - throw new EnvironmentFailureException("Couldn't get canonical path of file " + absolutePath); + throw new EnvironmentFailureException("Couldn't get canonical path of file " + absolutePath, ex); } } diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureFactoryTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureFactoryTest.java index 6a37f1476d820b46809d1bb3053ee583364a60fa..564fb93fda57bb9a70397a3443b4b103c6c44f69 100644 --- a/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureFactoryTest.java +++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureFactoryTest.java @@ -25,7 +25,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import ch.systemsx.cisd.bds.storage.IStorage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * @@ -57,8 +56,8 @@ public class DataStructureFactoryTest try { DataStructureFactory.getDataStructureClassFor(new Version(2, 0)); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("No class found for version V2.0", e.getMessage()); } diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureV1_0Test.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureV1_0Test.java index cbc6ae1e1df6038ae41dcdab89f847baf3695fd4..6e3a03d0c02c5cd3ac942725fd31e9371cd0267c 100644 --- a/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureV1_0Test.java +++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/DataStructureV1_0Test.java @@ -28,8 +28,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import ch.systemsx.cisd.bds.storage.IDirectory; +import ch.systemsx.cisd.bds.storage.StorageException; import ch.systemsx.cisd.bds.storage.filesystem.FileStorage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; /** * @@ -81,8 +81,8 @@ public class DataStructureV1_0Test try { dataStructure.getFormatedData(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("Couldn't create formated data because of undefined format.", e.getMessage()); } @@ -156,8 +156,8 @@ public class DataStructureV1_0Test try { dataStructure.getExperimentIdentifier(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertPartOfString(ExperimentIdentifier.FOLDER, e.getMessage()); } @@ -183,8 +183,8 @@ public class DataStructureV1_0Test try { dataStructure.save(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("Empty original data directory.", e.getMessage()); } @@ -197,8 +197,8 @@ public class DataStructureV1_0Test try { dataStructure.save(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("Unspecified format.", e.getMessage()); } @@ -212,8 +212,8 @@ public class DataStructureV1_0Test try { dataStructure.save(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("Unspecified experiment identifier.", e.getMessage()); } @@ -228,8 +228,8 @@ public class DataStructureV1_0Test try { dataStructure.save(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("Unspecified processing type.", e.getMessage()); } @@ -250,8 +250,8 @@ public class DataStructureV1_0Test try { storage.getRoot(); - fail("UserFailureException expected because save() should unmount storage."); - } catch (UserFailureException e) + fail("StorageException expected because save() should unmount storage."); + } catch (StorageException e) { assertEquals("Can not get root of an unmounted storage.", e.getMessage()); } @@ -270,8 +270,8 @@ public class DataStructureV1_0Test try { dataStructure.load(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertPartOfString(Version.VERSION, e.getMessage()); } @@ -305,8 +305,8 @@ public class DataStructureV1_0Test try { dataStructure.load(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("Version of loaded data structure is V2.0 which is not backward compatible with V1.0", e.getMessage()); @@ -335,8 +335,8 @@ public class DataStructureV1_0Test { dataStructure.load(); dataStructure.getFormatedData(); - fail("UserFailureException expected."); - } catch (UserFailureException e) + fail("DataStructureException expected."); + } catch (DataStructureException e) { assertEquals("No class found for version V2.0", e.getMessage()); } diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/DirectoryTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/DirectoryTest.java index 43ba575c4f1f5f6376e502f92c40e724b443d066..6e293a12b670c49740d30d6684099052b7914da4 100644 --- a/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/DirectoryTest.java +++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/DirectoryTest.java @@ -29,7 +29,7 @@ import org.testng.annotations.Test; import ch.systemsx.cisd.bds.storage.IDirectory; import ch.systemsx.cisd.bds.storage.IFile; import ch.systemsx.cisd.bds.storage.INode; -import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.bds.storage.StorageException; import ch.systemsx.cisd.common.utilities.FileUtilities; /** @@ -116,8 +116,8 @@ public class DirectoryTest extends StorageTestCase try { directory.makeDirectory("sub-directory"); - AssertJUnit.fail("UserFailureException expected."); - } catch (UserFailureException e) + AssertJUnit.fail("StorageException expected."); + } catch (StorageException e) { assertTrue(e.getMessage().indexOf("sub-directory") >= 0); } diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorageTest.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorageTest.java index 67d2f5b687d8d24bf1324ad8fc0a8b3969dd20dd..60dfaf095427637076dba14f560bf37bb0689cd6 100644 --- a/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorageTest.java +++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/storage/filesystem/FileStorageTest.java @@ -21,7 +21,7 @@ import static org.testng.AssertJUnit.assertEquals; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.bds.storage.StorageException; /** * @@ -45,8 +45,8 @@ public class FileStorageTest extends StorageTestCase try { fileStorage.getRoot(); - AssertJUnit.fail("UserFailureException because storage isn't mounted."); - } catch (UserFailureException e) + AssertJUnit.fail("StorageException because storage isn't mounted."); + } catch (StorageException e) { assertEquals("Can not get root of an unmounted storage.", e.getMessage()); } @@ -61,8 +61,8 @@ public class FileStorageTest extends StorageTestCase try { fileStorage.getRoot(); - AssertJUnit.fail("UserFailureException because storage isn't mounted."); - } catch (UserFailureException e) + AssertJUnit.fail("StorageException because storage isn't mounted."); + } catch (StorageException e) { assertEquals("Can not get root of an unmounted storage.", e.getMessage()); }