WorkspaceManager extends ObjectImpl implements RelationalObject { public String exportArtifact(final UnitOfWork transaction, final Exportable artifact, final String storageType, final Properties parameters) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == org.komodo.spi.repository.Repository.UnitOfWork.State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); ArgCheck.isNotNull(artifact, "artifact"); try { StorageService storageService = PluginService.getInstance().getStorageService(storageType); if (storageService == null) throw new KException(Messages.getString(Relational.STORAGE_TYPE_INVALID, storageType)); StorageConnector connector = storageService.getConnector(parameters); connector.write(artifact, transaction, parameters); return parameters.getProperty(StorageConnector.DOWNLOADABLE_PATH_PROPERTY); } catch (Exception e) { throw handleError(e); } } private  WorkspaceManager(Repository repository, UnitOfWork uow ); static WorkspaceManager getInstance( Repository repository, UnitOfWork transaction); String getOwner(); @Override KomodoType[] getChildTypes(); @Override Filter[] getFilters(); @Override int getTypeId(); @Override KomodoType getTypeIdentifier(UnitOfWork uow); static void uncacheInstance(final Repository repository, final String owner); Model createModel( final UnitOfWork uow,
                              final Vdb vdb,
                              final String modelName ); Dataservice createDataservice( final UnitOfWork uow,
                                        final KomodoObject parent,
                                        final String serviceName ); Connection createConnection( final UnitOfWork uow,
                                        final KomodoObject parent,
                                        final String sourceName ); DdlFile createDdlFile( final UnitOfWork uow,
                                  final KomodoObject parent,
                                  final String ddlFileName,
                                  final byte[] content ); Driver createDriver( UnitOfWork uow,
                                KomodoObject parent,
                                String driverName,
                                final byte[] content ); Driver createDriver( UnitOfWork uow,
                                KomodoObject parent,
                                String driverName); Folder createFolder( final UnitOfWork uow,
                                final KomodoObject parent,
                                final String folderName ); ResourceFile createResourceFile( final UnitOfWork uow,
                                            final KomodoObject parent,
                                            final String resourceFileName,
                                            final byte[] content ); Schema createSchema( final UnitOfWork uow,
                                final KomodoObject parent,
                                final String schemaName ); Teiid createTeiid( final UnitOfWork uow,
                              final KomodoObject parent,
                              final String id ); UdfFile createUdfFile( final UnitOfWork uow,
                                  final KomodoObject parent,
                                  final String udfFileName,
                                  final byte[] content ); Vdb createVdb( final UnitOfWork uow,
                          final KomodoObject parent,
                          final String vdbName,
                          final String externalFilePath ); void delete( final UnitOfWork transaction,
                        final KomodoObject... kobjects ); String[] findByType( final UnitOfWork transaction,
                                final String type,
                                String parentPath,
                                final String namePattern,
                                boolean includeSubTypes); String[] findByType( final UnitOfWork transaction,
                                final String type); String[] findByType( final UnitOfWork transaction,
                                final String type,
                                boolean includeSubTypes); Model[] findModels( final UnitOfWork transaction ); Schema[] findSchemas( final UnitOfWork transaction ); Dataservice[] findDataservices( UnitOfWork transaction ); Connection[] findConnections( UnitOfWork transaction ); Driver[] findDrivers( UnitOfWork transaction ); Teiid[] findTeiids( UnitOfWork transaction ); Vdb[] findVdbs( final UnitOfWork transaction ); @Override void remove( final UnitOfWork transaction ); @Override final void rename( final UnitOfWork transaction,
                              final String newName ); T resolve( final UnitOfWork transaction,
                                                 final Object object,
                                                 final Class<T> resolvedClass ); @Override void setFilters( Filter[] newFilters ); ImportMessages importArtifact(final UnitOfWork transaction,
                                         final KomodoObject parent,
                                         StorageReference storageRef); ImportMessages importArtifact(final UnitOfWork transaction,
                                         final KomodoObject parent, 
                                         StorageReference storageRef,
                                         ImportOptions importOptions); String exportArtifact(final UnitOfWork transaction, final Exportable artifact,
                                       final String storageType, final Properties parameters); static final int TYPE_ID; }
@Test public void shouldExportVdb() throws Exception { String tmpDirPath = System.getProperty("java.io.tmpdir"); File tmpDir = new File(tmpDirPath); long timestamp = System.currentTimeMillis(); myFileDir = new File(tmpDir, "myfile-" + timestamp); assertTrue(myFileDir.mkdir()); File vdbDestFile = new File(myFileDir, "vdbFile.xml"); Properties parameters = new Properties(); parameters.setProperty("files-home-path-property", myFileDir.getAbsolutePath()); parameters.setProperty("file-path-property", vdbDestFile.getName()); Vdb vdb = mock(Vdb.class); String sampleExample = TestUtilities.streamToString(TestUtilities.sampleExample()); when(vdb.export(getTransaction(), parameters)).thenReturn(sampleExample.getBytes()); when(vdb.getName(getTransaction())).thenReturn(TestUtilities.SAMPLE_VDB_FILE); wsMgr.exportArtifact(getTransaction(), vdb, "file", parameters); File cmpFile = TestUtilities.createTempFile("sampleExampleFile", XML_SUFFIX); FileUtils.write(TestUtilities.sampleExample(), cmpFile); TestUtilities.compareFileContents(cmpFile, vdbDestFile); }