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

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


      }
      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


    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

  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

      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

      != 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

      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

    if ( !runInBackground && !getPolicy().isAllowed( SchedulerAction.NAME ) ) {
      throw new SecurityException();
    }

    boolean hasInputFile = !StringUtils.isEmpty( scheduleRequest.getInputFile() );
    RepositoryFile file = null;
    if ( hasInputFile ) {
      try {
        file = getRepository().getFile( scheduleRequest.getInputFile() );
      } catch ( UnifiedRepositoryException ure ) {
        hasInputFile = false;
        logger.warn( ure.getMessage(), ure );
      }
    }

    // if we have an inputfile, generate job name based on that if the name is not passed in
    if ( hasInputFile && StringUtils.isEmpty( scheduleRequest.getJobName() ) ) {
      scheduleRequest.setJobName( file.getName().substring( 0, file.getName().lastIndexOf( "." ) ) ); //$NON-NLS-1$
    } else if ( !StringUtils.isEmpty( scheduleRequest.getActionClass() ) ) {
      String actionClass =
          scheduleRequest.getActionClass().substring( scheduleRequest.getActionClass().lastIndexOf( "." ) + 1 );
      scheduleRequest.setJobName( actionClass ); //$NON-NLS-1$
    } else if ( !hasInputFile && StringUtils.isEmpty( scheduleRequest.getJobName() ) ) {
      // just make up a name
      scheduleRequest.setJobName( "" + System.currentTimeMillis() ); //$NON-NLS-1$
    }

    if ( hasInputFile ) {
      Map<String, Serializable> metadata = getRepository().getFileMetadata( file.getId() );
      if ( metadata.containsKey( "_PERM_SCHEDULABLE" ) ) {
        boolean schedulable = Boolean.parseBoolean( (String) metadata.get( "_PERM_SCHEDULABLE" ) );
        if ( !schedulable ) {
          throw new IllegalAccessException();
        }
View Full Code Here

    if ( contextId.startsWith( ":" ) || contextId.matches( "^[A-z]\t:.*" ) ) { //$NON-NLS-1$
      //
      // The context is a repository file (A)
      //

      final RepositoryFile file = repository.getFile( FileResource.idToPath( contextId ) );
      if ( file == null ) {
        logger.error( MessageFormat.format( "Repository file [{0}] not found", contextId ) );
        return Response.serverError().build();
      }

      Response response = null;

      ctxt( "Yep, [{0}] is a repository file id", contextId ); //$NON-NLS-1$
      final String ext = RepositoryFilenameUtils.getExtension( file.getName() );
      String pluginId = pluginManager.getPluginIdForType( ext );
      if ( pluginId == null ) {

        // A.3.a (faux content generator for .url files)
        response = getUrlResponse( file, resourceId );
        if ( response != null ) {
          return response;
        } else {
          logger.error( MessageFormat.format( "No plugin was found to service content of type [{0}]", ext ) );
          return Response.serverError().build();
        }
      }

      // A.1.
      response = getPluginFileResponse( pluginId, resourceId );
      if ( response != null ) {
        return response;
      }

      // A.2.
      response = getRepositoryFileResponse( file.getPath(), resourceId );
      if ( response != null ) {
        return response;
      }

      // A.3.b (real content generator)
View Full Code Here

    if ( !isPathValid( path ) ) {
      throw new IllegalSelectorException();
    }

    // check if entity exists in repo
    RepositoryFile repositoryFile = getRepository().getFile( path );

    if ( repositoryFile == null ) {
      // file does not exist or is not readable but we can't tell at this point
      throw new FileNotFoundException( path );
    }

   // send zip with manifest by default
    boolean withManifest = "false".equals( strWithManifest ) ? false : true;
    boolean requiresZip = repositoryFile.isFolder() || withManifest;
    BaseExportProcessor exportProcessor = getDownloadExportProcessor( path, requiresZip, withManifest );
    originalFileName = requiresZip ? repositoryFile.getName() + ".zip" : repositoryFile.getName(); //$NON-NLS-1$//$NON-NLS-2$
    encodedFileName = URLEncoder.encode( originalFileName, "UTF-8" ).replaceAll( "\\+", "%20" );
    String quotedFileName = "\"" + originalFileName + "\"";

    // add export handlers for each expected file type
    exportProcessor.addExportHandler( getDownloadExportHandler() );
View Full Code Here

   * @throws FileNotFoundException
   */
  // have to accept anything for browsers to work
  public RepositoryFileToStreamWrapper doGetFileAsInline( String pathId ) throws FileNotFoundException {
    String path = null;
    RepositoryFile repositoryFile = null;
    // Check if the path is actually and ID
    path = idToPath( pathId );
    if ( isPath( path ) ) {
      if ( !isPathValid( path ) ) {
        throw new IllegalArgumentException();
      }
      repositoryFile = getRepository().getFile( path );
    } else {
      // Yes path provided is an ID
      repositoryFile = getRepository().getFileById( pathId );
    }

    if ( repositoryFile == null ) {
      // file does not exist or is not readable but we can't tell at this point
      throw new FileNotFoundException();
    }

    // check whitelist acceptance of file (based on extension)
    if ( !getWhitelist().accept( repositoryFile.getName() ) ) {
      // if whitelist check fails, we can still inline if you have PublishAction, otherwise we're FORBIDDEN
      if ( !getPolicy().isAllowed( PublishAction.NAME ) ) {
        throw new IllegalArgumentException();
      }
    }

    try {
      SimpleRepositoryFileData fileData =
          getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class );
      final InputStream is = fileData.getInputStream();

      // copy streaming output
      StreamingOutput streamingOutput = getStreamingOutput( is );

      RepositoryFileToStreamWrapper wrapper = new RepositoryFileToStreamWrapper();
      wrapper.setOutputStream( streamingOutput );
      wrapper.setRepositoryFile( repositoryFile );

      return wrapper;
    } catch ( Exception e ) {
      logger.error( Messages.getInstance().getString(
          "FileResource.EXPORT_FAILED", repositoryFile.getName() + " " + e.getMessage() ), e );
      throw new InternalError();
    }
  }
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.