Package org.pentaho.platform.api.repository2.unified

Examples of org.pentaho.platform.api.repository2.unified.IStreamListener


      final PentahoJcrConstants pentahoJcrConstants, final IPathConversionHelper pathConversionHelper,
      final String childNodeFilter, final ILockHelper lockHelper, final int depth, final boolean showHidden,
      final IRepositoryAccessVoterManager accessVoterManager, RepositoryRequest.FILES_TYPE_FILTER types,
      MutableBoolean foundFiltered, boolean isRootFiltered ) throws RepositoryException {

    RepositoryFile file = nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, childNode );
    if ( isSupportedNodeType( pentahoJcrConstants, childNode )
        && ( accessVoterManager.hasAccess( file, RepositoryFilePermission.READ, JcrRepositoryFileAclUtils.getAcl(
            session, pentahoJcrConstants, file.getId() ), PentahoSessionHolder.getSession() ) ) ) {
      MutableBoolean foundFilteredAtomic = new MutableBoolean( !isPentahoFolder( pentahoJcrConstants, childNode ) );
      RepositoryFileTree repositoryFileTree =
          getTreeByNode( session, pentahoJcrConstants, pathConversionHelper, lockHelper, childNode, depth - 1,
              childNodeFilter, showHidden, accessVoterManager, types, foundFilteredAtomic );
      if ( repositoryFileTree != null && ( foundFilteredAtomic.booleanValue() || isRootFiltered ) ) {
View Full Code Here


              sourcePath =
              sourceFile.getPath().substring( 0, sourceFile.getPath().lastIndexOf( FileUtils.PATH_SEPARATOR ) );
          if ( !sourcePath.equals( destDir.getPath() ) ) { // We're saving to a different folder than we're copying
            // from
            IRepositoryFileData data = getData( sourceFile );
            RepositoryFileAcl acl = getRepository().getAcl( sourceFileId );
            RepositoryFile
                destFile =
                getRepository().getFile( destDir.getPath() + FileUtils.PATH_SEPARATOR + fileName );
            if ( destFile == null ) { // destFile doesn't exist so we'll create it.
              RepositoryFile duplicateFile =
                  new RepositoryFile.Builder( fileName ).hidden( sourceFile.isHidden() ).versioned(
                      sourceFile.isVersioned() ).build();
              final RepositoryFile repositoryFile =
                  getRepository().createFile( destDir.getId(), duplicateFile, data, acl, null );
              getRepository()
                  .setFileMetadata( repositoryFile.getId(), getRepository().getFileMetadata( sourceFileId ) );
            } else if ( mode == MODE_OVERWRITE ) { // destFile exists so check to see if we want to overwrite it.
              RepositoryFileDto destFileDto = toFileDto( destFile, null, false );
              destFileDto.setHidden( sourceFile.isHidden() );
              destFile = toFile( destFileDto );
              final RepositoryFile repositoryFile = getRepository().updateFile( destFile, data, null );
              getRepository().updateAcl( acl );
              getRepository()
                  .setFileMetadata( repositoryFile.getId(), getRepository().getFileMetadata( sourceFileId ) );
            }
          }
        }
      }
    } else {
      for ( String sourceFileId : sourceFileIds ) {
        RepositoryFile sourceFile = getRepository().getFileById( sourceFileId );
        if ( destDir != null && destDir.isFolder() && sourceFile != null && !sourceFile.isFolder() ) {

          // First try to see if regular name is available
          String fileName = sourceFile.getName();
          String copyText = "";
          String rootCopyText = "";
          String nameNoExtension = fileName;
          String extension = "";
          int indexOfDot = fileName.lastIndexOf( '.' );
          if ( !( indexOfDot == -1 ) ) {
            nameNoExtension = fileName.substring( 0, indexOfDot );
            extension = fileName.substring( indexOfDot );
          }

          RepositoryFileDto
              testFile =
              getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + nameNoExtension + extension ); //$NON-NLS-1$
          if ( testFile != null ) {
            // Second try COPY_PREFIX, If the name already ends with a COPY_PREFIX don't append twice
            if ( !nameNoExtension
                .endsWith( Messages.getInstance().getString( "FileResource.COPY_PREFIX" ) ) ) { //$NON-NLS-1$
              copyText = rootCopyText = Messages.getInstance().getString( "FileResource.COPY_PREFIX" );
              fileName = nameNoExtension + copyText + extension;
              testFile = getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + fileName );
            }
          }

          // Third try COPY_PREFIX + DUPLICATE_INDICATOR
          Integer nameCount = 1;
          while ( testFile != null ) {
            nameCount++;
            copyText =
                rootCopyText + Messages.getInstance().getString( "FileResource.DUPLICATE_INDICATOR", nameCount );
            fileName = nameNoExtension + copyText + extension;
            testFile = getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + fileName );
          }
          IRepositoryFileData data = getData( sourceFile );
          RepositoryFileAcl acl = getRepository().getAcl( sourceFileId );
          RepositoryFile duplicateFile = null;

          // If the title is different than the source file, copy it separately
          if ( !sourceFile.getName().equals( sourceFile.getTitle() ) ) {
            duplicateFile =
View Full Code Here

        destFileDto.setHidden( isHidden );

        RepositoryFile destFile = toFile( destFileDto );

        // add the existing acls and file data
        RepositoryFileAcl acl = getRepository().getAcl( sourceFile.getId() );
        if ( !file.isFolder() ) {
          IRepositoryFileData data = getData( sourceFile );

          getRepository().updateFile( destFile, data, null );
          getRepository().updateAcl( acl );
View Full Code Here

    logger.info( "getEffectiveAces" );
    List<RepositoryFileAce> folder1EffectiveAces = repo.getEffectiveAces( folder1.getId() );
    assertEquals( 1, folder1EffectiveAces.size() );

    logger.info( "getAcl" );
    RepositoryFileAcl folder1Acl = repo.getAcl( folder1.getId() );
    assertEquals( USERNAME_SUZY, folder1Acl.getOwner().getName() );

    logger.info( "updateAcl" );
    userRoleDao.createUser( tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null );
    RepositoryFileAcl updatedFolder1Acl =
        repo.updateAcl( new RepositoryFileAcl.Builder( folder1Acl ).entriesInheriting( false ).ace(
            userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ), RepositoryFileSid.Type.USER,
            RepositoryFilePermission.ALL ).build() );
    assertNotNull( updatedFolder1Acl );
    assertEquals( 1, updatedFolder1Acl.getAces().size() );

    logger.info( "lockFile" );
    assertFalse( file1.isLocked() );
    repo.lockFile( file1.getId(), "I locked this file" );
    logger.info( "canUnlockFile" );
View Full Code Here

  public RepositoryFileAcl processAclForFile( String filePath ) {
    // If we are not overwriting ACL's or owners then return null.
    // If we are writing ACL's we'll have to check later in RepositoryFileImportHandler whether to overwrite
    // based on the isOverwriteAcl setting and whether we are creating or updating the RepositoryFile.
    RepositoryFileAcl acl = null;
    if ( applyAclSettings || retainOwnership ) {
      try {
        if ( manifest != null ) {
          ExportManifestEntity entity = manifest.getExportManifestEntity( filePath );
          if ( entity != null ) {
View Full Code Here

   * @throws ExportException
   */
  private void addToManifest( RepositoryFile repositoryFile ) throws ExportException {
    if ( this.withManifest ) {
      // add this entity to the manifest
      RepositoryFileAcl fileAcl = unifiedRepository.getAcl( repositoryFile.getId() );
      try {
        exportManifest.add( repositoryFile, fileAcl );
      } catch ( ExportManifestFormatException e ) {
        throw new ExportException( e.getMessage() );
      }
View Full Code Here

   *
   * @see org.pentaho.platform.api.action.IAction#execute()
   */
  public void execute() throws Exception {
    // scan the repository for all files with a RESERVEDMAPKEY_LINEAGE_ID
    RepositoryFileTree tree = repository.getTree( ClientRepositoryPaths.getRootFolderPath(), -1, null, false );
    ArrayList<RepositoryFile> generatedContentList = new ArrayList<RepositoryFile>();
    findGeneratedContent( generatedContentList, tree );
    for ( RepositoryFile deleteMe : generatedContentList ) {
      repository.deleteFile( deleteMe.getId(), true, GeneratedContentCleaner.class.getName() );
      logger.info( "GeneratedContentCleaner deleting: " + deleteMe.getPath() );
View Full Code Here

   */
  @Test
  public void testBIServer7777() throws Exception {
    // file tree with empty children
    RepositoryFile empty = new RepositoryFile.Builder( "empty" ).build();
    RepositoryFileTree emptyDir = new RepositoryFileTree( empty, Collections.<RepositoryFileTree>emptyList() );
    RepositoryFile root = new RepositoryFile.Builder( "rootDir" ).build();
    ArrayList<RepositoryFileTree> children = new ArrayList<RepositoryFileTree>( 1 );
    children.add( emptyDir );
    RepositoryFileTree rootDir = new RepositoryFileTree( root, children );
    // to DTO
    RepositoryFileTreeAdapter adapter = new RepositoryFileTreeAdapter();
    RepositoryFileTreeDto dtoThere = adapter.marshal( rootDir );
    assertNotNull( dtoThere.getChildren().get( 0 ).getChildren() );
    // serialize
    final JAXBContext jaxbContext = JAXBContext.newInstance( RepositoryFileTreeDto.class );
    Marshaller marshaller = jaxbContext.createMarshaller();
    StringWriter sw = new StringWriter();
    marshaller.marshal( dtoThere, sw );
    // and bring it back
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    StringReader sr = new StringReader( sw.toString() );
    RepositoryFileTreeDto dtoBackAgain = (RepositoryFileTreeDto) unmarshaller.unmarshal( sr );
    assertNotNull( dtoBackAgain.getChildren().get( 0 ).getChildren() );
    // unmarshall
    RepositoryFileTree rootDir2 = adapter.unmarshal( dtoBackAgain );
    assertNotNull( rootDir2.getChildren().get( 0 ).getChildren() );
    assertEquals( rootDir, rootDir2 );
  }
View Full Code Here

    RepositoryFile file1AtVersion = repo.getFileAtVersion( file1.getId(), versionSummary.getId() );
    assertNotNull( file1AtVersion );
    assertEquals( versionSummary.getId(), file1AtVersion.getVersionId() );

    logger.info( "getTree" );
    RepositoryFileTree tree = repo.getTree( new RepositoryRequest( ClientRepositoryPaths.getRootFolderPath(), true, -1, null ) );
    assertNotNull( tree.getFile().getId() );

    logger.info( "getDataForReadInBatch" );
    List<NodeRepositoryFileData> result =
        repo.getDataForReadInBatch( Arrays.asList( file1, copiedFile ), NodeRepositoryFileData.class );
    assertEquals( 2, result.size() );
View Full Code Here

      Collections.sort( children );
    } else {
      children = null;
    }
    return new RepositoryFileTree( rootFile, children );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.IStreamListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.