diff --git a/bds/source/java/ch/systemsx/cisd/bds/container/Container.java b/bds/source/java/ch/systemsx/cisd/bds/container/Container.java deleted file mode 100644 index 0db93992aff0bf8e9e8edaf1ecdfab9a8fb52d2d..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/container/Container.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.container; - -import java.io.File; - -import ch.systemsx.cisd.bds.AbstractDataStructure; -import ch.systemsx.cisd.bds.DataStructureFactory; -import ch.systemsx.cisd.bds.IStorage; -import ch.systemsx.cisd.bds.Version; -import ch.systemsx.cisd.bds.fs.FileStorage; -import ch.systemsx.cisd.bds.hdf5.HDF5Storage; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - -/** - * - * - * @author Franz-Josef Elmer - */ -public class Container -{ - private final File baseDir; - - public Container(File baseDir) - { - assert baseDir != null : "Unspecified base directory."; - assert baseDir.isDirectory() : "Is not a directory : " + baseDir.getAbsolutePath(); - this.baseDir = baseDir; - } - - public AbstractDataStructure load(String name) - { - IStorage storage = createStorage(name); - storage.load(); - Version version = Version.loadFrom(storage.getRoot()); - return DataStructureFactory.createDataStructure(storage, version); - } - - private IStorage createStorage(String name) - { - File file = new File(baseDir, name); - if (file.exists() == false) - { - throw new UserFailureException("No container name '" + name + "' exists in " + baseDir.getAbsolutePath()); - } - if (file.isDirectory()) - { - return new FileStorage(file); - } - File hdf5File = new File(baseDir, name + ".hdf5"); - if (hdf5File.exists()) - { - return new HDF5Storage(hdf5File); - } - throw new UserFailureException("Couldn't found appropriate container named '" + name + "' in " - + baseDir.getAbsolutePath()); - - } -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/fs/AbstractNode.java b/bds/source/java/ch/systemsx/cisd/bds/fs/AbstractNode.java deleted file mode 100644 index befbaa1da9af312a99f584eda60ba33d391129b0..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/fs/AbstractNode.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.fs; - -import java.io.File; - -import ch.systemsx.cisd.bds.IDirectory; -import ch.systemsx.cisd.bds.INode; - -/** - * - * - * @author Franz-Josef Elmer - */ -abstract class AbstractNode implements INode -{ - protected final File fileNode; - - AbstractNode(File file) - { - assert file != null : "Unspecified file"; - this.fileNode = file; - } - - public String getName() - { - return fileNode.getName(); - } - - public IDirectory tryToGetParent() - { - File dir = fileNode.getParentFile(); - return dir == null ? null : new Directory(dir); - } - -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/fs/Directory.java b/bds/source/java/ch/systemsx/cisd/bds/fs/Directory.java deleted file mode 100644 index b7ecbc8c26268d3934424751f36a5bca0c8f6cbd..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/fs/Directory.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.fs; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Iterator; - -import ch.systemsx.cisd.bds.IDirectory; -import ch.systemsx.cisd.bds.INode; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - -/** - * - * - * @author Franz-Josef Elmer - */ -class Directory extends AbstractNode implements IDirectory -{ - public Directory(File directory) - { - super(directory); - assert directory.isDirectory() : "Not a directory: " + directory.getAbsolutePath(); - } - - public INode getNode(String name) - { - // TODO Auto-generated method stub - return null; - } - - public IDirectory appendDirectory(String name) - { - // TODO Auto-generated method stub - return null; - } - - public void appendKeyValuePair(String key, String value) - { - File file = new File(fileNode, key); - try - { - FileWriter fileWriter = new FileWriter(file); - fileWriter.write(value); - fileWriter.close(); - } catch (IOException ex) - { - file.delete(); - throw new EnvironmentFailureException("Can not create " + file.getAbsolutePath() + ": " + ex); - } - } - - public void appendNode(INode node) - { - // TODO Auto-generated method stub - - } - - public void appendRealFile(File file) - { - File newFile = new File(fileNode, file.getName()); - if (file.renameTo(newFile) == false) - { - throw new EnvironmentFailureException("Couldn't move file " + file.getAbsolutePath() + " to " - + fileNode.getAbsolutePath()); - } - } - - public void appendLink(String name, INode node) - { - // TODO Auto-generated method stub - - } - - public Iterator<INode> iterator() - { - // TODO Auto-generated method stub - return null; - } - - public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException - { - // TODO Auto-generated method stub - - } - -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/fs/FileStorage.java b/bds/source/java/ch/systemsx/cisd/bds/fs/FileStorage.java deleted file mode 100644 index aefe534501bb6dc334b11d82e8bfeda9aa480175..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/fs/FileStorage.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.fs; - -import java.io.File; - -import ch.systemsx.cisd.bds.IDirectory; -import ch.systemsx.cisd.bds.IStorage; - -/** - * - * - * @author Franz-Josef Elmer - */ -public class FileStorage implements IStorage -{ - private Directory root; - - public FileStorage(File folder) - { - root = new Directory(folder); - } - - public IDirectory getRoot() - { - return root; - } - - public void load() - { - } - - public void save() - { - } - -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/fs/Link.java b/bds/source/java/ch/systemsx/cisd/bds/fs/Link.java deleted file mode 100644 index 09dc58b4e50ad35385a01b5cedca166ef44e63d0..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/fs/Link.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.fs; - -import java.io.File; - -import ch.systemsx.cisd.bds.IDirectory; -import ch.systemsx.cisd.bds.ILink; -import ch.systemsx.cisd.bds.INode; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; - -/** - * - * - * @author Franz-Josef Elmer - */ -class Link implements ILink -{ - - private final String name; - private IDirectory parent; - private final INode reference; - - Link(String name, INode reference) - { - this.name = name; - this.reference = reference; - } - - public String getName() - { - return name; - } - - void setParent(IDirectory parentOrNull) - { - parent = parentOrNull; - } - - public IDirectory tryToGetParent() - { - return parent; - } - - public INode getReference() - { - return reference; - } - - public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException - { - // TODO Auto-generated method stub - } - -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/fs/NodeFactory.java b/bds/source/java/ch/systemsx/cisd/bds/fs/NodeFactory.java deleted file mode 100644 index b23c7aa6b4a3c1767e7d8e4b4dbaeacb26198dbf..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/fs/NodeFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.fs; - -import java.io.File; -import java.io.IOException; - -import ch.systemsx.cisd.bds.INode; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; - -/** - * - * - * @author Franz-Josef Elmer - */ -class NodeFactory -{ - static INode createNode(File file) - { - assert file != null : "Unspecified node"; - String absolutePath = file.getAbsolutePath(); - try - { - String canonicalPath = file.getCanonicalPath(); - if (absolutePath.equals(canonicalPath) == false) - { - return new Link(file.getName(), createNode(new File(canonicalPath))); - } - if (file.isDirectory()) - { - return new Directory(file); - } - return new StringFile(file); - } catch (IOException ex) - { - throw new EnvironmentFailureException("Couldn't get canonical path of file " + absolutePath); - } - } -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/fs/StringFile.java b/bds/source/java/ch/systemsx/cisd/bds/fs/StringFile.java deleted file mode 100644 index 1061b43852b58a8946c25744fc16f4cbeccb02d1..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/fs/StringFile.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.fs; - -import java.io.File; - -import ch.systemsx.cisd.bds.IFile; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; -import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.common.utilities.FileUtilities; - -/** - * - * - * @author Franz-Josef Elmer - */ -class StringFile extends AbstractNode implements IFile<String> -{ - StringFile(File file) - { - super(file); - assert file.isFile() : "Not a file " + file.getAbsolutePath(); - } - - public String getValue() - { - return FileUtilities.loadToString(fileNode); - } - - public void extractTo(File directory) throws UserFailureException, EnvironmentFailureException - { - // TODO Auto-generated method stub - } - -} diff --git a/bds/source/java/ch/systemsx/cisd/bds/hdf5/HDF5Storage.java b/bds/source/java/ch/systemsx/cisd/bds/hdf5/HDF5Storage.java deleted file mode 100644 index 04c04c6c3bcf508c693cd6dbc398f85837ca57ce..0000000000000000000000000000000000000000 --- a/bds/source/java/ch/systemsx/cisd/bds/hdf5/HDF5Storage.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.hdf5; - -import java.io.File; - -import ch.systemsx.cisd.bds.IDirectory; -import ch.systemsx.cisd.bds.IStorage; - -/** - * - * - * @author Franz-Josef Elmer - */ -public class HDF5Storage implements IStorage -{ - public HDF5Storage(File hdf5File) - { - assert hdf5File != null : "Unspecified HDF5 file."; - } - - public IDirectory getRoot() - { - // TODO Auto-generated method stub - return null; - } - - public void load() - { - // TODO Auto-generated method stub - - } - - public void save() - { - // TODO Auto-generated method stub - - } - -}