net.roboconf.core.utils.Utils.deleteFilesRecursively()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中net.roboconf.core.utils.Utils.deleteFilesRecursively()方法的一些代码示例,展示了Utils.deleteFilesRecursively()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.deleteFilesRecursively()方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:deleteFilesRecursively

Utils.deleteFilesRecursively介绍

[英]Deletes files recursively.
[中]递归删除文件。

代码示例

代码示例来源:origin: net.roboconf/roboconf-dm

@Override
public void deleteCommand( Application app, String commandName ) throws IOException {
  File cmdFile = findCommandFile( app, commandName );
  Utils.deleteFilesRecursively( cmdFile );
}

代码示例来源:origin: roboconf/roboconf-platform

Utils.deleteFilesRecursively( tmpDir );
Assert.assertFalse( "Temp directory could not be deleted: " + tmpDir.getName(), tmpDir.exists());
Utils.deleteFilesRecursively((File) null);
Utils.deleteFilesRecursively((File[]) null);
Utils.deleteFilesRecursively( nullFiles );
Utils.deleteFilesRecursively( new File( "inexisting-file" ));

代码示例来源:origin: roboconf/roboconf-platform

/**
 * Deletes files recursively and remains quiet even if an exception is thrown.
 * @param files the files to delete
 */
public static void deleteFilesRecursivelyAndQuietly( File... files ) {
  try {
    deleteFilesRecursively( files );
  } catch( IOException e ) {
    Logger logger = Logger.getLogger( Utils.class.getName());
    logException( logger, e );
  }
}

代码示例来源:origin: net.roboconf/roboconf-agent

/**
 * Deletes the resources for a given instance.
 * @param instance an instance
 * @throws IOException if resources could not be deleted
 */
public static void deleteInstanceResources( Instance instance )	throws IOException {
  File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance );
  Utils.deleteFilesRecursively( dir );
}

代码示例来源:origin: net.roboconf/roboconf-dm

@Override
public void deleteTarget( String targetId ) throws IOException, UnauthorizedActionException {
  // No machine using this target can be running.
  boolean used = false;
  synchronized( LOCK ) {
    used = isTargetUsed( targetId );
  }
  if( used )
    throw new UnauthorizedActionException( "Deletion is not permitted." );
  // Delete the files related to this target
  this.targetIds.remove( targetId );
  File targetDirectory = findTargetDirectory( targetId );
  Utils.deleteFilesRecursively( targetDirectory );
}

代码示例来源:origin: net.roboconf/roboconf-dm-scheduler

private void unscheduleJob( String jobId ) throws IOException {
  File f = getJobFile( jobId );
  try {
    if( f.exists()) {
      Properties props = Utils.readPropertiesFileQuietly( f, this.logger );
      String appName = props.getProperty( APP_NAME, "" );
      if( ! Utils.isEmptyOrWhitespaces( appName ))
        this.scheduler.unscheduleJob( TriggerKey.triggerKey( jobId, appName ));
    }
  } catch( SchedulerException e ) {
    // Catch all the exceptions (including the runtime ones)
    throw new IOException( e );
  } finally {
    Utils.deleteFilesRecursively( f );
  }
}

代码示例来源:origin: roboconf/roboconf-platform

/**
 * Compares an assumed ZIP file with a content described in a map.
 * @param zipFile
 * @param entryToContent
 * @throws ZipException
 * @throws IOException
 */
public static void compareZipContent( File zipFile, Map<String,String> entryToContent ) throws IOException {
  File tempDir = new File( System.getProperty( "java.io.tmpdir" ), UUID.randomUUID().toString());
  if( ! tempDir.mkdir())
    Assert.fail( "Failed to create a temporary directory." );
  try {
    Utils.extractZipArchive( zipFile, tempDir );
    compareUnzippedContent( tempDir, entryToContent );
  } finally {
    Utils.deleteFilesRecursively( tempDir );
  }
}

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testReadUrlContent() throws Exception {
  File f = this.folder.newFile();
  Utils.writeStringInto( "kikou", f );
  String readContent = Utils.readUrlContent( f.toURI().toURL().toString());
  Assert.assertEquals( "kikou", readContent );
  Utils.deleteFilesRecursively( f );
  Assert.assertFalse( f.exists());
  Logger logger = Logger.getLogger( getClass().getName());
  readContent = Utils.readUrlContentQuietly( f.toURI().toURL().toString(), logger );
  Assert.assertEquals( "", readContent );
}

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testInterceptWritingFiles_inexistingOutputDirectory_withFiles() throws Exception {
  File outputDirectory = this.folder.newFolder();
  Utils.deleteFilesRecursively( outputDirectory );
  Assert.assertFalse( outputDirectory.isDirectory());
  File file = this.folder.newFile();
  Properties props = new Properties();
  props.put( "loc", file.getAbsolutePath());
  props.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + "loc", "" );
  UserDataHelpers.interceptWritingFiles( props, outputDirectory );
  Assert.assertTrue( outputDirectory.isDirectory());
  Assert.assertTrue( file.isFile());
}

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testInterceptWritingFiles_inexistingOutputDirectory() throws Exception {
  File outputDirectory = this.folder.newFolder();
  Utils.deleteFilesRecursively( outputDirectory );
  Assert.assertFalse( outputDirectory.isDirectory());
  UserDataHelpers.interceptWritingFiles( new Properties(), outputDirectory );
  Assert.assertFalse( outputDirectory.isDirectory());
}

代码示例来源:origin: net.roboconf/roboconf-dm

@Override
public void deleteApplicationTemplate( String tplName, String tplVersion )
throws UnauthorizedActionException, InvalidApplicationException, IOException {
  ApplicationTemplate tpl = findTemplate( tplName, tplVersion );
  if( tpl == null )
    throw new InvalidApplicationException( new RoboconfError( ErrorCode.PROJ_APPLICATION_TEMPLATE_NOT_FOUND ));
  if( this.applicationMngr.isTemplateUsed( tpl )) {
    throw new UnauthorizedActionException( tplName + " (" + tplVersion + ") is still used by applications. It cannot be deleted." );
  } else {
    this.logger.info( "Deleting the application template called " + tpl.getName() + "..." );
    this.templates.remove( tpl );
    this.notificationMngr.applicationTemplate( tpl, EventType.DELETED );
    this.targetsMngr.applicationWasDeleted( tpl );
    File targetDirectory = ConfigurationUtils.findTemplateDirectory( tpl, this.configurationMngr.getWorkingDirectory());
    Utils.deleteFilesRecursively( targetDirectory );
    this.logger.info( "Application template " + tpl.getName() + " was successfully deleted." );
  }
}

代码示例来源:origin: roboconf/roboconf-platform

Utils.deleteFilesRecursively( propertiesFile );

代码示例来源:origin: roboconf/roboconf-platform

@Test
public void testFindIconUrl() throws Exception {
  // Create fake icons
  ApplicationTemplate tpl = new ApplicationTemplate( "tpl" ).version( "v1" ).directory( this.folder.newFolder());
  File descDir = new File( tpl.getDirectory(), Constants.PROJECT_DIR_DESC );
  Assert.assertTrue( descDir.mkdirs());
  Assert.assertTrue( new File( descDir, "tp.jpg" ).createNewFile());
  Application app = new Application( "app", tpl ).directory( this.folder.newFolder());
  descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC );
  Assert.assertTrue( descDir.mkdirs());
  Assert.assertTrue( new File( descDir, "whatever.jpg" ).createNewFile());
  // Check the URLs
  Assert.assertEquals( "/tpl/v1/tp.jpg", IconUtils.findIconUrl( tpl ));
  Assert.assertEquals( "/app/whatever.jpg", IconUtils.findIconUrl( app ));
  // And we delete the icon
  Utils.deleteFilesRecursively( descDir );
  Assert.assertEquals( "", IconUtils.findIconUrl( app ));
}

代码示例来源:origin: net.roboconf/roboconf-dm

Utils.deleteFilesRecursively( targetDirectory );

相关文章

微信公众号

最新文章

更多