Package pt.webdetails.cpf.repository.api

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


public class SaikuPluginLifecycleListener implements IPluginLifecycleListener {

  private static final Logger log = LoggerFactory.getLogger(SaikuPluginLifecycleListener.class);

  public void init() throws PluginLifecycleException {
    IContentAccessFactory contentAccessFactory = PentahoPluginEnvironment.getInstance().getContentAccessFactory();
    String mondrianPropsFilename = "mondrian.properties"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    final ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
    final ClassLoader altLoader = this.getClass().getClassLoader();


      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);
         
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;
        }
      }
View Full Code Here

    if ( installedPlugins == null ) {
      logger.error( "PluginCatalogEngine found zero installed plugins" );
      return;
    }

    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

    if( path.isEmpty() ) {
      return false;
    }
   
    ICdeEnvironment env = getCdeEnvironment();
    IContentAccessFactory factory = getContentAccessFactory( env );

    path = StringUtils.strip( path.toLowerCase(), "/" );

    if ( path.startsWith( getSystemDir( env ) ) ) {
      return true;
View Full Code Here

  public static IReadAccess getSystemReadAccess( String pluginId, String basePath ) {
    return getSystemReadAccess( pluginId, basePath, getCdeEnvironment() );
  }

  public static IReadAccess getSystemReadAccess( String pluginId, String basePath, ICdeEnvironment environment ) {
    IContentAccessFactory factory = environment.getContentAccessFactory();
    if ( StringUtils.isEmpty( pluginId ) ) {
      return factory.getPluginSystemReader( basePath );
    } else {
      return factory.getOtherPluginSystemReader( pluginId, basePath );
    }
  }
View Full Code Here

  public static IRWAccess getSystemRWAccess( String pluginId, String basePath ) {
    return getSystemRWAccess( pluginId, basePath, getCdeEnvironment() );
  }

  public static IRWAccess getSystemRWAccess( String pluginId, String basePath, ICdeEnvironment environment ) {
    IContentAccessFactory factory = environment.getContentAccessFactory();
    if ( StringUtils.isEmpty( pluginId ) ) {
      return factory.getPluginSystemWriter( basePath );
    } else {
      return factory.getOtherPluginSystemWriter( pluginId, basePath );
    }
  }
View Full Code Here

    if ( StringUtils.isEmpty( resource ) ) {
      return null;
    }

    IContentAccessFactory factory = environment.getContentAccessFactory();

    String systemDir = environment.getSystemDir() + "/";
    String repoDir = environment.getPluginRepositoryDir() + "/";

    resource = StringUtils.strip( resource, "/" );

    if ( resource.regionMatches( true, 0, systemDir, 0, systemDir.length() ) ) {

      resource = resource.replaceFirst( systemDir, "" );

      String pluginId = environment.getPluginId() + "/";
      // system dir - this plugin
      if ( resource.regionMatches( true, 0, pluginId, 0, pluginId.length() ) ) {
        return factory.getPluginSystemWriter( basePath );

      } else {
        // system dir - other plugin
        pluginId = resource.substring( 0, resource.indexOf( "/" ) );
        return factory.getOtherPluginSystemWriter( pluginId, basePath );

      }

    } else if ( resource.regionMatches( true, 0, repoDir, 0, repoDir.length() ) ) {

      // plugin repository dir
      return factory.getPluginRepositoryWriter( basePath );

    } else {

      // one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
      // or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')

      if ( factory.getPluginSystemReader( basePath ).fileExists( resource ) ) {
        return factory.getPluginSystemWriter( basePath );
      } else {
        // user solution dir
        return factory.getUserContentAccess( basePath );
      }
    }
  }
View Full Code Here

                                                            ICdeEnvironment environment ) {
    if ( StringUtils.isEmpty( resource ) ) {
      return null;
    }

    IContentAccessFactory factory = environment.getContentAccessFactory();

    String systemDir = environment.getSystemDir() + "/";
    String repoDir = environment.getPluginRepositoryDir() + "/";

    resource = StringUtils.strip( resource, "/" );

    if ( resource.regionMatches( true, 0, systemDir, 0, systemDir.length() ) ) {

      resource = resource.replaceFirst( systemDir, "" );

      String pluginId = environment.getPluginId() + "/";
      // system dir - this plugin
      if ( resource.regionMatches( true, 0, pluginId, 0, pluginId.length() ) ) {

        resource = resource.replaceFirst( pluginId, "" );

        return factory.getPluginSystemReader( basePath ).fetchFile( resource );

      } else {
        // system dir - other plugin
        pluginId = resource.substring( 0, resource.indexOf( "/" ) );
        resource = resource.replaceFirst( pluginId, "" );

        return factory.getOtherPluginSystemReader( pluginId, basePath ).fetchFile( resource );
      }

    } else if ( resource.regionMatches( true, 0, repoDir, 0, repoDir.length() ) ) {

      // plugin repository dir
      resource = resource.replaceFirst( repoDir, "" );
      return factory.getPluginRepositoryReader( basePath ).fetchFile( resource );

    } else {

      // one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
      // or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')

      if ( factory.getPluginSystemReader( basePath ).fileExists( resource ) ) {
        return factory.getPluginSystemReader( basePath ).fetchFile( resource );

      } else if ( factory.getUserContentAccess( basePath ).fileExists( resource ) ) {
        // user solution dir
        return factory.getUserContentAccess( basePath ).fetchFile( resource );
      }
    }
    return null;
  }
View Full Code Here

    if ( StringUtils.isEmpty( resource ) ) {
      return null;
    }

    IContentAccessFactory factory = environment.getContentAccessFactory();

    String systemDir = environment.getSystemDir() + "/";
    String repoDir = environment.getPluginRepositoryDir() + "/";

    resource = StringUtils.strip( resource, "/" );

    if ( resource.regionMatches( true, 0, systemDir, 0, systemDir.length() ) ) {

      resource = resource.replaceFirst( systemDir, "" );

      String pluginId = environment.getPluginId() + "/";
      // system dir - this plugin
      if ( resource.regionMatches( true, 0, pluginId, 0, pluginId.length() ) ) {
        return factory.getPluginSystemReader( basePath );

      } else {
        // system dir - other plugin
        pluginId = resource.substring( 0, resource.indexOf( "/" ) );
        return factory.getOtherPluginSystemReader( pluginId, basePath );

      }

    } else if ( resource.regionMatches( true, 0, repoDir, 0, repoDir.length() ) ) {

      // plugin repository dir
      return factory.getPluginRepositoryReader( basePath );

    } else {

      // one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
      // or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')

      if ( factory.getPluginSystemReader( basePath ).fileExists( resource ) ) {
        return factory.getPluginSystemReader( basePath );
      } else {
        // user solution dir
        return factory.getUserContentAccess( basePath );
      }
    }
  }
View Full Code Here

   * instantiation and basic init
   */
  private static DependenciesManager createInstance() {
    DependenciesManager manager = new DependenciesManager();
    IUrlProvider urlProvider = CdeEngine.getEnv().getUrlProvider();
    IContentAccessFactory factory = CdeEnvironment.getContentAccessFactory();
    manager.registerPackage( StdPackages.COMPONENT_STYLES, PackageType.CSS );
    manager.registerPackage( StdPackages.COMPONENT_DEF_SCRIPTS, PackageType.JS );
    manager.registerPackage(
      StdPackages.COMPONENT_SNIPPETS,
      new DependenciesPackage( StdPackages.COMPONENT_SNIPPETS, PackageType.JS, factory, urlProvider ) ); // TODO change
View Full Code Here

TOP

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

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.