Package org.pentaho.platform.api.util

Examples of org.pentaho.platform.api.util.ITempFileDeleter


    IPentahoSession userSession = (IPentahoSession) session.getAttribute( PentahoSystem.PENTAHO_SESSION_KEY );
    if ( userSession != null ) {
      return userSession;
    }
    userSession = new PentahoHttpSession( userName, session, request.getLocale(), userSession );
    ITempFileDeleter deleter = PentahoSystem.get( ITempFileDeleter.class, userSession );
    if ( deleter != null ) {
      userSession.setAttribute( ITempFileDeleter.DELETER_SESSION_VARIABLE, deleter );
    }
    return userSession;
View Full Code Here


  protected boolean handleUnzip( File file ) throws IOException {
    String fileNames = file.getName();

    // .zip/.tar/.gz/.tgz files are always considered temporary and deleted on session expire

    ITempFileDeleter fileDeleter = null;
    if ( ( session != null ) ) {
      fileDeleter = (ITempFileDeleter) session.getAttribute( ITempFileDeleter.DELETER_SESSION_VARIABLE );
      if ( fileDeleter != null ) {
        fileDeleter.trackTempFile( file ); // make sure the deleter knows to clean this puppy up...
      }
    }

    if ( ( getUploadedFileItem().getName().toLowerCase().endsWith( ".zip" ) || getUploadedFileItem().getContentType()
        .equals( "application/zip" ) ) ) { //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

    // first extract the gz
    String filename = handleGZip( file, true );

    File tarFile = new File( filename );

    ITempFileDeleter fileDeleter;
    if ( ( session != null ) ) {
      fileDeleter = (ITempFileDeleter) session.getAttribute( ITempFileDeleter.DELETER_SESSION_VARIABLE );
      if ( fileDeleter != null ) {
        fileDeleter.trackTempFile( tarFile ); // make sure the deleter knows to clean this puppy up...
      }
    }

    return handleTar( tarFile );
  }
View Full Code Here

      pentahoSession = new NoDestroyStandaloneSession( null );
    }
    if ( callSetAuthenticatedForAnonymousUsers ) {
      pentahoSession.setAuthenticated( getAnonymousUser() );
    }
    ITempFileDeleter deleter = PentahoSystem.get( ITempFileDeleter.class, pentahoSession );
    if ( deleter != null ) {
      pentahoSession.setAttribute( ITempFileDeleter.DELETER_SESSION_VARIABLE, deleter );
    }
    return pentahoSession;
  }
View Full Code Here

    return createTempFile( session, prefix, extn, new File( getSolutionPath( "system/tmp" ) ), trackFile ); //$NON-NLS-1$
  }

  public File createTempFile( final IPentahoSession session, final String prefix, final String extn,
      final File parentDir, boolean trackFile ) throws IOException {
    ITempFileDeleter fileDeleter = null;
    if ( session == null ) {
      return null;
    }
    if ( trackFile ) {
      fileDeleter = (ITempFileDeleter) session.getAttribute( ITempFileDeleter.DELETER_SESSION_VARIABLE );
    }
    String name = session.getName();
    final String newPrefix =
        new StringBuilder().append( prefix ).append( name.substring( 0, name.length() > 10 ? 10 : name.length() ) )
            .append( '-' ).toString();
    if ( parentDir != null ) {
      parentDir.mkdirs();
    }
    final File file = File.createTempFile( newPrefix, extn, parentDir );
    if ( fileDeleter != null ) {
      fileDeleter.trackTempFile( file );
    } else {
      // There is no deleter, so cleanup on VM exit. (old behavior)
      file.deleteOnExit();
    }
    return file;
View Full Code Here

    return createTempFile( session, prefix, extn, new File( getSolutionPath( "system/tmp" ) ), trackFile ); //$NON-NLS-1$
  }

  public File createTempFile( final IPentahoSession session, final String prefix, final String extn,
      final File parentDir, boolean trackFile ) throws IOException {
    ITempFileDeleter fileDeleter = null;
    if ( ( session != null ) && trackFile ) {
      fileDeleter = (ITempFileDeleter) session.getAttribute( ITempFileDeleter.DELETER_SESSION_VARIABLE );
    }
    final String newPrefix =
        new StringBuilder().append( prefix ).append( session.getId().substring( 0, 10 ) ).append( '-' ).toString();
    final File file = File.createTempFile( newPrefix, extn, parentDir );
    if ( fileDeleter != null ) {
      fileDeleter.trackTempFile( file );
    } else {
      // There is no deleter, so cleanup on VM exit. (old behavior)
      file.deleteOnExit();
    }
    return file;
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.util.ITempFileDeleter

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.