if (!assetExists(decodedUniqueId)) {
throw new IllegalArgumentException("Asset does not exist");
}
try {
FileSystem fileSystem = descriptor.getFileSystem();
Path sourcePath = fileSystem.provider().getPath(URI.create(decodedUniqueId));
if (name == null) {
name = sourcePath.getFileName().toString();
}
Path destinationPath = fileSystem.provider().getPath(URI.create(descriptor.getStringRepositoryRoot() + location + fileSystem.getSeparator() + name));
createIfNotExists(destinationPath);
CommentedOption commentedOption = new CommentedOption(getIdentity(), "Moved asset " + sourcePath.getFileName()
+ " into " + location);
fileSystem.provider().move(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING, commentedOption);