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