org.pentaho.di.repository.RepositoryDirectoryInterface Java Examples

The following examples show how to use org.pentaho.di.repository.RepositoryDirectoryInterface. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobGeneratorTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  final StarDomain starDomain = mock( StarDomain.class );

  final Domain domain = mock( Domain.class );
  when( domain.getProperty( eq( DefaultIDs.DOMAIN_TARGET_DATABASE ) ) ).thenReturn( "test_domain_target_db" );
  when( starDomain.getDomain() ).thenReturn( domain );

  final Repository repository = mock( Repository.class );
  final RepositoryDirectoryInterface targetDirectory = mock( RepositoryDirectoryInterface.class );

  final DatabaseMeta meta = Mockito.mock( DatabaseMeta.class );
  Mockito.when( meta.getName() ).thenReturn( "test_domain_target_db" );
  final LinkedList<DatabaseMeta> databases = new LinkedList<DatabaseMeta>() {
    {
      add( meta );
    }
  };

  final String locale = Locale.US.toString();

  jobGenerator = new JobGenerator( starDomain, repository, targetDirectory, databases, locale );
}
 
Example #2
Source File: RepositoryVfsFileObject.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public FileObject[] getChildren() throws FileSystemException {
  try {
    RepositoryDirectoryInterface dir = provider.getRepo().findDirectory( path );
    if ( dir == null ) {
      return null;
    }
    List<RepositoryObjectInterface> ch = new ArrayList<>();
    ch.addAll( dir.getChildren() );
    ch.addAll( dir.getRepositoryObjects() );

    FileObject[] result = new RepositoryVfsFileObject[ch.size()];
    for ( int i = 0; i < ch.size(); i++ ) {
      result[i] = new RepositoryVfsFileObject( provider, path + '/' + ch.get( i ).getName() );
    }
    return result;
  } catch ( Exception ex ) {
    throw new FileSystemException( ex );
  }
}
 
Example #3
Source File: KettleDatabaseRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean exists( String name, RepositoryDirectoryInterface repositoryDirectory,
  RepositoryObjectType objectType ) throws KettleException {
  try {
    switch ( objectType ) {
      case JOB:
        securityProvider.validateAction( RepositoryOperation.READ_JOB );
        return jobDelegate.existsJobMeta( name, repositoryDirectory, objectType );

      case TRANSFORMATION:
        securityProvider.validateAction( RepositoryOperation.READ_TRANSFORMATION );
        return transDelegate.existsTransMeta( name, repositoryDirectory, objectType );

      default:
        throw new KettleException( "We can't verify the existance of repository element type ["
          + objectType + "]" );
    }
  } finally {
    connectionDelegate.closeReadTransaction();
  }
}
 
Example #4
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private RepositoryDirectoryInterface initRepositoryDirectoryTree( RepositoryFileTree repoTree )
  throws KettleException {
  RepositoryFile rootFolder = repoTree.getFile();
  RepositoryDirectory rootDir = new RepositoryDirectory();
  rootDir.setObjectId( new StringObjectId( rootFolder.getId().toString() ) );
  fillRepositoryDirectoryFromTree( rootDir, repoTree );

  // Example: /etc
  RepositoryDirectory etcDir = rootDir.findDirectory( ClientRepositoryPaths.getEtcFolderPath() );

  RepositoryDirectory newRoot = new RepositoryDirectory();
  newRoot.setObjectId( rootDir.getObjectId() );
  newRoot.setVisible( false );

  for ( int i = 0; i < rootDir.getNrSubdirectories(); i++ ) {
    RepositoryDirectory childDir = rootDir.getSubdirectory( i );
    // Don't show /etc
    boolean isEtcChild = childDir.equals( etcDir );
    if ( isEtcChild ) {
      continue;
    }
    newRoot.addSubdirectory( childDir );
  }
  return newRoot;
}
 
Example #5
Source File: KettleDatabaseRepositoryDirectoryDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void delRepositoryDirectory( RepositoryDirectoryInterface dir, boolean deleteNonEmptyFolder ) throws KettleException {
  try {
    if ( !deleteNonEmptyFolder ) {
      String[] trans = repository.getTransformationNames( dir.getObjectId(), false ); // TODO : include or exclude
                                                                                      // deleted objects?
      String[] jobs = repository.getJobNames( dir.getObjectId(), false ); // TODO : include or exclude deleted
                                                                          // objects?
      ObjectId[] subDirectories = repository.getSubDirectoryIDs( dir.getObjectId() );
      if ( trans.length == 0 && jobs.length == 0 && subDirectories.length == 0 ) {
        repository.directoryDelegate.deleteDirectory( dir.getObjectId() );
        repository.commit();
      } else {
        throw new KettleException( "This directory is not empty!" );
      }
    } else {
      repository.directoryDelegate.deleteDirectory( dir );
      repository.commit();
    }
  } catch ( Exception e ) {
    throw new KettleException( "Unexpected error deleting repository directory:", e );
  }
}
 
Example #6
Source File: KettleDatabaseRepositoryTransDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String[] getTransformationsWithIDList( List<Object[]> list, RowMetaInterface rowMeta ) throws KettleException {
  String[] transList = new String[list.size()];
  for ( int i = 0; i < list.size(); i++ ) {
    long id_transformation =
      rowMeta.getInteger(
        list.get( i ), quote( KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION ), -1L );
    if ( id_transformation > 0 ) {
      RowMetaAndData transRow = getTransformation( new LongObjectId( id_transformation ) );
      if ( transRow != null ) {
        String transName =
          transRow.getString( KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME, "<name not found>" );
        long id_directory =
          transRow.getInteger( KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY, -1L );
        RepositoryDirectoryInterface dir =
          repository.loadRepositoryDirectoryTree().findDirectory( new LongObjectId( id_directory ) );

        transList[i] = dir.getPathObjectCombination( transName );
      }
    }
  }

  return transList;
}
 
Example #7
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override public void saveRepositoryDirectory( final RepositoryDirectoryInterface dir ) throws KettleException {
  // id of root dir is null--check for it
  if ( "/".equals( dir.getParent().getName() ) ) {
    throw new KettleException( BaseMessages.getString( PKG, "PurRepository.FailedDirectoryCreation.Message" ) );
  }

  readWriteLock.writeLock().lock();
  try {
    RepositoryFile
      newFolder =
      pur.createFolder( dir.getParent().getObjectId() != null ? dir.getParent().getObjectId().getId() : null,
        new RepositoryFile.Builder( dir.getName() ).folder( true ).build(), null );

    dir.setObjectId( new StringObjectId( newFolder.getId().toString() ) );
  } catch ( Exception e ) {
    throw new KettleException( "Unable to save repository directory with path [" + getPath( null, dir, null ) + "]",
      e );
  } finally {
    readWriteLock.writeLock().unlock();
  }
}
 
Example #8
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public RepositoryDirectoryInterface createRepositoryDirectory( RepositoryDirectoryInterface parentDirectory,
  String directoryPath ) throws KettleException {
  String folder = calcDirectoryName( parentDirectory );
  String newFolder = folder;
  if ( folder.endsWith( "/" ) ) {
    newFolder += directoryPath;
  } else {
    newFolder += "/" + directoryPath;
  }

  FileObject parent = KettleVFS.getFileObject( newFolder );
  try {
    parent.createFolder();
  } catch ( FileSystemException e ) {
    throw new KettleException( "Unable to create folder " + newFolder, e );
  }

  // Incremental change of the directory structure...
  //
  RepositoryDirectory newDir = new RepositoryDirectory( parentDirectory, directoryPath );
  parentDirectory.addSubdirectory( newDir );
  newDir.setObjectId( new StringObjectId( calcObjectId( newDir ) ) );

  return newDir;
}
 
Example #9
Source File: UIRepositoryDirectory.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public UIRepositoryDirectory createFolder( String name ) throws Exception {
  RepositoryDirectoryInterface thisDir = getDirectory();
  RepositoryDirectoryInterface dir;
  //PDI-5202: the directory might exist already. If so, don't create a new one.
  String dirName = checkDirNameExistsInRepo( name );
  if ( dirName == null ) {
    dir = rep.createRepositoryDirectory( thisDir, name );
  } else {
    dir = rep.findDirectory( thisDir.getPath() + "/" + dirName );
  }
  UIRepositoryDirectory newDir = null;
  try {
    newDir = UIObjectRegistry.getInstance().constructUIRepositoryDirectory( dir, this, rep );
  } catch ( UIObjectCreationException uoe ) {
    newDir = new UIRepositoryDirectory( dir, this, rep );
  }
  UIRepositoryDirectories directories = getChildren();
  if ( !contains( directories, newDir ) ) {
    directories.add( newDir );
  } else {
    throw new KettleException( "Unable to create folder with the same name [" + name + "]" );
  }
  kidElementCache = null; // rebuild the element cache for correct positioning.
  return newDir;
}
 
Example #10
Source File: JobMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testFireCurrentDirChanged() throws Exception {
  String pathBefore = "/path/before", pathAfter = "path/after";
  RepositoryDirectoryInterface repoDirOrig = mock( RepositoryDirectoryInterface.class );
  when( repoDirOrig.getPath() ).thenReturn( pathBefore );
  RepositoryDirectoryInterface repoDir = mock( RepositoryDirectoryInterface.class );
  when( repoDir.getPath() ).thenReturn( pathAfter );

  jobMeta.setRepository( mock( Repository.class ) );
  jobMeta.setRepositoryDirectory( repoDirOrig );

  CurrentDirectoryChangedListener listener = mock( CurrentDirectoryChangedListener.class );
  jobMeta.addCurrentDirectoryChangedListener( listener );
  jobMeta.setRepositoryDirectory( repoDir );

  verify( listener, times( 1 ) ).directoryChanged( jobMeta, pathBefore, pathAfter );
}
 
Example #11
Source File: PanCommandExecutor.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void executeRepositoryBasedCommand( Repository repository, String dirName, String listTrans, String listDirs, String exportRepo ) throws Exception {

    RepositoryDirectoryInterface directory = loadRepositoryDirectory( repository, dirName, "Pan.Error.NoRepProvided",
                "Pan.Log.Allocate&ConnectRep", "Pan.Error.CanNotFindSpecifiedDirectory" );

    if ( directory == null ) {
      return; // not much we can do here
    }

    if ( isEnabled( listTrans ) ) {
      printRepositoryStoredTransformations( repository, directory ); // List the transformations in the repository

    } else if ( isEnabled( listDirs ) ) {
      printRepositoryDirectories( repository, directory ); // List the directories in the repository

    } else if ( !Utils.isEmpty( exportRepo ) ) {
      // Export the repository
      System.out.println( BaseMessages.getString( getPkgClazz(), "Pan.Log.ExportingObjectsRepToFile", "" + exportRepo ) );
      repository.getExporter().exportAllObjects( null, exportRepo, directory, "all" );
      System.out.println( BaseMessages.getString( getPkgClazz(), "Pan.Log.FinishedExportObjectsRepToFile", "" + exportRepo ) );
    }
  }
 
Example #12
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public JobMeta loadJob( String jobname, RepositoryDirectoryInterface repdir, ProgressMonitorListener monitor,
  String versionName ) throws KettleException {

  // This is a standard load of a transformation serialized in XML...
  //
  String filename = calcDirectoryName( repdir ) + jobname + EXT_JOB;
  JobMeta jobMeta = new JobMeta( filename, this );
  jobMeta.setFilename( null );
  jobMeta.setName( jobname );
  jobMeta.setObjectId( new StringObjectId( calcObjectId( repdir, jobname, EXT_JOB ) ) );

  jobMeta.setRepository( this );
  jobMeta.setMetaStore( getMetaStore() );

  readDatabases( jobMeta, true );
  jobMeta.clearChanged();

  return jobMeta;

}
 
Example #13
Source File: AbstractBaseCommandExecutor.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public RepositoryDirectoryInterface loadRepositoryDirectory( Repository repository, String dirName, String noRepoProvidedMsgTkn,
                                                                String allocateAndConnectRepoMsgTkn, String cannotFindDirMsgTkn ) throws KettleException {

  if ( repository == null ) {
    System.out.println( BaseMessages.getString( getPkgClazz(), noRepoProvidedMsgTkn ) );
    return null;
  }

  RepositoryDirectoryInterface directory;

  // Default is the root directory
  logDebug( allocateAndConnectRepoMsgTkn );
  directory = repository.loadRepositoryDirectoryTree();

  if ( !StringUtils.isEmpty( dirName ) ) {

    directory = directory.findDirectory( dirName ); // Find the directory name if one is specified...

    if ( directory == null ) {
      System.out.println( BaseMessages.getString( getPkgClazz(), cannotFindDirMsgTkn, "" + dirName ) );
    }
  }
  return directory;
}
 
Example #14
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public ObjectId[] getSubDirectoryIDs( ObjectId id_directory ) throws KettleException {
  RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
  RepositoryDirectoryInterface directory = tree.findDirectory( id_directory );
  ObjectId[] objectIds = new ObjectId[directory.getNrSubdirectories()];
  for ( int i = 0; i < objectIds.length; i++ ) {
    objectIds[i] = directory.getSubdirectory( i ).getObjectId();
  }
  return objectIds;
}
 
Example #15
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void openTransformation( String name, RepositoryDirectoryInterface repdir ) {
  lastOpened = new RepositoryObjectReference( RepositoryObjectType.TRANSFORMATION, repdir, name );
  if ( callback != null ) {
    if ( callback.open( lastOpened ) ) {
      close();
    }
  } else {
    close();
  }
}
 
Example #16
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private String calcFilename( RepositoryDirectoryInterface dir, String name, String extension ) {
  StringBuilder filename = new StringBuilder();
  filename.append( calcDirectoryName( dir ) );

  String objectName = name + extension;
  filename.append( objectName );

  return filename.toString();
}
 
Example #17
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public boolean renameTransformation( String name, String newname, RepositoryDirectoryInterface repdir ) {
  boolean retval = false;

  try {
    if ( Utils.isEmpty( newname ) ) {
      throw new KettleException( BaseMessages.getString(
        PKG, "RepositoryExplorerDialog.Exception.NameCanNotBeEmpty" ) );
    }
    if ( !name.equals( newname ) ) {
      ObjectId id = rep.getTransformationID( name, repdir );
      if ( id != null ) {
        // System.out.println("Renaming transformation ["+name+"] with ID = "+id);
        String comment = BaseMessages.getString( REPOSITORY_PKG, "Repository.Rename", name, newname );
        rep.renameTransformation( id, comment, repdir, newname );
        retval = true;
      }
    } else {
      MessageBox mb = new MessageBox( shell, SWT.ICON_ERROR | SWT.OK );
      mb
        .setMessage( BaseMessages.getString(
          PKG, "RepositoryExplorerDialog.Trans.Rename.ErrorFinding.Message1" )
          + name + "]" + Const.CR
          + BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Rename.ErrorFinding.Message2" ) );
      mb.setText( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Rename.ErrorFinding.Title" ) );
      mb.open();
    }
  } catch ( KettleException dbe ) {
    new ErrorDialog(
      shell,
      BaseMessages.getString( PKG, "RepositoryExplorerDialog.Trans.Rename.ErrorRenaming.Title" ), BaseMessages
        .getString( PKG, "RepositoryExplorerDialog.Trans.Rename.ErrorRenaming.Message" )
        + name + "]!", dbe );
  }

  return retval;
}
 
Example #18
Source File: KettleDatabaseRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public ObjectId renameRepositoryDirectory( ObjectId id, RepositoryDirectoryInterface newParentDir, String newName ) throws KettleException {
  ObjectId result = null;
  securityProvider.validateAction( RepositoryOperation.RENAME_DIRECTORY );
  result = directoryDelegate.renameRepositoryDirectory( id, newParentDir, newName );
  commit();
  return result;
}
 
Example #19
Source File: RepositoryBrowserController.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if there is a duplicate folder in a given directory (i.e. hidden folder)
 *
 * @param parent - Parent directory
 * @param name   - Name of folder
 * @return - true if the parent directory has a folder equal to name, false otherwise
 */
private boolean hasDupeFolder( String parent, String name ) {
  try {
    RepositoryDirectoryInterface rdi = getRepository().findDirectory( parent ).findChild( name );
    return rdi != null;
  } catch ( Exception e ) {
    System.out.println( e );
  }
  return false;
}
 
Example #20
Source File: PurRepositoryStressTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void testLocksDeleteRepositoryDirectory() throws Exception {
  ObjectId objId = mock( ObjectId.class );
  doReturn( "id1" ).when( objId ).getId();

  RepositoryDirectoryInterface repFile = mock( RepositoryDirectoryInterface.class );
  doReturn( objId ).when( repFile ).getObjectId();

  purRepository.deleteRepositoryDirectory( repFile, true );
  verify( repFile, times( 2 ) ).getObjectId();
}
 
Example #21
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectId getTransformationID( String name, RepositoryDirectoryInterface repositoryDirectory )
  throws KettleException {
  try {
    return getObjectId( name, repositoryDirectory, RepositoryObjectType.TRANSFORMATION, false );
  } catch ( Exception e ) {
    String path = repositoryDirectory != null ? repositoryDirectory.toString() : "null";
    throw new IdNotFoundException( "Unable to get ID for job [" + name + "]", e, name, path,
      RepositoryObjectType.TRANSFORMATION );
  }
}
 
Example #22
Source File: PurRepositoryUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetJobPathWithExtension() {
  PurRepository pur = new PurRepository();
  RepositoryDirectoryInterface rdi = mock( RepositoryDirectoryInterface.class );
  doReturn( mock( ObjectId.class ) ).when( rdi ).getObjectId();
  doReturn( "/home/admin" ).when( rdi ).getPath();

  assertEquals( "/home/admin/job.kjb", pur.getPath( "job.kjb", rdi, RepositoryObjectType.JOB ) );
}
 
Example #23
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public String[] getTransformationNames( ObjectId id_directory, boolean includeDeleted ) throws KettleException {
  try {
    List<String> list = new ArrayList<String>();

    RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
    RepositoryDirectoryInterface directory = tree.findDirectory( id_directory );

    String folderName = calcDirectoryName( directory );
    FileObject folder = KettleVFS.getFileObject( folderName );

    for ( FileObject child : folder.getChildren() ) {
      if ( child.getType().equals( FileType.FILE ) ) {
        if ( !child.isHidden() || !repositoryMeta.isHidingHiddenFiles() ) {
          String name = child.getName().getBaseName();

          if ( name.endsWith( EXT_TRANSFORMATION ) ) {

            String transName = name.substring( 0, name.length() - 4 );
            list.add( transName );
          }
        }
      }
    }

    return list.toArray( new String[list.size()] );
  } catch ( Exception e ) {
    throw new KettleException(
      "Unable to get list of transformations names in folder with id : " + id_directory, e );
  }
}
 
Example #24
Source File: RepositoryImportProgressDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public RepositoryImportProgressDialog( Shell parent, int style, Repository rep, String fileDirectory,
  String[] filenames, RepositoryDirectoryInterface baseDirectory, String versionComment,
  ImportRules importRules ) {
  super( parent, style );

  this.props = PropsUI.getInstance();
  this.parent = parent;

  this.rep = rep;
  this.fileDirectory = fileDirectory;
  this.filenames = filenames;
  this.baseDirectory = baseDirectory;
  this.versionComment = versionComment;
  this.importRules = importRules;
}
 
Example #25
Source File: UIEERepositoryDirectoryIT.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
protected RepositoryDirectoryInterface loadStartDirectory() throws Exception {
  RepositoryDirectoryInterface rootDir = repository.loadRepositoryDirectoryTree();
  RepositoryDirectoryInterface startDir = rootDir.findDirectory( "public" );
  assertNotNull( startDir );
  return startDir;
}
 
Example #26
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public RepositoryObjectReference( RepositoryObjectType type, RepositoryDirectoryInterface dir, String name,
  String versionLabel ) {
  this.type = type;
  this.directory = dir;
  this.name = name;
  this.versionLabel = versionLabel;
}
 
Example #27
Source File: Trans.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the repository directory.
 *
 * @return the repository directory
 * @see org.pentaho.di.core.logging.LoggingObjectInterface#getRepositoryDirectory()
 */
@Override
public RepositoryDirectoryInterface getRepositoryDirectory() {
  if ( transMeta == null ) {
    return null;
  }
  return transMeta.getRepositoryDirectory();
}
 
Example #28
Source File: PurRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Deprecated
@Override public RepositoryDirectoryInterface loadRepositoryDirectoryTree( boolean eager ) throws KettleException {

  // this method forces a reload of the repository directory tree structure
  // a new rootRef will be obtained - this is a SoftReference which will be used
  // by any calls to getRootDir()

  RepositoryDirectoryInterface rootDir;
  if ( eager ) {
    RepositoryFileTree rootFileTree = loadRepositoryFileTree( ClientRepositoryPaths.getRootFolderPath() );
    rootDir = initRepositoryDirectoryTree( rootFileTree );
  } else {
    readWriteLock.readLock().lock();
    RepositoryFile root;
    try {
      root = pur.getFile( "/" );
    } finally {
      readWriteLock.readLock().unlock();
    }

    IUser user = this.getUserInfo();
    boolean showHidden = user != null ? user.isAdmin() : true;

    rootDir =
      new LazyUnifiedRepositoryDirectory( root, null, pur, purRepositoryServiceRegistry, showHidden );
  }
  rootRef.setRef( rootDir );
  return rootDir;
}
 
Example #29
Source File: PurRepositoryUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateValidRepositoryDirectoryForNotRoot() throws KettleException {
  RepositoryDirectoryInterface treeMocked = mock( RepositoryDirectoryInterface.class );
  PurRepository repository = mock( PurRepository.class );
  LazyUnifiedRepositoryDirectory lazy = mock( LazyUnifiedRepositoryDirectory.class );
  String newDirectory = "admin1";
  //if not root then we can create any folder
  when( treeMocked.isRoot() ).thenReturn( false );
  when( treeMocked.getPath() ).thenReturn( newDirectory );
  when( repository.findDirectory( anyString() ) ).thenReturn( lazy );
  when( repository.createRepositoryDirectory( treeMocked, newDirectory ) ).thenCallRealMethod();

  assertEquals( "/admin1", repository.createRepositoryDirectory( treeMocked, newDirectory ).getPath() );
}
 
Example #30
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectId renameJob( ObjectId id_job, String versionComment, RepositoryDirectoryInterface newDir,
  String newName ) throws KettleException {
  ObjectId objectId = renameObject( id_job, newDir, newName, EXT_JOB );
  if ( !Utils.isEmpty( versionComment ) ) {
    insertLogEntry( "Rename job : " + versionComment );
  }
  return objectId;
}