Package pt.webdetails.cpf.repository.api

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


  // External Editor v
  @Exposed( accessLevel = AccessLevel.PUBLIC )
  public void getFile( final OutputStream out ) throws IOException {

    String path = getRequestParameters().getStringParameter( MethodParams.PATH, "" );
    IUserContentAccess access = CdeEnvironment.getUserContentAccess();

    if ( access.fileExists( path ) ) {
      setResponseHeaders( "text/plain", NO_CACHE_DURATION, null );
      writeOut( out, IOUtils.toString( access.getFileInputStream( path ) ) );
    } else {
      writeOut( out, "No file found in given path " + path );
    }
  }
View Full Code Here


  @Exposed( accessLevel = AccessLevel.PUBLIC )
  public void createFolder( OutputStream out ) throws PentahoAccessControlException, IOException {

    String path = getRequestParameters().getStringParameter( MethodParams.PATH, null );
    IUserContentAccess access = CdeEnvironment.getUserContentAccess();

    if ( access.fileExists( path ) ) {
      writeOut( out, "already exists: " + path );
    } else {
      if ( access.createFolder( path ) ) {
        writeOut( out, path + "created ok" );
      } else {
        writeOut( out, "error creating folder " + path );
      }
    }
View Full Code Here

  @Exposed( accessLevel = AccessLevel.PUBLIC )
  public void deleteFile( OutputStream out ) throws PentahoAccessControlException, IOException {

    String path = getRequestParameters().getStringParameter( MethodParams.PATH, null );

    IUserContentAccess access = CdeEnvironment.getUserContentAccess();
    if ( access.hasAccess( path, FileAccess.DELETE ) && access.deleteFile( path ) ) {
      writeOut( out, "file  " + path + " removed ok" );
    } else {
      writeOut( out, "Error removing " + path );
    }
  }
View Full Code Here

    IParameterProvider requestParams = getRequestParameters();
    String path = requestParams.getStringParameter( MethodParams.PATH, null );
    String contents = requestParams.getStringParameter( MethodParams.DATA, null );
    boolean createNew = requestParams.hasParameter( "createNew" );

    IUserContentAccess access = CdeEnvironment.getUserContentAccess();

    if ( access.hasAccess( path, FileAccess.WRITE )
      || ( createNew && access.hasAccess( FilenameUtils.getFullPath( path ), FileAccess.WRITE ) ) ) {

      if ( access.saveFile( path, new ByteArrayInputStream( contents.getBytes( ENCODING ) ) ) ) {
        // saved ok
        writeOut( out, "file '" + path + "' saved ok" );
      } else {
        // error
        logger.error( "writeFile: failed saving " + path );
View Full Code Here

  protected void appendMessageFiles( IBasicFile sourceDashboardBaseMsgFile, IBasicFile globalBaseMessageFile,
      IBasicFile targetDashboardBaseMsgFile ) throws IOException {

    Locale locale = CdeEngine.getEnv().getLocale();

    IUserContentAccess userContentAccess =
        CdeEngine.getEnv().getContentAccessFactory().getUserContentAccess( msgsRelativeDir );
    IRWAccess systemWriter =
        CdeEngine.getEnv().getContentAccessFactory().getPluginSystemWriter(
            Utils.joinPath( BASE_CACHE_DIR, msgsRelativeDir ) );

    // 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 localizedMsgGlobalName = BASE_GLOBAL_MESSAGE_SET_FILENAME + "_" + locale.getLanguage() + ".properties";

    if ( userContentAccess.fileExists( localizedMsgGlobalName ) ) {

      systemWriter.saveFile( localizedMsgGlobalName, userContentAccess.getFileInputStream( localizedMsgGlobalName ) );

    } else if ( globalBaseMessageFile != null ) {

      systemWriter.saveFile( localizedMsgGlobalName, globalBaseMessageFile.getContents() );
    }

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

      systemWriter.saveFile( sourceDashboardBaseMsgFile.getName(), sourceDashboardBaseMsgFile.getContents() );

      String localizedMsgTargetName =
          FilenameUtils.getBaseName( sourceDashboardBaseMsgFile.getName() ) + "_" + locale.getLanguage()
              + ".properties";

      if ( userContentAccess.fileExists( localizedMsgTargetName ) ) {

        systemWriter.saveFile( localizedMsgTargetName, userContentAccess.getFileInputStream( localizedMsgTargetName ) );
      }
    }
  }
View Full Code Here

TOP

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

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.