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

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


    }

    public FileRecord getFileById( final Serializable fileId ) {
      FileRecord r = idMap.get( fileId );
      if ( r == null ) {
        throw new UnifiedRepositoryException( String.format( "file id [%s] does not exist", fileId ) );
      }
      return r;
    }
View Full Code Here


    private Map<Serializable, List<FrozenFileRecord>> versionMap = new HashMap<Serializable, List<FrozenFileRecord>>();

    public FrozenFileRecord getLatestVersion( final Serializable fileId ) {
      List<FrozenFileRecord> history = versionMap.get( fileId );
      if ( history == null ) {
        throw new UnifiedRepositoryException( String.format( "version history for [%s] does not exist", fileId ) );
      }
      return history.get( history.size() - 1 );
    }
View Full Code Here

    }

    public void deleteVersion( final Serializable fileId, final Serializable versionId ) {
      List<FrozenFileRecord> history = versionMap.get( fileId );
      if ( history == null ) {
        throw new UnifiedRepositoryException( String.format( "version history for [%s] does not exist", fileId ) );
      }
      Integer versionNumber = versionNumber( versionId );
      if ( versionNumber >= 0 && versionNumber < history.size() ) {
        FrozenFileRecord r = history.get( versionNumber );
        if ( r == null ) {
          throw new UnifiedRepositoryException( String.format( "version [%s] does not exist", versionId ) );
        }
        history.set( versionNumber, null );
      } else {
        throw new UnifiedRepositoryException( String.format( "unknown version [%s]", fileId ) );
      }
    }
View Full Code Here

    public FrozenFileRecord restoreVersion( final Serializable fileId, final Serializable versionId,
        final String author, final String versionMessage, final Date date ) {
      List<FrozenFileRecord> history = versionMap.get( fileId );
      if ( history == null ) {
        throw new UnifiedRepositoryException( String.format( "version history for [%s] does not exist", fileId ) );
      }
      Integer versionNumber = versionNumber( versionId );
      if ( versionNumber >= 0 && versionNumber < history.size() ) {
        FrozenFileRecord r = history.get( versionNumber );
        if ( r == null ) {
          throw new UnifiedRepositoryException( String.format( "version [%s] does not exist", versionId ) );
        }
        history.add( new FrozenFileRecord( history.size(), new RepositoryFile.Builder( r.getFile() ).versionId(
            history.size() ).build(), r.getData(), r.getMetadata(), author, versionMessage, date ) );
        return history.get( history.size() - 1 );
      }

      throw new UnifiedRepositoryException( String.format( "unknown version [%s]", fileId ) );
    }
View Full Code Here

    }

    public List<FrozenFileRecord> getVersions( final Serializable fileId ) {
      List<FrozenFileRecord> history = versionMap.get( fileId );
      if ( history == null ) {
        throw new UnifiedRepositoryException( String.format( "version history for [%s] does not exist", fileId ) );
      }
      List<FrozenFileRecord> cleanedHistory = new ArrayList<FrozenFileRecord>( history );
      for ( Iterator<FrozenFileRecord> iter = cleanedHistory.iterator(); iter.hasNext(); ) {
        FrozenFileRecord r = iter.next();
        if ( r == null ) {
View Full Code Here

    }

    public FrozenFileRecord getFileAtVersion( final Serializable fileId, final Serializable versionId ) {
      List<FrozenFileRecord> history = versionMap.get( fileId );
      if ( history == null ) {
        throw new UnifiedRepositoryException( String.format( "version history for [%s] does not exist", fileId ) );
      }
      Integer versionNumber = versionNumber( versionId );
      FrozenFileRecord r = history.get( versionNumber );
      if ( r == null ) {
        throw new UnifiedRepositoryException( String.format( "version [%s] does not exist", versionId ) );
      }
      return r;
    }
View Full Code Here

    }

    public void restore( final Serializable fileId ) {
      Trash trash = userToTrashMap.get( currentUserProvider.getUser() );
      if ( trash == null ) {
        throw new UnifiedRepositoryException( "no trash found for user" );
      }

      String origPath = trash.getIdToOrigPathMap().get( fileId );
      List<FileRecord> dels = trash.getOrigPathToFilesMap().get( origPath );
      FileRecord found = null;
View Full Code Here

      return hasAccess( fileId, EnumSet.of( WRITE ) );
    }

    public void lockFile( final Serializable fileId, final String message ) {
      if ( !hasAccess( fileId, EnumSet.of( WRITE ) ) ) {
        throw new UnifiedRepositoryException( "access denied" );
      }
      FileRecord r = idManager.getFileById( fileId );
      if ( r.getFile().getLockOwner() != null ) {
        throw new IllegalStateException( "file is already locked" );
      }
View Full Code Here

          new Date() ).lockMessage( message ).locked( true ).build() );
    }

    public void unlockFile( final Serializable fileId ) {
      if ( !hasAccess( fileId, EnumSet.of( WRITE ) ) ) {
        throw new UnifiedRepositoryException( "access denied" );
      }
      FileRecord r = idManager.getFileById( fileId );
      if ( r.getFile().getLockOwner() == null ) {
        throw new IllegalStateException( "file is not locked" );
      }
View Full Code Here

            session.getWorkspace().copy( finalEncodedSrcAbsPath, JcrStringHelper.pathEncode( finalDestAbsPath ) );
          } else {
            session.getWorkspace().move( finalEncodedSrcAbsPath, JcrStringHelper.pathEncode( finalDestAbsPath ) );
          }
        } catch ( ItemExistsException iae ) {
          throw new UnifiedRepositoryException( ( file.isFolder() ? "Folder " : "File " ) + "with path ["
              + cleanDestAbsPath + "] already exists in the repository" );
        }

        JcrRepositoryFileUtils.checkinNearestVersionableNodeIfNecessary( session, pentahoJcrConstants,
            destParentFolderNode, versionMessage );
View Full Code Here

TOP

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

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.