summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/persistency/XMLClusterStorage.java')
-rw-r--r--src/main/java/com/c2kernel/persistency/XMLClusterStorage.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java
index 8f1ed02..4a250e5 100644
--- a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java
+++ b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java
@@ -22,6 +22,7 @@ package com.c2kernel.persistency;
import java.io.File;
import java.util.ArrayList;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
@@ -38,17 +39,17 @@ public class XMLClusterStorage extends ClusterStorage {
}
@Override
- public void open(Authenticator auth) throws ClusterStorageException {
+ public void open(Authenticator auth) throws PersistencyException {
String rootProp = Gateway.getProperties().getString("XMLStorage.root");
if (rootProp == null)
- throw new ClusterStorageException("XMLClusterStorage.open() - Root path not given in config file.");
+ throw new PersistencyException("XMLClusterStorage.open() - Root path not given in config file.");
rootDir = new File(rootProp).getAbsolutePath();
if( !FileStringUtility.checkDir( rootDir ) ) {
Logger.error("XMLClusterStorage.open() - Path " + rootDir + "' does not exist. Attempting to create.");
boolean success = FileStringUtility.createNewDir(rootDir);
- if (!success) throw new ClusterStorageException("XMLClusterStorage.open() - Could not create dir "+ rootDir +". Cannot continue.");
+ if (!success) throw new PersistencyException("XMLClusterStorage.open() - Could not create dir "+ rootDir +". Cannot continue.");
}
}
@@ -77,7 +78,7 @@ public class XMLClusterStorage extends ClusterStorage {
// retrieve object by path
@Override
- public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException {
+ public C2KLocalObject get(ItemPath itemPath, String path) throws PersistencyException {
try {
String type = ClusterStorage.getClusterType(path);
String filePath = getFilePath(itemPath, path)+".xml";
@@ -99,7 +100,7 @@ public class XMLClusterStorage extends ClusterStorage {
// store object by path
@Override
- public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException {
+ public void put(ItemPath itemPath, C2KLocalObject obj) throws PersistencyException {
try {
String filePath = getFilePath(itemPath, getPath(obj)+".xml");
Logger.msg(7, "Writing "+filePath);
@@ -108,18 +109,18 @@ public class XMLClusterStorage extends ClusterStorage {
String dir = filePath.substring(0, filePath.lastIndexOf('/'));
if( !FileStringUtility.checkDir( dir ) ) {
boolean success = FileStringUtility.createNewDir(dir);
- if (!success) throw new ClusterStorageException("XMLClusterStorage.put() - Could not create dir "+ dir +". Cannot continue.");
+ if (!success) throw new PersistencyException("XMLClusterStorage.put() - Could not create dir "+ dir +". Cannot continue.");
}
FileStringUtility.string2File(filePath, data);
} catch (Exception e) {
Logger.error(e);
- throw new ClusterStorageException("XMLClusterStorage.put() - Could not write "+getPath(obj)+" to "+itemPath);
+ throw new PersistencyException("XMLClusterStorage.put() - Could not write "+getPath(obj)+" to "+itemPath);
}
}
// delete cluster
@Override
- public void delete(ItemPath itemPath, String path) throws ClusterStorageException {
+ public void delete(ItemPath itemPath, String path) throws PersistencyException {
try {
String filePath = getFilePath(itemPath, path+".xml");
boolean success = FileStringUtility.deleteDir(filePath, true, true);
@@ -128,14 +129,14 @@ public class XMLClusterStorage extends ClusterStorage {
success = FileStringUtility.deleteDir(filePath, true, true);
if (success) return;
} catch(Exception e) { }
- throw new ClusterStorageException("XMLClusterStorage.delete() - Failure deleting path "+path+" in "+itemPath);
+ throw new PersistencyException("XMLClusterStorage.delete() - Failure deleting path "+path+" in "+itemPath);
}
/* navigation */
// directory listing
@Override
- public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath itemPath, String path) throws PersistencyException {
String[] result = new String[0];
try {
String filePath = getFilePath(itemPath, path);
@@ -162,7 +163,7 @@ public class XMLClusterStorage extends ClusterStorage {
return result;
} catch (Exception e) {
Logger.error(e);
- throw new ClusterStorageException("XMLClusterStorage.getClusterContents() - Could not get contents of "+path+" from "+itemPath+": "+e.getMessage());
+ throw new PersistencyException("XMLClusterStorage.getClusterContents() - Could not get contents of "+path+" from "+itemPath+": "+e.getMessage());
}
}