本文整理汇总了Java中org.irods.jargon.core.pub.io.IRODSFile.exists方法的典型用法代码示例。如果您正苦于以下问题:Java IRODSFile.exists方法的具体用法?Java IRODSFile.exists怎么用?Java IRODSFile.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.irods.jargon.core.pub.io.IRODSFile
的用法示例。
在下文中一共展示了IRODSFile.exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.irods.jargon.core.pub.io.IRODSFile; //导入方法依赖的package包/类
@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
try {
final AttributedList<Path> children = new AttributedList<Path>();
final IRODSFileSystemAO fs = session.getClient();
final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute());
if(!f.exists()) {
throw new NotfoundException(directory.getAbsolute());
}
for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) {
final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true);
if(StringUtils.equals(normalized, directory.getAbsolute())) {
continue;
}
final PathAttributes attributes = new PathAttributes();
final ObjStat stats = fs.getObjStat(file.getAbsolutePath());
attributes.setModificationDate(stats.getModifiedAt().getTime());
attributes.setCreationDate(stats.getCreatedAt().getTime());
attributes.setSize(stats.getObjSize());
attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum()))));
attributes.setOwner(stats.getOwnerName());
attributes.setGroup(stats.getOwnerZone());
children.add(new Path(directory, PathNormalizer.name(normalized),
file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file),
attributes));
listener.chunk(directory, children);
}
return children;
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory);
}
}
示例2: find
import org.irods.jargon.core.pub.io.IRODSFile; //导入方法依赖的package包/类
@Override
public PathAttributes find(final Path file) throws BackgroundException {
try {
final IRODSFileSystemAO fs = session.getClient();
final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute());
if(!f.exists()) {
throw new NotfoundException(file.getAbsolute());
}
final PathAttributes attributes = new PathAttributes();
final ObjStat stats = fs.getObjStat(f.getAbsolutePath());
attributes.setModificationDate(stats.getModifiedAt().getTime());
attributes.setCreationDate(stats.getCreatedAt().getTime());
attributes.setSize(stats.getObjSize());
attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum()))));
attributes.setOwner(stats.getOwnerName());
attributes.setGroup(stats.getOwnerZone());
return attributes;
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Failure to read attributes of {0}", e, file);
}
}
示例3: move
import org.irods.jargon.core.pub.io.IRODSFile; //导入方法依赖的package包/类
@Override
public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException {
try {
final IRODSFileSystemAO fs = session.getClient();
final IRODSFile s = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute());
if(!s.exists()) {
throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute()));
}
if(status.isExists()) {
delete.delete(Collections.singletonList(renamed), connectionCallback, callback);
}
final IRODSFile d = fs.getIRODSFileFactory().instanceIRODSFile(renamed.getAbsolute());
s.renameTo(d);
return renamed;
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Cannot rename {0}", e, file);
}
}
示例4: retrieveDocumentForId
import org.irods.jargon.core.pub.io.IRODSFile; //导入方法依赖的package包/类
Document retrieveDocumentForId(final String id)
throws FileNotFoundException, JargonException {
log.info("retrieveDocumentForId()");
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("null or empty id");
}
log.info("id:{}", id);
log.info("get irodsFileFactory...");
IRODSFile docFile = connectorContext.getIrodsAccessObjectFactory()
.getIRODSFileFactory(irodsAccount).instanceIRODSFile(id);
if (!docFile.exists()) {
throw new FileNotFoundException("file not found");
}
if (docFile.isDirectory()) {
return retriveCollectionForId(docFile);
} else {
return retriveDataObjectForId(docFile);
}
}
示例5: delete
import org.irods.jargon.core.pub.io.IRODSFile; //导入方法依赖的package包/类
@Override
public void delete(final List<Path> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException {
final List<Path> deleted = new ArrayList<Path>();
for(Path file : files) {
boolean skip = false;
for(Path d : deleted) {
if(file.isChild(d)) {
skip = true;
break;
}
}
if(skip) {
continue;
}
deleted.add(file);
callback.delete(file);
try {
final IRODSFile f = session.getClient().getIRODSFileFactory().instanceIRODSFile(file.getAbsolute());
if(!f.exists()) {
throw new NotfoundException(String.format("%s doesn't exist", file.getAbsolute()));
}
if(f.isFile()) {
session.getClient().fileDeleteForce(f);
}
else if(f.isDirectory()) {
session.getClient().directoryDeleteForce(f);
}
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Cannot delete {0}", e, file);
}
}
}
示例6: download
import org.irods.jargon.core.pub.io.IRODSFile; //导入方法依赖的package包/类
@Override
public void download(final Path file, final Local local, final BandwidthThrottle throttle,
final StreamListener listener, final TransferStatus status,
final ConnectionCallback connectionCallback, final PasswordCallback passwordCallback) throws BackgroundException {
try {
final IRODSFileSystemAO fs = session.getClient();
final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute());
if(f.exists()) {
final TransferControlBlock block = DefaultTransferControlBlock.instance(StringUtils.EMPTY,
preferences.getInteger("connection.retry"));
final TransferOptions options = new DefaultTransferOptionsConfigurer().configure(new TransferOptions());
options.setUseParallelTransfer(session.getHost().getTransferType().equals(Host.TransferType.concurrent));
block.setTransferOptions(options);
final DataTransferOperations transfer = fs.getIRODSAccessObjectFactory()
.getDataTransferOperations(fs.getIRODSAccount());
transfer.getOperation(f, new File(local.getAbsolute()),
new DefaultTransferStatusCallbackListener(status, listener, block),
block);
}
else {
throw new NotfoundException(file.getAbsolute());
}
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Download {0} failed", e, file);
}
}