当前位置: 首页>>代码示例>>Java>>正文


Java AtomicMoveNotSupportedException类代码示例

本文整理汇总了Java中java.nio.file.AtomicMoveNotSupportedException的典型用法代码示例。如果您正苦于以下问题:Java AtomicMoveNotSupportedException类的具体用法?Java AtomicMoveNotSupportedException怎么用?Java AtomicMoveNotSupportedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AtomicMoveNotSupportedException类属于java.nio.file包,在下文中一共展示了AtomicMoveNotSupportedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFileSystemExceptions

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
public void testFileSystemExceptions() throws IOException {
    for (FileSystemException ex : Arrays.asList(new FileSystemException("a", "b", "c"),
        new NoSuchFileException("a", "b", "c"),
        new NotDirectoryException("a"),
        new DirectoryNotEmptyException("a"),
        new AtomicMoveNotSupportedException("a", "b", "c"),
        new FileAlreadyExistsException("a", "b", "c"),
        new AccessDeniedException("a", "b", "c"),
        new FileSystemLoopException("a"))) {

        FileSystemException serialize = serialize(ex);
        assertEquals(serialize.getClass(), ex.getClass());
        assertEquals("a", serialize.getFile());
        if (serialize.getClass() == NotDirectoryException.class ||
            serialize.getClass() == FileSystemLoopException.class ||
            serialize.getClass() == DirectoryNotEmptyException.class) {
            assertNull(serialize.getOtherFile());
            assertNull(serialize.getReason());
        } else {
            assertEquals(serialize.getClass().toString(), "b", serialize.getOtherFile());
            assertEquals(serialize.getClass().toString(), "c", serialize.getReason());
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ExceptionSerializationTests.java

示例2: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
    HashSet<CopyOption> copyOptions = Sets.newHashSet(options);
    if (copyOptions.contains(StandardCopyOption.ATOMIC_MOVE)) {
        throw new AtomicMoveNotSupportedException(source.toString(), target.toString(),
            "ATOMIC_MOVE not supported yet");
    }
    if (Files.isDirectory(source)) {
        MCRPath src = MCRFileSystemUtils.checkPathAbsolute(source);
        MCRDirectory srcRootDirectory = getRootDirectory(src);
        if (srcRootDirectory.hasChildren()) {
            throw new IOException("Directory is not empty");
        }
    }
    copy(source, target, options);
    delete(source);
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRFileSystemProvider.java

示例3: copyIfLocked

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void copyIfLocked(final Path source, final Path target, final Mover mover) throws IOException {
  checkNotNull(source);
  checkNotNull(target);
  try {
    mover.accept(source, target);
  }
  catch (AtomicMoveNotSupportedException atomicMoveNotSupported) {
      throw atomicMoveNotSupported;
  }
  catch (FileSystemException e) { // NOSONAR
    // Windows can throw a FileSystemException on move or moveAtomic
    // if the file is in use; in this case, copy and attempt to delete
    // source
    log.warn("Using copy to move {} to {}", source, target);
    copy(source, target);
    try {
      delete(source);
    }
    catch (IOException deleteException) { // NOSONAR
      log.error("Unable to delete {} after move: {}", source, deleteException.getMessage());
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:SimpleFileOperations.java

示例4: temporaryBlobMoveFallback

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Test
public void temporaryBlobMoveFallback() throws Exception {
  final byte[] content = new byte[TEST_DATA_LENGTH];
  new Random().nextBytes(content);

  doThrow(new AtomicMoveNotSupportedException("", "", "")).when(fileOperations).moveAtomic(any(), any());

  final Blob blob = underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);
  verifyMoveOperations(blob);

  final byte[] output = extractContent(blob);
  assertThat("data must survive", content, is(equalTo(output)));

  final BlobMetrics metrics = blob.getMetrics();
  assertThat("size must be calculated correctly", metrics.getContentSize(), is(equalTo((long) TEST_DATA_LENGTH)));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:17,代码来源:FileBlobStoreIT.java

示例5: close

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void close() throws IOException {
  try {
    this.channel.position(0); // reset channel to beginning to compute full SHA1
    String calculatedSha1 = ZsyncUtil.computeSha1(this.channel);
    if (!this.sha1.equals(calculatedSha1)) {
      throw new ChecksumValidationIOException(this.sha1, calculatedSha1);
    }
    try {
      Files.move(this.tempPath, this.path, REPLACE_EXISTING, ATOMIC_MOVE);
    } catch (AtomicMoveNotSupportedException e) {
      Files.move(this.tempPath, this.path, REPLACE_EXISTING);
    }
    Files.setLastModifiedTime(this.path, fromMillis(this.mtime));
  } finally {
    this.channel.close();
    this.listener.close();
  }
}
 
开发者ID:salesforce,项目名称:zsync4j,代码行数:20,代码来源:OutputFileWriter.java

示例6: sauvegarde

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
public boolean sauvegarde(Object o) {
        if (this.getParentFile() != null && !this.getParentFile().exists()) {
            this.getParentFile().mkdirs();
        }
        
        IOMethod m;
        m = new JsonIO();
//        m = new GsonIO();
//        m = new Jackson();
        try {
            File security = new File(this.getParent()+Adresse.separatorChar+"."+this.getName());
            m.sauvegarde(security, o);
            if(!this.exists()) {this.createNewFile();}
            try {
                Files.move(security.toPath(), this.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
            } catch(AtomicMoveNotSupportedException ex) {
                Files.move(security.toPath(), this.toPath(), StandardCopyOption.REPLACE_EXISTING);
            }
            if(!security.delete()) {security.deleteOnExit();}
        } catch(Exception e) {
            Logger.getLogger(Adresse.class.getName()).log(Level.SEVERE, "adresse : "+this.getAbsolutePath(), e);
            DialogueBloquant.error("dialog file not saved");
            return false;
        }
        return true;
    }
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:27,代码来源:Adresse.java

示例7: replaceFile

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
public synchronized static void replaceFile(final File sourceFile, final File destFile)
        throws IOException {
    if (sourceFile == null) {
        throw new NullPointerException("sourceFile");
    }
    if (destFile == null) {
        throw new NullPointerException("destFile");
    }
    Path sourcePath = Paths.get(sourceFile.getAbsolutePath());
    Path destPath = Paths.get(destFile.getAbsolutePath());
    try {
        Files.move(sourcePath, destPath, FileReplaceOptions);
    } catch (AtomicMoveNotSupportedException ex) {
        Files.move(sourcePath, destPath, FallbackFileReplaceOptions);
    }
}
 
开发者ID:fragmer,项目名称:ClassiCubeLauncher,代码行数:17,代码来源:PathUtil.java

示例8: rename

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private static void rename(Path sourceFile, Path targetFile) throws IOException {
  try {
    Files.move(sourceFile, targetFile, StandardCopyOption.ATOMIC_MOVE);
  } catch (AtomicMoveNotSupportedException e) {
    LOG.warn("Atomic rename from '{}' to '{}' not supported", sourceFile, targetFile);
    Files.move(sourceFile, targetFile);
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:9,代码来源:PluginCache.java

示例9: moveIntoPlace

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private static void moveIntoPlace(final File from, final File to) throws IOException {
    try {
        move(from.toPath(), to.toPath(), ATOMIC_MOVE);
    } catch (final AtomicMoveNotSupportedException ex) {
        move(from.toPath(), to.toPath(), REPLACE_EXISTING);
    } finally {
        deleteIfExists(from.toPath());
    }
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:10,代码来源:CachedResource.java

示例10: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void move(Path srcpath, SecureDirectoryStream<Path> targetdir, Path targetpath) throws IOException {
    checkClosed();
    checkFileSystem(srcpath);
    checkFileSystem(targetpath);
    throw new AtomicMoveNotSupportedException(srcpath.toString(), targetpath.toString(),
        "Currently not implemented");
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:9,代码来源:MCRDirectoryStream.java

示例11: moveAtomic

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void moveAtomic(final Path source, final Path target) throws IOException {
  checkNotNull(source);
  checkNotNull(target);
  DirectoryHelper.mkdir(target.getParent());
  try {
    Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
  }
  catch (UnsupportedOperationException e) { // NOSONAR
    throw new AtomicMoveNotSupportedException(source.toString(), target.toString(), e.getMessage());
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:13,代码来源:SimpleFileOperations.java

示例12: overwriteAtomic

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void overwriteAtomic(final Path source, final Path target) throws IOException {
  checkNotNull(source);
  checkNotNull(target);
  DirectoryHelper.mkdir(target.getParent());
  try {
    Files.move(source, target, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
  }
  catch (UnsupportedOperationException e) { // NOSONAR
    throw new AtomicMoveNotSupportedException(source.toString(), target.toString(), e.getMessage());
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:13,代码来源:SimpleFileOperations.java

示例13: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private void move(final Path source, final Path target) throws IOException {
  if (supportsAtomicMove) {
    try {
      fileOperations.copyIfLocked(source, target, fileOperations::moveAtomic);
      return;
    }
    catch (AtomicMoveNotSupportedException e) { // NOSONAR
      supportsAtomicMove = false;
      log.warn("Disabling atomic moves for blob store {}, could not move {} to {}, reason deleted: {}",
          blobStoreConfiguration.getName(), source, target, e.getReason());
    }
  }
  log.trace("Using normal move for blob store {}, moving {} to {}", blobStoreConfiguration.getName(), source, target);
  fileOperations.copyIfLocked(source, target, fileOperations::move);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:FileBlobStore.java

示例14: overwrite

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private void overwrite(final Path source, final Path target) throws IOException {
  if (supportsAtomicMove) {
    try {
      fileOperations.copyIfLocked(source, target, fileOperations::overwriteAtomic);
      return;
    }
    catch (AtomicMoveNotSupportedException e) { // NOSONAR
      supportsAtomicMove = false;
      log.warn("Disabling atomic moves for blob store {}, could not overwrite {} with {}, reason deleted: {}",
          blobStoreConfiguration.getName(), source, target, e.getReason());
    }
  }
  log.trace("Using normal overwrite for blob store {}, overwriting {} with {}", blobStoreConfiguration.getName(), source, target);
  fileOperations.copyIfLocked(source, target, fileOperations::overwrite);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:FileBlobStore.java

示例15: temporaryBlobMoveFallbackPersists

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Test
public void temporaryBlobMoveFallbackPersists() throws Exception {
  final byte[] content = new byte[TEST_DATA_LENGTH];
  new Random().nextBytes(content);

  doThrow(new AtomicMoveNotSupportedException("", "", "")).when(fileOperations).moveAtomic(any(), any());

  underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);
  underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);

  verify(fileOperations, times(1)).moveAtomic(any(), any());
  verify(fileOperations, times(4)).move(any(), any());
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:14,代码来源:FileBlobStoreIT.java


注:本文中的java.nio.file.AtomicMoveNotSupportedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。