-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
[Feature] Add xquery recursive collection creation with just one path expression #5062
base: develop
Are you sure you want to change the base?
[Feature] Add xquery recursive collection creation with just one path expression #5062
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent first contribution. Just a few things that can be tidied up.
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
} else { | ||
try { | ||
return new StringValue(this, collection.getName()); | ||
} catch (XMLDBException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception should be marked final
if (collectionNeedsClose && collection != null) { | ||
try { | ||
collection.close(); | ||
} catch (final Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid catch-all Exception
. Instead specify explicitly multiple exceptions separated by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code has gone?
…eate-with-just-the-path
…' of github.com:enima007/exist into feature/add-xquery-collection-create-with-just-the-path
…eate-with-just-the-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paths to xmldb:create-collection#1
must be absolute.
declare | ||
%test:assertEquals("/db/parent-collection/path/to/new-collection") | ||
function t:fnCreateNewRecursiveCollection() { | ||
let $collection := xmldb:create-collection($t:path-collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that you are currently testing that:
xmldb:create-collection("/parent-collection/path/to/new-collection")
creates the collection /db/parent-collection/path/to/new-collection
?
If so, that should not work! The xmldb:create-collection#1
function should always take an absolute path, i.e. starting with /db
. This test should be modified to check for an error result, and the implementation updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
exist-core/src/main/java/org/exist/xquery/functions/xmldb/XMLDBCreateCollection.java
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. 1 Bug 48.0% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
try { | ||
final Collection newCollection = createCollectionPath(collection, collectionName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoudl this go in to try(final Collection newCollection..)
?
Description:
Added an xmldb:create-collection#1 function to XMLDBModule.java and updated XMLDBCreateCollection.java implementation
to allow the creation of a new collection just by specifying its path.
Reference:
Closes #4238.
Type of tests:
Added a small assertEqual test in exist-core/src/test/xquery/xmldb/collection-create-tests.xql to check if
the collection is created successfully.