本文整理汇总了Java中org.irods.jargon.core.exception.JargonException类的典型用法代码示例。如果您正苦于以下问题:Java JargonException类的具体用法?Java JargonException怎么用?Java JargonException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JargonException类属于org.irods.jargon.core.exception包,在下文中一共展示了JargonException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.irods.jargon.core.exception.JargonException; //导入依赖的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.exception.JargonException; //导入依赖的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: login
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
public void login(final HostPasswordStore keychain, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
try {
final IRODSAccount account = client.getIRODSAccount();
final Credentials credentials = host.getCredentials();
account.setUserName(credentials.getUsername());
account.setPassword(credentials.getPassword());
final AuthResponse response = client.getIRODSAccessObjectFactory().authenticateIRODSAccount(account);
if(log.isDebugEnabled()) {
log.debug(String.format("Connected to %s", response.getStartupResponse()));
}
if(!response.isSuccessful()) {
throw new LoginFailureException(MessageFormat.format(LocaleFactory.localizedString(
"Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(host)));
}
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map(e);
}
}
示例4: map
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
public BackgroundException map(final JargonException e) {
final StringBuilder buffer = new StringBuilder();
this.append(buffer, e.getMessage());
if(e instanceof CatNoAccessException) {
return new AccessDeniedException(buffer.toString(), e);
}
if(e instanceof FileNotFoundException) {
return new NotfoundException(buffer.toString(), e);
}
if(e instanceof DataNotFoundException) {
return new NotfoundException(buffer.toString(), e);
}
if(e instanceof AuthenticationException) {
return new LoginFailureException(buffer.toString(), e);
}
if(e instanceof InvalidUserException) {
return new LoginFailureException(buffer.toString(), e);
}
if(e instanceof InvalidGroupException) {
return new LoginFailureException(buffer.toString(), e);
}
return this.wrap(e, buffer);
}
示例5: move
import org.irods.jargon.core.exception.JargonException; //导入依赖的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);
}
}
示例6: retrieveFile
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
protected void retrieveFile(String remoteFileName, String localDirPath)
throws ReplicationServiceException {
try {
if(overrideJargonProperties!=null) {
irodsFileSystem.getIrodsSession().setJargonProperties(overrideJargonProperties);
}
File localFile = new File(localDirPath);
IRODSFileFactory irodsFileFactory = irodsFileSystem .getIRODSFileFactory(irodsAccount);
IRODSFile remoteFile = irodsFileFactory.instanceIRODSFile(remoteFileName);
DataTransferOperations dataTransferOperations = irodsFileSystem
.getIRODSAccessObjectFactory()
.getDataTransferOperations(irodsAccount);
dataTransferOperations.getOperation(remoteFile.getAbsolutePath(), localFile.getAbsolutePath(), "", null, null);
} catch (JargonException e) {
throw new ReplicationServiceException(e);
}
}
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-repository-package,代码行数:22,代码来源:ReplicationServiceIrodsGenericImpl.java
示例7: getMetadataOfDataObject
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
protected Map<String, AVUMetaData> getMetadataOfDataObject(String dataObjectAbsolutePath)
throws ReplicationServiceException {
try {
Map<String, AVUMetaData> eudatMetadata = new HashMap<String, AVUMetaData>();
DataObjectAO dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount);
List<MetaDataAndDomainData> listMetaData = dataObjectAO.findMetadataValuesForDataObject(dataObjectAbsolutePath);
for (MetaDataAndDomainData temp : listMetaData) {
eudatMetadata.put(temp.getAvuAttribute(), new AVUMetaData(temp.getAvuAttribute(),temp.getAvuValue(),temp.getAvuUnit()));
}
return eudatMetadata;
} catch (JargonException e) {
throw new ReplicationServiceException(e);
}
}
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-repository-package,代码行数:19,代码来源:ReplicationServiceIrodsGenericImpl.java
示例8: DocumentMapper
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
/**
* Default constuctor
*
* @param connectorContext
* {@link ConnectorContext} with access and environmental
* information
*/
DocumentMapper(ConnectorContext connectorContext) {
if (connectorContext == null) {
throw new IllegalArgumentException("null connectorContext");
}
this.connectorContext = null;
// FIXME: auth shim here until I understand the pluggable auth for
// modeshape
try {
irodsAccount = IRODSAccount.instance("localhost", 1247, "test1",
"test", "", "test1", "test1-resc");
} catch (JargonException je) {
throw new JargonRuntimeException("exception getting irods account",
je);
}
}
示例9: retrieveDocumentForId
import org.irods.jargon.core.exception.JargonException; //导入依赖的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);
}
}
示例10: delete
import org.irods.jargon.core.exception.JargonException; //导入依赖的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);
}
}
}
示例11: statusCallback
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
public FileStatusCallbackResponse statusCallback(final org.irods.jargon.core.transfer.TransferStatus t) throws JargonException {
if(log.isDebugEnabled()) {
log.debug(String.format("Progress with %s", t));
}
final long bytes = t.getBytesTransfered() - status.getOffset();
status.progress(bytes);
switch(t.getTransferType()) {
case GET:
listener.recv(bytes);
break;
case PUT:
listener.sent(bytes);
break;
}
if(status.isCanceled()) {
if(log.isDebugEnabled()) {
log.debug(String.format("Set canceled for block %s", block));
}
block.setCancelled(true);
return FileStatusCallbackResponse.SKIP;
}
else {
if(!t.isIntraFileStatusReport()) {
if(t.getTotalFilesTransferredSoFar() == t.getTotalFilesToTransfer()) {
status.setComplete();
}
}
}
return FileStatusCallbackResponse.CONTINUE;
}
示例12: touch
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
try {
final IRODSFileSystemAO fs = session.getClient();
final int descriptor = fs.createFile(file.getAbsolute(),
DataObjInp.OpenFlags.WRITE_TRUNCATE, DataObjInp.DEFAULT_CREATE_MODE);
fs.fileClose(descriptor, false);
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Cannot create file {0}", e, file);
}
return file;
}
示例13: find
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
public boolean find(final Path file) throws BackgroundException {
if(file.isRoot()) {
return true;
}
try {
final IRODSFileSystemAO fs = session.getClient();
final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute());
return fs.isFileExists(f);
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map("Failure to read attributes of {0}", e, file);
}
}
示例14: logout
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
protected void logout() throws BackgroundException {
try {
client.getIRODSSession().closeSession();
}
catch(JargonException e) {
throw new IRODSExceptionMappingService().map(e);
}
}
示例15: toURI
import org.irods.jargon.core.exception.JargonException; //导入依赖的package包/类
@Override
public URI toURI(final boolean includePassword) throws JargonException {
try {
return new URI(String.format("irods://%s.%s%[email protected]%s:%d%s",
this.getUserName(),
this.getZone(),
includePassword ? String.format(":%s", this.getPassword()) : StringUtils.EMPTY,
this.getHost(),
this.getPort(),
URIEncoder.encode(this.getHomeDirectory())));
}
catch(URISyntaxException e) {
throw new JargonException(e.getMessage());
}
}