Package pt.webdetails.cpf.repository.api

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


  }

  public void save( String file, String structure ) throws DashboardStructureException,
    IOException {
    logger.info( "Saving File:" + file );
    IRWAccess access = CdeEnvironment.getPluginRepositoryWriter();

    if ( !access.fileExists( REPOSITORY_CDF_DD_TEMPLATES_CUSTOM ) ) {
      access.createFolder( REPOSITORY_CDF_DD_TEMPLATES_CUSTOM );
    }

    structure = addDashboardStyleAndRendererTypeToTemplate( structure );

    byte[] fileData = structure.getBytes( CharsetHelper.getEncoding() );
    if ( !access.saveFile( Utils.joinPath( REPOSITORY_CDF_DD_TEMPLATES_CUSTOM, file ), new ByteArrayInputStream(
        fileData ) ) ) {
      throw new DashboardStructureException( Messages
          .getString( "DashboardStructure.ERROR_006_SAVE_FILE_ADD_FAIL_EXCEPTION" ) );
    }
  }
View Full Code Here


  /* Utils.getSystemRWAccess Tests */

  @Test
  public void testGetSystemRWAccessSystemPlugin() throws Exception {
    IRWAccess result = Utils.getSystemRWAccess( "", null, environment );
    verify( factory, atLeastOnce() ).getPluginSystemWriter( null );
    assertEquals( systemWriteAccess, result );
  }
View Full Code Here

    assertEquals( systemWriteAccess, result );
  }

  @Test
  public void testGetSystemRWAccessOtherPluginPath() throws Exception {
    IRWAccess result = Utils.getSystemRWAccess( OTHER_PLUGIN_ID, null, environment );
    verify( factory, atLeastOnce() ).getOtherPluginSystemWriter( OTHER_PLUGIN_ID, null );
    assertEquals( systemWriteAccess, result );
  }
View Full Code Here

  /* Utils.getAppropriateWriteAccess Tests */

  @Test
  public void testGetAppropriateWriteAccessEmptyPath() throws Exception {
    doReturn( true ).when( systemReadAccess ).fileExists( any( String.class ) );
    IRWAccess result = Utils.getAppropriateWriteAccess( "", null, environment );
    assertEquals( null, result );
  }
View Full Code Here

  }

  @Test
  public void testGetAppropriateWriteAccessStaticPath() throws Exception {
    doReturn( true ).when( systemReadAccess ).fileExists( any( String.class ) );
    IRWAccess result = Utils.getAppropriateWriteAccess( STATIC_PATH, null, environment );
    verify( factory, atLeastOnce() ).getPluginSystemWriter( null );
    assertEquals( systemWriteAccess, result );
  }
View Full Code Here

    assertEquals( systemWriteAccess, result );
  }

  @Test
  public void testGetAppropriateWriteAccessSystemPluginPath() throws Exception {
    IRWAccess result = Utils.getAppropriateWriteAccess( SYSTEM_PLUGIN_PATH, null, environment );
    verify( factory, atLeastOnce() ).getPluginSystemWriter( null );
    assertEquals( systemWriteAccess, result );
  }
View Full Code Here

    assertEquals( systemWriteAccess, result );
  }

  @Test
  public void testGetAppropriateWriteAccessSystemOtherPluginPath() throws Exception {
    IRWAccess result = Utils.getAppropriateWriteAccess( SYSTEM_OTHER_PLUGIN_PATH, null, environment );
    verify( factory, atLeastOnce() ).getOtherPluginSystemWriter( "otherPlugin", null );
    assertEquals( systemWriteAccess, result );
  }
View Full Code Here

    assertEquals( systemWriteAccess, result );
  }

  @Test
  public void testGetAppropriateWriteAccessReposPath() throws Exception {
    IRWAccess result = Utils.getAppropriateWriteAccess( REPOS_PATH, null, environment );
    verify( factory, atLeastOnce() ).getUserContentAccess( null );
    assertEquals( userContentAccess, result );
  }
View Full Code Here

      }
    };
  }

  public IRWAccess getWriter() {
    return new IRWAccess() {
      @Override public boolean saveFile( String s, InputStream inputStream ) {
        return savedFile;
      }

      @Override public boolean copyFile( String s, String s2 ) {
View Full Code Here

    }
    return readAccess;
  }

  public static IRWAccess getSystemOrUserRWAccess( String filePath ) {
    IRWAccess rwAccess = null;
    if ( filePath.startsWith( "/" + CdeEnvironment.getSystemDir() + "/" ) && ( filePath.endsWith( ".wcdf" ) || filePath
      .endsWith( ".cdfde" ) ) ) {
      rwAccess = getSystemRWAccess( filePath.split( "/" )[ 2 ], null );
    } else if ( CdeEnvironment.getUserContentAccess().fileExists( filePath ) ) {
View Full Code Here

TOP

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

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.