@Override public synchronized void updateElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException { RepositoryFile folder = getElementTypeRepositoryFolder( namespace, elementType ); RepositoryFile detailsFile = findChildByName( folder.getId(), ELEMENT_TYPE_DETAILS_FILENAME, true ); DataNode dataNode = getElementTypeDataNode( elementType ); pur.updateFile( detailsFile, new NodeRepositoryFileData( dataNode ), null ); elementType.setMetaStoreName( getName() ); }
@Override public synchronized void updateElement( String namespace, IMetaStoreElementType elementType, String elementId, IMetaStoreElement element ) throws MetaStoreException { // verify that the element type belongs to this meta store // if ( elementType.getMetaStoreName() == null || !elementType.getName().equals( getName() ) ) { String elementTypeName = elementType.getName(); elementType = getElementTypeByName( namespace, elementTypeName ); if ( elementType == null ) { throw new MetaStoreException( "The element type '" + elementTypeName + "' could not be found in the meta store in which you are updating." ); } } RepositoryFile existingFile = pur.getFileById( elementId ); if ( existingFile == null ) { throw new MetaStoreException( "The element to update with id " + elementId + " could not be found in the store" ); } DataNode elementDataNode = new DataNode( PurRepository.checkAndSanitize( element.getName() ) ); elementToDataNode( element, elementDataNode ); RepositoryFile updatedFile = pur.updateFile( existingFile, new NodeRepositoryFileData( elementDataNode ), null ); element.setId( updatedFile.getId().toString() ); }
pur.updateFile( file, new NodeRepositoryFileData( databaseMetaTransformer.elementToDataNode( element ) ), versionComment );
pur.updateFile( file, data, versionComment );
pur.updateFile( file, new NodeRepositoryFileData( objectTransformer.elementToDataNode( element ) ), versionComment ); } catch ( SOAPFaultException e ) {
pur.updateFile( file, new NodeRepositoryFileData( transformer.elementToDataNode( element ) ), versionComment );
public RepositoryFile call() throws Exception { return delegatee.updateFile( file, data, versionMessage ); } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.updateFile", file != null ? file.getId() : null ), exceptionConstructor ); //$NON-NLS-1$
public RepositoryFileDto updateBinaryFile( final RepositoryFileDto file, final SimpleRepositoryFileDataDto simpleJaxWsData, final String versionMessage ) { return repositoryFileAdapter.marshal( repo.updateFile( repositoryFileAdapter.unmarshal( file ), SimpleRepositoryFileDataDto.convert( simpleJaxWsData ), versionMessage ) ); }
public RepositoryFileDto updateFile( RepositoryFileDto file, NodeRepositoryFileDataDto data, String versionMessage ) { return repositoryFileAdapter.marshal( repo.updateFile( repositoryFileAdapter.unmarshal( file ), nodeRepositoryFileDataAdapter.unmarshal( data ), versionMessage ) ); }
/** * Save the data to a file at the specified path. It will create the file it is doesn't exist (if * {@code create == true}), it will overwrite the file it it does exist (if {@code overwrite == true}, and it * will create any necessary parent directories (if {@code createParentDirs == true} * * @param filePath * @param data * @param create * @param overwrite * @param createParentDirs * @return */ public RepositoryFile saveFile( final String filePath, final IRepositoryFileData data, final boolean create, final boolean overwrite, final boolean createParentDirs, final boolean versioned, final String versionMessage ) { // See if the file exists final RepositoryFile file = repository.getFile( filePath ); if ( file == null ) { if ( !create ) { return null; } return createFile( filePath, data, createParentDirs, versioned, versionMessage ); } // Since the file exists, make sure we should update it if ( !overwrite ) { return null; } return repository.updateFile( file, data, versionMessage ); }
repository.updateFile( file, payload, "New File" ); //$NON-NLS-1$ path = file.getPath(); for ( IStreamListener listener : listeners ) { repository.updateFile( file, payload, "New File" ); //$NON-NLS-1$
@Test public void testWriteToPath() throws IOException { final String fileName = "test-file1.txt"; final String filePath = publicDirPath + "/" + fileName; IUnifiedRepository repo = mock( IUnifiedRepository.class ); RepositoryFile existingFile = new RepositoryFile.Builder( "123", fileName ).build(); // simulate file already exists doReturn( existingFile ).when( repo ).getFile( filePath ); mp.defineInstance( IUnifiedRepository.class, repo ); RepositoryFileWriter writer = new RepositoryFileWriter( filePath, "UTF-8" ); writer.write( "test123" ); writer.close(); verify( repo ).updateFile( argThat( isLikeFile( existingFile ) ), argThat( hasData( "test123", "UTF-8", "text/plain" ) ), anyString() ); }
@Test public void testUpdateDatasourceWithName() throws Exception { final String fileId = "456"; final String databasesFolderPath = "/etc/pdi/databases"; final String dotKdb = ".kdb"; IUnifiedRepository repo = mock( IUnifiedRepository.class ); // stub out get parent folder doReturn( new RepositoryFile.Builder( "123", "databases" ).folder( true ).build() ).when( repo ).getFile( databasesFolderPath ); doReturn( reservedChars ).when( repo ).getReservedChars(); // stub out get file to update RepositoryFile f = new RepositoryFile.Builder( fileId, EXP_DBMETA_NAME + dotKdb ).path( databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb ).build(); doReturn( f ).when( repo ).getFile( databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb ); // stub out update file which requires a file to be returned doReturn( f ).when( repo ) .updateFile( any( RepositoryFile.class ), any( NodeRepositoryFileData.class ), anyString() ); IDatasourceMgmtService datasourceMgmtService = new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() ); IDatabaseConnection databaseConnection = createDatabaseConnection( EXP_DBMETA_NAME ); updateDatabaseConnection( databaseConnection ); datasourceMgmtService.updateDatasourceByName( EXP_DBMETA_NAME, databaseConnection ); verify( repo ).updateFile( argThat( isLikeFile( new RepositoryFile.Builder( EXP_DBMETA_NAME + ".kdb" ).build() ) ), argThat( hasData( pathPropertyPair( "/databaseMeta/HOST_NAME", EXP_UPDATED_DBMETA_HOSTNAME ) ) ), anyString() ); }
RepositoryFile.DEFAULT_LOCALE, databaseConnection.getName() ).build(); file = repository.updateFile( file, new NodeRepositoryFileData( databaseHelper .databaseConnectionToDataNode( databaseConnection ) ), null ); renameIfNecessary( databaseConnection, file );