Added database status check in methods.

This commit is contained in:
Christian P. MOMON 2017-04-26 08:28:48 +02:00
parent 7ea53a7955
commit 020df07995
3 changed files with 1667 additions and 1289 deletions

View file

@ -84,7 +84,7 @@ public class FileTreeSikevaDB implements SikevaDB
}
else if (StringUtils.equals(homeDirectory.getAbsolutePath(), "/"))
{
throw new SikevaDBException("Invalide home directory (file system root).");
throw new SikevaDBException("Invalid home directory (file system root).");
}
else
{
@ -114,6 +114,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void clear() throws SikevaDBException
{
if (isOpened())
{
try
{
@ -128,17 +130,10 @@ public class FileTreeSikevaDB implements SikevaDB
throw new SikevaDBException("Error clearing database", exception);
}
}
/**
* {@inheritDoc}
*
*/
@Override
public void close()
else
{
this.archiver.close();
this.status = Status.CLOSED;
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
@ -146,10 +141,32 @@ public class FileTreeSikevaDB implements SikevaDB
*
*/
@Override
public long countOfElements()
public void close() throws SikevaDBException
{
if (isOpened())
{
this.archiver.close();
this.status = Status.CLOSED;
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
*
*/
@Override
public long countOfElements() throws SikevaDBException
{
long result;
if (isOpened())
{
File[] topFiles = this.dataDirectory.listFiles();
result = 0;
@ -165,6 +182,11 @@ public class FileTreeSikevaDB implements SikevaDB
result += 1;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -173,12 +195,16 @@ public class FileTreeSikevaDB implements SikevaDB
/**
* {@inheritDoc}
*
* @throws SikevaDBException
*
*/
@Override
public long countOfElements(final String key)
public long countOfElements(final String key) throws SikevaDBException
{
long result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -197,6 +223,11 @@ public class FileTreeSikevaDB implements SikevaDB
result = subFiles.length;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -222,10 +253,12 @@ public class FileTreeSikevaDB implements SikevaDB
*
*/
@Override
public long countOfElements(final String key, final String subkey)
public long countOfElements(final String key, final String subkey) throws SikevaDBException
{
long result;
if (isOpened())
{
if ((key == null) || (subkey == null))
{
throw new IllegalArgumentException("Null key detected [key=" + key + "][subkey=" + subkey + "].");
@ -243,6 +276,11 @@ public class FileTreeSikevaDB implements SikevaDB
result = 0;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -257,7 +295,7 @@ public class FileTreeSikevaDB implements SikevaDB
{
if (this.status == Status.OPENED)
{
throw new SikevaDBException("Invalid state.");
throw new SikevaDBException("Invalid database status (opened).");
}
else if (this.homeDirectory == null)
{
@ -282,7 +320,11 @@ public class FileTreeSikevaDB implements SikevaDB
@Override
public void destroy() throws SikevaDBException
{
if (this.homeDirectory == null)
if (isOpened())
{
throw new SikevaDBException("Invalid database status (opened).");
}
else if (this.homeDirectory == null)
{
throw new SikevaDBException("Invalid home directory (undefined), destroy operation is cancelled.");
}
@ -364,6 +406,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
Element result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -378,6 +422,11 @@ public class FileTreeSikevaDB implements SikevaDB
result.setSubkey(null);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -407,7 +456,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
Element result;
//
if (isOpened())
{
if ((key == null) || (subkey == null))
{
throw new IllegalArgumentException("Null key detected [key=" + key + "][subkey=" + subkey + "].");
@ -425,6 +475,11 @@ public class FileTreeSikevaDB implements SikevaDB
result.setSubkey(subkey);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -438,6 +493,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
Elements result;
if (isOpened())
{
result = new Elements((int) countOfElements());
File[] topFiles = this.dataDirectory.listFiles();
@ -464,6 +521,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -478,6 +540,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
Elements result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -498,6 +562,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -522,7 +591,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
StringList result;
//
if (isOpened())
{
result = new StringList((int) countOfElements());
File[] topFiles = this.dataDirectory.listFiles();
@ -545,6 +615,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -578,6 +653,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
StringList result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -597,6 +674,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -612,6 +694,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
String result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -630,6 +714,11 @@ public class FileTreeSikevaDB implements SikevaDB
result = null;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -660,6 +749,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
String result;
if (isOpened())
{
if ((key == null) || (subkey == null))
{
throw new IllegalArgumentException("Null key detected [key=" + key + "][subkey=" + subkey + "].");
@ -679,6 +770,11 @@ public class FileTreeSikevaDB implements SikevaDB
result = null;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -694,6 +790,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
StringList result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -721,6 +819,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -829,6 +932,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
//
result = 0;
@ -857,6 +962,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -872,6 +982,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Null key detected.");
@ -900,6 +1012,11 @@ public class FileTreeSikevaDB implements SikevaDB
result = 0;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -929,6 +1046,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
if ((key == null) || (subkey == null))
{
throw new IllegalArgumentException("Null key detected [key=" + key + "][subkey=" + subkey + "].");
@ -949,6 +1068,11 @@ public class FileTreeSikevaDB implements SikevaDB
result = 0;
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -985,6 +1109,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void put(final Element element) throws SikevaDBException
{
if (isOpened())
{
if (element == null)
{
@ -1022,6 +1148,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1039,6 +1170,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void put(final String key, final String value) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1066,6 +1199,11 @@ public class FileTreeSikevaDB implements SikevaDB
put(element);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1073,6 +1211,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void put(final String key, final String subkey, final String value) throws SikevaDBException
{
if (isOpened())
{
if ((key == null) || (subkey == null))
{
@ -1101,6 +1241,11 @@ public class FileTreeSikevaDB implements SikevaDB
put(element);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1108,6 +1253,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void remove(final String key) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1131,6 +1278,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1148,6 +1300,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void remove(final String key, final String subkey) throws SikevaDBException
{
if (isOpened())
{
if ((key == null) || (subkey == null))
{
@ -1172,6 +1326,11 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1179,6 +1338,8 @@ public class FileTreeSikevaDB implements SikevaDB
*/
@Override
public void removeMany(final String key, final String... subkeys) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1195,16 +1356,23 @@ public class FileTreeSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (opened).");
}
}
/**
* {@inheritDoc}
*
*/
@Override
public void renameKey(final String oldKey, final String newKey)
public void renameKey(final String oldKey, final String newKey) throws SikevaDBException
{
this.logger.debug("renameKey starting... [{}][{}]", oldKey, newKey);
if (isOpened())
{
if (oldKey == null)
{
throw new IllegalArgumentException("OldKey is null.");
@ -1234,6 +1402,11 @@ public class FileTreeSikevaDB implements SikevaDB
oldFile.renameTo(newFile);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
this.logger.debug("renameKey done.");
}
@ -1256,11 +1429,13 @@ public class FileTreeSikevaDB implements SikevaDB
{
this.logger.debug("renameSybKey starting... [{}][{}][{}]", oldSubkey, newSubkey);
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Top key is null.");
}
if (oldSubkey == null)
else if (oldSubkey == null)
{
throw new IllegalArgumentException("OldKey is null.");
}
@ -1290,6 +1465,11 @@ public class FileTreeSikevaDB implements SikevaDB
throw new IllegalArgumentException("Invalid oldKey [" + oldSubkey + "].");
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
this.logger.debug("renameSubKey done.");
}
@ -1304,6 +1484,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
this.logger.info("replaceInValue starting... [{}]", key);
if (isOpened())
{
//
String value = getValue(key);
@ -1315,6 +1497,11 @@ public class FileTreeSikevaDB implements SikevaDB
//
put(key, value);
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
this.logger.info("replaceInValue done.");
}
@ -1329,6 +1516,8 @@ public class FileTreeSikevaDB implements SikevaDB
{
this.logger.info("replaceInValues starting... [{}]", key);
if (isOpened())
{
//
Elements elements = getElements(key);
@ -1355,6 +1544,11 @@ public class FileTreeSikevaDB implements SikevaDB
put(element.getKey(), element.getSubkey(), value);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
this.logger.info("replaceInValues done.");
}

View file

@ -144,6 +144,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void clear() throws SikevaDBException
{
if (isOpened())
{
Connection connection = null;
PreparedStatement statement = null;
@ -165,6 +167,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -253,6 +260,8 @@ public class SQLSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
@ -275,6 +284,11 @@ public class SQLSikevaDB implements SikevaDB
{
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -289,6 +303,8 @@ public class SQLSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -319,6 +335,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -348,6 +369,8 @@ public class SQLSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -383,6 +406,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -560,6 +588,8 @@ public class SQLSikevaDB implements SikevaDB
{
Element result;
if (isOpened())
{
if (id == Element.NO_ID)
{
result = null;
@ -616,6 +646,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -630,7 +665,8 @@ public class SQLSikevaDB implements SikevaDB
{
Element result;
//
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -688,6 +724,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -717,7 +758,8 @@ public class SQLSikevaDB implements SikevaDB
{
Element result;
//
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -781,6 +823,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -795,6 +842,8 @@ public class SQLSikevaDB implements SikevaDB
{
Elements result;
if (isOpened())
{
//
result = new Elements((int) countOfElements());
@ -838,6 +887,11 @@ public class SQLSikevaDB implements SikevaDB
{
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -852,7 +906,8 @@ public class SQLSikevaDB implements SikevaDB
{
Elements result;
//
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -904,6 +959,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -918,6 +978,8 @@ public class SQLSikevaDB implements SikevaDB
{
StringList result;
if (isOpened())
{
//
result = new StringList();
@ -946,6 +1008,11 @@ public class SQLSikevaDB implements SikevaDB
{
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -978,7 +1045,8 @@ public class SQLSikevaDB implements SikevaDB
{
StringList result;
//
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -1016,6 +1084,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1039,6 +1112,8 @@ public class SQLSikevaDB implements SikevaDB
{
String result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -1083,6 +1158,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1112,6 +1192,8 @@ public class SQLSikevaDB implements SikevaDB
{
String result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -1161,6 +1243,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1175,6 +1262,8 @@ public class SQLSikevaDB implements SikevaDB
{
StringList result;
if (isOpened())
{
//
result = new StringList((int) countOfElements(key));
@ -1204,6 +1293,11 @@ public class SQLSikevaDB implements SikevaDB
{
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1308,6 +1402,8 @@ public class SQLSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
//
Connection connection = null;
PreparedStatement statement = null;
@ -1331,6 +1427,11 @@ public class SQLSikevaDB implements SikevaDB
{
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1345,6 +1446,8 @@ public class SQLSikevaDB implements SikevaDB
{
long result;
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -1375,6 +1478,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1404,7 +1512,8 @@ public class SQLSikevaDB implements SikevaDB
{
long result;
//
if (isOpened())
{
if (key == null)
{
throw new IllegalArgumentException("Key is null.");
@ -1441,6 +1550,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
//
return result;
@ -1514,6 +1628,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void put(final Element element) throws SikevaDBException
{
if (isOpened())
{
if (element == null)
{
@ -1568,7 +1684,8 @@ public class SQLSikevaDB implements SikevaDB
{
connection = getConnection();
connection.setAutoCommit(true);
statement = connection.prepareStatement("INSERT INTO sikevadb_elements (TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE) VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
statement = connection
.prepareStatement("INSERT INTO sikevadb_elements (TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE) VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
statement.setString(1, element.getKey());
statement.setString(2, element.getSubkey());
@ -1628,6 +1745,11 @@ public class SQLSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1645,6 +1767,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void put(final String key, final String value) throws SikevaDBException
{
if (isOpened())
{
//
Element element = getElement(key);
@ -1719,6 +1843,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1726,6 +1855,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void put(final String key, final String subkey, final String value) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1813,6 +1944,11 @@ public class SQLSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1820,6 +1956,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void remove(final String key) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1866,6 +2004,11 @@ public class SQLSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1883,6 +2026,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void remove(final String key, final String subkey) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1925,6 +2070,11 @@ public class SQLSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (opened).");
}
}
/**
* {@inheritDoc}
@ -1932,6 +2082,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void removeMany(final String key, final String... subkeys) throws SikevaDBException
{
if (isOpened())
{
if (key == null)
{
@ -1978,6 +2130,11 @@ public class SQLSikevaDB implements SikevaDB
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -1988,6 +2145,8 @@ public class SQLSikevaDB implements SikevaDB
{
logger.info("renameKey starting... [{}][{}]", oldKey, newKey);
if (isOpened())
{
if (oldKey == null)
{
throw new IllegalArgumentException("OldKey is null.");
@ -2024,6 +2183,11 @@ public class SQLSikevaDB implements SikevaDB
closeQuietly(connection, statement, resultSet);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
logger.info("renameKey done.");
}
@ -2044,6 +2208,8 @@ public class SQLSikevaDB implements SikevaDB
*/
@Override
public void renameSubkey(final String key, final String oldKey, final String newKey) throws SikevaDBException
{
if (isOpened())
{
if ((key == null) || (oldKey == null) || (newKey == null))
{
@ -2054,6 +2220,11 @@ public class SQLSikevaDB implements SikevaDB
// TODO Auto-generated method stub
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
}
/**
* {@inheritDoc}
@ -2064,6 +2235,8 @@ public class SQLSikevaDB implements SikevaDB
{
logger.info("replaceInValue starting... [{}]", key);
if (isOpened())
{
//
String value = getValue(key);
@ -2075,6 +2248,11 @@ public class SQLSikevaDB implements SikevaDB
//
put(key, value);
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
logger.info("replaceInValue done.");
}
@ -2088,13 +2266,13 @@ public class SQLSikevaDB implements SikevaDB
{
logger.info("replaceInValues starting... [{}]", key);
//
if (isOpened())
{
Elements elements = getElements(key);
long count = 0;
for (Element element : elements)
{
//
logger.info(element.getKey() + " (" + element.getSubkey() + ") " + count + "/" + elements.size());
if (element.getSubkey() != null)
@ -2115,6 +2293,11 @@ public class SQLSikevaDB implements SikevaDB
put(element.getKey(), element.getSubkey(), value);
}
}
}
else
{
throw new SikevaDBException("Invalid database status (closed).");
}
logger.info("replaceInValues done.");
}

View file

@ -605,10 +605,11 @@ public class TreeFileSikevaDBTest
}
/**
* @throws SikevaDBException
*
*/
@AfterClass
public static void afterClass()
public static void afterClass() throws SikevaDBException
{
if (database != null)
{