2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package complex
.ofopxmlstorages
;
21 import com
.sun
.star
.uno
.UnoRuntime
;
22 import com
.sun
.star
.uno
.XInterface
;
23 import com
.sun
.star
.uno
.AnyConverter
;
25 import com
.sun
.star
.lang
.*;
26 import com
.sun
.star
.embed
.*;
27 import com
.sun
.star
.packages
.*;
28 import com
.sun
.star
.io
.*;
29 import com
.sun
.star
.beans
.*;
31 import share
.LogWriter
;
33 public class TestHelper
{
35 LogWriter m_aLogWriter
;
38 public TestHelper( LogWriter aLogWriter
, String sTestPrefix
)
40 m_aLogWriter
= aLogWriter
;
41 m_sTestPrefix
= sTestPrefix
;
44 public boolean WriteBytesToStream( XStream xStream
,
49 StringPair
[][] aRelations
)
51 // get output stream of substream
52 XOutputStream xOutput
= xStream
.getOutputStream();
53 if ( xOutput
== null )
55 Error( "Can't get XOutputStream implementation from substream '" + sStreamName
+ "'!" );
59 // get XTrucate implementation from output stream
60 XTruncate xTruncate
= (XTruncate
) UnoRuntime
.queryInterface( XTruncate
.class, xOutput
);
61 if ( xTruncate
== null )
63 Error( "Can't get XTruncate implementation from substream '" + sStreamName
+ "'!" );
67 // write requested byte sequence
71 xOutput
.writeBytes( pBytes
);
75 Error( "Can't write to stream '" + sStreamName
+ "', exception: " + e
);
79 // get access to the XPropertySet interface
80 XPropertySet xPropSet
= (XPropertySet
) UnoRuntime
.queryInterface( XPropertySet
.class, xStream
);
81 if ( xPropSet
== null )
83 Error( "Can't get XPropertySet implementation from substream '" + sStreamName
+ "'!" );
87 // set properties to the stream
90 xPropSet
.setPropertyValue( "MediaType", sMediaType
);
91 xPropSet
.setPropertyValue( "Compressed", Boolean
.valueOf( bCompressed
) );
95 Error( "Can't set properties to substream '" + sStreamName
+ "', exception: " + e
);
99 // check size property of the stream
102 long nSize
= AnyConverter
.toLong( xPropSet
.getPropertyValue( "Size" ) );
103 if ( nSize
!= pBytes
.length
)
105 Error( "The 'Size' property of substream '" + sStreamName
+ "' contains wrong value!" );
111 Error( "Can't get 'Size' property from substream '" + sStreamName
+ "', exception: " + e
);
115 // get access to the relationship information
116 XRelationshipAccess xRelAccess
= (XRelationshipAccess
) UnoRuntime
.queryInterface( XRelationshipAccess
.class, xStream
);
117 if ( xRelAccess
== null )
119 Error( "Can't get XRelationshipAccess implementation from substream '" + sStreamName
+ "'!" );
123 // set the relationship information
126 xRelAccess
.insertRelationships( aRelations
, false );
130 Error( "Can't set relationships to substream '" + sStreamName
+ "', exception: " + e
);
134 // free the stream resources, garbage collector may remove the object too late
135 if ( !disposeStream( xStream
, sStreamName
) )
141 public boolean WriteBytesToSubstream( XStorage xStorage
,
146 StringPair
[][] aRelations
)
148 // open substream element
149 XStream xSubStream
= null;
152 Object oSubStream
= xStorage
.openStreamElement( sStreamName
, ElementModes
.WRITE
);
153 xSubStream
= (XStream
) UnoRuntime
.queryInterface( XStream
.class, oSubStream
);
154 if ( xSubStream
== null )
156 Error( "Can't create substream '" + sStreamName
+ "'!" );
162 Error( "Can't create substream '" + sStreamName
+ "', exception : " + e
+ "!" );
166 return WriteBytesToStream( xSubStream
, sStreamName
, sMediaType
, bCompressed
, pBytes
, aRelations
);
169 public boolean setStorageTypeAndCheckProps( XStorage xStorage
,
172 StringPair
[][] aRelations
)
176 // get access to the XPropertySet interface
177 XPropertySet xPropSet
= (XPropertySet
) UnoRuntime
.queryInterface( XPropertySet
.class, xStorage
);
178 if ( xPropSet
!= null )
182 // get "IsRoot" and "OpenMode" properties and control there values
183 boolean bPropIsRoot
= AnyConverter
.toBoolean( xPropSet
.getPropertyValue( "IsRoot" ) );
184 int nPropMode
= AnyConverter
.toInt( xPropSet
.getPropertyValue( "OpenMode" ) );
187 if ( bPropIsRoot
!= bIsRoot
)
189 Error( "'IsRoot' property contains wrong value!" );
194 && ( nPropMode
| ElementModes
.READ
) != ( nMode
| ElementModes
.READ
) )
195 || ( !bIsRoot
&& ( nPropMode
& nMode
) != nMode
) )
197 Error( "'OpenMode' property contains wrong value, expected " + nMode
+ ", in reality " + nPropMode
+ "!" );
203 Error( "Can't control properties of substorage, exception: " + e
);
208 Error( "Can't get XPropertySet implementation from storage!" );
211 // get access to the relationship information
212 XRelationshipAccess xRelAccess
= (XRelationshipAccess
) UnoRuntime
.queryInterface( XRelationshipAccess
.class, xStorage
);
214 if ( xRelAccess
== null )
216 Error( "Can't get XRelationshipAccess implementation from the storage!" );
220 // set the relationship information
223 xRelAccess
.insertRelationships( aRelations
, false );
227 Error( "Can't set relationships to the storage, exception: " + e
);
235 public boolean checkRelations( StringPair
[][] aStorRels
, StringPair
[][] aTestRels
)
237 if ( aStorRels
.length
!= aTestRels
.length
)
239 Error( "The provided relations sequence has different size than the storage's one!" );
243 for ( int nStorInd
= 0; nStorInd
< aStorRels
.length
; nStorInd
++ )
246 for ( int nStorTagInd
= 0; nStorTagInd
< aStorRels
[nStorInd
].length
; nStorTagInd
++ )
248 if ( aStorRels
[nStorInd
][nStorTagInd
].First
.equals( "Id" ) )
250 nStorIDInd
= nStorTagInd
;
255 if ( nStorIDInd
== -1 )
257 Error( "One of the storage relations entries has no ID!" );
261 for ( int nInd
= 0; nInd
< aTestRels
.length
; nInd
++ )
264 for ( int nTagInd
= 0; nTagInd
< aTestRels
[nInd
].length
; nTagInd
++ )
266 if ( aTestRels
[nInd
][nTagInd
].First
.equals( "Id" ) )
275 Error( "One of the test hardcoded entries has no ID, num = " + nInd
+ ", length = " + aTestRels
[nInd
].length
+ ", global length = " + aTestRels
.length
+ "!" );
279 if ( aStorRels
[nStorInd
][nStorIDInd
].Second
.equals( aTestRels
[nInd
][nIDInd
].Second
) )
281 boolean[] pRelCheckMark
= new boolean[ aTestRels
[nInd
].length
];
282 for ( int nCheckInd
= 0; nCheckInd
< pRelCheckMark
.length
; nCheckInd
++ )
284 pRelCheckMark
[nCheckInd
] = false;
287 for ( int nStorTagInd
= 0; nStorTagInd
< aStorRels
[nStorInd
].length
; nStorTagInd
++ )
289 boolean bFound
= false;
290 for ( int nTagInd
= 0; nTagInd
< aTestRels
[nInd
].length
; nTagInd
++ )
292 if ( aTestRels
[nInd
][nTagInd
].First
.equals( aStorRels
[nStorInd
][nStorTagInd
].First
) )
294 if ( !aTestRels
[nInd
][nTagInd
].Second
.equals( aStorRels
[nStorInd
][nStorTagInd
].Second
) )
296 Error( "Test rel. num. " + nInd
+ " has different tag \"" + aTestRels
[nInd
][nTagInd
].First
+ "\" value!" );
301 pRelCheckMark
[nTagInd
] = true;
308 Error( "Stor rel. num. " + nStorInd
+ " has unexpected tag \"" + aStorRels
[nStorInd
][nStorTagInd
].First
+ "\", ID = \"" + aStorRels
[nStorInd
][nStorIDInd
].Second
+ "\"!" );
313 for ( int nCheckInd
= 0; nCheckInd
< pRelCheckMark
.length
; nCheckInd
++ )
315 if ( !pRelCheckMark
[nCheckInd
] && !aTestRels
[nInd
][nCheckInd
].Second
.equals( "" ) )
317 Error( "Test rel. num. " + nInd
+ " has unexpected tag \"" + aTestRels
[nInd
][nCheckInd
].First
+ "\" with nonempty value!" );
330 public boolean checkStorageProperties( XStorage xStorage
,
333 StringPair
[][] aRelations
)
337 // get access to the XPropertySet interface
338 XPropertySet xPropSet
= (XPropertySet
) UnoRuntime
.queryInterface( XPropertySet
.class, xStorage
);
339 if ( xPropSet
!= null )
343 // get "IsRoot" and "OpenMode" properties and control there values
344 boolean bPropIsRoot
= AnyConverter
.toBoolean( xPropSet
.getPropertyValue( "IsRoot" ) );
345 int nPropMode
= AnyConverter
.toInt( xPropSet
.getPropertyValue( "OpenMode" ) );
348 if ( bPropIsRoot
!= bIsRoot
)
350 Error( "'IsRoot' property contains wrong value!" );
355 && ( nPropMode
| ElementModes
.READ
) != ( nMode
| ElementModes
.READ
) )
356 || ( !bIsRoot
&& ( nPropMode
& nMode
) != nMode
) )
358 Error( "'OpenMode' property contains wrong value, expected " + nMode
+ ", in reality " + nPropMode
+ "!" );
364 Error( "Can't get properties of substorage, exception: " + e
);
369 Error( "Can't get XPropertySet implementation from storage!" );
372 // get access to the relationship information
373 XRelationshipAccess xRelAccess
= (XRelationshipAccess
) UnoRuntime
.queryInterface( XRelationshipAccess
.class, xStorage
);
375 if ( xRelAccess
== null )
377 Error( "Can't get XRelationshipAccess implementation from the checked storage!" );
381 // get the relationship information
382 StringPair
[][] aStorRels
;
385 aStorRels
= xRelAccess
.getAllRelationships();
389 Error( "Can't get relationships of the checked storage, exception: " + e
);
393 if ( !checkRelations( aStorRels
, aRelations
) )
395 Error( "StorageRelationsChecking has failed!" );
402 public boolean InternalCheckStream( XStream xStream
,
406 StringPair
[][] aRelations
)
408 // get input stream of substream
409 XInputStream xInput
= xStream
.getInputStream();
410 if ( xInput
== null )
412 Error( "Can't get XInputStream implementation from substream '" + sName
+ "'!" );
416 byte pContents
[][] = new byte[1][]; // ???
421 xInput
.readBytes( pContents
, pBytes
.length
+ 1 );
425 Error( "Can't read from stream '" + sName
+ "', exception: " + e
);
429 // check size of stream data
430 if ( pContents
.length
== 0 )
432 Error( "SubStream '" + sName
+ "' reading produced disaster!" );
436 if ( pBytes
.length
!= pContents
[0].length
)
438 Error( "SubStream '" + sName
+ "' contains wrong amount of data! (" + pContents
[0].length
+ "/" + pBytes
.length
+ ")" );
443 for ( int ind
= 0; ind
< pBytes
.length
; ind
++ )
445 if ( pBytes
[ind
] != pContents
[0][ind
] )
447 Error( "SubStream '" + sName
+ "' contains wrong data! ( byte num. "
448 + ind
+ " should be" + pBytes
[ind
] + " but it is " + pContents
[0][ind
] + ")" );
456 // get access to the XPropertySet interface
457 XPropertySet xPropSet
= (XPropertySet
) UnoRuntime
.queryInterface( XPropertySet
.class, xStream
);
458 if ( xPropSet
!= null )
462 // get "MediaType" and "Size" properties and control there values
463 String sPropMediaType
= AnyConverter
.toString( xPropSet
.getPropertyValue( "MediaType" ) );
464 long nPropSize
= AnyConverter
.toLong( xPropSet
.getPropertyValue( "Size" ) );
467 if ( !sPropMediaType
.equals( sMediaType
) )
469 Error( "'MediaType' property contains wrong value for stream '" + sName
+ "',\nexpected: '"
470 + sMediaType
+ "', set: '" + sPropMediaType
+ "'!" );
474 if ( nPropSize
!= pBytes
.length
)
476 Error( "'Size' property contains wrong value for stream'" + sName
+ "'!" );
482 Error( "Can't get properties of substream '" + sName
+ "', exception: " + e
);
487 Error( "Can't get XPropertySet implementation from stream '" + sName
+ "'!" );
491 // get access to the relationship information
492 XRelationshipAccess xRelAccess
= (XRelationshipAccess
) UnoRuntime
.queryInterface( XRelationshipAccess
.class, xStream
);
494 if ( xRelAccess
== null )
496 Error( "Can't get XRelationshipAccess implementation from the stream\"" + sName
+ "\"!" );
500 // get the relationship information
501 StringPair
[][] aStorRels
;
504 aStorRels
= xRelAccess
.getAllRelationships();
508 Error( "Can't get relationships of the substream '" + sName
+ "', exception: " + e
);
512 if ( !checkRelations( aStorRels
, aRelations
) )
514 Error( "Stream '" + sName
+ "' RelationsChecking has failed!" );
521 public boolean checkStream( XStorage xParentStorage
,
525 StringPair
[][] aRelations
)
527 // open substream element first
528 XStream xSubStream
= null;
531 Object oSubStream
= xParentStorage
.openStreamElement( sName
, ElementModes
.READ
);
532 xSubStream
= (XStream
) UnoRuntime
.queryInterface( XStream
.class, oSubStream
);
533 if ( xSubStream
== null )
535 Error( "Can't open substream '" + sName
+ "'!" );
541 Error( "Can't open substream '" + sName
+ "', exception : " + e
+ "!" );
545 boolean bResult
= InternalCheckStream( xSubStream
, sName
, sMediaType
, pBytes
, aRelations
);
547 // free the stream resources, garbage collector may remove the object too late
548 if ( !disposeStream( xSubStream
, sName
) )
554 public boolean copyStorage( XStorage xSourceStorage
, XStorage xDestStorage
)
556 // copy xSourceStorage to xDestStorage
559 xSourceStorage
.copyToStorage( xDestStorage
);
563 Error( "Storage copying failed, exception: " + e
);
570 public boolean commitStorage( XStorage xStorage
)
572 // XTransactedObject must be supported by storages
573 XTransactedObject xTransact
= (XTransactedObject
) UnoRuntime
.queryInterface( XTransactedObject
.class, xStorage
);
574 if ( xTransact
== null )
576 Error( "Storage doesn't implement transacted access!" );
586 Error( "Storage commit failed, exception:" + e
);
593 public boolean disposeStream( XStream xStream
, String sStreamName
)
595 XComponent xComponent
= (XComponent
) UnoRuntime
.queryInterface( XComponent
.class, xStream
);
596 if ( xComponent
== null )
598 Error( "Can't get XComponent implementation from substream '" + sStreamName
+ "'!" );
604 xComponent
.dispose();
608 Error( "Substream '" + sStreamName
+ "' disposing throws exception: " + e
);
615 public boolean disposeStorage( XStorage xStorage
)
617 // dispose the storage
618 XComponent xComponent
= (XComponent
) UnoRuntime
.queryInterface( XComponent
.class, xStorage
);
619 if ( xComponent
== null )
621 Error( "Can't retrieve XComponent implementation from storage!" );
627 xComponent
.dispose();
631 Error( "Storage disposing failed!" );
638 public XInputStream
getInputStream( XStream xStream
)
640 XInputStream xInTemp
= null;
643 xInTemp
= xStream
.getInputStream();
644 if ( xInTemp
== null )
645 Error( "Can't get the input part of a stream!" );
647 catch ( Exception e
)
649 Error( "Can't get the input part of a stream, exception :" + e
);
655 public boolean closeOutput( XStream xStream
)
657 XOutputStream xOutTemp
= null;
660 xOutTemp
= xStream
.getOutputStream();
661 if ( xOutTemp
== null )
663 Error( "Can't get the output part of a stream!" );
667 catch ( Exception e
)
669 Error( "Can't get the output part of a stream, exception :" + e
);
675 xOutTemp
.closeOutput();
677 catch ( Exception e
)
679 Error( "Can't close output part of a stream, exception :" + e
);
686 public XStorage
openSubStorage( XStorage xStorage
, String sName
, int nMode
)
688 // open existing substorage
691 Object oSubStorage
= xStorage
.openStorageElement( sName
, nMode
);
692 XStorage xSubStorage
= (XStorage
) UnoRuntime
.queryInterface( XStorage
.class, oSubStorage
);
697 Error( "Can't open substorage '" + sName
+ "', exception: " + e
);
703 public XStream
CreateTempFileStream( XMultiServiceFactory xMSF
)
705 // try to get temporary file representation
706 XStream xTempFileStream
= null;
709 Object oTempFile
= xMSF
.createInstance( "com.sun.star.io.TempFile" );
710 xTempFileStream
= (XStream
)UnoRuntime
.queryInterface( XStream
.class, oTempFile
);
715 if ( xTempFileStream
== null )
716 Error( "Can't create temporary file!" );
718 return xTempFileStream
;
721 public String
CreateTempFile( XMultiServiceFactory xMSF
)
723 String sResult
= null;
725 // try to get temporary file representation
726 XPropertySet xTempFileProps
= null;
729 Object oTempFile
= xMSF
.createInstance( "com.sun.star.io.TempFile" );
730 xTempFileProps
= (XPropertySet
)UnoRuntime
.queryInterface( XPropertySet
.class, oTempFile
);
735 if ( xTempFileProps
!= null )
739 xTempFileProps
.setPropertyValue( "RemoveFile", Boolean
.FALSE
);
740 sResult
= AnyConverter
.toString( xTempFileProps
.getPropertyValue( "Uri" ) );
744 Error( "Can't control TempFile properties, exception: " + e
);
749 Error( "Can't create temporary file representation!" );
752 // close temporary file explicitly
755 XStream xStream
= (XStream
)UnoRuntime
.queryInterface( XStream
.class, xTempFileProps
);
756 if ( xStream
!= null )
758 XOutputStream xOut
= xStream
.getOutputStream();
762 XInputStream xIn
= xStream
.getInputStream();
767 Error( "Can't close TempFile!" );
771 Error( "Can't close TempFile, exception: " + e
);
777 public boolean copyElementTo( XStorage xSource
, String sName
, XStorage xDest
)
779 // copy element with name sName from xSource to xDest
782 xSource
.copyElementTo( sName
, xDest
, sName
);
786 Error( "Element copying failed, exception: " + e
);
793 public boolean copyElementTo( XStorage xSource
, String sName
, XStorage xDest
, String sTargetName
)
795 // copy element with name sName from xSource to xDest
798 xSource
.copyElementTo( sName
, xDest
, sTargetName
);
802 Error( "Element copying failed, exception: " + e
);
809 public boolean moveElementTo( XStorage xSource
, String sName
, XStorage xDest
)
811 // move element with name sName from xSource to xDest
814 xSource
.moveElementTo( sName
, xDest
, sName
);
818 Error( "Element moving failed, exception: " + e
);
825 public boolean renameElement( XStorage xStorage
, String sOldName
, String sNewName
)
827 // rename element with name sOldName to sNewName
830 xStorage
.renameElement( sOldName
, sNewName
);
834 Error( "Element renaming failed, exception: " + e
);
841 public boolean removeElement( XStorage xStorage
, String sName
)
843 // remove element with name sName
846 xStorage
.removeElement( sName
);
850 Error( "Element removing failed, exception: " + e
);
857 public XStream
OpenStream( XStorage xStorage
,
861 // open substream element
862 XStream xSubStream
= null;
865 Object oSubStream
= xStorage
.openStreamElement( sStreamName
, nMode
);
866 xSubStream
= (XStream
) UnoRuntime
.queryInterface( XStream
.class, oSubStream
);
867 if ( xSubStream
== null )
868 Error( "Can't create substream '" + sStreamName
+ "'!" );
872 Error( "Can't create substream '" + sStreamName
+ "', exception : " + e
+ "!" );
878 public boolean cantOpenStorage( XStorage xStorage
, String sName
)
880 // try to open an opened substorage, open call must fail
883 Object oDummyStorage
= xStorage
.openStorageElement( sName
, ElementModes
.READ
);
884 Error( "The trying to reopen opened substorage '" + sName
+ "' must fail!" );
894 public boolean cantOpenStream( XStorage xStorage
, String sName
, int nMode
)
896 // try to open the substream with specified mode must fail
899 Object oDummyStream
= xStorage
.openStreamElement( sName
, nMode
);
900 Error( "The trying to open substoream '" + sName
+ "' must fail!" );
910 public XStorage
createStorageFromURL(
911 XSingleServiceFactory xFactory
,
915 XStorage xResult
= null;
919 PropertyValue
[] aAddArgs
= new PropertyValue
[1];
920 aAddArgs
[0] = new PropertyValue();
921 aAddArgs
[0].Name
= "StorageFormat";
922 aAddArgs
[0].Value
= "OFOPXMLFormat";
924 Object pArgs
[] = new Object
[3];
925 pArgs
[0] = (Object
) aURL
;
926 pArgs
[1] = Integer
.valueOf( nMode
);
927 pArgs
[2] = (Object
) aAddArgs
;
929 Object oTempStorage
= xFactory
.createInstanceWithArguments( pArgs
);
930 xResult
= (XStorage
) UnoRuntime
.queryInterface( XStorage
.class, oTempStorage
);
934 Error( "Can't create storage from URL, exception: " + e
);
938 if ( xResult
== null )
939 Error( "Can't create storage from URL!" );
944 public XStorage
createStorageFromStream(
945 XSingleServiceFactory xFactory
,
949 XStorage xResult
= null;
953 PropertyValue
[] aAddArgs
= new PropertyValue
[1];
954 aAddArgs
[0] = new PropertyValue();
955 aAddArgs
[0].Name
= "StorageFormat";
956 aAddArgs
[0].Value
= "OFOPXMLFormat";
958 Object pArgs
[] = new Object
[3];
959 pArgs
[0] = (Object
) xStream
;
960 pArgs
[1] = Integer
.valueOf( nMode
);
961 pArgs
[2] = (Object
) aAddArgs
;
963 Object oTempStorage
= xFactory
.createInstanceWithArguments( pArgs
);
964 xResult
= (XStorage
) UnoRuntime
.queryInterface( XStorage
.class, oTempStorage
);
968 Error( "Can't create storage from stream, exception: " + e
);
972 if ( xResult
== null )
973 Error( "Can't create storage from stream!" );
978 public XStorage
createStorageFromInputStream(
979 XSingleServiceFactory xFactory
,
980 XInputStream xInStream
)
982 XStorage xResult
= null;
986 PropertyValue
[] aAddArgs
= new PropertyValue
[1];
987 aAddArgs
[0] = new PropertyValue();
988 aAddArgs
[0].Name
= "StorageFormat";
989 aAddArgs
[0].Value
= "OFOPXMLFormat";
991 Object pArgs
[] = new Object
[3];
992 pArgs
[0] = (Object
) xInStream
;
993 pArgs
[1] = Integer
.valueOf( ElementModes
.READ
);
994 pArgs
[2] = (Object
) aAddArgs
;
996 Object oTempStorage
= xFactory
.createInstanceWithArguments( pArgs
);
997 xResult
= (XStorage
) UnoRuntime
.queryInterface( XStorage
.class, oTempStorage
);
1001 Error( "Can't create storage from input stream, exception: " + e
);
1005 if ( xResult
== null )
1006 Error( "Can't create storage from input stream!" );
1011 public XStorage
createTempStorage( XMultiServiceFactory xMSF
, XSingleServiceFactory xFactory
)
1013 // create a temporary storage
1014 XStorage xResult
= null;
1015 XStream xStream
= CreateTempFileStream( xMSF
);
1016 if ( xStream
== null )
1018 Error( "Can't create temp file stream!" );
1024 xResult
= createStorageFromStream( xFactory
, xStream
, ElementModes
.WRITE
);
1026 catch( Exception e
)
1028 Error( "Can't create temp storage, exception: " + e
);
1034 public XStorage
cloneStorage( XMultiServiceFactory xMSF
, XSingleServiceFactory xFactory
, XStorage xStorage
)
1036 // create a copy of a last committed version of specified storage
1037 XStorage xResult
= null;
1040 xResult
= createTempStorage( xMSF
, xFactory
);
1041 if ( xResult
!= null )
1042 xStorage
.copyLastCommitTo( xResult
);
1044 catch( Exception e
)
1046 Error( "Can't clone storage, exception: " + e
);
1053 public XStorage
cloneSubStorage( XMultiServiceFactory xMSF
, XSingleServiceFactory xFactory
, XStorage xStorage
, String sName
)
1055 // create a copy of a last committed version of specified substorage
1056 XStorage xResult
= null;
1059 xResult
= createTempStorage( xMSF
, xFactory
);
1060 if ( xResult
!= null )
1061 xStorage
.copyStorageElementLastCommitTo( sName
, xResult
);
1063 catch( Exception e
)
1065 Error( "Can't clone substorage '" + sName
+ "', exception: " + e
);
1072 public XStream
cloneSubStream( XStorage xStorage
, String sName
)
1074 // clone existing substream
1077 XStream xStream
= xStorage
.cloneStreamElement( sName
);
1080 catch( Exception e
)
1082 Error( "Can't clone substream '" + sName
+ "', exception: " + e
);
1088 public void Error( String sError
)
1090 m_aLogWriter
.println( m_sTestPrefix
+ "Error: " + sError
);
1093 public void Message( String sMessage
)
1095 m_aLogWriter
.println( m_sTestPrefix
+ sMessage
);
1098 public void PrintRelations( StringPair
[][] aRels
)
1100 m_aLogWriter
.println( "========" );
1101 for ( int nInd1
= 0; nInd1
< aRels
.length
; nInd1
++ )
1103 for ( int nInd2
= 0; nInd2
< aRels
[nInd1
].length
; nInd2
++ )
1105 m_aLogWriter
.println( "\"" + aRels
[nInd1
][nInd2
].First
+ "\" = \"" + aRels
[nInd1
][nInd2
].Second
+ "\", " );
1107 m_aLogWriter
.println( "========" );