Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Yoda) .canWrite() - jargon exception, rethrow as unchecked - Exception processing specific query #422

Open
jjkoehorst opened this issue Mar 25, 2023 · 3 comments
Labels
Milestone

Comments

@jjkoehorst
Copy link

Hello,

I am connecting to a Yoda instance which has hacked around in iRODS making it so that not all functionalities are available (don't ask me why). Unfortunately canWrite() is one of them and when I check if a user has write permissions it throws a (see below)...

Which in principle is ok but is there a way to catch this error? I was trying a simple:

            try {
                writable = credentials.getFileFactory().instanceIRODSFile(pathBar.getValue()).canWrite();
            } catch (JargonException e) {
                // Check if directory is writable, YODA does not have the canWrite() function so on exception return true
                writable = true;
                logger.debug("Can write function not available");
            }

But I guess the stack trace is internally to prevent entire breakdown of a process but is there a way to check if a canWrite is possible and handle it accordingly?

2023-03-25 08:28:36 [http-nio-8083-exec-4] ERROR o.i.jargon.core.pub.io.IRODSFileImpl - jargon exception, rethrow as unchecked
org.irods.jargon.core.exception.SpecificQueryException: Exception processing specific query
	at org.irods.jargon.core.connection.IRODSErrorScanner.checkSpecificCodesAndThrowIfExceptionLocated(IRODSErrorScanner.java:173)
	at org.irods.jargon.core.connection.IRODSErrorScanner.inspectAndThrowIfNeeded(IRODSErrorScanner.java:112)
	at org.irods.jargon.core.connection.IRODSMidLevelProtocol.processMessageInfoLessThanZero(IRODSMidLevelProtocol.java:1606)
	at org.irods.jargon.core.connection.IRODSMidLevelProtocol.readMessage(IRODSMidLevelProtocol.java:1110)
	at org.irods.jargon.core.connection.IRODSMidLevelProtocol.readMessage(IRODSMidLevelProtocol.java:1078)
	at org.irods.jargon.core.connection.IRODSMidLevelProtocol.irodsFunction(IRODSMidLevelProtocol.java:445)
	at org.irods.jargon.core.connection.IRODSMidLevelProtocol.irodsFunction(IRODSMidLevelProtocol.java:571)
	at org.irods.jargon.core.connection.IRODSMidLevelProtocol.irodsFunction(IRODSMidLevelProtocol.java:927)
	at org.irods.jargon.core.pub.SpecificQueryAOImpl.queryOnAliasGivenDefinition(SpecificQueryAOImpl.java:483)
	at org.irods.jargon.core.pub.SpecificQueryAOImpl.executeSpecificQueryUsingAliasWithoutAliasLookup(SpecificQueryAOImpl.java:392)
	at org.irods.jargon.core.pub.SpecificQueryAOImpl.findSpecificQueryByAlias(SpecificQueryAOImpl.java:155)
	at org.irods.jargon.core.pub.SpecificQueryAOImpl.executeSpecificQueryUsingAlias(SpecificQueryAOImpl.java:441)
	at org.irods.jargon.core.pub.CollectionAOImpl.findPermissionForUserGrantedThroughUserGroup(CollectionAOImpl.java:1802)
	at org.irods.jargon.core.pub.CollectionAOImpl.getPermissionViaSpecQueryAsGroupMember(CollectionAOImpl.java:1760)
	at org.irods.jargon.core.pub.CollectionAOImpl.getPermissionForUserName(CollectionAOImpl.java:1746)
	at org.irods.jargon.core.pub.CollectionAOImpl.getPermissionForCollection(CollectionAOImpl.java:1661)
	at org.irods.jargon.core.pub.IRODSFileSystemAOImpl.getDirectoryPermissionsForGivenUser(IRODSFileSystemAOImpl.java:322)
	at org.irods.jargon.core.pub.IRODSFileSystemAOImpl.getDirectoryPermissions(IRODSFileSystemAOImpl.java:294)
	at org.irods.jargon.core.pub.IRODSFileSystemAOImpl.isFileWriteable(IRODSFileSystemAOImpl.java:224)
	at org.irods.jargon.core.pub.io.IRODSFileImpl.canWrite(IRODSFileImpl.java:337)
	at nl.fairbydesign.views.browser.BrowserView.lambda$new$7a59a3a5$1(BrowserView.java:404)
@korydraughn korydraughn added this to the 4.3.5.0 milestone Aug 29, 2024
@korydraughn
Copy link
Collaborator

Perhaps the exception is caused due to the target specific query missing.

Are you still able to produce this?
What version of Jargon are you using?
What version of iRODS are you communicating with?
Have you checked the log file of the iRODS server to see which specific query is being called by Jargon?

@trel
Copy link
Member

trel commented Aug 29, 2024

I see this codeblock...

private UserFilePermission findPermissionForUserGrantedThroughUserGroup(final String userName, final String zone,
final String absPath) throws JargonException {
log.info("findPermissionForUserGrantedThroughUserGroup()");
log.info("userName:{}", userName);
log.info("zone:{}", zone);
log.info("absPath:{}", absPath);
IRODSFile collFile = getIRODSFileFactory().instanceIRODSFile(absPath);
SpecificQueryAO specificQueryAO = getIRODSAccessObjectFactory().getSpecificQueryAO(getIRODSAccount());
if (!specificQueryAO.isSupportsSpecificQuery()) {
log.info("no specific query support, so just return null");
return null;
}
// I support spec query, give it a try
List<String> arguments = new ArrayList<String>(2);
arguments.add(collFile.getAbsolutePath());
arguments.add(userName);
SpecificQuery specificQuery = SpecificQuery.instanceArguments("listUserACLForCollectionViaGroup", arguments, 0,
zone);

Which is looking for a SpecificQuery by alias listUserACLForCollectionViaGroup
That SpecificQuery was added to the catalog in iRODS 3.3.1 in 2013.

Blame shows the Jargon code hasn't moved in 11 years.

So my guess is that you're just missing that SpecificQuery...

https://github.com/irods/irods/blob/ecaf66d06478bbe2a3e7be47d98f04ed97b94e9a/scripts/irods/database_upgrade.py#L24

@korydraughn
Copy link
Collaborator

Nice find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants