Package pt.webdetails.cpf.repository.api

Examples of pt.webdetails.cpf.repository.api.IReadAccess


      try {
      if (altLoader != origLoader) {
        Thread.currentThread().setContextClassLoader(altLoader);
      }
       
        IReadAccess mf = contentAccessFactory.getPluginSystemReader("../mondrian");
        if (mf.fileExists(mondrianPropsFilename)) {
          IBasicFile bf = mf.fetchFile(mondrianPropsFilename);
            MondrianProperties.instance().load(bf.getContents());
            log.debug("Loaded mondrian properties file: " + mondrianPropsFilename);
         
        } else {
          log.debug("Cannot find mondrian properties file: "+  mondrianPropsFilename);
View Full Code Here


  public void getContent( final String fileName, final OutputStream out ) throws Exception {

    // write out the scripts
    // TODO support caching
    IReadAccess access = CdfEngine.getPluginSystemReader( null );

    if ( access.fileExists( fileName ) ) {
      IOUtils.copy( access.getFileInputStream( fileName ), out );
    }
  }
View Full Code Here

      // We can't provide this type of file
      throw new SecurityException( "Not allowed" );
    }

    IUserContentAccess contentAccess = CdfEngine.getUserContentReader( null );
    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );

    if ( contentAccess.fileExists( resourcePath ) && contentAccess.hasAccess( resourcePath, FileAccess.EXECUTE ) ) {
      PluginIOUtils.writeOutAndFlush( out, contentAccess.getFileInputStream( resourcePath ) );
    } else if ( systemAccess.fileExists( resourcePath ) ) {
      PluginIOUtils.writeOutAndFlush( out, systemAccess.getFileInputStream( resourcePath ) );
    } else {
      logger.info( " resource not found: " + resourcePath );
    }
  }
View Full Code Here

   *          servlet response
   */
  protected void processRequest( HttpServletRequest request, HttpServletResponse response ) throws ServletException,
    IOException {

    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );
    String resource = request.getParameter( Parameter.RESOURCE ); //$NON-NLS-1$

    if ( StringUtils.isEmpty( resource ) ) {
      error( Messages.getErrorString( "GetResource.ERROR_0001_RESOURCE_PARAMETER_MISSING" ) ); //$NON-NLS-1$
      response.setStatus( HttpServletResponse.SC_SERVICE_UNAVAILABLE );
      return;
    }

    if ( !systemAccess.fileExists( resource ) ) {
      error( Messages.getErrorString( "GetResource.ERROR_0003_RESOURCE_MISSING", resource ) ); //$NON-NLS-1$
      response.setStatus( HttpServletResponse.SC_SERVICE_UNAVAILABLE );
      return;
    }

    InputStream in = systemAccess.getFileInputStream( resource );
    String mimeType = MimeTypes.getMimeType( resource );

    if ( StringUtils.isEmpty( mimeType ) ) {
      // Hard coded to PNG because BIRT does not give us a mime type at all...
      response.setContentType( MimeTypes.PNG );
View Full Code Here

      logger.warn( "Couldn't find CDA. Skipping auto-includes" );
      return queries;
    }

    /* Bail out if cdf/includes folder does not exists */
    IReadAccess autoIncludesFolder = CdfEngine.getUserContentReader( null );
    if ( !autoIncludesFolder.fileExists(
      CdfEngine.getEnvironment().getCdfPluginRepositoryDir() + CdfConstants.INCLUDES_DIR ) ) {
      return queries;
    }

    List<AutoInclude> autoIncludes = getAutoIncludes( config );
View Full Code Here

  }

  private List<AutoInclude> getAutoIncludes( Document config ) {
    synchronized( autoIncludesLock ) {
      if ( autoIncludes == null ) {
        IReadAccess cdaRoot =
          CdfEngine.getUserContentReader( CdfEngine.getEnvironment().getCdfPluginRepositoryDir()
            + CdfConstants.INCLUDES_DIR );
        autoIncludes = AutoInclude.buildAutoIncludeList( config, cdaRoot );
      }
      return autoIncludes;
View Full Code Here

  private Document getConfigFile() {

    try {
      IContentAccessFactory factory = CdfEngine.getEnvironment().getContentAccessFactory();
      IReadAccess access = factory.getPluginRepositoryReader( null );

      if ( !access.fileExists( CONFIG_FILE ) ) {
        access = factory.getPluginSystemReader( null );
        if ( !access.fileExists( CONFIG_FILE ) ) {
          logger.error( CONFIG_FILE + " not found!" );
          return null;
        }
      }
      if ( logger.isDebugEnabled() ) {
        logger.debug( String.format( "Reading %s from %s", CONFIG_FILE, access ) );
      }
      return XmlDom4JUtils.getDocumentFromStream( access.getFileInputStream( CONFIG_FILE ) );

    } catch ( Exception e ) {
      logger.error( "Couldn't read context configuration file.", e );
      return null;
    }
View Full Code Here

      IUrlProvider urlProvider,
      PathOrigin origin,
      String[] files)
  {
    super( name, type, factory, urlProvider );
    IReadAccess reader = origin.getReader( factory );
    for ( String filePath : files ) {
      String version = Long.toString( reader.getLastModified( filePath ) );
      registerFileDependency( filePath, version, origin, filePath );
    }
    registryClosed = true;
  }
View Full Code Here

                       int inactiveInterval ) throws Exception {

    String intro = ""; //$NON-NLS-1$
    String footer = ""; //$NON-NLS-1$

    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );
    style = StringUtils.isEmpty( style ) ? "" : "-" + style;

    final String dashboardTemplate = "template-dashboard" + style + ".html"; //$NON-NLS-1$

    ArrayList<String> i18nTagsList = new ArrayList<String>();

    IBasicFile templateResourceFile = null;
    IReadAccess pluginRepoAccess = CdfEngine.getPluginRepositoryReader( "templates/" );

    if ( pluginRepoAccess.fileExists( dashboardTemplate ) ) {
      templateResourceFile = pluginRepoAccess.fetchFile( dashboardTemplate );

    } else if ( systemAccess.fileExists( dashboardTemplate ) ) {
      // then try in system
      templateResourceFile = systemAccess.fetchFile( dashboardTemplate );
    }
View Full Code Here

      if ( allowedFormats.indexOf( extension ) < 0 ) {
        // We can't provide this type of file
        throw new SecurityException( "Not allowed" );
      }

      IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );

      if ( !systemAccess.fileExists( path ) ) {
        logger.warn( "resource does not exist: " + path );
        return;
      }

      PluginIOUtils.writeOutAndFlush( response.getOutputStream(), systemAccess.getFileInputStream( path ) );
      response.getOutputStream().flush();

    } catch ( Exception e ) {
      logger.error( e );
      response.sendError( HttpServletResponse.SC_FORBIDDEN );
View Full Code Here

TOP

Related Classes of pt.webdetails.cpf.repository.api.IReadAccess

Copyright © 2015 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.