Examples of IUnifiedRepository


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

   * @param pathId  (colon separated path for the repository file)
   * @param newName (New name of the file)
   * @return
   */
  public boolean doRename( String pathId, String newName ) throws Exception {
    IUnifiedRepository repository = getRepository();
    RepositoryFile fileToBeRenamed = repository.getFile( FileUtils.idToPath( pathId ) );
    StringBuilder buf = new StringBuilder( fileToBeRenamed.getPath().length() );
    buf.append( getParentPath( fileToBeRenamed.getPath() ) );
    buf.append( RepositoryFile.SEPARATOR );
    buf.append( newName );
    if ( !fileToBeRenamed.isFolder() ) {
      String extension = getExtension( fileToBeRenamed.getName() );
      if ( extension != null ) {
        buf.append( extension );
      }
    }
    repository.moveFile( fileToBeRenamed.getId(), buf.toString(), "Renaming the file" );
    RepositoryFile movedFile = repository.getFileById( fileToBeRenamed.getId() );
    if ( movedFile != null ) {
      if ( !movedFile.isFolder() ) {
        Map<String, Properties> localePropertiesMap = movedFile.getLocalePropertiesMap();
        if ( localePropertiesMap == null ) {
          localePropertiesMap = new HashMap<String, Properties>();
          Properties properties = new Properties();
          properties.setProperty( "file.title", newName );
          properties.setProperty( "title", newName );
          localePropertiesMap.put( "default", properties );
        } else {
          for ( Map.Entry<String, Properties> entry : localePropertiesMap.entrySet() ) {
            Properties properties = entry.getValue();
            if ( properties.containsKey( "file.title" ) ) {
              properties.setProperty( "file.title", newName );
            }
            if ( properties.containsKey( "title" ) ) {
              properties.setProperty( "title", newName );
            }
          }
        }
        RepositoryFile updatedFile =
          new RepositoryFile.Builder( movedFile ).localePropertiesMap( localePropertiesMap ).name( newName ).title(
            newName ).build();
        repository.updateFile( updatedFile, getData( movedFile ), "Updating the file" );
      }
      return true;
    } else {
      return false;
      //return Response.ok( "File to be renamed does not exist" ).build();
View Full Code Here

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

      }
      throw new MondrianCatalogServiceException( Messages.getInstance().getErrorString(
        "MondrianCatalogHelper.ERROR_0003_INSUFFICIENT_PERMISSION" ), Reason.ACCESS_DENIED ); //$NON-NLS-1$
    }

    IUnifiedRepository solutionRepository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile deletingFile = solutionRepository.getFile( RepositoryFile.SEPARATOR + "etc" //$NON-NLS-1$
      + RepositoryFile.SEPARATOR + "mondrian" + RepositoryFile.SEPARATOR + catalog.getName() ); //$NON-NLS-1$
    solutionRepository.deleteFile( deletingFile.getId(), true, "" ); //$NON-NLS-1$
    reInit( pentahoSession );
  }
View Full Code Here

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

    outputStream.addListener( this );
    return outputStream;
  }

  public void fileCreated( String filePath ) {
    IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile outputFile = repository.getFile( filePath );
    if ( outputFile != null ) {
      Map<String, Serializable> fileMetadata = repository.getFileMetadata( outputFile.getId() );
      RepositoryFile inputFile = repository.getFile( inputFilePath );
      if ( inputFile != null ) {
        fileMetadata.put( PentahoJcrConstants.PHO_CONTENTCREATOR, inputFile.getId() );
        repository.setFileMetadata( outputFile.getId(), fileMetadata );
      }
    }
  }
View Full Code Here

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

  public void setInputFilePath( String filePath ) {
    this.inputFilePath = filePath;
  }

  public InputStream getInputStream() throws Exception {
    IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile repositoryFile = repository.getFile( inputFilePath );
    if ( ( repositoryFile == null ) || repositoryFile.isFolder() ) {
      throw new FileNotFoundException();
    }
    return new RepositoryFileInputStream( repositoryFile );
  }
View Full Code Here

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

      path = URLDecoder
        .decode( pathParams.getStringParameter( "path", "" ), "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    if ( path != null && path.length() > 0 ) {
      IUnifiedRepository unifiedRepository = PentahoSystem.get( IUnifiedRepository.class, null );
      RepositoryFile file = unifiedRepository.getFile( path );
      HttpServletRequest httpRequest = (HttpServletRequest) pathParams.getParameter( "httprequest" ); //$NON-NLS-1$
      HttpServletResponse httpResponse = (HttpServletResponse) pathParams.getParameter( "httpresponse" ); //$NON-NLS-1$
      String buffer =
        XactionUtil.executeScheduleUi( file, httpRequest, httpResponse, PentahoSessionHolder.getSession(),
          outputHandler.getMimeTypeListener() );
View Full Code Here

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

      != null ) ) { //$NON-NLS-1$
      contentType = pathParams.getStringParameter( "contentType", TEXT_HTML ); //$NON-NLS-1$
    }

    if ( path != null && path.length() > 0 ) {
      IUnifiedRepository unifiedRepository = PentahoSystem.get( IUnifiedRepository.class, null );
      RepositoryFile file = unifiedRepository.getFile( path );

      HttpServletRequest httpRequest = (HttpServletRequest) pathParams.getParameter( "httprequest" ); //$NON-NLS-1$

      HttpServletResponse httpResponse = (HttpServletResponse) pathParams.getParameter( "httpresponse" ); //$NON-NLS-1$
View Full Code Here

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

      path = URLDecoder
        .decode( pathParams.getStringParameter( "path", "" ), "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    if ( path != null && path.length() > 0 ) {
      IUnifiedRepository unifiedRepository = PentahoSystem.get( IUnifiedRepository.class, null );
      RepositoryFile file = unifiedRepository.getFile( path );
      String buffer = XactionUtil.doParameter( file, requestParams, PentahoSessionHolder.getSession() );
      outputStream.write( buffer.toString().getBytes( LocaleHelper.getSystemEncoding() ) );
    }
  }
View Full Code Here

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

  }

  @Test
  public void testCreateDatasource() throws Exception {
    final String parentFolderId = "123";
    IUnifiedRepository repo = mock( IUnifiedRepository.class );
    // stub out get parent folder
    doReturn( new RepositoryFile.Builder( parentFolderId, "databases" ).folder( true ).build() ).when( repo ).getFile(
        "/etc/pdi/databases" );
    doReturn( reservedChars ).when( repo ).getReservedChars();
View Full Code Here

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

  @Test
  public void testDeleteDatasourceWithName() 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
View Full Code Here

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

  @Test
  public void testUpdateDatasourceWithName() 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 update
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.