Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

set -e

# Uncomment below to assist in debugging
#set -x

TARGET="useage"
DEBUG=false
OFFLINE=false
Expand Down Expand Up @@ -173,7 +176,7 @@ fi

if [ "${TARGET}" == "format-poms" ]; then
SAXON="${HOME}/.m2/repository/net/sf/saxon/Saxon-HE/9.9.1-8/Saxon-HE-9.9.1-8.jar"
POMS="$(find . -name pom.xml)"
POMS="$(find $SCRIPT_DIR -name pom.xml)"
for pom in $POMS; do

echo -n "Formatting ${pom} ... "
Expand Down
4 changes: 2 additions & 2 deletions elemental-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@
</dependency>
</dependencies>
<configuration>
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" />
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
<forkCount>${surefire.forkCount}</forkCount>
<reuseForks>${surefire.reuseForks}</reuseForks>
<argLine>@{jacocoArgLine} --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED -Dfile.encoding=${project.build.sourceEncoding}</argLine>
Expand Down Expand Up @@ -807,4 +807,4 @@
</profile>
</profiles>

</project>
</project>
55 changes: 54 additions & 1 deletion exist-ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>test</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -184,7 +183,34 @@
<include>pom.xml</include>
<include>src/test/resources-filtered/conf.xml</include>
<include>src/test/resources/log4j2.xml</include>
<include>src/main/java/org/exist/ant/AbstractXMLDBTask.java</include>
<include>src/main/java/org/exist/ant/AddGroupTask.java</include>
<include>src/main/java/org/exist/ant/AddUserTask.java</include>
<include>src/main/java/org/exist/ant/ChmodTask.java</include>
<include>src/main/java/org/exist/ant/ChownTask.java</include>
<include>src/test/java/org/exist/ant/FileTaskTest.java</include>
<include>src/main/java/org/exist/ant/ListGroupsTask.java</include>
<include>src/main/java/org/exist/ant/ListUsersTask.java</include>
<include>src/main/java/org/exist/ant/LockResourceTask.java</include>
<include>src/main/java/org/exist/ant/RemoveGroupTask.java</include>
<include>src/main/java/org/exist/ant/RemoveUserTask.java</include>
<include>src/main/java/org/exist/ant/RestoreTask.java</include>
<include>src/test/java/org/exist/ant/ServerTaskTest.java</include>
<include>src/main/java/org/exist/ant/UserPasswordTask.java</include>
<include>src/main/java/org/exist/ant/UserTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBCopyTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBCreateTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBExistTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBExtractTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBListTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBMoveTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBRemoveTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBShutdownTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBStoreTask.java</include>
<include>src/test/java/org/exist/ant/XmldbTaskTest.java</include>
<include>src/main/java/org/exist/ant/XMLDBXPathTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBXQueryTask.java</include>
<include>src/main/java/org/exist/ant/XMLDBXUpdateTask.java</include>
</includes>
</licenseSet>

Expand All @@ -202,7 +228,34 @@
<exclude>xquery-license-style.xml</exclude>
<exclude>src/test/resources-filtered/conf.xml</exclude>
<exclude>src/test/resources/log4j2.xml</exclude>
<exclude>src/main/java/org/exist/ant/AbstractXMLDBTask.java</exclude>
<exclude>src/main/java/org/exist/ant/AddGroupTask.java</exclude>
<exclude>src/main/java/org/exist/ant/AddUserTask.java</exclude>
<exclude>src/main/java/org/exist/ant/ChmodTask.java</exclude>
<exclude>src/main/java/org/exist/ant/ChownTask.java</exclude>
<exclude>src/test/java/org/exist/ant/FileTaskTest.java</exclude>
<exclude>src/main/java/org/exist/ant/ListGroupsTask.java</exclude>
<exclude>src/main/java/org/exist/ant/ListUsersTask.java</exclude>
<exclude>src/main/java/org/exist/ant/LockResourceTask.java</exclude>
<exclude>src/main/java/org/exist/ant/RemoveGroupTask.java</exclude>
<exclude>src/main/java/org/exist/ant/RemoveUserTask.java</exclude>
<exclude>src/main/java/org/exist/ant/RestoreTask.java</exclude>
<exclude>src/test/java/org/exist/ant/ServerTaskTest.java</exclude>
<exclude>src/main/java/org/exist/ant/UserPasswordTask.java</exclude>
<exclude>src/main/java/org/exist/ant/UserTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBCopyTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBCreateTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBExistTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBExtractTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBListTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBMoveTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBRemoveTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBShutdownTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBStoreTask.java</exclude>
<exclude>src/test/java/org/exist/ant/XmldbTaskTest.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBXPathTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBXQueryTask.java</exclude>
<exclude>src/main/java/org/exist/ant/XMLDBXUpdateTask.java</exclude>
</excludes>
</licenseSet>
</licenseSets>
Expand Down
111 changes: 62 additions & 49 deletions exist-ant/src/main/java/org/exist/ant/AbstractXMLDBTask.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* admin@evolvedbinary.com
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -37,6 +61,7 @@
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.CollectionManagementService;

import javax.annotation.Nullable;
import java.util.StringTokenizer;


Expand Down Expand Up @@ -186,79 +211,67 @@ protected void registerDatabase() throws BuildException
}


protected final Collection mkcol(final Collection rootCollection, final String baseURI, String path, final String relPath ) throws XMLDBException
{
CollectionManagementService mgtService;
Collection current = rootCollection;
Collection collection;
String token;

///TODO : use dedicated function in XmldbURI
final StringTokenizer tokenizer = new StringTokenizer( relPath, "/" );

while( tokenizer.hasMoreTokens() ) {

token = tokenizer.nextToken();
protected final Collection mkcol(Collection collection, final String baseURI, String path, final String relPath) throws XMLDBException {
final StringTokenizer tokenizer = new StringTokenizer(relPath, "/");

if( path != null ) {
while (tokenizer.hasMoreTokens()) {
final String token = tokenizer.nextToken();
if (path != null) {
path = path + "/" + token;
} else {
path = "/" + token;
}

log( "Get collection " + baseURI + path, Project.MSG_DEBUG );
collection = DatabaseManager.getCollection( baseURI + path, user, password );

if( collection == null ) {
log( "Create collection management service for collection " + current.getName(), Project.MSG_DEBUG );
mgtService = current.getService( CollectionManagementService.class );
log( "Create child collection " + token, Project.MSG_DEBUG );
current = mgtService.createCollection( token );
log( "Created collection " + current.getName() + '.', Project.MSG_DEBUG );
Collection child = DatabaseManager.getCollection(baseURI + path, user, password);
if (child == null) {
final CollectionManagementService mgtService = collection.getService(CollectionManagementService.class);
log("Create child collection " + token, Project.MSG_DEBUG);
child = mgtService.createCollection(token);
log("Created collection " + child.getName() + '.', Project.MSG_DEBUG);
}

} else {
current = collection;
try {
// close the parent collection
collection.close();
} catch (final XMLDBException e) {
// no-op
}

collection = child;
}
return( current );

return collection;
}


protected final void setPermissions(final Resource res ) throws BuildException
{
Collection base = null;
UserManagementService service = null;

if( uri == null ) {
throw( new BuildException( "you have to specify an XMLDB collection URI" ) );
protected final void setPermissions(final Resource res) throws BuildException {
if (uri == null) {
throw new BuildException( "you have to specify an XMLDB collection URI");
}

try {
log( "Get base collection: " + uri, Project.MSG_DEBUG );
base = DatabaseManager.getCollection( uri, user, password );
log("Get base collection: " + uri, Project.MSG_DEBUG);
try (final Collection base = DatabaseManager.getCollection(uri, user, password)) {

if( base == null ) {
if (base == null ) {
final String msg = "Collection " + uri + " could not be found.";

if( failonerror ) {
throw( new BuildException( msg ) );
if (failonerror) {
throw new BuildException(msg);
} else {
log( msg, Project.MSG_ERR );
log(msg, Project.MSG_ERR);
}
} else {
service = base.getService( UserManagementService.class);

setPermissions( res, service );
final UserManagementService service = base.getService(UserManagementService.class);
setPermissions(res, service);
}

}
catch( final XMLDBException e ) {
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();

if( failonerror ) {
throw( new BuildException( msg, e ) );
if (failonerror) {
throw new BuildException(msg, e);
} else {
log( msg, e, Project.MSG_ERR );
log(msg, e, Project.MSG_ERR);
}
}
}
Expand All @@ -283,7 +296,7 @@ protected final void setPermissions(final Collection col ) throws BuildException
}


protected final void setPermissions(final Resource res, final UserManagementService service ) throws BuildException
protected final void setPermissions(@Nullable final Resource res, final UserManagementService service ) throws BuildException
{
try {
if( permissions != null ) {
Expand Down
34 changes: 27 additions & 7 deletions exist-ant/src/main/java/org/exist/ant/AddGroupTask.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* admin@evolvedbinary.com
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -34,12 +58,8 @@ public class AddGroupTask extends UserTask
{
private String name;

/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException
{
super.execute();
@Override
public void executeUserTask() throws BuildException {

if( name == null ) {
throw( new BuildException( "Must specify a group name" ) );
Expand All @@ -49,7 +69,7 @@ public void execute() throws BuildException
final GroupAider group = new GroupAider( name );

log( "Adding group " + name, Project.MSG_INFO );
service.addGroup( group );
getService().addGroup( group );

}
catch( final XMLDBException e ) {
Expand Down
34 changes: 27 additions & 7 deletions exist-ant/src/main/java/org/exist/ant/AddUserTask.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* admin@evolvedbinary.com
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -37,12 +61,8 @@ public class AddUserTask extends UserTask {
private String primaryGroup;
private String secret;

/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException
{
super.execute();
@Override
public void executeUserTask() throws BuildException {

if( name == null ) {
throw( new BuildException( "Must specify at leat a user name" ) );
Expand All @@ -60,7 +80,7 @@ public void execute() throws BuildException
}

log( "Adding user " + name, Project.MSG_INFO );
service.addAccount( usr );
getService().addAccount( usr );

}
catch( final XMLDBException e ) {
Expand Down
Loading