@Override public void deleteElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException { pur.deleteFile( elementId, true, null ); }
protected void permanentlyDeleteSharedObject( final ObjectId id ) throws KettleException { try { readWriteLock.writeLock().lock(); try { pur.deleteFile( id.getId(), true, null ); } finally { readWriteLock.writeLock().unlock(); } } catch ( Exception e ) { throw new KettleException( "Unable to delete object with id [" + id + "]", e ); } }
public void deleteFileById( final ObjectId id ) throws KettleException { try { readWriteLock.writeLock().lock(); try { pur.deleteFile( id.getId(), null ); } finally { readWriteLock.writeLock().unlock(); } rootRef.clearRef(); } catch ( Exception e ) { throw new KettleException( "Unable to delete object with id [" + id + "]", e ); } }
@Override public void delete( final List<ObjectId> ids ) throws KettleException { for ( ObjectId id : ids ) { pur.deleteFile( id.getId(), true, null ); } rootRef.clearRef(); }
@Override public void deleteNamespace( String namespace ) throws MetaStoreException { RepositoryFile namespaceFile = getNamespaceRepositoryFile( namespace ); if ( namespaceFile == null ) { return; // already gone. } List<RepositoryFile> children = getChildren( namespaceFile.getId() ); if ( children == null || children.isEmpty() ) { // Delete the file, there are no children. // pur.deleteFile( namespaceFile.getId(), true, "Delete namespace" ); } else { // Dependencies exists, throw an exception. // List<String> elementTypeIds = new ArrayList<String>(); for ( RepositoryFile child : children ) { elementTypeIds.add( child.getId().toString() ); } throw new MetaStoreDependenciesExistsException( elementTypeIds, "Namespace '" + namespace + " can not be deleted because it is not empty" ); } }
@Override public void deleteElementType( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException { RepositoryFile namespaceRepositoryFile = validateNamespace( namespace ); RepositoryFile elementTypeFile = findChildByName( namespaceRepositoryFile.getId(), elementType.getName() ); List<RepositoryFile> children = getChildren( elementTypeFile.getId() ); removeHiddenFilesFromList( children ); if ( children.isEmpty() ) { pur.deleteFile( elementTypeFile.getId(), true, null ); } else { List<String> ids = getElementIds( namespace, elementType ); throw new MetaStoreDependenciesExistsException( ids, "Can't delete element type with name '" + elementType.getName() + "' because it is not empty" ); } }
@Override public void deleteRepositoryDirectory( final RepositoryDirectoryInterface dir, final boolean deleteHomeDirectories ) throws KettleException { readWriteLock.writeLock().lock(); try { // Fetch the folder to be deleted RepositoryFile folder; RepositoryFile homeFolder; folder = pur.getFileById( dir.getObjectId().getId() ); // Fetch the user's home directory homeFolder = pur.getFile( ClientRepositoryPaths.getUserHomeFolderPath( user.getLogin() ) ); // Make sure the user is not trying to delete their own home directory if ( isSameOrAncestorFolder( folder, homeFolder ) ) { // Then throw an exception that the user cannot delete their own home directory throw new KettleException( "You are not allowed to delete your home folder." ); } if ( !deleteHomeDirectories && isUserHomeDirectory( folder ) ) { throw new RepositoryObjectAccessException( "Cannot delete another users home directory", RepositoryObjectAccessException.AccessExceptionType.USER_HOME_DIR ); } pur.deleteFile( dir.getObjectId().getId(), null ); rootRef.clearRef(); } catch ( Exception e ) { throw new KettleException( "Unable to delete directory with path [" + getPath( null, dir, null ) + "]", e ); } finally { readWriteLock.writeLock().unlock(); } }
public Void call() throws Exception { delegatee.deleteFile( fileId, permanent, versionMessage ); return null; } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.deleteFile", fileId ) ); //$NON-NLS-1$
public Void call() throws Exception { delegatee.deleteFile( fileId, versionMessage ); return null; } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.deleteFile", fileId ) ); //$NON-NLS-1$
public void deleteFile( String fileId, String versionMessage ) { repo.deleteFile( fileId, versionMessage ); }
public void deleteFileWithPermanentFlag( String fileId, boolean permanent, String versionMessage ) { repo.deleteFile( fileId, permanent, versionMessage ); }
private void deleteEmptyFile() { IUnifiedRepository repo = PentahoSystem.get( IUnifiedRepository.class ); RepositoryFile file = repo.getFile( outputFilePath ); Long emptyFileSize = new Long( 0 ); Long fileSize = file.getFileSize(); if ( fileSize.equals( emptyFileSize ) ) { repo.deleteFile( file.getId(), true, null ); } }
private void testDeleteDatasourceWithName( boolean throwException) 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 delete doReturn( new RepositoryFile.Builder( fileId, EXP_DBMETA_NAME + dotKdb ).build() ).when( repo ).getFile( databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb ); IDatasourceMgmtService datasourceMgmtService = new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() ); if( throwException ) { deleteDatasourceWithNameThrowException( repo ); } datasourceMgmtService.deleteDatasourceByName( EXP_DBMETA_NAME ); verify( repo ).deleteFile( eq( fileId ), eq( true ), anyString() ); }
private void testDeleteDatasourceWithId( boolean throwException ) throws Exception { 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 ).getFileById( EXP_FILE_ID ); doReturn( reservedChars ).when( repo ).getReservedChars(); // stub out get file to delete doReturn( new RepositoryFile.Builder( EXP_FILE_ID, EXP_DBMETA_NAME + dotKdb ).build() ).when( repo ).getFileById( EXP_FILE_ID); IDatasourceMgmtService datasourceMgmtService = new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() ); if( throwException ) { deleteDatasourceWithIdThrowException( repo ); } datasourceMgmtService.deleteDatasourceById( EXP_FILE_ID ); verify( repo ).deleteFile( eq( EXP_FILE_ID ), eq( true ), anyString() ); }
private void deleteDatasource( RepositoryFile file ) throws DatasourceMgmtServiceException { try { if ( file != null ) { // Permanently Deletes the File repository.deleteFile( file.getId(), true, null ); } else { throw new DatasourceMgmtServiceException( Messages.getInstance().getErrorString( "DatasourceMgmtService.ERROR_0002_UNABLE_TO_DELETE_DATASOURCE", "", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } catch ( UnifiedRepositoryException ure ) { throw new DatasourceMgmtServiceException( Messages .getInstance() .getErrorString( "DatasourceMgmtService.ERROR_0002_UNABLE_TO_DELETE_DATASOURCE", file.getName(), ure.getLocalizedMessage() ), ure ); //$NON-NLS-1$ } }
@Override public Void call() throws Exception { RepositoryFile aclNode = getAclNode( fileToAddAclFor ); if ( acl == null ) { if ( aclNode != null ) { unifiedRepository.deleteFile( aclNode.getId(), true, Messages.getInstance().getString( "AclNodeHelper.WARN_0001_REMOVE_ACL_NODE", aclNode.getPath() ) ); } // ignore if no ACL node is present. } else { if ( aclNode == null ) { // Create ACL Node with reference to given file. aclNode = createAclNode( fileToAddAclFor ); } // Update ACL on file. RepositoryFileAcl existing = unifiedRepository.getAcl( aclNode.getId() ); RepositoryFileAcl updated = new RepositoryFileAcl.Builder( existing ) .aces( acl.getAces() ) .build(); unifiedRepository.updateAcl( updated ); } return null; } } );