diff --git a/src/main/java/fr/soleil/archiving/snap/api/manager/SnapManagerApi.java b/src/main/java/fr/soleil/archiving/snap/api/manager/SnapManagerApi.java index d01f901537fc0c861f60757d9a8c3919083f7da5..955b6c01303a08e79bcf8c0176cecfb71ef7c9e3 100644 --- a/src/main/java/fr/soleil/archiving/snap/api/manager/SnapManagerApi.java +++ b/src/main/java/fr/soleil/archiving/snap/api/manager/SnapManagerApi.java @@ -743,6 +743,9 @@ public class SnapManagerApi { public static SnapAttributeExtract[] getSnapValues(final int idSnap, final String... attributeNames) throws SnapshotingException { + if (snapDataBase == null) { + throw new SnapshotingException(DATA_BASE_API_NOT_INIT); + } final SnapAttributeExtract[] conf = snapDataBase.getAttributeConfig(attributeNames); snapDataBase.getSnapResults(Arrays.asList(conf), idSnap); return conf; diff --git a/src/main/java/fr/soleil/archiving/snap/api/tools/StringFormater.java b/src/main/java/fr/soleil/archiving/snap/api/tools/StringFormater.java deleted file mode 100644 index cd4b6efd90a27be5b20683bf297da64ca72c7944..0000000000000000000000000000000000000000 --- a/src/main/java/fr/soleil/archiving/snap/api/tools/StringFormater.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Synchrotron Soleil - * - * File : StringFormater.java - * - * Project : apiDev - * - * Description : - * - * Author : SOLEIL - * - * Original : 28 févr. 2006 - * - * Revision: Author: - * Date: State: - * - * Log: StringFormater.java,v - */ -package fr.soleil.archiving.snap.api.tools; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class StringFormater { - final static Logger logger = LoggerFactory.getLogger(StringFormater.class); - - // Special characters - private final static String[] protect = { "[", "]", ",", ";", "'", "\"", "~", "\n" }; - - // Associated code : in fact, the corresponding xml code number (ISO 8859/1) - private final static String[] code = { "91", "93", "44", "59", "39", "34", "126", "10" }; - - // transforms #code# -> corresponding character - public static String formatStringToRead(String toFormat) { - String result; - if (toFormat != null) { - result = toFormat; - for (int i = 0; i < code.length; i++) { - result = result.replaceAll("#" + code[i] + "#", protect[i]); - } - } else { - result = ""; - } - return result; - } - - // transforms character -> corresponding #code# - public static String formatStringToWrite(String toFormat) { - String result; - if (toFormat != null) { - result = toFormat; - for (int i = 0; i < protect.length; i++) { - result = result.replaceAll("\\" + protect[i], "#" + code[i] + "#"); - } - } else { - result = ""; - } - return result; - } - - public static void main(String[] args) { - String toto1 = "toto \n toto"; - String toto2 = formatStringToWrite(toto1); - String toto3 = formatStringToRead(toto2); - logger.debug("toto1 = |" + toto1 + "|"); - logger.debug("toto2 = |" + toto2 + "|"); - logger.debug("toto3 = |" + toto3 + "|"); - } - -}