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

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


      if ( trash == null ) {
        trash = new Trash();
        userToTrashMap.put( currentUserProvider.getUser(), trash );
      }

      RepositoryFile popFile =
          new RepositoryFile.Builder( deletedRecord.getFile() ).originalParentFolderPath( origPath ).deletedDate(
              new Date() ).build();
      deletedRecord.setFile( popFile );

      List<FileRecord> dels = trash.getOrigPathToFilesMap().get( origPath );
View Full Code Here


      }
      FileRecord parentFolder = root.getFileRecord( origPath );
      parentFolder.addChild( found );
      trash.getIdToOrigPathMap().remove( fileId );

      RepositoryFile popFile =
          new RepositoryFile.Builder( found.getFile() ).originalParentFolderPath( null ).deletedDate( null ).build();
      found.setFile( popFile );
    }
View Full Code Here

      theTenant = JcrTenantUtils.getCurrentTenant();
    }
    if ( theTenant == null || theTenant.getId() == null ) {
      theTenant = JcrTenantUtils.getDefaultTenant();
    }
    RepositoryFile userHomeFolder = null;
    String userId = tenantedUserNameUtils.getPrincipleId( theTenant, username );
    final RepositoryFileSid userSid = new RepositoryFileSid( userId );
    RepositoryFile tenantHomeFolder = null;
    RepositoryFile tenantRootFolder = null;
    RepositoryFileSid ownerSid = null;
    // Get the Tenant Root folder. If the Tenant Root folder does not exist then exit.
    tenantRootFolder =
        JcrRepositoryFileUtils.getFileByAbsolutePath( session, ServerRepositoryPaths
            .getTenantRootFolderPath( theTenant ), pathConversionHelper, lockHelper, false, null );
    if ( tenantRootFolder != null ) {
      // Try to see if Tenant Home folder exist
      tenantHomeFolder =
          JcrRepositoryFileUtils.getFileByAbsolutePath( session, ServerRepositoryPaths
              .getTenantHomeFolderPath( theTenant ), pathConversionHelper, lockHelper, false, null );

      if ( tenantHomeFolder == null ) {
        String ownerId = tenantedUserNameUtils.getPrincipleId( theTenant, username );
        ownerSid = new RepositoryFileSid( ownerId, Type.USER );

        String tenantAuthenticatedRoleId = tenantedRoleNameUtils.getPrincipleId( theTenant, authenticatedRoleName );
        RepositoryFileSid tenantAuthenticatedRoleSid = new RepositoryFileSid( tenantAuthenticatedRoleId, Type.ROLE );

        aclsForTenantHomeFolder =
            new RepositoryFileAcl.Builder( userSid ).ace( tenantAuthenticatedRoleSid, EnumSet
                .of( RepositoryFilePermission.READ ) );

        aclsForUserHomeFolder =
            new RepositoryFileAcl.Builder( userSid ).ace( ownerSid, EnumSet.of( RepositoryFilePermission.ALL ) );
        tenantHomeFolder =
            internalCreateFolder( session, tenantRootFolder.getId(), new RepositoryFile.Builder( ServerRepositoryPaths
                .getTenantHomeFolderName() ).folder( true ).title(
                Messages.getInstance().getString( "AbstractJcrBackedUserRoleDao.usersFolderDisplayName" ) ).build(),
                aclsForTenantHomeFolder.build(), "tenant home folder" ); //$NON-NLS-1$
      } else {
        String ownerId = tenantedUserNameUtils.getPrincipleId( theTenant, username );
View Full Code Here

    // 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 )
View Full Code Here

    // 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 );

    final String EXP_HOST_NAME = "hello";
View Full Code Here

      throw new RuntimeException( Messages.getInstance().getString( "JcrRepositoryFileDao.ERROR_0006_ACCESS_DENIED" ) ); //$NON-NLS-1$
    }

    // Get repository file info and acl info of parent
    if ( parentFolderId != null ) {
      RepositoryFile parentRepositoryFile = getFileById( parentFolderId );
      if ( parentRepositoryFile != null ) {
        RepositoryFileAcl parentAcl = aclDao.getAcl( parentRepositoryFile.getId() );
        // Invoke accessVoterManager to see if we have access to perform this operation
        if ( !accessVoterManager.hasAccess( parentRepositoryFile, RepositoryFilePermission.WRITE, parentAcl,
            PentahoSessionHolder.getSession() ) ) {
          return null;
        }
      }
    }
    PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
    JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary( session, pentahoJcrConstants, parentFolderId );
    Node folderNode = JcrRepositoryFileUtils.createFolderNode( session, pentahoJcrConstants, parentFolderId, folder );
    // create a temporary folder object with correct path for default acl purposes.
    String path = JcrRepositoryFileUtils.getAbsolutePath( session, pentahoJcrConstants, folderNode );
    RepositoryFile tmpFolder = new RepositoryFile.Builder( folder ).path( path ).build();
    // we must create the acl during checkout
    JcrRepositoryFileAclUtils.createAcl( session, pentahoJcrConstants, folderNode.getIdentifier(), acl == null
        ? defaultAclHandler.createDefaultAcl( tmpFolder ) : acl );
    session.save();
    if ( folder.isVersioned() ) {
View Full Code Here

    Assert.notNull( file );
    Assert.isTrue( !file.isFolder() );

    // Get repository file info and acl info of parent
    if ( parentFolderId != null ) {
      RepositoryFile parentRepositoryFile = getFileById( parentFolderId );
      if ( parentRepositoryFile != null ) {
        RepositoryFileAcl parentAcl = aclDao.getAcl( parentRepositoryFile.getId() );
        // Invoke accessVoterManager to see if we have access to perform this operation
        if ( !accessVoterManager.hasAccess( parentRepositoryFile, RepositoryFilePermission.WRITE, parentAcl,
            PentahoSessionHolder.getSession() ) ) {
          return null;
        }
      }
    }
    // Assert.notNull(content);
    DataNode emptyDataNode = new DataNode( file.getName() );
    emptyDataNode.setProperty( " ", "content" ); //$NON-NLS-1$ //$NON-NLS-2$
    final IRepositoryFileData emptyContent = new NodeRepositoryFileData( emptyDataNode );

    return (RepositoryFile) jcrTemplate.execute( new JcrCallback() {
      @Override
      public Object doInJcr( final Session session ) throws RepositoryException, IOException {
        PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
        JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary( session, pentahoJcrConstants, parentFolderId );
        Node fileNode =
            JcrRepositoryFileUtils.createFileNode( session, pentahoJcrConstants, parentFolderId, file, content == null
                ? emptyContent : content, findTransformerForWrite( content == null ? emptyContent.getClass() : content
                .getClass() ) );
        // create a tmp file with correct path for default acl creation purposes.
        String path = JcrRepositoryFileUtils.getAbsolutePath( session, pentahoJcrConstants, fileNode );
        RepositoryFile tmpFile = new RepositoryFile.Builder( file ).path( path ).build();
        // we must create the acl during checkout
        aclDao.createAcl( fileNode.getIdentifier(), acl == null ? defaultAclHandler.createDefaultAcl( tmpFile ) : acl );
        session.save();
        if ( file.isVersioned() ) {
          JcrRepositoryFileUtils.checkinNearestVersionableNodeIfNecessary( session, pentahoJcrConstants, fileNode,
View Full Code Here

    return (RepositoryFile) jcrTemplate.execute( new JcrCallback() {
      @Override
      public Object doInJcr( final Session session ) throws RepositoryException, IOException {
        PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
        Node fileNode = session.getNodeByIdentifier( fileId.toString() );
        RepositoryFile file =
            fileNode != null ? JcrRepositoryFileUtils.nodeToFile( session, pentahoJcrConstants, pathConversionHelper,
                lockHelper, fileNode, loadMaps, locale ) : null;
        if ( file != null ) {
          RepositoryFileAcl acl = aclDao.getAcl( file.getId() );
          // Invoke accessVoterManager to see if we have access to perform this operation
          if ( !accessVoterManager.hasAccess( file, RepositoryFilePermission.READ, acl, PentahoSessionHolder
              .getSession() ) ) {
            return null;
          }
View Full Code Here

      // items are nodes or properties; this must be a node
      Assert.isTrue( fileNode.isNode() );
    } catch ( PathNotFoundException e ) {
      fileNode = null;
    }
    RepositoryFile file =
        fileNode != null ? JcrRepositoryFileUtils.nodeToFile( session, pentahoJcrConstants, pathConversionHelper,
            lockHelper, (Node) fileNode, loadMaps, locale ) : null;
    if ( file != null ) {
      RepositoryFileAcl acl = aclDao.getAcl( file.getId() );
      // Invoke accessVoterManager to see if we have access to perform this operation
      if ( !accessVoterManager.hasAccess( file, RepositoryFilePermission.READ, acl, PentahoSessionHolder.getSession() ) ) {
        return null;
      }
    }
View Full Code Here

        IRepositoryFileData data =
            JcrRepositoryFileUtils.getContent( session, pentahoJcrConstants, fileId, versionId, findTransformerForRead(
                JcrRepositoryFileUtils.getFileContentType( session, pentahoJcrConstants, fileId, versionId ),
                contentClass ) );
        if ( fileId != null ) {
          RepositoryFile file = internalGetFileById( fileId, false, null );
          if ( file != null ) {
            RepositoryFileAcl acl = aclDao.getAcl( fileId );
            // Invoke accessVoterManager to see if we have access to perform this operation
            if ( !accessVoterManager.hasAccess( file, RepositoryFilePermission.READ, acl, PentahoSessionHolder
                .getSession() ) ) {
View Full Code Here

TOP

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

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.