@@ -46,7 +46,7 @@ private TmManager() {
4646 public static int storeTMX (String memory , String tmx , String project , String client , String subject )
4747 throws IOException , SQLException , SAXException , ParserConfigurationException {
4848 if (!isOpen (memory )) {
49- throw new IOException ( CLOSED );
49+ openMemory ( memory );
5050 }
5151 int imported = databases .get (memory ).storeTMX (tmx , project , client , subject );
5252 Files .deleteIfExists (new File (tmx ).toPath ());
@@ -87,7 +87,7 @@ public static void removeMemory(String memory) throws SQLException, IOException
8787
8888 public static void close (String memory ) throws SQLException , IOException {
8989 if (!isOpen (memory )) {
90- throw new IOException ( CLOSED ) ;
90+ return ;
9191 }
9292 if (databases .containsKey (memory )) {
9393 int users = count .get (memory );
@@ -102,9 +102,10 @@ public static void close(String memory) throws SQLException, IOException {
102102 }
103103 }
104104
105- public static String exportMemory (String memory , String name , Set <String > languages , String srcLang ) throws SQLException , IOException {
105+ public static String exportMemory (String memory , String name , Set <String > languages , String srcLang )
106+ throws SQLException , IOException {
106107 if (!isOpen (memory )) {
107- throw new IOException ( CLOSED );
108+ openMemory ( memory );
108109 }
109110 File tempFolder = new File (RemoteTM .getWorkFolder (), "tmp" );
110111 File tmx = new File (tempFolder , name + ".tmx" );
@@ -140,52 +141,52 @@ public static void closeMemories() throws SQLException, IOException {
140141 }
141142 }
142143
143- public static Set <String > getAllClients (String memory ) throws IOException {
144+ public static Set <String > getAllClients (String memory ) throws IOException , SQLException {
144145 if (!isOpen (memory )) {
145- throw new IOException ( CLOSED );
146+ openMemory ( memory );
146147 }
147148 return databases .get (memory ).getAllClients ();
148149 }
149150
150151 public static Set <String > getAllLanguages (String memory ) throws SQLException , IOException {
151152 if (!isOpen (memory )) {
152- throw new IOException ( CLOSED );
153+ openMemory ( memory );
153154 }
154155 return databases .get (memory ).getAllLanguages ();
155156 }
156157
157- public static Set <String > getAllProjects (String memory ) throws IOException {
158+ public static Set <String > getAllProjects (String memory ) throws IOException , SQLException {
158159 if (!isOpen (memory )) {
159- throw new IOException ( CLOSED );
160+ openMemory ( memory );
160161 }
161162 return databases .get (memory ).getAllProjects ();
162163 }
163164
164- public static Set <String > getAllSubjects (String memory ) throws IOException {
165+ public static Set <String > getAllSubjects (String memory ) throws IOException , SQLException {
165166 if (!isOpen (memory )) {
166- throw new IOException ( CLOSED );
167+ openMemory ( memory );
167168 }
168169 return databases .get (memory ).getAllSubjects ();
169170 }
170171
171172 public static void storeTu (String memory , Element tu ) throws SQLException , IOException {
172173 if (!isOpen (memory )) {
173- throw new IOException ( CLOSED );
174+ openMemory ( memory );
174175 }
175176 databases .get (memory ).storeTu (tu );
176177 }
177178
178179 public static Element getTu (String memory , String tuid )
179180 throws IOException , SQLException , SAXException , ParserConfigurationException {
180181 if (!isOpen (memory )) {
181- throw new IOException ( CLOSED );
182+ openMemory ( memory );
182183 }
183184 return databases .get (memory ).getTu (tuid );
184185 }
185186
186187 public static void removeTu (String memory , String tuid ) throws IOException , SQLException {
187188 if (!isOpen (memory )) {
188- throw new IOException ( CLOSED );
189+ openMemory ( memory );
189190 }
190191 databases .get (memory ).removeTu (tuid );
191192 }
@@ -201,15 +202,15 @@ public static List<Match> searchTranslation(String memory, String searchStr, Str
201202 int similarity , boolean caseSensitive )
202203 throws IOException , SAXException , ParserConfigurationException , SQLException {
203204 if (!isOpen (memory )) {
204- throw new IOException ( CLOSED );
205+ openMemory ( memory );
205206 }
206207 return databases .get (memory ).searchTranslation (searchStr , srcLang , tgtLang , similarity , caseSensitive );
207208 }
208209
209210 public static List <Element > searchAll (String memory , String searchStr , String srcLang , int similarity ,
210211 boolean caseSensitive ) throws IOException , SAXException , ParserConfigurationException , SQLException {
211212 if (!isOpen (memory )) {
212- throw new IOException ( CLOSED );
213+ openMemory ( memory );
213214 }
214215 return databases .get (memory ).searchAll (searchStr , srcLang , similarity , caseSensitive );
215216 }
@@ -218,7 +219,7 @@ public static List<Element> concordanceSearch(String memory, String searchStr, S
218219 boolean isRegexp , boolean caseSensitive )
219220 throws SQLException , SAXException , IOException , ParserConfigurationException {
220221 if (!isOpen (memory )) {
221- throw new IOException ( CLOSED );
222+ openMemory ( memory );
222223 }
223224 return databases .get (memory ).concordanceSearch (searchStr , srcLang , limit , isRegexp , caseSensitive );
224225 }
0 commit comments