1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10ef39d40dSAndrew Rist  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ef39d40dSAndrew Rist  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19ef39d40dSAndrew Rist  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23cdf0e10cSrcweir package ifc.registry;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import lib.MultiMethodTest;
26cdf0e10cSrcweir import lib.Status;
27cdf0e10cSrcweir import lib.StatusException;
28cdf0e10cSrcweir import util.RegistryTools;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
31cdf0e10cSrcweir import com.sun.star.registry.InvalidRegistryException;
32cdf0e10cSrcweir import com.sun.star.registry.XRegistryKey;
33cdf0e10cSrcweir import com.sun.star.registry.XSimpleRegistry;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir /**
37cdf0e10cSrcweir * Testing <code>com.sun.star.registry.XSimpleRegistry</code>
38cdf0e10cSrcweir * interface methods :
39cdf0e10cSrcweir * <ul>
40cdf0e10cSrcweir *  <li><code> getURL()</code></li>
41cdf0e10cSrcweir *  <li><code> open()</code></li>
42cdf0e10cSrcweir *  <li><code> isValid()</code></li>
43cdf0e10cSrcweir *  <li><code> close()</code></li>
44cdf0e10cSrcweir *  <li><code> destroy()</code></li>
45cdf0e10cSrcweir *  <li><code> getRootKey()</code></li>
46cdf0e10cSrcweir *  <li><code> isReadOnly()</code></li>
47cdf0e10cSrcweir *  <li><code> mergeKey()</code></li>
48cdf0e10cSrcweir * </ul> <p>
49cdf0e10cSrcweir * This test needs the following object relations :
50cdf0e10cSrcweir * <ul>
51cdf0e10cSrcweir *  <li> <code>'NR'</code> <b>optional</b> (of type <code>String</code>):
52cdf0e10cSrcweir *   if this object relation isn't null than the testing component
53cdf0e10cSrcweir *   doesn't support some methods of the interface
54cdf0e10cSrcweir *   (<code>open(), close(), destroy()</code>)</li>
55cdf0e10cSrcweir *  <li> <code>'XSimpleRegistry.open'</code> (of type <code>String</code>):
56cdf0e10cSrcweir *    The full system path to the registry file which is opened and modified.
57cdf0e10cSrcweir *  </li>
58cdf0e10cSrcweir *  <li> <code>'XSimpleRegistry.destroy'</code> (of type <code>String</code>):
59cdf0e10cSrcweir *    The full system path to the registry fiel which is destroyed.
60cdf0e10cSrcweir *  </li>
61cdf0e10cSrcweir *  <li> <code>'XSimpleRegistry.merge'</code> (of type <code>String</code>):
62cdf0e10cSrcweir *    The full system path to the registry file which is merged with the
63cdf0e10cSrcweir *    registry tested.
64cdf0e10cSrcweir *  </li>
65cdf0e10cSrcweir * </ul> <p>
66cdf0e10cSrcweir * @see com.sun.star.registry.XSimpleRegistry
67cdf0e10cSrcweir */
68cdf0e10cSrcweir public class _XSimpleRegistry extends MultiMethodTest {
69cdf0e10cSrcweir     public XSimpleRegistry oObj = null;
70cdf0e10cSrcweir     protected String nr = null;
71cdf0e10cSrcweir     protected boolean configuration = false;
72cdf0e10cSrcweir     protected String openF = null;
73cdf0e10cSrcweir     protected String destroyF = null;
74cdf0e10cSrcweir     protected String mergeF = null;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     /**
77cdf0e10cSrcweir     * Retrieves object relations.
78cdf0e10cSrcweir     * @throws StatusException If one of required relations not found.
79cdf0e10cSrcweir     */
before()80cdf0e10cSrcweir     protected void before() {
81cdf0e10cSrcweir         if (tEnv.getObjRelation("configuration") != null) {
82cdf0e10cSrcweir             configuration = true;
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         nr = (String) tEnv.getObjRelation("NR");
86cdf0e10cSrcweir 
87cdf0e10cSrcweir         openF = (String) tEnv.getObjRelation("XSimpleRegistry.open");
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         if (openF == null) {
90cdf0e10cSrcweir             throw new StatusException(Status.failed(
91cdf0e10cSrcweir                                               "Relation 'XSimpleRegistry.open' not found"));
92cdf0e10cSrcweir         }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         destroyF = (String) tEnv.getObjRelation("XSimpleRegistry.destroy");
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         if (destroyF == null) {
97cdf0e10cSrcweir             throw new StatusException(Status.failed(
98cdf0e10cSrcweir                                               "Relation 'XSimpleRegistry.destroy' not found"));
99cdf0e10cSrcweir         }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         mergeF = (String) tEnv.getObjRelation("XSimpleRegistry.merge");
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         if (mergeF == null) {
104cdf0e10cSrcweir             throw new StatusException(Status.failed(
105cdf0e10cSrcweir                                               "Relation 'XSimpleRegistry.merge' not found"));
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /**
110cdf0e10cSrcweir     * If the method is supported opens the registry key with the URL
111cdf0e10cSrcweir     * from <code>'XSimpleRegistry.open'</code> relation, then closes it. <p>
112cdf0e10cSrcweir     *
113cdf0e10cSrcweir     * Has <b> OK </b> status if the method isn't supported by the component
114cdf0e10cSrcweir     * (the object relation <code>'NR'</code> isn't null) or no exceptions were
115cdf0e10cSrcweir     * thrown during open/close operations. <p>
116cdf0e10cSrcweir     */
_open()117cdf0e10cSrcweir     public void _open() {
118cdf0e10cSrcweir         if (nr != null) {
119cdf0e10cSrcweir             log.println("'open()' isn't supported by '" + nr + "'");
120cdf0e10cSrcweir             tRes.tested("open()", true);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir             return;
123cdf0e10cSrcweir         }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         log.println("Trying to open registry :" + openF);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         try {
128cdf0e10cSrcweir             oObj.open(openF, false, true);
129cdf0e10cSrcweir             oObj.close();
130cdf0e10cSrcweir         } catch (InvalidRegistryException e) {
131cdf0e10cSrcweir             e.printStackTrace(log);
132cdf0e10cSrcweir             tRes.tested("open()", false);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir             return;
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         tRes.tested("open()", true);
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     /**
141cdf0e10cSrcweir     * Test opens the registry key with the URL from
142cdf0e10cSrcweir     * <code>'XSimpleRegistry.open'</code> relation not only for read,
143cdf0e10cSrcweir     * calls the method, checks returned value and closes the registry. <p>
144cdf0e10cSrcweir     *
145cdf0e10cSrcweir     * Has <b> OK </b> status if returned value is false and no exceptions were
146cdf0e10cSrcweir     * thrown. <p>
147cdf0e10cSrcweir     */
_isReadOnly()148cdf0e10cSrcweir     public void _isReadOnly() {
149cdf0e10cSrcweir         boolean result = false;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         try {
152cdf0e10cSrcweir             openReg(oObj, openF, false, true);
153cdf0e10cSrcweir             result = !oObj.isReadOnly();
154cdf0e10cSrcweir             closeReg(oObj);
155cdf0e10cSrcweir         } catch (InvalidRegistryException e) {
156cdf0e10cSrcweir             e.printStackTrace(log);
157cdf0e10cSrcweir             result = false;
158cdf0e10cSrcweir         }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         tRes.tested("isReadOnly()", result);
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     /**
164cdf0e10cSrcweir     * Test opens the registry key with the URL from
165cdf0e10cSrcweir     * <code>'XSimpleRegistry.open'</code> relation, calls the method,
166cdf0e10cSrcweir     * checks returned value and closes the registry key. <p>
167cdf0e10cSrcweir     *
168cdf0e10cSrcweir     * Has <b>OK</b> status if returned value isn't null and no exceptions were
169cdf0e10cSrcweir     * thrown. <p>
170cdf0e10cSrcweir     */
_getRootKey()171cdf0e10cSrcweir     public void _getRootKey() {
172cdf0e10cSrcweir         boolean result = false;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         try {
175cdf0e10cSrcweir             openReg(oObj, openF, false, true);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir             XRegistryKey rootKey = oObj.getRootKey();
178cdf0e10cSrcweir             result = rootKey != null;
179cdf0e10cSrcweir             closeReg(oObj);
180cdf0e10cSrcweir         } catch (InvalidRegistryException e) {
181cdf0e10cSrcweir             e.printStackTrace(log);
182cdf0e10cSrcweir             result = false;
183cdf0e10cSrcweir         }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir         tRes.tested("getRootKey()", result);
186cdf0e10cSrcweir     }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     /**
189cdf0e10cSrcweir     * Merges the current registry with the registry from URL got from
190cdf0e10cSrcweir     * <code>'XSimpleRegistry.merge'</code> relation under 'MergeKey' key.
191cdf0e10cSrcweir     * Then the keys of these two registries retrieved :
192cdf0e10cSrcweir     * <ul>
193cdf0e10cSrcweir     *  <li> Root key from 'XSimpleRegistry.merge' registry </li>
194cdf0e10cSrcweir     *  <li> 'MergeKey' key from the current registry </li>
195cdf0e10cSrcweir     * </ul>
196cdf0e10cSrcweir     * Then these two keys are recursively compared. <p>
197cdf0e10cSrcweir     *
198cdf0e10cSrcweir     * Has <b> OK </b> status if the method isn't supported by the component
199cdf0e10cSrcweir     * (the object relation <code>'NR'</code> isn't null)
200cdf0e10cSrcweir     * or
201cdf0e10cSrcweir     * if it's supported and after successfull merging the keys mentioned
202cdf0e10cSrcweir     * above are recursively equal. <p>
203cdf0e10cSrcweir     */
_mergeKey()204cdf0e10cSrcweir     public void _mergeKey() {
205cdf0e10cSrcweir         if (configuration) {
206cdf0e10cSrcweir             log.println(
207cdf0e10cSrcweir                     "You can't merge into this registry. It's just a wrapper for a configuration node, which has a fixed structure which can not be modified");
208cdf0e10cSrcweir             tRes.tested("mergeKey()", true);
209cdf0e10cSrcweir 
210cdf0e10cSrcweir             return;
211cdf0e10cSrcweir         }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir         if (nr != null) {
214cdf0e10cSrcweir             log.println("'mergeKey()' isn't supported by '" + nr + "'");
215cdf0e10cSrcweir             tRes.tested("mergeKey()", true);
216cdf0e10cSrcweir 
217cdf0e10cSrcweir             return;
218cdf0e10cSrcweir         }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir         openReg(oObj, openF, false, true);
221cdf0e10cSrcweir 
222cdf0e10cSrcweir         try {
223cdf0e10cSrcweir             RegistryTools.printRegistryInfo(oObj.getRootKey(), log);
224cdf0e10cSrcweir             oObj.mergeKey("MergeKey", mergeF);
225cdf0e10cSrcweir             RegistryTools.printRegistryInfo(oObj.getRootKey(), log);
226cdf0e10cSrcweir         } catch (com.sun.star.registry.MergeConflictException e) {
227cdf0e10cSrcweir             e.printStackTrace(log);
228cdf0e10cSrcweir             tRes.tested("mergeKey()", false);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir             return;
231cdf0e10cSrcweir         } catch (com.sun.star.registry.InvalidRegistryException e) {
232cdf0e10cSrcweir             e.printStackTrace(log);
233cdf0e10cSrcweir             tRes.tested("mergeKey()", false);
234cdf0e10cSrcweir 
235cdf0e10cSrcweir             return;
236cdf0e10cSrcweir         }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir         boolean isEqual = false;
239cdf0e10cSrcweir         XSimpleRegistry reg = null;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir         try {
242cdf0e10cSrcweir             reg = RegistryTools.createRegistryService((XMultiServiceFactory) tParam.getMSF());
243cdf0e10cSrcweir         } catch (com.sun.star.uno.Exception e) {
244cdf0e10cSrcweir             log.print("Can't create registry service: ");
245cdf0e10cSrcweir             e.printStackTrace(log);
246cdf0e10cSrcweir             tRes.tested("mergeKey()", false);
247cdf0e10cSrcweir 
248cdf0e10cSrcweir             return;
249cdf0e10cSrcweir         }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir         openReg(reg, mergeF, false, true);
252cdf0e10cSrcweir 
253cdf0e10cSrcweir         try {
254cdf0e10cSrcweir             XRegistryKey key = oObj.getRootKey().openKey("MergeKey");
255cdf0e10cSrcweir             XRegistryKey mergeKey = reg.getRootKey();
256cdf0e10cSrcweir             isEqual = RegistryTools.compareKeyTrees(key, mergeKey);
257cdf0e10cSrcweir         } catch (com.sun.star.registry.InvalidRegistryException e) {
258cdf0e10cSrcweir             log.print("Can't get root key: ");
259cdf0e10cSrcweir             e.printStackTrace(log);
260cdf0e10cSrcweir             tRes.tested("mergeKey()", false);
261cdf0e10cSrcweir 
262cdf0e10cSrcweir             return;
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         closeReg(reg);
266cdf0e10cSrcweir         closeReg(oObj);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir         tRes.tested("mergeKey()", isEqual);
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     /**
272cdf0e10cSrcweir     * Test opens the registry key with the URL from
273cdf0e10cSrcweir     * <code>'XSimpleRegistry.open'</code> relation, calls the method,
274cdf0e10cSrcweir     * checks returned value and closes the registry key. <p>
275cdf0e10cSrcweir     *
276cdf0e10cSrcweir     * Has <b> OK </b> status if returned value isn't null and if length of the
277cdf0e10cSrcweir     * returned string is greater than 0. <p>
278cdf0e10cSrcweir     */
_getURL()279cdf0e10cSrcweir     public void _getURL() {
280cdf0e10cSrcweir         openReg(oObj, openF, false, true);
281cdf0e10cSrcweir 
282cdf0e10cSrcweir         String url = oObj.getURL();
283cdf0e10cSrcweir         closeReg(oObj);
284cdf0e10cSrcweir         log.println("Getting URL: " + url+";");
285cdf0e10cSrcweir         tRes.tested("getURL()", (url != null));
286cdf0e10cSrcweir     }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     /**
289cdf0e10cSrcweir     * Test checks value returned by the object relation <code>'NR'</code>,
290cdf0e10cSrcweir     * opens the registry key with the URL from
291cdf0e10cSrcweir     * <code>XSimpleRegistry.open'</code> relation, calls the method
292cdf0e10cSrcweir     * and checks the validity of the registry key. <p>
293cdf0e10cSrcweir     *
294cdf0e10cSrcweir     * Has <b> OK </b> status if the registry key isn't valid after the method
295cdf0e10cSrcweir     * call, or if the method isn't supported by the component (the object
296cdf0e10cSrcweir     * relation <code>'NR'</code> isn't null). <p>
297cdf0e10cSrcweir     */
_close()298cdf0e10cSrcweir     public void _close() {
299cdf0e10cSrcweir         if (nr != null) {
300cdf0e10cSrcweir             log.println("'close()' isn't supported by '" + nr + "'");
301cdf0e10cSrcweir             tRes.tested("close()", true);
302cdf0e10cSrcweir 
303cdf0e10cSrcweir             return;
304cdf0e10cSrcweir         }
305cdf0e10cSrcweir 
306cdf0e10cSrcweir         try {
307cdf0e10cSrcweir             oObj.open(openF, false, true);
308cdf0e10cSrcweir             oObj.close();
309cdf0e10cSrcweir         } catch (com.sun.star.registry.InvalidRegistryException e) {
310cdf0e10cSrcweir             e.printStackTrace(log);
311cdf0e10cSrcweir             tRes.tested("close()", false);
312cdf0e10cSrcweir 
313cdf0e10cSrcweir             return;
314cdf0e10cSrcweir         }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir         tRes.tested("close()", !oObj.isValid());
317cdf0e10cSrcweir     }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     /**
320cdf0e10cSrcweir     * Test checks value returned by the object relation <code>'NR'</code>,
321cdf0e10cSrcweir     * opens the registry key with the URL from
322cdf0e10cSrcweir     * <code>'XSimpleRegistry.destroy'</code> relation, calls the method
323cdf0e10cSrcweir     * and checks the validity of the registry key. <p>
324cdf0e10cSrcweir     *
325cdf0e10cSrcweir     * Has <b> OK </b> status if the registry key isn't valid after the method
326cdf0e10cSrcweir     * call, or if the method isn't supported by the component (the object
327cdf0e10cSrcweir     * relation <code>'NR'</code> isn't null). <p>
328cdf0e10cSrcweir     */
_destroy()329cdf0e10cSrcweir     public void _destroy() {
330cdf0e10cSrcweir         if (configuration) {
331cdf0e10cSrcweir             log.println(
332cdf0e10cSrcweir                     "This registry is a wrapper for a configuration access. It can not be destroyed.");
333cdf0e10cSrcweir             tRes.tested("destroy()", true);
334cdf0e10cSrcweir 
335cdf0e10cSrcweir             return;
336cdf0e10cSrcweir         }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir         if (nr != null) {
339cdf0e10cSrcweir             log.println("'destroy()' isn't supported by '" + nr + "'");
340cdf0e10cSrcweir             tRes.tested("destroy()", true);
341cdf0e10cSrcweir 
342cdf0e10cSrcweir             return;
343cdf0e10cSrcweir         }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir         try {
346cdf0e10cSrcweir             oObj.open(destroyF, false, true);
347cdf0e10cSrcweir             oObj.destroy();
348cdf0e10cSrcweir         } catch (com.sun.star.registry.InvalidRegistryException e) {
349cdf0e10cSrcweir             e.printStackTrace(log);
350cdf0e10cSrcweir             tRes.tested("destroy()", false);
351cdf0e10cSrcweir 
352cdf0e10cSrcweir             return;
353cdf0e10cSrcweir         }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir         tRes.tested("destroy()", !oObj.isValid());
356cdf0e10cSrcweir     }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir     /**
359cdf0e10cSrcweir     * Test opens the registry key with the URL from
360cdf0e10cSrcweir     * <code>'XSimpleRegistry.open'</code> relation, calls the method,
361cdf0e10cSrcweir     * checks returned value and closes the registry key. <p>
362cdf0e10cSrcweir     * Has <b> OK </b> status if returned value is true. <p>
363cdf0e10cSrcweir     */
_isValid()364cdf0e10cSrcweir     public void _isValid() {
365cdf0e10cSrcweir         boolean valid = true;
366cdf0e10cSrcweir 
367cdf0e10cSrcweir         openReg(oObj, openF, false, true);
368cdf0e10cSrcweir         valid = oObj.isValid();
369cdf0e10cSrcweir         closeReg(oObj);
370cdf0e10cSrcweir 
371cdf0e10cSrcweir         tRes.tested("isValid()", valid);
372cdf0e10cSrcweir     }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir     /**
375cdf0e10cSrcweir     * Method calls <code>close()</code> of the interface
376cdf0e10cSrcweir     * <code>com.sun.star.registry.XRegistryKey</code>. <p>
377cdf0e10cSrcweir     * @param reg interface <code>com.sun.star.registry.XRegistryKey</code>
378cdf0e10cSrcweir     * @param url specifies the complete URL to access the data source
379cdf0e10cSrcweir     * @param arg1 specifies if the data source should be opened for read only
380cdf0e10cSrcweir     * @param arg2 specifies if the data source should be created if it does not
381cdf0e10cSrcweir     * already exist
382cdf0e10cSrcweir     */
openReg(XSimpleRegistry reg, String url, boolean arg1, boolean arg2)383cdf0e10cSrcweir     public void openReg(XSimpleRegistry reg, String url, boolean arg1,
384cdf0e10cSrcweir                         boolean arg2) {
385cdf0e10cSrcweir         if (nr == null) {
386cdf0e10cSrcweir             try {
387cdf0e10cSrcweir                 reg.open(url, arg1, arg2);
388cdf0e10cSrcweir             } catch (com.sun.star.registry.InvalidRegistryException e) {
389cdf0e10cSrcweir                 log.print("Couldn't open registry:");
390cdf0e10cSrcweir                 e.printStackTrace(log);
391cdf0e10cSrcweir             }
392cdf0e10cSrcweir         }
393cdf0e10cSrcweir     }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     /**
396cdf0e10cSrcweir     * Method calls <code>close()</code> of the interface
397cdf0e10cSrcweir     * <code>com.sun.star.registry.XRegistryKey</code>. <p>
398*e6b649b5SPedro Giffuni     * @param reg <code>com.sun.star.registry.XRegistryKey</code>
399cdf0e10cSrcweir     */
closeReg(XSimpleRegistry reg)400cdf0e10cSrcweir     public void closeReg(XSimpleRegistry reg) {
401cdf0e10cSrcweir         if (nr == null) {
402cdf0e10cSrcweir             try {
403cdf0e10cSrcweir                 reg.close();
404cdf0e10cSrcweir             } catch (com.sun.star.registry.InvalidRegistryException e) {
405cdf0e10cSrcweir                 log.print("Couldn't close registry:");
406cdf0e10cSrcweir                 e.printStackTrace(log);
407cdf0e10cSrcweir             }
408cdf0e10cSrcweir         }
409cdf0e10cSrcweir     }
410*e6b649b5SPedro Giffuni }
411