Package pt.webdetails.cpf.repository.api

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


   *          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 = MimeTypeHandler.getMimeTypeFromFileName( 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


      // return from cache. Make sure we return a clone of the original object
      return cacheContainer.get( cacheKey );

    }

    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );
   
    // Read file
    final InputStream in = systemAccess.getFileInputStream( path );
    final StringBuilder resource = new StringBuilder();
    int c;
    while ( ( c = in.read() ) != -1 ) {
      resource.append( (char) c );
    }
View Full Code Here

    final IContentAccessFactory accessFactory = CdfEngine.getEnvironment().getContentAccessFactory();

    for ( final Plugin plugin : installedPlugins ) {

      try {
        IReadAccess pluginSystemAccess = accessFactory.getOtherPluginSystemReader( plugin.getId(), null );

        /*
         * Open the plugin.xml files in the plugin folder list to check for a run command for the associated file type
         */
        final Document xml = XmlDom4JUtils.getDocumentFromFile( pluginSystemAccess, PLUGIN_XML );
View Full Code Here

    Locale locale = CdfEngine.getEnvironment().getLocale();
    ResourceBundle bundle = Messages.locales.get( locale );
    if ( bundle == null ) {

      try {
        IReadAccess access = CdfEngine.getPluginSystemReader( null );

        if ( access.fileExists( CdfConstants.GLOBAL_MESSAGES_PROPERTIES_FILE ) ) {
          InputStream in = access.getFileInputStream( CdfConstants.GLOBAL_MESSAGES_PROPERTIES_FILE );
          bundle = new PropertyResourceBundle( in );
          Messages.locales.put( locale, bundle );
        }
      } catch ( Exception e ) {
        logger.error( "Could not get localization bundle", e ); //$NON-NLS-1$
View Full Code Here

  public static IBasicFile getDashboardTemplate( String templatePath ) {

    templatePath = FilenameUtils.separatorsToUnix( templatePath );

    IUserContentAccess repoAccess = CdfEngine.getUserContentReader( null );
    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );
    IBasicFile dashboardTemplateFile = null;

    if ( !StringUtils.isEmpty( templatePath ) && repoAccess.fileExists( templatePath ) ) {

      // Check for access permissions
      if ( repoAccess.hasAccess( templatePath, FileAccess.EXECUTE ) ) {
        dashboardTemplateFile = repoAccess.fetchFile( templatePath );
      } else {
        logger.error( "Access Denied to " + templatePath );
      }
    } else {
      dashboardTemplateFile = systemAccess.fetchFile( CdfConstants.DEFAULT_DASHBOARD_TEMPLATE_HTML );
    }

    return dashboardTemplateFile;
  }
View Full Code Here

  private Map<String, List<? extends DependenciesPackage>> dashboardIncludes =
      new HashMap<String, List<? extends DependenciesPackage>>();

  public CdfHeadersProvider() {
    IReadAccess reader = getContentAccess().getPluginSystemReader( BASE_DIR );
    // base includes
    baseProperties = new Properties();
    loadProperties( reader, BASE_DEPENDENCIES, baseProperties );
    // extra includes
    extraProperties = loadProperties( reader, CDF_DASHBOARD_DEPENDENCIES, new Properties() );
View Full Code Here

  private boolean isAcceptedDashboardType( String dashboardType ) {
    return acceptedDashboardTypes.contains( dashboardType );
  }

  private List<StaticDependenciesPackage> createDependenciesPackages( String dashboardType ) {
    IReadAccess reader = getContentAccess().getPluginSystemReader( BASE_DIR );
    String fileName = String.format( "resources.%s.properties", dashboardType );
    Properties dtProperties = new Properties( getBaseProperties() );
    if ( reader.fileExists( fileName ) ) {
      loadProperties( reader, fileName, dtProperties );
    }

    PathSet pathSet = new PathSet();
    addBaseDependencies( pathSet, dtProperties );
View Full Code Here

    if( paths != null ){

      for( String path : paths ){

        IReadAccess access = Utils.getAppropriateReadAccess( path );

        if( access != null && access.fileExists( path ) && access.fetchFile( path ).isDirectory() ){
          files.add( access.fetchFile( path ) );
        } else {
          logger.error( "Discarding path '" + path + "': file does not exist or isn't a directory." );
        }
      }
    }
View Full Code Here

          return file1.getFullPath().toLowerCase().compareTo( file2.getFullPath().toLowerCase() );
        }
      }
    } );

    IReadAccess access = CdeEnvironment.getPluginSystemReader( SYSTEM_CDF_DD_TEMPLATES );

    for ( int i = 0; i < jsonFiles.length; i++ ) {
      final JSONObject template = new JSONObject();

      String imgResourcePath = resoureUrl+"unknown.png";

      if ( access.fileExists( jsonFiles[i].getName().replace( ".cdfde", ".png" ) ) ) {
        imgResourcePath = resoureUrl+jsonFiles[i].getName().replace( ".cdfde", ".png" );
      }

      template.put( "img", imgResourcePath );
      template.put( "type", type );
View Full Code Here

      String pluginStylesDir = entity.getRegisteredEntity().valueOf( "path" );
      String finalPath = pluginStylesDir + "/";
      String pluginId = entity.getPlugin().getId();
      style = null;

      IReadAccess access = CdeEnvironment.getOtherPluginSystemReader( pluginId );

      //Clean final path if it starts with sytem/pluginId/
      //Allows specification for style paths to be in the form (assuming styles is the folder):
      // * system/<plugin>/styles
      // * /system/<plugin>/styles - no need to clear start info
      // * styles
      if (finalPath.startsWith("system/" + pluginId + "/"))
        finalPath = finalPath.substring(("system/" + pluginId + "/").length());

      if ( access.fileExists( finalPath ) && access.fetchFile( finalPath ).isDirectory() ) {
        style = new Style( access, finalPath, pluginId );
        styles.add( style );
      }
    }

View Full Code Here

TOP

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

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.