Package pt.webdetails.cpf.repository.api

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


        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


      if( !access.fileExists(file) && access.hasAccess(file, FileAccess.READ)) {
        log.error("Access to Repository has failed File does not exist: " + file);
        throw new NullPointerException("Access to Repository has failed");
      }
      IBasicFile bf = access.fetchFile(file);

      String doc = IOUtils.toString(bf.getContents());
      if (doc == null) {
        throw new SaikuServiceException("Error retrieving saiku document from solution repository: " + file);
      }
      return Response.ok(doc.getBytes("UTF-8"), MediaType.TEXT_PLAIN).header(
          "content-length",doc.getBytes("UTF-8").length).build();
View Full Code Here

    };
    List<IBasicFile> files = new ArrayList<IBasicFile>();
    IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);
        path = path.replace(":", "/");
    if (access.fileExists(path)) {
      IBasicFile bf = access.fetchFile(path);
      if (!bf.isDirectory()) {
        files.add(bf);
        log.debug("Found file in " + path);
      } else {
        files = root.listFiles(path, txtFilter, 0, true, hidden);
        log.debug("Found files in " + path + " : " + files.size());
View Full Code Here

    try {     
      Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

      // Get comments hbm file
      IBasicFile commentsHbmFile =
          CdfEngine.getEnvironment().getHibernateConfigurations().getCommentsConfigurationFile();

      if ( commentsHbmFile == null || commentsHbmFile.getContents() == null ) {
        logger.error( "Unable to find comments hbm file" );
        throw new PluginHibernateException( "Unable to find comments hbm file", null );
      }

      // Close session and rebuild
      PluginHibernateUtil.closeSession();
      PluginHibernateUtil.getConfiguration().addInputStream( commentsHbmFile.getContents() );
      PluginHibernateUtil.rebuildSessionFactory();

    } catch ( Exception e ) {
      logger.error( "Unable to initialize comments engine", e );
      throw new PluginHibernateException( "Unable to initialize comments engine", e );
View Full Code Here

  private void initialize() throws PluginHibernateException {

    try {

      // Get storage hbm file
      IBasicFile storageHbmFile = CdfEngine.getEnvironment().getHibernateConfigurations().getStorageConfigurationFile();

      if ( storageHbmFile == null || storageHbmFile.getContents() == null ) {
        logger.error( "Unable to find storage hbm file" );
        throw new PluginHibernateException( "Unable to find storage hbm file", null );
      }

      // Close session and rebuild
      PluginHibernateUtil.closeSession();
      PluginHibernateUtil.getConfiguration().addInputStream( storageHbmFile.getContents() );
      PluginHibernateUtil.rebuildSessionFactory();

    } catch ( Exception e ) {
      logger.error( "Unable to initialize storage engine", e );
      throw new PluginHibernateException( "Unable to initialize storage engine", e );
View Full Code Here

  public void execute( final OutputStream out, final String solution, final String path, String templateName,
                       String style, String dashboardsMessagesBaseFilename, HashMap<String, String> parameterMap,
                       String user, int inactiveInterval )
    throws Exception {

    IBasicFile dashboardTemplateFile = HtmlDashboardRenderer.getDashboardTemplate( solution, path, templateName );

    execute( out, dashboardTemplateFile, style, dashboardsMessagesBaseFilename, parameterMap, user, inactiveInterval );
  }
View Full Code Here

  public void execute( final OutputStream out, final String templatePath, String style,
                       String dashboardsMessagesBaseFilename, HashMap<String, String> parameterMap, String user,
                       int inactiveInterval ) throws Exception {

    IBasicFile dashboardTemplateFile = HtmlDashboardRenderer.getDashboardTemplate( templatePath );

    execute( out, dashboardTemplateFile, style, dashboardsMessagesBaseFilename, parameterMap, user, inactiveInterval );
  }
View Full Code Here

    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 );
    }

    String templateContent;
    if ( templateResourceFile != null ) { //if a file was obtained correctly
      templateContent = Util.toString( templateResourceFile.getContents() );
    } else { //if not get a default one
      logger.error( "Template " + dashboardTemplate + "not available on cdf/templates, loading fallback instead" );
      templateContent = Util.toString( systemAccess.fetchFile( "template-dashboard.html" ).getContents() );
    }
View Full Code Here

    String localeSuffix = "_" + CdfEngine.getEnvironment().getLocale().getLanguage();

    targetDashboardBaseMsgFile = !targetDashboardBaseMsgFile.endsWith( localeSuffix ) ?
      targetDashboardBaseMsgFile + localeSuffix : targetDashboardBaseMsgFile;
    IBasicFile fBaseMsgGlobal = getSystemReader().fetchFile(
      globalBaseMessageFile + "_" + CdfEngine.getEnvironment().getLocale().getLanguage() + ".properties" );

    String theLine;
    if ( !getSystemReader().fileExists( targetDashboardBaseMsgFile + ".properties" ) ) {

      File tempMessageFile = null;
      String locale = CdfEngine.getEnvironment().getLocale().getLanguage();

      try {

        // we append the content of global and base message files here,
        // then we write the end result to targetDashboardBaseMsgFile
        String tempMessageFileName = System.getProperty( "java.io.tmpdir" ) + "tempMessageFile_" + System.currentTimeMillis();
        tempMessageFile = new File( tempMessageFileName );
        BufferedWriter bwTempBaseMsgTarget = new BufferedWriter( new FileWriter( tempMessageFile, true ) );

        // If localized global message file doesn't exists then use the standard base global message file
        // and generate a fake global message file. So this way we're sure that we always have the file
        String globalBaseMessageFileName = globalBaseMessageFile + "_" + locale + ".properties";

        if ( !getSystemReader().fileExists( globalBaseMessageFileName ) ) {

          InputStream content = new ByteArrayInputStream( StringUtils.EMPTY.getBytes() );

          if( getSystemReader().fileExists( globalBaseMessageFile + ".properties" ) ){
            content = getSystemReader().fetchFile( globalBaseMessageFile + ".properties" ).getContents();
          }

          getSystemWriter().saveFile( globalBaseMessageFileName, content );
          fBaseMsgGlobal = getSystemReader().fetchFile( globalBaseMessageFileName );
        }

        BufferedReader brBaseMsgGlobal = new BufferedReader( new InputStreamReader( fBaseMsgGlobal.getContents() ) );
        while ( ( theLine = brBaseMsgGlobal.readLine() ) != null ) {
          bwTempBaseMsgTarget.write( theLine + "\n" );
        }
        brBaseMsgGlobal.close();

        // Append specific message file only if it exists otherwise just use the global message files
        if ( !StringUtils.isEmpty( sourceDashboardBaseMsgFile ) ) {

          IBasicFile msgFile = null;

          if ( getUserContentReader().fileExists( sourceDashboardBaseMsgFile + "_" + locale + ".properties" ) ) {

            // a local Messages_<locale>.properties exists
            msgFile = getUserContentReader().fetchFile( sourceDashboardBaseMsgFile + "_" + locale + ".properties" );

          } else if( getUserContentReader().fileExists( sourceDashboardBaseMsgFile + ".properties" ) ) {

            // a local Messages_<locale>.properties does not exist, but a local Messages.properties does
            msgFile = getUserContentReader().fetchFile( sourceDashboardBaseMsgFile + ".properties" );
          }

          if( msgFile != null && msgFile.getContents() != null ){
            BufferedReader brBaseMsgDashboard = new BufferedReader( new InputStreamReader( msgFile.getContents() ) );
            while ( ( theLine = brBaseMsgDashboard.readLine() ) != null ) {
              bwTempBaseMsgTarget.write( theLine + "\n" );
            }
            brBaseMsgDashboard.close();
          }
View Full Code Here

    // CdfConstants.BASE_GLOBAL_MESSAGE_SET_URL, create it blank
    if ( !getSystemReader().fileExists( standardGlobalMessageFilenamePath ) ) {
      getSystemWriter().saveFile( standardGlobalMessageFilenamePath, new ByteArrayInputStream( "".getBytes() ) );
    }

    IBasicFile fromFile = getSystemReader().fetchFile( standardGlobalMessageFilenamePath );
    String toFile = Util.joinPath( targetDashboardCacheDir, standardGlobalMessageFilename );

    if ( getSystemWriter().fileExists( toFile ) ) {
      return;
    }

    getSystemWriter().saveFile( toFile, fromFile.getContents() );
  }
View Full Code Here

TOP

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

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.