├── .github ├── FUNDING.yml └── workflows │ └── gradle.yml ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── xmldb-api.importorder └── LICENSE_HEADER ├── AUTHORS ├── .gitignore ├── renovate.json ├── benchmarks ├── LICENSE ├── src ├── main │ └── java │ │ └── org │ │ └── xmldb │ │ └── api │ │ ├── modules │ │ ├── package-info.java │ │ ├── BinaryResource.java │ │ ├── TransactionService.java │ │ ├── XUpdateQueryService.java │ │ ├── DatabaseInstanceService.java │ │ ├── CollectionManagementService.java │ │ ├── XPathQueryService.java │ │ └── XMLResource.java │ │ ├── security │ │ ├── package-info.java │ │ ├── AccountPrincipal.java │ │ ├── AclEntryType.java │ │ ├── AclEntryPermission.java │ │ ├── UserPrincipal.java │ │ ├── GroupPrincipal.java │ │ ├── AclEntryFlag.java │ │ ├── Permission.java │ │ ├── Attributes.java │ │ └── UserPrincipalLookupService.java │ │ ├── package-info.java │ │ └── base │ │ ├── package-info.java │ │ ├── CompiledExpression.java │ │ ├── Identifier.java │ │ ├── ResourceType.java │ │ ├── Service.java │ │ ├── ResourceIterator.java │ │ ├── Configurable.java │ │ ├── DatabaseAction.java │ │ ├── ServiceProvider.java │ │ ├── ErrorCodes.java │ │ ├── ServiceProviderCache.java │ │ ├── Database.java │ │ ├── Resource.java │ │ └── ResourceSet.java ├── test │ └── java │ │ └── org │ │ └── xmldb │ │ └── api │ │ ├── security │ │ ├── AclEntryTypeTest.java │ │ ├── AclEntryPermissionTest.java │ │ ├── AclEntryFlagTest.java │ │ └── PermissionsTest.java │ │ ├── modules │ │ ├── XMLResourceTest.java │ │ └── BinaryResourceTest.java │ │ └── base │ │ ├── ResourceTypeTest.java │ │ ├── ResourceIteratorTest.java │ │ ├── ServiceProviderCacheTest.java │ │ └── XMLDBExceptionTest.java └── jmh │ └── java │ └── org │ └── xmldb │ └── api │ ├── DatabaseState.java │ ├── TestDatabase.java │ └── DatabaseManagerBenchmark.java ├── gradle.properties ├── settings.gradle ├── README.adoc └── gradlew.bat /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: reinhapa 2 | patreon: reinhapa 3 | liberapay: reinhapa 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmldb-org/xmldb-api/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/xmldb-api.importorder: -------------------------------------------------------------------------------- 1 | #Organize Import Order 2 | #Tue Feb 08 20:27:30 CET 2022 3 | 0=java 4 | 1=javax 5 | 2=org 6 | 3=com 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Maintainer 2 | Patrick Reinhart 3 | 4 | Contributors 5 | Kimbro Staken 6 | Lars Martin 7 | Per Nyfelt 8 | Vladimir R. Bossicard 9 | Jeroen Breedveld 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ ignores 2 | .idea/ 3 | *.iml 4 | # Eclipse ignoers 5 | .project 6 | .classpath 7 | .settings/ 8 | bin/ 9 | # Gradle ignores 10 | .gradle/ 11 | build/ 12 | # CVS default ignores begin 13 | tags 14 | TAGS 15 | .make.state 16 | .nse_depinfo 17 | *~ 18 | \#* 19 | .#* 20 | ,* 21 | _$* 22 | *$ 23 | *.old 24 | *.bak 25 | *.BAK 26 | *.orig 27 | *.rej 28 | .del-* 29 | *.a 30 | *.olb 31 | *.o 32 | *.obj 33 | *.so 34 | *.exe 35 | *.Z 36 | *.elc 37 | *.ln 38 | core 39 | # CVS default ignores end 40 | build 41 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended", 5 | "group:all", 6 | "schedule:daily" 7 | ], 8 | "dependencyDashboard": true, 9 | "packageRules": [ 10 | { 11 | "matchUpdateTypes": [ 12 | "minor", 13 | "patch" 14 | ], 15 | "automerge": true 16 | }, 17 | { 18 | "matchUpdateTypes": [ 19 | "major" 20 | ], 21 | "automerge": false 22 | }, 23 | { 24 | "matchManagers": [ 25 | "gradle-wrapper" 26 | ], 27 | "allowedVersions": "<9" 28 | } 29 | ], 30 | "schedule": [ 31 | "at any time" 32 | ] 33 | } -------------------------------------------------------------------------------- /benchmarks: -------------------------------------------------------------------------------- 1 | Benchmark Mode Cnt Score Error Units 2 | DatabaseManagerBenchmark.getCollection thrpt 5 16.419 ± 0.486 ops/us 3 | DatabaseManagerBenchmark.registerDatabase thrpt 5 38.682 ± 0.208 ops/us 4 | DatabaseManagerBenchmark.getCollection avgt 5 0.060 ± 0.004 us/op 5 | DatabaseManagerBenchmark.registerDatabase avgt 5 0.026 ± 0.001 us/op 6 | 7 | Benchmark Mode Cnt Score Error Units 8 | DatabaseManagerBenchmark.deregisterDatabase thrpt 5 67.050 ± 9.119 ops/us 9 | DatabaseManagerBenchmark.getCollection thrpt 5 16.208 ± 0.694 ops/us 10 | DatabaseManagerBenchmark.registerDatabase thrpt 5 56.525 ± 2.594 ops/us 11 | DatabaseManagerBenchmark.deregisterDatabase avgt 5 0.015 ± 0.002 us/op 12 | DatabaseManagerBenchmark.getCollection avgt 5 0.062 ± 0.005 us/op 13 | DatabaseManagerBenchmark.registerDatabase avgt 5 0.018 ± 0.001 us/op 14 | 15 | Benchmark Mode Cnt Score Error Units 16 | DatabaseManagerBenchmark.deregisterDatabase thrpt 5 59.543 ± 0.267 ops/us 17 | DatabaseManagerBenchmark.getCollection thrpt 5 16.630 ± 1.101 ops/us 18 | DatabaseManagerBenchmark.registerDatabase thrpt 5 56.962 ± 1.218 ops/us 19 | DatabaseManagerBenchmark.deregisterDatabase avgt 5 0.017 ± 0.001 us/op 20 | DatabaseManagerBenchmark.getCollection avgt 5 0.060 ± 0.002 us/op 21 | DatabaseManagerBenchmark.registerDatabase avgt 5 0.017 ± 0.001 us/op 22 | -------------------------------------------------------------------------------- /gradle/LICENSE_HEADER: -------------------------------------------------------------------------------- 1 | The XML:DB Initiative Software License, Version 1.0 2 | 3 | Copyright (c) ${copyrightYear} The XML:DB Initiative. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted 6 | provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions 9 | and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of 12 | conditions and the following disclaimer in the documentation and/or other materials provided with 13 | the distribution. 14 | 15 | 3. The end-user documentation included with the redistribution, if any, must include the 16 | following acknowledgment: "This product includes software developed by the XML:DB Initiative 17 | (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 18 | and wherever such third-party acknowledgments normally appear. 19 | 20 | 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 21 | software without prior written permission. For written permission, please contact info@xmldb.org. 22 | 23 | 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 24 | their name, without prior written permission of the XML:DB Initiative. 25 | 26 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 29 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 31 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | ================================================================================================= 35 | This software consists of voluntary contributions made by many individuals on behalf of the 36 | XML:DB Initiative. For more information on the XML:DB Initiative, please see 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The XML:DB Initiative Software License, Version 1.0 2 | 3 | 4 | Copyright (c) 2000-2001 The XML:DB Initiative. All rights 5 | reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in 16 | the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | 3. The end-user documentation included with the redistribution, 20 | if any, must include the following acknowledgment: 21 | "This product includes software developed by the 22 | XML:DB Initiative (http://www.xmldb.org/)." 23 | Alternately, this acknowledgment may appear in the software itself, 24 | if and wherever such third-party acknowledgments normally appear. 25 | 26 | 4. The name "XML:DB Initiative" must not be used to endorse or 27 | promote products derived from this software without prior written 28 | permission. For written permission, please contact info@xmldb.org. 29 | 30 | 5. Products derived from this software may not be called "XML:DB", 31 | nor may "XML:DB" appear in their name, without prior written 32 | permission of the XML:DB Initiative. 33 | 34 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 38 | ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 39 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 40 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 41 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 42 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 43 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 44 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 45 | SUCH DAMAGE. 46 | ==================================================================== 47 | 48 | This software consists of voluntary contributions made by many 49 | individuals on behalf of the XML:DB Initiative. For more information 50 | on the XML:DB Initiative, please see . 51 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: CI 5 | env: 6 | MIN_JDK: '17' 7 | on: 8 | push: 9 | branches: [ main, protobuf ] 10 | pull_request: 11 | branches: [ main, protobuf ] 12 | workflow_dispatch: 13 | 14 | jobs: 15 | codacy-analysis-cli: 16 | runs-on: ubuntu-latest 17 | name: Codacy Analysis CLI 18 | steps: 19 | - uses: actions/checkout@v6 20 | - name: Run codacy-analysis-cli 21 | uses: codacy/codacy-analysis-cli-action@master 22 | build: 23 | name: ${{ matrix.os }} / OpenJDK ${{ matrix.jdk }} 24 | runs-on: ${{ matrix.os }} 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any 27 | ORG_GRADLE_PROJECT_sonarToken: ${{ secrets.SONAR_TOKEN || '**undefined**' }} 28 | strategy: 29 | matrix: 30 | jdk: ['17', '21'] 31 | os: [ubuntu-latest] 32 | steps: 33 | - uses: actions/checkout@v6 34 | with: 35 | fetch-depth: 0 36 | - name: Set up JDK ${{ matrix.jdk }} 37 | uses: actions/setup-java@v5 38 | with: 39 | distribution: temurin 40 | java-version: ${{ matrix.jdk }} 41 | - name: Grant execute permission for gradlew 42 | run: chmod +x gradlew 43 | - name: Build without sonar 44 | if: ${{ env.ORG_GRADLE_PROJECT_sonarToken == '**undefined**' || matrix.jdk != env.MIN_JDK }} 45 | run: ./gradlew check 46 | - name: Build with sonar 47 | if: ${{ env.ORG_GRADLE_PROJECT_sonarToken != '**undefined**' }} 48 | run: ./gradlew check sonar 49 | - name: Run codecov analysis 50 | uses: codecov/codecov-action@v5 51 | deploy: 52 | if: ${{ github.event_name != 'pull_request' && github.repository == 'xmldb-org/xmldb-api' }} 53 | needs: [ build, codacy-analysis-cli ] 54 | runs-on: ubuntu-latest 55 | name: Deploy 56 | steps: 57 | - uses: actions/checkout@v6 58 | with: 59 | fetch-depth: 0 60 | - name: Set up JDK 61 | uses: actions/setup-java@v5 62 | with: 63 | distribution: temurin 64 | java-version: ${{ env.MIN_JDK }} 65 | - name: Deploy 66 | env: 67 | ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} 68 | ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }} 69 | ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} 70 | ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} 71 | run: ./gradlew publish --no-daemon 72 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | /** 41 | * Defines additional services and more detailed resources. 42 | */ 43 | package org.xmldb.api.modules; 44 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | /** 41 | * Contains security related interfaces and helper classes. 42 | */ 43 | package org.xmldb.api.security; 44 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | /** 41 | * XML:DB API specification base package defining the {@link org.xmldb.api.DatabaseManager}. 42 | */ 43 | package org.xmldb.api; 44 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | /** 41 | * Contains the basic XML:DB API definitions as {@link org.xmldb.api.base.Database}, 42 | * {@link org.xmldb.api.base.Collection} and their content. 43 | */ 44 | package org.xmldb.api.base; 45 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/AccountPrincipal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import java.security.Principal; 43 | 44 | /** 45 | * Base XML:DB account principal. 46 | * 47 | * @since 2.0 48 | */ 49 | public interface AccountPrincipal extends Principal { 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/CompiledExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | /** 43 | * Represents a complied expression. 44 | */ 45 | public interface CompiledExpression { 46 | /** 47 | * Prepare the expression for being reused. 48 | */ 49 | void reset(); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/Identifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | /** 43 | * Represents the unique identifications for a resource within a database. 44 | * 45 | * @since 2.0 46 | */ 47 | public interface Identifier extends java.io.Serializable, Comparable { 48 | } 49 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # The XML:DB Initiative Software License, Version 1.0 3 | # 4 | # Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without modification, are permitted 7 | # provided that the following conditions are met: 8 | # 9 | # 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | # and the following disclaimer. 11 | # 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | # conditions and the following disclaimer in the documentation and/or other materials provided with 14 | # the distribution. 15 | # 16 | # 3. The end-user documentation included with the redistribution, if any, must include the 17 | # following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | # (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | # and wherever such third-party acknowledgments normally appear. 20 | # 21 | # 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | # software without prior written permission. For written permission, please contact info@xmldb.org. 23 | # 24 | # 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | # their name, without prior written permission of the XML:DB Initiative. 26 | # 27 | # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | # DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # ================================================================================================= 36 | # This software consists of voluntary contributions made by many individuals on behalf of the 37 | # XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | # 39 | # 40 | 41 | # Deployment options - override in HOME/.gradle/gradle.properties 42 | sonatypeUsername= 43 | sonatypePassword= 44 | 45 | systemProp.javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl 46 | systemProp.javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl 47 | systemProp.javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/AclEntryType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | /** 43 | * A typesafe enumeration of the access control entry types. 44 | * 45 | * @since 2.0 46 | */ 47 | public enum AclEntryType { 48 | /** 49 | * Represents an access control entry type that allows access. 50 | */ 51 | ALLOW, 52 | /** 53 | * Represents an access control entry type indicating a denial of access. 54 | */ 55 | DENY 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/security/AclEntryTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.security.AclEntryType.ALLOW; 44 | import static org.xmldb.api.security.AclEntryType.DENY; 45 | 46 | import org.junit.jupiter.api.Test; 47 | 48 | class AclEntryTypeTest { 49 | @Test 50 | void testValidValues() { 51 | assertThat(AclEntryType.values()).containsExactly(ALLOW, DENY); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/AclEntryPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | /** 43 | * A typesafe enumeration of the access entry permission types. 44 | * 45 | * @since 2.0 46 | */ 47 | public enum AclEntryPermission { 48 | /** 49 | * Permission to read the data of the collection / resource. 50 | */ 51 | READ, 52 | /** 53 | * Permission to modify the collection / resource data. 54 | */ 55 | WRITE, 56 | /** 57 | * Permission to list a execute a resource. 58 | */ 59 | EXECUTE; 60 | } 61 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | plugins { 41 | id 'org.ajoberstar.reckon.settings' version '1.0.1' 42 | } 43 | 44 | reckon { 45 | defaultInferredScope = 'minor' 46 | snapshots() 47 | scopeCalc = calcScopeFromProp().or(calcScopeFromCommitMessages()) 48 | stageCalc = calcStageFromProp() 49 | // enable parse of old `xmldb-api-xxx' tags 50 | tagParser = tagName -> java.util.Optional.of(tagName) 51 | .map(name -> name.replaceFirst(/xmldb-api-(\d+\.\d+)/, '$1.0')) 52 | .flatMap(name -> org.ajoberstar.reckon.core.Version.parse(name)) 53 | } 54 | 55 | rootProject.name = 'xmldb-api' 56 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/modules/XMLResourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.base.ResourceType.XML_RESOURCE; 44 | 45 | import org.junit.jupiter.api.Test; 46 | import org.mockito.Spy; 47 | import org.mockito.junit.jupiter.MockitoSettings; 48 | 49 | @MockitoSettings 50 | class XMLResourceTest { 51 | @Spy 52 | XMLResource xmlResource; 53 | 54 | @Test 55 | void testGetResourceType() { 56 | assertThat(xmlResource.getResourceType()).isEqualTo(XML_RESOURCE); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/security/AclEntryPermissionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.security.AclEntryPermission.EXECUTE; 44 | import static org.xmldb.api.security.AclEntryPermission.READ; 45 | import static org.xmldb.api.security.AclEntryPermission.WRITE; 46 | 47 | import org.junit.jupiter.api.Test; 48 | 49 | class AclEntryPermissionTest { 50 | @Test 51 | void testValidValues() { 52 | assertThat(AclEntryPermission.values()).containsExactly(READ, WRITE, EXECUTE); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/modules/BinaryResourceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.base.ResourceType.BINARY_RESOURCE; 44 | 45 | import org.junit.jupiter.api.Test; 46 | import org.mockito.Spy; 47 | import org.mockito.junit.jupiter.MockitoSettings; 48 | 49 | @MockitoSettings 50 | class BinaryResourceTest { 51 | @Spy 52 | BinaryResource binaryResource; 53 | 54 | @Test 55 | void testGetResourceType() { 56 | assertThat(binaryResource.getResourceType()).isEqualTo(BINARY_RESOURCE); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = XML:DB Initiative for XML Databases 2 | Patrick Reinhart 3 | :group-name: net.sf.xmldb-org 4 | :project-org: xmldb-org 5 | :project-name: xmldb-api 6 | :project-full-path: {project-org}/{project-name} 7 | :github-branch: master 8 | 9 | image:https://img.shields.io/badge/license-XML:DB-blue.svg["XML:DB Initiative Software License", link="https://github.com/{project-full-path}/blob/{github-branch}/LICENSE"] 10 | image:https://img.shields.io/github/release/{project-full-path}.svg["Release", link="https://github.com/{project-full-path}/releases"] 11 | image:https://img.shields.io/maven-central/v/{group-name}/{project-name}.svg?label=Maven%20Central["Maven Central", link="https://search.maven.org/search?q=g:%22{group-name}%22%20AND%20a:%22{project-name}%22"] 12 | image:https://sonarcloud.io/api/project_badges/measure?project={project-org}_{project-name}&metric=alert_status["Quality Gate Status", link ="https://sonarcloud.io/summary/new_code?id={project-org}_{project-name}"] 13 | image:https://javadoc.io/badge2/{group-name}/{project-name}/javadoc.svg["javadoc", link="https://javadoc.io/doc/{group-name}/{project-name}"] 14 | image:https://github.com/{project-full-path}/actions/workflows/gradle.yml/badge.svg["CI", link="https://github.com/{project-full-path}/actions/workflows/gradle.yml"] 15 | 16 | 17 | This is a conversion to Git of the `xapi` module from the XML:DB CVS repository 18 | via `anonymous@a.cvs.sourceforge.net:/cvsroot/xmldb-org`. 19 | 20 | The archived project and code can be found at https://sourceforge.net/projects/xmldb-org/ 21 | 22 | Supported Java versions: 23 | image:https://img.shields.io/badge/Java-17-blue.svg["Java 17", link="https://adoptium.net/"] 24 | image:https://img.shields.io/badge/Java-21-blue.svg["Java 21", link="https://adoptium.net/"] 25 | 26 | == Content 27 | The API interfaces are what driver developers must implement when creating a 28 | new driver and are the interfaces that applications are developed against. 29 | Along with the interfaces a concrete DriverManager implementation is also 30 | provides. 31 | 32 | == Building for eXist-db 33 | The XML:DB API can be built as a JAR file. This is also used by http://exist-db.org/[eXist-db]'s 34 | implementation of the XML:DB API. 35 | 36 | Java 11 or later is required to build the JAR file. 37 | 38 | [source,bash,subs="attributes"] 39 | ---- 40 | $ git clone https://github.com/{project-full-path}.git 41 | $ cd {project-name} 42 | $ gradlew build 43 | ---- 44 | 45 | The JAR file will be located in the `build/libs` folder. 46 | 47 | 48 | == Getting the binaries for your build: 49 | The latest versions of the API are available at https://search.maven.org/search?q=g:{group-name} 50 | 51 | Snapshot builds are available from the Maven snapshot repository 52 | https://central.sonatype.com/repository/maven-snapshots/net/sf/xmldb-org/xmldb-api/[https://central.sonatype.com/repository/maven-snapshots] 53 | 54 | 55 | == Contribute 56 | Contributions are always welcome. Use https://google.github.io/styleguide/javaguide.html[Google code style format] for your changes. 57 | 58 | 59 | == License 60 | This project is licensed under the https://github.com/{project-full-path}/blob/{github-branch}/LICENSE[XML:DB Software license] -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/BinaryResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.xmldb.api.base.Resource; 43 | import org.xmldb.api.base.ResourceType; 44 | import org.xmldb.api.base.XMLDBException; 45 | 46 | /** 47 | * Resource for encapsulation of binary data that is stored in the data base. Support for 48 | * BinaryResources is optional. 49 | * 50 | * The standard {@code getContent} method returns a {@code byte[]} and the standard setContent 51 | * expects an {@code byte[]}. 52 | */ 53 | public interface BinaryResource extends Resource { 54 | 55 | @Override 56 | default ResourceType getResourceType() { 57 | return ResourceType.BINARY_RESOURCE; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/UserPrincipal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | /** 43 | * A {@code Principal} representing an identity used to determine access rights to objects in the 44 | * XMLDB. 45 | * 46 | *

47 | * A {@code UserPrincipal} object is an abstract representation of an identity. It has a 48 | * {@link #getName() name} that is the account name that it represents. User principal objects may 49 | * be obtained using a {@link UserPrincipalLookupService}, or returned by {@link Attributes} 50 | * implementations that provide access to identity related attributes. 51 | * 52 | * @since 2.0 53 | */ 54 | public interface UserPrincipal extends AccountPrincipal { 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/security/AclEntryFlagTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.security.AclEntryFlag.COLLECTION_INHERIT; 44 | import static org.xmldb.api.security.AclEntryFlag.INHERIT_ONLY; 45 | import static org.xmldb.api.security.AclEntryFlag.NO_PROPAGATE_INHERIT; 46 | import static org.xmldb.api.security.AclEntryFlag.RESOURCE_INHERIT; 47 | 48 | import org.junit.jupiter.api.Test; 49 | 50 | class AclEntryFlagTest { 51 | @Test 52 | void testValidValues() { 53 | assertThat(AclEntryFlag.values()).containsExactly(RESOURCE_INHERIT, COLLECTION_INHERIT, 54 | NO_PROPAGATE_INHERIT, INHERIT_ONLY); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH= 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /src/jmh/java/org/xmldb/api/DatabaseState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api; 41 | 42 | import org.openjdk.jmh.annotations.Level; 43 | import org.openjdk.jmh.annotations.Scope; 44 | import org.openjdk.jmh.annotations.Setup; 45 | import org.openjdk.jmh.annotations.State; 46 | import org.openjdk.jmh.annotations.TearDown; 47 | import org.xmldb.api.base.XMLDBException; 48 | 49 | @State(Scope.Benchmark) 50 | public class DatabaseState { 51 | TestDatabase database; 52 | 53 | @Setup(Level.Trial) 54 | public void up() throws XMLDBException { 55 | database = new TestDatabase(); 56 | DatabaseManager.registerDatabase(database); 57 | } 58 | 59 | @TearDown(Level.Trial) 60 | public void down() throws XMLDBException { 61 | DatabaseManager.deregisterDatabase(database); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/GroupPrincipal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | /** 43 | * A {@code UserPrincipal} representing a group identity, used to determine access rights 44 | * to objects in a file system. The exact definition of a group is implementation specific, but 45 | * typically, it represents an identity created for administrative purposes so as to determine the 46 | * access rights for the members of the group. Whether an entity can be a member of multiple groups, 47 | * and whether groups can be nested, are implementation specified and therefore not specified. 48 | * 49 | * @see UserPrincipalLookupService#lookupPrincipalByGroupName 50 | * 51 | * @since 2.0 52 | */ 53 | public interface GroupPrincipal extends AccountPrincipal { 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/base/ResourceTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.base.ResourceType.BINARY_RESOURCE; 44 | import static org.xmldb.api.base.ResourceType.XML_RESOURCE; 45 | 46 | import org.junit.jupiter.api.Test; 47 | 48 | class ResourceTypeTest { 49 | @Test 50 | void testValidValues() { 51 | assertThat(ResourceType.values()).containsExactly(BINARY_RESOURCE, XML_RESOURCE); 52 | } 53 | 54 | @Test 55 | void testToString() { 56 | assertThat(BINARY_RESOURCE.typeName()).isEqualTo("BinaryResource"); 57 | assertThat(BINARY_RESOURCE).hasToString("BinaryResource"); 58 | assertThat(XML_RESOURCE.typeName()).isEqualTo("XMLResource"); 59 | assertThat(XML_RESOURCE).hasToString("XMLResource"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/base/ResourceIteratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import static org.mockito.Mockito.spy; 43 | import static org.mockito.Mockito.verify; 44 | import static org.mockito.Mockito.when; 45 | 46 | import java.util.function.Consumer; 47 | 48 | import org.junit.jupiter.api.Test; 49 | import org.mockito.Mock; 50 | import org.mockito.Spy; 51 | import org.mockito.junit.jupiter.MockitoSettings; 52 | 53 | @MockitoSettings 54 | class ResourceIteratorTest { 55 | @Spy 56 | ResourceIterator resourceIterator; 57 | @Mock 58 | Resource resource; 59 | @Mock 60 | Consumer action; 61 | 62 | @Test 63 | void testForEachRemaining() throws XMLDBException { 64 | when(resourceIterator.hasMoreResources()).thenReturn(true, false); 65 | when(resourceIterator.nextResource()).thenReturn(resource); 66 | 67 | resourceIterator.forEachRemaining(action); 68 | 69 | verify(action).accept(resource); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/jmh/java/org/xmldb/api/TestDatabase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api; 41 | 42 | import java.util.Properties; 43 | 44 | import org.xmldb.api.base.Collection; 45 | import org.xmldb.api.base.Database; 46 | 47 | public class TestDatabase implements Database { 48 | @Override 49 | public String getName() { 50 | return "testdb"; 51 | } 52 | 53 | @Override 54 | public Collection getCollection(String uri, Properties info) { 55 | return null; 56 | } 57 | 58 | @Override 59 | public boolean acceptsURI(String uri) { 60 | return false; 61 | } 62 | 63 | @Override 64 | public String getConformanceLevel() { 65 | return ""; 66 | } 67 | 68 | @Override 69 | public String getProperty(String name) { 70 | return ""; 71 | } 72 | 73 | @Override 74 | public String getProperty(String name, String defaultValue) { 75 | return ""; 76 | } 77 | 78 | @Override 79 | public void setProperty(String name, String value) { 80 | // no action 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/jmh/java/org/xmldb/api/DatabaseManagerBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api; 41 | 42 | import java.util.concurrent.TimeUnit; 43 | 44 | import org.openjdk.jmh.annotations.Benchmark; 45 | import org.openjdk.jmh.annotations.BenchmarkMode; 46 | import org.openjdk.jmh.annotations.Mode; 47 | import org.openjdk.jmh.annotations.OutputTimeUnit; 48 | import org.openjdk.jmh.infra.Blackhole; 49 | import org.xmldb.api.base.XMLDBException; 50 | 51 | @BenchmarkMode({Mode.Throughput, Mode.AverageTime}) 52 | @OutputTimeUnit(TimeUnit.MICROSECONDS) 53 | public class DatabaseManagerBenchmark { 54 | 55 | @Benchmark 56 | public void registerDatabase(DatabaseState state) throws XMLDBException { 57 | DatabaseManager.registerDatabase(state.database); 58 | } 59 | 60 | @Benchmark 61 | public void getCollection(DatabaseState state, Blackhole bh) throws XMLDBException { 62 | bh.consume(DatabaseManager.getCollection("xmldb:testdatabase:testcollection")); 63 | } 64 | 65 | @Benchmark 66 | public void deregisterDatabase(DatabaseState state) { 67 | DatabaseManager.deregisterDatabase(state.database); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/AclEntryFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | /** 43 | * Defines the flags for used by the flags component of an ACL {@link AclEntry entry}. 44 | * 45 | * @since 2.0 46 | */ 47 | public enum AclEntryFlag { 48 | /** 49 | * Can be placed on a collection and indicates that the ACL entry should be added to each new 50 | * resource created. 51 | */ 52 | RESOURCE_INHERIT, 53 | 54 | /** 55 | * Can be placed on a collection and indicates that the ACL entry should be added to each new 56 | * collection created. 57 | */ 58 | COLLECTION_INHERIT, 59 | 60 | /** 61 | * Can be placed on a collection to indicate that the ACL entry should not be placed on the newly 62 | * created collection which is inheritable by sub collections of the created collection. 63 | */ 64 | NO_PROPAGATE_INHERIT, 65 | 66 | /** 67 | * Can be placed on a collection but does not apply to the collection, only to newly created 68 | * resources/collections as specified by the {@link #RESOURCE_INHERIT} and 69 | * {@link #COLLECTION_INHERIT} flags. 70 | */ 71 | INHERIT_ONLY; 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/TransactionService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.xmldb.api.base.Service; 43 | import org.xmldb.api.base.XMLDBException; 44 | 45 | /** 46 | * Provides the ability to bundle {@code Collection} operations into a transaction. 47 | * 48 | * Note: This interface needs much better definition 49 | */ 50 | public interface TransactionService extends Service { 51 | 52 | /** 53 | * Begin the transaction 54 | * 55 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 56 | * vendor specific errors that occur. 57 | */ 58 | void begin() throws XMLDBException; 59 | 60 | /** 61 | * Commit the transaction 62 | * 63 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 64 | * vendor specific errors that occur. 65 | */ 66 | void commit() throws XMLDBException; 67 | 68 | /** 69 | * Rollback the transaction 70 | * 71 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 72 | * vendor specific errors that occur. 73 | */ 74 | void rollback() throws XMLDBException; 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/ResourceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | /** 43 | * Enumeration of all available resource types. 44 | * 45 | * @since 2.0 46 | */ 47 | public enum ResourceType { 48 | /** 49 | * Represents a resource type for binary data. This constant is used to identify and interact with 50 | * resources that consist of binary content in a repository or database. 51 | */ 52 | BINARY_RESOURCE("BinaryResource"), 53 | /** 54 | * Represents a resource type for XML data. This constant is used to identify and interact with 55 | * resources consisting of XML content in a repository or database. 56 | */ 57 | XML_RESOURCE("XMLResource"); 58 | 59 | private final String name; 60 | 61 | ResourceType(String name) { 62 | this.name = name; 63 | } 64 | 65 | /** 66 | * Returns the old style resource type name from XML:DB API version 1.0 constant. 67 | * 68 | * @return the classic type name 69 | */ 70 | public String typeName() { 71 | return name; 72 | } 73 | 74 | /** 75 | * Returns the old style resource type name from XML:DB API version 1.0 constant. 76 | * 77 | * @return the classic type name 78 | */ 79 | @Override 80 | public String toString() { 81 | return typeName(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | /** 43 | * Represents the known XMLDB permission types. 44 | * 45 | * @since 2.0 46 | */ 47 | public enum Permission { 48 | 49 | /** 50 | * Read permission, owner. 51 | */ 52 | OWNER_READ, 53 | 54 | /** 55 | * Write permission, owner. 56 | */ 57 | OWNER_WRITE, 58 | 59 | /** 60 | * Execute/search permission, owner. 61 | */ 62 | OWNER_EXECUTE, 63 | 64 | /** 65 | * Read permission, group. 66 | */ 67 | GROUP_READ, 68 | 69 | /** 70 | * Write permission, group. 71 | */ 72 | GROUP_WRITE, 73 | 74 | /** 75 | * Execute/search permission, group. 76 | */ 77 | GROUP_EXECUTE, 78 | 79 | /** 80 | * Read permission, others. 81 | */ 82 | OTHERS_READ, 83 | 84 | /** 85 | * Write permission, others. 86 | */ 87 | OTHERS_WRITE, 88 | 89 | /** 90 | * Execute/search permission, others. 91 | */ 92 | OTHERS_EXECUTE, 93 | 94 | /** 95 | * Set User ID. 96 | */ 97 | SET_UID, 98 | 99 | /** 100 | * Set Group ID. 101 | */ 102 | SET_GID, 103 | 104 | /** 105 | * The Sticky bit. 106 | */ 107 | STICKY_BIT; 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/XUpdateQueryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.xmldb.api.base.Service; 43 | import org.xmldb.api.base.XMLDBException; 44 | 45 | /** 46 | * XUpdateQueryService is a {@code Service} that enables the execution of XUpdate queries within the 47 | * context of a {@code Collection} or against a single document stored in a collection. 48 | */ 49 | public interface XUpdateQueryService extends Service { 50 | 51 | /** 52 | * Runs a set of XUpdate operations against the collection. All selected documents are to be 53 | * updated and stored back to the repository. 54 | * 55 | * @param commands The XUpdate commands to use. 56 | * @return the number of modified nodes. 57 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 58 | * vendor specific errors that occur. 59 | */ 60 | long update(String commands) throws XMLDBException; 61 | 62 | /** 63 | * Runs a set of XUpdate operations against a resource stored in a collection. The resource will 64 | * be updated in place in the collection. 65 | * 66 | * @param id the id of the resource to update 67 | * @param commands The XUpdate commands to use. 68 | * @return the number of modified nodes. 69 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 70 | * vendor specific errors that occur. 71 | */ 72 | long updateResource(String id, String commands) throws XMLDBException; 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | 43 | /** 44 | * The {@code Service} interface provides an extension mechanism for {@code Collection} 45 | * implementations. It is to be implemented by Service instances that define their own set of 46 | * methods to perform the necessary action. For an example of what a functional {@code Service} 47 | * interface should look like look at XPathQueryService. 48 | * 49 | * @see org.xmldb.api.modules.XPathQueryService 50 | */ 51 | public interface Service extends Configurable { 52 | /** 53 | * Returns the name associated with the Service instance. 54 | * 55 | * @return the name of the object. 56 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 57 | * vendor specific errors that occur. 58 | */ 59 | String getName() throws XMLDBException; 60 | 61 | /** 62 | * Gets the Version attribute of the Service object 63 | * 64 | * @return The Version value 65 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 66 | * vendor specific errors that occur. 67 | */ 68 | String getVersion() throws XMLDBException; 69 | 70 | /** 71 | * Sets the Collection attribute of the Service object 72 | * 73 | * @param col The new Collection value 74 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 75 | * vendor specific errors that occur. 76 | */ 77 | void setCollection(Collection col) throws XMLDBException; 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/ResourceIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import java.util.Objects; 43 | import java.util.function.Consumer; 44 | 45 | /** 46 | * ResourceIterator is used to iterate over a set of resources. 47 | */ 48 | public interface ResourceIterator { 49 | /** 50 | * Returns true as long as there are still more resources to be iterated. 51 | * 52 | * @return true if there are more resources to iterate, false otherwise. 53 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 54 | * vendor specific errors that occur. 55 | */ 56 | boolean hasMoreResources() throws XMLDBException; 57 | 58 | /** 59 | * Returns the next {@code Resource} instance in the iterator. 60 | * 61 | * @return the next {@code Resource} instance in the iterator. 62 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 63 | * vendor specific errors that occur. {@code ErrorCodes.NO_SUCH_RESOURCE} if the resource 64 | * iterator is empty or all resources have already been retrieved. 65 | */ 66 | Resource nextResource() throws XMLDBException; 67 | 68 | 69 | /** 70 | * Calls the given action for each resource. 71 | * 72 | * @param action the action being called with each resource found 73 | * @throws XMLDBException if an error during internal loop occurs 74 | */ 75 | default void forEachRemaining(Consumer action) throws XMLDBException { 76 | Objects.requireNonNull(action); 77 | while (hasMoreResources()) { 78 | action.accept(nextResource()); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/Configurable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | /** 43 | * Provides the ability to configure properties about an object. 44 | */ 45 | public interface Configurable { 46 | 47 | /** 48 | * Returns the value of the property identified by {@code name}. 49 | * 50 | * @param name the name of the property to retrieve. 51 | * @return the property value or null if no property exists. 52 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 53 | * vendor specific errors that occur. 54 | */ 55 | String getProperty(String name) throws XMLDBException; 56 | 57 | /** 58 | * Returns the value of the property identified by {@code name} or the {@code defaultValue} if no 59 | * property is set for the given {@code name}. 60 | * 61 | * @param name the name of the property to retrieve. 62 | * @param defaultValue the fallback default value to return in case no value is available. 63 | * @return the property value or null if no property exists. 64 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 65 | * vendor specific errors that occur. 66 | * 67 | * @since 2.0 68 | */ 69 | String getProperty(String name, String defaultValue) throws XMLDBException; 70 | 71 | /** 72 | * Sets the property {@code name} to have the value provided in {@code value}. 73 | * 74 | * @param name the name of the property to set. 75 | * @param value the value to set for the property. 76 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 77 | * vendor specific errors that occur. 78 | */ 79 | void setProperty(String name, String value) throws XMLDBException; 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/DatabaseAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import org.xmldb.api.DatabaseManager; 43 | 44 | /** 45 | * Represents an action performed on a database when it is deregistered from the system. This 46 | * interface provides a mechanism for databases to define custom procedures or behaviors during the 47 | * deregistration process. 48 | *

49 | * Implementations of this interface should handle the logic necessary to clean up resources, close 50 | * active connections, or perform any required tasks when the database is removed. The specifics of 51 | * these actions depend on the database implementation. 52 | */ 53 | public interface DatabaseAction { 54 | /** 55 | * Method called by {@linkplain DatabaseManager#deregisterDatabase(Database) } to notify the 56 | * Database that it was de-registered. 57 | *

58 | * The {@code deregister} method is intended only to be used by database and not by applications. 59 | * Databases are recommended to not implement {@code DatabaseAction} in a public class. If there 60 | * are active connections to the database at the time that the {@code deregister} method is 61 | * called, it is implementation specific as to whether the connections are closed or allowed to 62 | * continue. Once this method is called, it is implementation specific as to whether the database 63 | * may limit the ability to open collections of a database, invoke other {@code Database} methods 64 | * or throw a {@code XMLDBException}. Consult your database's documentation for additional 65 | * information on its behavior. 66 | * 67 | * @see DatabaseManager#registerDatabase(Database, DatabaseAction) 68 | * @see DatabaseManager#deregisterDatabase(Database) 69 | * @since 3 70 | */ 71 | void deregister(); 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/DatabaseInstanceService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.xmldb.api.base.Service; 43 | import org.xmldb.api.base.XMLDBException; 44 | 45 | /** 46 | * A service to manage the database instance. The service defines a single method shutdown() to shut 47 | * down the database instance used by the current driver. 48 | */ 49 | public interface DatabaseInstanceService extends Service { 50 | 51 | /** 52 | * Immediately shutdown the current database instance. 53 | * 54 | * The current user must be a member of the "dba" group or an exception will be thrown. 55 | * 56 | * This operation is synchronous and will not return until the database is shutdown 57 | * 58 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 59 | * vendor specific errors that occur. 60 | */ 61 | void shutdown() throws XMLDBException; 62 | 63 | /** 64 | * Shutdown the current database instance after the specified delay (in milliseconds). 65 | * 66 | * The current user must be a member of the "dba" group or an exception will be thrown. 67 | * 68 | * This operation is asynchronous and the delay is scheduled with the database scheduler. 69 | * 70 | * @param delay the delay in milliseconds to wait before shutdown 71 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 72 | * vendor specific errors that occur. 73 | */ 74 | void shutdown(long delay) throws XMLDBException; 75 | 76 | /** 77 | * Returns {@code true} if the database instance is running local, i.e. in the same thread as this 78 | * service. 79 | * 80 | * @return {@code true} on a local instance, {@code false} otherwise 81 | */ 82 | boolean isLocalInstance(); 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/Attributes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import java.util.List; 43 | import java.util.Set; 44 | 45 | /** 46 | * Represents the basic attributes of either a {@link org.xmldb.api.base.Resource} or 47 | * {@link org.xmldb.api.base.Collection}. 48 | * 49 | * @since 2.0 50 | */ 51 | public interface Attributes { 52 | 53 | /** 54 | * Returns the owner of the collection or resource. 55 | * 56 | * @return the resource owner 57 | * 58 | * @see PermissionManagementService#setOwner 59 | */ 60 | UserPrincipal owner(); 61 | 62 | /** 63 | * Returns the group owner of the collection or resource. 64 | * 65 | * @return the resource group owner 66 | * 67 | * @see PermissionManagementService#setGroup 68 | */ 69 | GroupPrincipal group(); 70 | 71 | /** 72 | * Returns the permissions of the collection or resource. The collection or resource permissions 73 | * are returned as a set of {@link Permission} elements. The returned set is a copy of the 74 | * collection or resource permissions and is modifiable. This allows the result to be modified and 75 | * passed to the {@link PermissionManagementService#setPermissions} methods to update the 76 | * collection's or resources's permissions. 77 | * 78 | * @return the collection or resource permissions 79 | * 80 | * @see PermissionManagementService#setPermissions 81 | */ 82 | Set permissions(); 83 | 84 | /** 85 | * Returns the ACL of the collection or resource. The collection or resource permissions are 86 | * returned as a list of {@link AclEntry} elements. The returned list is a copy of the collection 87 | * or resource ACL and is modifiable. This allows the result to be modified and passed to the 88 | * {@link PermissionManagementService#setAcl} methods to update the collection's or resources's 89 | * Access Control List. 90 | * 91 | * @return the collection or resource ACL entries 92 | * 93 | * @see PermissionManagementService#setAcl 94 | */ 95 | List acl(); 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/ServiceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import static org.xmldb.api.base.ErrorCodes.NO_SUCH_SERVICE; 43 | 44 | import java.util.Optional; 45 | 46 | /** 47 | * The {@code ServiceProvider} interface access to the {@link Service} implementation instances and 48 | * is able to query for implemented ones. 49 | * 50 | * @since 2.0 51 | */ 52 | public interface ServiceProvider { 53 | 54 | /** 55 | * Determines if a service of the specified type is available. 56 | * 57 | * @param the type of service 58 | * @param serviceType the class type of the service to check for 59 | * @return {@code true} if a service of the specified type is available, {@code false} otherwise 60 | * 61 | * @since 2.0 62 | */ 63 | boolean hasService(Class serviceType); 64 | 65 | /** 66 | * Returns optional {@code Service} instance for the requested {@code serviceType}. If no 67 | * {@code Service} exists or can be provided an empty optional is returned. 68 | * 69 | * @param the type of service 70 | * @param serviceType the type of service to return 71 | * @return a optional instance of the given service type 72 | * 73 | * @since 2.0 74 | */ 75 | Optional findService(Class serviceType); 76 | 77 | /** 78 | * Returns a {@code Service} instance for the requested {@code serviceType}. If no {@code Service} 79 | * exists a {@link XMLDBException} with {@link ErrorCodes#NO_SUCH_SERVICE} is thrown. 80 | * 81 | * @param the type of service 82 | * @param serviceType the type of service to return 83 | * @return a instance of the given service type 84 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#NO_SUCH_SERVICE} if the 85 | * service does not exist, {@link ErrorCodes#VENDOR_ERROR} for any vendor specific errors 86 | * that occur. {@link ErrorCodes#COLLECTION_CLOSED} if the {@code close} method has been 87 | * called on the {@code Collection} 88 | * 89 | * @since 2.0 90 | */ 91 | default S getService(Class serviceType) throws XMLDBException { 92 | return findService(serviceType) 93 | .orElseThrow(() -> new XMLDBException(NO_SUCH_SERVICE, "Unknown service: " + serviceType)); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/security/UserPrincipalLookupService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import org.xmldb.api.base.Service; 43 | import org.xmldb.api.base.XMLDBException; 44 | 45 | /** 46 | * An object to lookup user and group principals by name. A {@link UserPrincipal} represents an 47 | * identity that may be used to determine access rights to objects in the XMLDB. A 48 | * {@link GroupPrincipal} represents a group identity. A {@code UserPrincipalLookupService} 49 | * defines methods to lookup identities by name or group name (which are typically user or account 50 | * names). Whether names and group names are case sensitive or not depends on the implementation. 51 | * The exact definition of a group is implementation specific but typically a group represents an 52 | * identity created for administrative purposes so as to determine the access rights for the members 53 | * of the group. In particular it is implementation specific if the namespace for names and 54 | * groups is the same or is distinct. To ensure consistent and correct behavior across platforms it 55 | * is recommended that this API be used as if the namespaces are distinct. In other words, the 56 | * {@link #lookupPrincipalByName lookupPrincipalByName} should be used to lookup users, and 57 | * {@link #lookupPrincipalByGroupName lookupPrincipalByGroupName} should be used to lookup groups. 58 | * 59 | * @see org.xmldb.api.base.Collection#getService 60 | * 61 | * @since 2.0 62 | */ 63 | public interface UserPrincipalLookupService extends Service { 64 | 65 | /** 66 | * Lookup a user principal by name. 67 | * 68 | * @param name the string representation of the user principal to lookup 69 | * 70 | * @return a user principal 71 | * 72 | * @throws XMLDBException the principal does not exist 73 | */ 74 | UserPrincipal lookupPrincipalByName(String name) throws XMLDBException; 75 | 76 | /** 77 | * Lookup a group principal by group name. 78 | * 79 | *

80 | * Where an implementation does not support any notion of group then this method always throws 81 | * {@link XMLDBException}. Where the namespace for user accounts and groups is the same, then this 82 | * method is identical to invoking {@link #lookupPrincipalByName lookupPrincipalByName}. 83 | * 84 | * @param group the string representation of the group to lookup 85 | * 86 | * @return a group principal 87 | * 88 | * @throws XMLDBException the principal does not exist or is not a group 89 | */ 90 | GroupPrincipal lookupPrincipalByGroupName(String group) throws XMLDBException; 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/ErrorCodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | /** 43 | * ErrorCodes defines XML:DB error codes that can be used to set the {@code errorCodes} attribute of 44 | * an {@code XMLDBException} 45 | */ 46 | public final class ErrorCodes { 47 | /** 48 | * Set when a more detailed error can not be determined. 49 | */ 50 | public static final int UNKNOWN_ERROR = 0; 51 | 52 | /** 53 | * Set when a vendor specific error has occured. 54 | */ 55 | public static final int VENDOR_ERROR = 1; 56 | 57 | /** 58 | * Set if the API implementation does not support the operation being invoked. 59 | */ 60 | public static final int NOT_IMPLEMENTED = 2; 61 | 62 | /** 63 | * Set if the content of a {@code Resource} is set to a content type different then that for which 64 | * the {@code Resource} was intended to support. 65 | */ 66 | public static final int WRONG_CONTENT_TYPE = 3; 67 | 68 | /** 69 | * Set if access to the requested {@code Collection} can not be granted due to the lack of proper 70 | * credentials. 71 | */ 72 | public static final int PERMISSION_DENIED = 4; 73 | 74 | /** 75 | * Set if the URI format is invalid. 76 | */ 77 | public static final int INVALID_URI = 5; 78 | 79 | /** 80 | * Set if the requested {@code Service} could not be located. 81 | */ 82 | public static final int NO_SUCH_SERVICE = 100; 83 | 84 | /** 85 | * Set if the requested {@code Collection} could not be located. 86 | */ 87 | public static final int NO_SUCH_COLLECTION = 200; 88 | 89 | /** 90 | * Set if the Collection instance is in an invalid state. 91 | */ 92 | public static final int INVALID_COLLECTION = 201; 93 | 94 | /** 95 | * Set when an operation is invoked against a {@code Collection} instance that has been closed. 96 | */ 97 | public static final int COLLECTION_CLOSED = 202; 98 | 99 | /** 100 | * Set if the requested {@code Resource} could not be located. 101 | */ 102 | public static final int NO_SUCH_RESOURCE = 300; 103 | 104 | /** 105 | * Set if the {@code Resource} provided to an operation is invalid. 106 | */ 107 | public static final int INVALID_RESOURCE = 301; 108 | 109 | /** 110 | * Set if the resource type requested is unknown to the API implementation. 111 | */ 112 | public static final int UNKNOWN_RESOURCE_TYPE = 302; 113 | 114 | /** 115 | * Set if a {@code Database} instance can not be located for the provided URI. 116 | */ 117 | public static final int NO_SUCH_DATABASE = 400; 118 | 119 | /** 120 | * Set if the {@code Database} instance being registered is invalid. 121 | */ 122 | public static final int INVALID_DATABASE = 401; 123 | 124 | /** 125 | * Set if the {@code Database} instance name being registered is already registered. 126 | */ 127 | public static final int INSTANCE_NAME_ALREADY_REGISTERED = 402; 128 | 129 | private ErrorCodes() {} 130 | 131 | /** 132 | * Returns a default message for the given error code. 133 | * 134 | * @param errorCode the error code constant defined in {@link ErrorCodes} 135 | * @return a default non-empty message representing the error code 136 | */ 137 | public static String defaultMessage(int errorCode) { 138 | return switch (errorCode) { 139 | case COLLECTION_CLOSED -> "Collection closed"; 140 | case INSTANCE_NAME_ALREADY_REGISTERED -> "Instance name already registered"; 141 | case INVALID_COLLECTION -> "Invalid collection"; 142 | case INVALID_DATABASE -> "Invalid database"; 143 | case INVALID_RESOURCE -> "Invalid resource"; 144 | case INVALID_URI -> "Invalid URI"; 145 | case NO_SUCH_COLLECTION -> "No such collection"; 146 | case NO_SUCH_DATABASE -> "No such database"; 147 | case NO_SUCH_RESOURCE -> "No such resource"; 148 | case NO_SUCH_SERVICE -> "No such service"; 149 | case NOT_IMPLEMENTED -> "Not implemented"; 150 | case PERMISSION_DENIED -> "Permission denied"; 151 | case UNKNOWN_ERROR -> "Unknown error"; 152 | case UNKNOWN_RESOURCE_TYPE -> "Unknown resource type"; 153 | case VENDOR_ERROR -> "Vendor error"; 154 | case WRONG_CONTENT_TYPE -> "Wrong content type"; 155 | default -> "Unknown error code: " + errorCode; 156 | }; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/CollectionManagementService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.xmldb.api.base.Collection; 43 | import org.xmldb.api.base.Service; 44 | import org.xmldb.api.base.XMLDBException; 45 | 46 | /** 47 | * CollectionManagementService is a {@code Service} that enables the basic management of collections 48 | * within a database. The functionality provided is very basic because collection management varies 49 | * widely among databases. This service simply provides functionality for those databases that are 50 | * able to implement this basic functionality. 51 | */ 52 | public interface CollectionManagementService extends Service { 53 | 54 | /** 55 | * Creates a new {@code Collection} in the database. The default configuration of the database is 56 | * determined by the implementer. The new {@code Collection} will be created relative to the 57 | * {@code Collection} from which the {@code CollectionManagementService} was retrieved. 58 | * 59 | * @param name The name of the collection to create. 60 | * @return The created {@code Collection} instance. 61 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 62 | * vendor specific errors that occur. 63 | */ 64 | Collection createCollection(String name) throws XMLDBException; 65 | 66 | /** 67 | * Removes a named {@code Collection} from the system. The name for the {@code Collection} to 68 | * remove is relative to the {@code Collection} from which the {@code CollectionManagementService} 69 | * was retrieved. 70 | * 71 | * @param name The name of the collection to remove. 72 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 73 | * vendor specific errors that occur. 74 | */ 75 | void removeCollection(String name) throws XMLDBException; 76 | 77 | /** 78 | * Moves either a {@code collection} or {@code } 79 | * 80 | * @param collection The source collection 81 | * @param destination The destination collection 82 | * @param newName The new name of the moved collection in the destination collection 83 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 84 | * vendor specific errors that occur. 85 | */ 86 | void move(String collection, String destination, String newName) throws XMLDBException; 87 | 88 | /** 89 | * Moves the resource specified by the {@code resourcePath} to the given {@code destinationPath} 90 | * and {@code newName}. 91 | * 92 | * @param resourcePath The source document 93 | * @param destinationPath The destination collection 94 | * @param newName The new name of the moved source in the destination collection 95 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 96 | * vendor specific errors that occur. 97 | */ 98 | void moveResource(String resourcePath, String destinationPath, String newName) 99 | throws XMLDBException; 100 | 101 | /** 102 | * Copy the resource specified by the {@code resourcePath} to the given {@code destinationPath} 103 | * and {@code newName}. 104 | * 105 | * @param resourcePath The source document 106 | * @param destinationPath The destination collection 107 | * @param newName The new name of the copied source in the destination collection 108 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 109 | * vendor specific errors that occur. 110 | */ 111 | void copyResource(String resourcePath, String destinationPath, String newName) 112 | throws XMLDBException; 113 | 114 | /** 115 | * Copy the collection specified by {@code collection} to the given {@code destination} and 116 | * {@code newName}. 117 | * 118 | * @param collection The source collection 119 | * @param destination The destination collection 120 | * @param newName The new name of the copied collection in the destination collection 121 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 122 | * vendor specific errors that occur. 123 | */ 124 | void copy(String collection, String destination, String newName) throws XMLDBException; 125 | } 126 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/base/ServiceProviderCacheTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; 44 | import static org.mockito.Mockito.verifyNoInteractions; 45 | import static org.mockito.Mockito.when; 46 | import static org.xmldb.api.base.ErrorCodes.NO_SUCH_SERVICE; 47 | 48 | import java.util.function.Supplier; 49 | 50 | import org.junit.jupiter.api.BeforeEach; 51 | import org.junit.jupiter.api.Test; 52 | import org.mockito.Mock; 53 | import org.mockito.junit.jupiter.MockitoSettings; 54 | import org.xmldb.api.modules.CollectionManagementService; 55 | import org.xmldb.api.modules.XPathQueryService; 56 | import org.xmldb.api.modules.XQueryService; 57 | import org.xmldb.api.security.UserPrincipalLookupService; 58 | 59 | @MockitoSettings 60 | class ServiceProviderCacheTest { 61 | @Mock 62 | CollectionManagementService collectionManagementService; 63 | @Mock 64 | Supplier collectionManagementServiceSupplier; 65 | @Mock 66 | Supplier combinedQueryServiceProvider; 67 | @Mock 68 | CombinedQueryService combinedQueryService; 69 | 70 | ServiceProviderCache cache; 71 | 72 | @BeforeEach 73 | void prepare() { 74 | cache = ServiceProviderCache.withRegistered(registry -> { 75 | registry.add(CollectionManagementService.class, collectionManagementServiceSupplier); 76 | registry.add(XPathQueryService.class, combinedQueryServiceProvider); 77 | registry.add(XQueryService.class, combinedQueryServiceProvider); 78 | }); 79 | } 80 | 81 | @Test 82 | void testWithRegistered() throws XMLDBException { 83 | verifyNoInteractions(collectionManagementServiceSupplier); 84 | assertThat(cache.hasService(CollectionManagementService.class)).isTrue(); 85 | assertThat(cache.hasService(XPathQueryService.class)).isTrue(); 86 | assertThat(cache.hasService(XQueryService.class)).isTrue(); 87 | assertThat(cache.hasService(UserPrincipalLookupService.class)).isFalse(); 88 | } 89 | 90 | @Test 91 | void testHasService() throws XMLDBException { 92 | verifyNoInteractions(collectionManagementServiceSupplier); 93 | assertThat(cache.hasService(CollectionManagementService.class)).isTrue(); 94 | assertThat(cache.hasService(XPathQueryService.class)).isTrue(); 95 | assertThat(cache.hasService(XQueryService.class)).isTrue(); 96 | assertThat(cache.hasService(UserPrincipalLookupService.class)).isFalse(); 97 | } 98 | 99 | @Test 100 | void testFindService() throws XMLDBException { 101 | when(collectionManagementServiceSupplier.get()).thenReturn(collectionManagementService); 102 | when(combinedQueryServiceProvider.get()).thenReturn(combinedQueryService); 103 | assertThat(cache.findService(CollectionManagementService.class)) 104 | .satisfies(s -> assertThat(s).contains(collectionManagementService)); 105 | assertThat(cache.findService(XPathQueryService.class)) 106 | .satisfies(s -> assertThat(s).contains(combinedQueryService)); 107 | assertThat(cache.findService(XQueryService.class)) 108 | .satisfies(s -> assertThat(s).contains(combinedQueryService)); 109 | assertThat(cache.findService(UserPrincipalLookupService.class)) 110 | .satisfies(s -> assertThat(s).isEmpty()); 111 | } 112 | 113 | @Test 114 | void testGetService() throws XMLDBException { 115 | when(collectionManagementServiceSupplier.get()).thenReturn(collectionManagementService); 116 | when(combinedQueryServiceProvider.get()).thenReturn(combinedQueryService); 117 | assertThat(cache.getService(CollectionManagementService.class)) 118 | .isEqualTo(collectionManagementService); 119 | assertThat(cache.getService(XPathQueryService.class)).isEqualTo(combinedQueryService); 120 | assertThat(cache.getService(XQueryService.class)).isEqualTo(combinedQueryService); 121 | assertThatExceptionOfType(XMLDBException.class) 122 | .isThrownBy(() -> cache.getService(UserPrincipalLookupService.class)).satisfies(e -> { 123 | assertThat(e.errorCode).isEqualTo(NO_SUCH_SERVICE); 124 | assertThat(e.vendorErrorCode).isZero(); 125 | }); 126 | } 127 | 128 | interface CombinedQueryService extends XPathQueryService, XQueryService { 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/XPathQueryService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.xmldb.api.base.ResourceSet; 43 | import org.xmldb.api.base.Service; 44 | import org.xmldb.api.base.XMLDBException; 45 | 46 | /** 47 | * XPathQueryService is a {@code Service} that enables the execution of XPath queries within the 48 | * context of a {@code Collection} or against a single XML {@code Resource} stored in the 49 | * {@code Collection}. 50 | */ 51 | public interface XPathQueryService extends Service { 52 | 53 | /** 54 | * Sets a namespace mapping in the internal namespace map used to evaluate queries. If 55 | * {@code prefix} is null or empty the default namespace is associated with the provided URI. A 56 | * null or empty {@code uri} results in an exception being thrown. 57 | * 58 | * @param prefix The prefix to set in the map. If {@code prefix} is empty or null the default 59 | * namespace will be associated with the provided URI. 60 | * @param uri The URI for the namespace to be associated with prefix. 61 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 62 | * vendor specific errors that occur. 63 | */ 64 | void setNamespace(String prefix, String uri) throws XMLDBException; 65 | 66 | /** 67 | * Returns the URI string associated with {@code prefix} from the internal namespace map. If 68 | * {@code prefix} is null or empty the URI for the default namespace will be returned. If a 69 | * mapping for the {@code prefix} can not be found null is returned. 70 | * 71 | * @param prefix The prefix to retrieve from the namespace map. 72 | * @return The URI associated with {@code prefix} 73 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 74 | * vendor specific errors that occur. 75 | */ 76 | String getNamespace(String prefix) throws XMLDBException; 77 | 78 | /** 79 | * Removes the namespace mapping associated with {@code prefix} from the internal namespace map. 80 | * If {@code prefix} is null or empty the mapping for the default namespace will be removed. 81 | * 82 | * @param prefix The prefix to remove from the namespace map. If {@code prefix} is null or empty 83 | * the mapping for the default namespace will be removed. 84 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 85 | * vendor specific errors that occur. 86 | */ 87 | void removeNamespace(String prefix) throws XMLDBException; 88 | 89 | /** 90 | * Removes all namespace mappings stored in the internal namespace map. 91 | * 92 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 93 | * vendor specific errors that occur. 94 | */ 95 | void clearNamespaces() throws XMLDBException; 96 | 97 | /** 98 | * Run an XPath query against the {@code Collection}. The XPath will be applied to all XML 99 | * resources stored in the {@code Collection}. The result is a {@code ResourceSet} containing the 100 | * results of the query. Any namespaces used in the {@code query} string will be evaluated using 101 | * the mappings setup using {@code setNamespace}. 102 | * 103 | * @param query The XPath query string to use. 104 | * @return A {@code ResourceSet} containing the results of the query. 105 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 106 | * vendor specific errors that occur. 107 | */ 108 | ResourceSet query(String query) throws XMLDBException; 109 | 110 | /** 111 | * Run an XPath query against an XML resource stored in the {@code Collection} associated with 112 | * this service. The result is a {@code ResourceSet} containing the results of the query. Any 113 | * namespaces used in the {@code query} string will be evaluated using the mappings setup using 114 | * {@code setNamespace}. 115 | * 116 | * @param query The XPath query string to use. 117 | * @param id The id of the document to run the query against. 118 | * @return A {@code ResourceSet} containing the results of the query. 119 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 120 | * vendor specific errors that occur. 121 | */ 122 | ResourceSet queryResource(String id, String query) throws XMLDBException; 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/ServiceProviderCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import java.util.ArrayList; 43 | import java.util.List; 44 | import java.util.Optional; 45 | import java.util.concurrent.locks.StampedLock; 46 | import java.util.function.Consumer; 47 | import java.util.function.Predicate; 48 | import java.util.function.Supplier; 49 | 50 | /** 51 | * Helper class responsible to lazy create {@link Service} implementations, based on the registered 52 | * on the {@link ProviderRegistry}. 53 | * 54 | * @since 2.0 55 | */ 56 | public final class ServiceProviderCache implements ServiceProvider { 57 | private final StampedLock lock; 58 | private final Consumer initializer; 59 | 60 | private List> providers; 61 | 62 | /** 63 | * Creates a new service provider cache instance with the given registry action being used, to 64 | * initialize all supported services, 65 | * 66 | * @param registry the registration action to define the supported services 67 | * @return the new service provider cache instance 68 | */ 69 | public static ServiceProviderCache withRegistered(Consumer registry) { 70 | return new ServiceProviderCache(registry); 71 | } 72 | 73 | private ServiceProviderCache(Consumer initializer) { 74 | lock = new StampedLock(); 75 | this.initializer = initializer; 76 | } 77 | 78 | private List> providers() { 79 | long stamp = lock.tryOptimisticRead(); 80 | if (stamp > 0 && lock.validate(stamp) && providers != null) { 81 | return providers; 82 | } 83 | // fallback to locking read 84 | stamp = lock.readLock(); 85 | try { 86 | if (providers != null) { 87 | return providers; 88 | } 89 | } finally { 90 | lock.unlockRead(stamp); 91 | } 92 | // create write lock to initialize values 93 | stamp = lock.writeLock(); 94 | try { 95 | providers = new ArrayList<>(); 96 | initializer.accept(this::addServiceCache); 97 | return providers; 98 | } finally { 99 | lock.unlockWrite(stamp); 100 | } 101 | } 102 | 103 | private void addServiceCache(Class serviceType, 104 | Supplier serviceSupplier) { 105 | providers.add(new ImplementationProvider<>(serviceType, serviceSupplier)); 106 | } 107 | 108 | /** 109 | * {@inheritDoc} 110 | */ 111 | @Override 112 | public boolean hasService(Class serviceType) { 113 | for (ImplementationProvider provider : providers()) { 114 | if (provider.test(serviceType)) { 115 | return true; 116 | } 117 | } 118 | return false; 119 | } 120 | 121 | /** 122 | * {@inheritDoc} 123 | */ 124 | @Override 125 | public Optional findService(Class serviceType) { 126 | for (ImplementationProvider provider : providers()) { 127 | if (provider.test(serviceType)) { 128 | return Optional.ofNullable(serviceType.cast(provider.instance())); 129 | } 130 | } 131 | return Optional.empty(); 132 | } 133 | 134 | static final class ImplementationProvider implements Predicate> { 135 | private final Class serviceType; 136 | private final Supplier serviceSupplier; 137 | 138 | ImplementationProvider(Class serviceType, Supplier serviceSupplier) { 139 | this.serviceType = serviceType; 140 | this.serviceSupplier = serviceSupplier; 141 | } 142 | 143 | @Override 144 | public boolean test(Class tested) { 145 | return serviceType.isAssignableFrom(tested); 146 | } 147 | 148 | S instance() { 149 | return serviceSupplier.get(); 150 | } 151 | } 152 | 153 | /** 154 | * Registry used to add available service providers. 155 | */ 156 | @FunctionalInterface 157 | public interface ProviderRegistry { 158 | /** 159 | * Registers a service provider for a given service type. 160 | * 161 | * @param the type of the service, extending {@code Service} 162 | * @param serviceType the class object representing the service type 163 | * @param serviceSupplier a supplier that provides instances of the service 164 | */ 165 | void add(Class serviceType, Supplier serviceSupplier); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/Database.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import java.util.Properties; 43 | 44 | /** 45 | * The interface that every XMLDB base class must implement. 46 | *

47 | * The {@code DatabaseManager} allows for multiple databases. 48 | * 49 | *

50 | * Each XMLDB should supply a class that implements the {@linkplain Database} interface. 51 | * 52 | *

53 | * The {@code DatabaseManager} will try to load as many drivers as it can find and then for any 54 | * given {@code Database} request, it will ask each {@code Database} in turn to try to connect to 55 | * the target URI. 56 | * 57 | *

58 | * It is strongly recommended that each {@code Database} class should be small and standalone so 59 | * that the {@code Database} class can be loaded and queried without bringing in vast quantities of 60 | * supporting code. 61 | * 62 | *

63 | * When a {@code Database} class is loaded, it should create an instance of itself and register it 64 | * with the {@code DatabaseManager}. This means that a user can load and register a driver by 65 | * calling: 66 | *

67 | * {@code Class.forName("foo.bah.Database")} 68 | *

69 | * A {@code Database} may create a {@linkplain DatabaseAction} implementation in order to receive 70 | * notifications when {@linkplain org.xmldb.api.DatabaseManager#deregisterDatabase} has been called. 71 | */ 72 | public interface Database extends Configurable { 73 | /** 74 | * Returns the name associated with the Database instance. 75 | * 76 | * @return the name of the object. 77 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 78 | * vendor specific errors that occur. 79 | */ 80 | String getName() throws XMLDBException; 81 | 82 | /** 83 | * Attempts to make a connection to the given database URI and return its root {@code Collection}. 84 | * The {@code Database} should return "null" if it realizes it is the wrong kind of driver to 85 | * connect to the given URI. This will be common, as when the {@code DatabaseManager} is asked to 86 | * connect to a given URI it passes the URI to each loaded database in turn. 87 | *

88 | * The driver should throw an {@code XMLDBException} if it is the right database to connect for 89 | * the given URI but has trouble connecting to the database. 90 | *

91 | * The {@code Properties} argument can be used to pass arbitrary string tag/value pairs as 92 | * connection arguments. Normally at least "user" and "password" properties should be included in 93 | * the {@code Properties} object. 94 | *

95 | * Note: If a property is specified as part of the {@code uri} and is also specified in the 96 | * {@code Properties} object, it is implementation-defined as to which value will take precedence. 97 | * For maximum portability, an application should only specify a property once. 98 | * 99 | * @param uri the URI of the database to which to connect and return the root collection 100 | * @param info a list of arbitrary string tag/value pairs as connection arguments. Normally at 101 | * least a "user" and "password" property should be included. 102 | * @return a {@code Collection} object that represents a connection to the URI 103 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 104 | * vendor specific errors that occur. {@link ErrorCodes#INVALID_URI} If the URI is not in 105 | * a valid format. {@link ErrorCodes#PERMISSION_DENIED} If the {@code username} and 106 | * {@code password} were not accepted by the database. 107 | * @since 3.0 108 | */ 109 | Collection getCollection(String uri, Properties info) throws XMLDBException; 110 | 111 | /** 112 | * acceptsURI determines whether this {@link Database} implementation can handle the URI. It 113 | * should return {@code true} if the Database instance knows how to handle the URI and 114 | * {@code false} otherwise. 115 | * 116 | * @param uri the URI to check for. 117 | * @return {@code true} if the URI can be handled, {@code false} otherwise. 118 | */ 119 | boolean acceptsURI(String uri); 120 | 121 | /** 122 | * Returns the XML:DB API Conformance level for the implementation. This can be used by client 123 | * programs to determine what functionality is available to them. 124 | * 125 | * @return the XML:DB API conformance level for this implementation. 126 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 127 | * vendor specific errors that occur. 128 | */ 129 | String getConformanceLevel() throws XMLDBException; 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/Resource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import java.io.OutputStream; 43 | import java.time.Instant; 44 | 45 | /** 46 | * The Resource interface represents an abstract encapsulation of a resource within a collection, 47 | * providing methods to interact with the resource's content and metadata. Resources can store 48 | * various types of data (e.g., XML, binary blobs) and are always associated with a specific 49 | * collection. 50 | * 51 | * @param the type of the resource content managed by this interface. 52 | */ 53 | public interface Resource extends AutoCloseable { 54 | 55 | /** 56 | * Returns the resource type for this Resource. 57 | * 58 | * XML:DB defined resource types are: XMLResource - all XML data stored in the database 59 | * BinaryResource - Binary blob data stored in the database 60 | * 61 | * @return the resource type for the Resource. 62 | */ 63 | ResourceType getResourceType(); 64 | 65 | /** 66 | * Returns the {@code Collection} instance that this resource is associated with. All resources 67 | * must exist within the context of a {@code collection}. 68 | * 69 | * @return the collection associated with the resource. 70 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 71 | * vendor specific errors that occur. 72 | */ 73 | Collection getParentCollection() throws XMLDBException; 74 | 75 | /** 76 | * Returns the unique id for this {@code Resource} or null if the {@code Resource} is anonymous. 77 | * The {@code Resource} will be anonymous if it is obtained as the result of a query. 78 | * 79 | * @return the id for the Resource or null if no id exists. 80 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 81 | * vendor specific errors that occur. 82 | */ 83 | String getId() throws XMLDBException; 84 | 85 | /** 86 | * Retrieves the content from the resource. The type of the content varies depending what type of 87 | * resource is being used. 88 | * 89 | * @return the content of the resource. 90 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 91 | * vendor specific errors that occur. 92 | */ 93 | T getContent() throws XMLDBException; 94 | 95 | /** 96 | * Retrieves the content from the resource. The type of the content varies depending what type of 97 | * resource is being used. 98 | * 99 | * @param stream the output stream to write the resource content to 100 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 101 | * vendor specific errors that occur. 102 | */ 103 | void getContentAsStream(OutputStream stream) throws XMLDBException; 104 | 105 | /** 106 | * Sets the content for this resource. The type of content that can be set depends on the type of 107 | * resource being used. 108 | * 109 | * @param value the content value to set for the resource. 110 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 111 | * vendor specific errors that occur. 112 | */ 113 | void setContent(T value) throws XMLDBException; 114 | 115 | /** 116 | * Returns whenever the current resource has been closed or not. 117 | * 118 | * @return {@code true} when the resource has been closed, {@code false} otherwise. 119 | */ 120 | boolean isClosed(); 121 | 122 | /** 123 | * Releases all resources consumed by the {@code Resource}. The {@code close} method must always 124 | * be called when use of a {@code Resource} is complete. It is not safe to use a {@code Resource} 125 | * after the {@code close} method has been called. 126 | * 127 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 128 | * vendor specific errors that occur. 129 | */ 130 | @Override 131 | void close() throws XMLDBException; 132 | 133 | /** 134 | * Returns the time of creation of the resource. 135 | * 136 | * @return the creation date of the current resource 137 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 138 | * vendor specific errors that occur. 139 | */ 140 | Instant getCreationTime() throws XMLDBException; 141 | 142 | /** 143 | * Returns the time of last modification of the resource. 144 | * 145 | * @return the last modification date of the current resource 146 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 147 | * vendor specific errors that occur. 148 | */ 149 | Instant getLastModificationTime() throws XMLDBException; 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/ResourceSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | /** 43 | * ResourceSet is a container for a set of resources. Generally a {@code ResourceSet} is obtained as 44 | * the result of a query. 45 | */ 46 | public interface ResourceSet extends AutoCloseable { 47 | /** 48 | * Returns the {@code Resource} instance stored at the index specified by index. 49 | * 50 | * If the underlying implementation uses a paging or streaming optimization for retrieving 51 | * Resource instances. Calling this method MAY result in a block until the requested Resource has 52 | * been downloaded. 53 | * 54 | * @param index the index of the resource to retrieve. 55 | * @return The {@code Resource} instance 56 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 57 | * vendor specific errors that occur. {@link ErrorCodes#NO_SUCH_RESOURCE} if the index is 58 | * out of range for the set. 59 | */ 60 | Resource getResource(long index) throws XMLDBException; 61 | 62 | /** 63 | * Adds a {@code Resource} instance to the set. 64 | * 65 | * @param res The {@code Resource} to add to the set. 66 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 67 | * vendor specific errors that occur. 68 | */ 69 | void addResource(Resource res) throws XMLDBException; 70 | 71 | /** 72 | * Adds all {@code Resource} instances in the resourceSet to this set. 73 | * 74 | * @param rSet The {@code ResourceSet} containing all the {@code Resource}'s to add to the set. 75 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 76 | * vendor specific errors that occur. 77 | */ 78 | void addAll(ResourceSet rSet) throws XMLDBException; 79 | 80 | 81 | /** 82 | * Removes the Resource located at {@code index} from the set. 83 | * 84 | * @param index The index of the {@code Resource} instance to remove. 85 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 86 | * vendor specific errors that occur. 87 | */ 88 | void removeResource(long index) throws XMLDBException; 89 | 90 | /** 91 | * Returns an iterator over all {@code Resource} instances stored in the set. 92 | * 93 | * @return a {@code ResourceIterator} over all {@code Resource} instances in the set. 94 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 95 | * vendor specific errors that occur. 96 | */ 97 | ResourceIterator getIterator() throws XMLDBException; 98 | 99 | /** 100 | * Returns a Resource containing an XML representation of all resources stored in the set. 101 | * 102 | * @return A {@code Resource} instance containing an XML representation of all set members. 103 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 104 | * vendor specific errors that occur. 105 | */ 106 | Resource getMembersAsResource() throws XMLDBException; 107 | 108 | /** 109 | * Returns the number of resources contained in the set. 110 | * 111 | * If the underlying implementation uses a paging or streaming optimization for retrieving 112 | * {@code Resource} instances. Calling this method MAY force the downloading of all set members 113 | * before the size can be determined. 114 | * 115 | * @return The number of {@code Resource} instances in the set. 116 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 117 | * vendor specific errors that occur. 118 | */ 119 | long getSize() throws XMLDBException; 120 | 121 | /** 122 | * Removes all {@code Resource} instances from the set. 123 | * 124 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 125 | * vendor specific errors that occur. 126 | */ 127 | void clear() throws XMLDBException; 128 | 129 | /** 130 | * Returns whenever the current resource has been closed or not. 131 | * 132 | * @return {@code true} when the resource has been closed, {@code false} otherwise. 133 | * @since 3.0 134 | */ 135 | boolean isClosed(); 136 | 137 | /** 138 | * Releases all resources consumed by the {@code ResourceSet}. The {@code close} method must 139 | * always be called when use of a {@code ResourceSet} is complete. It is not safe to use a 140 | * {@code ResourceSet} after the {@code close} method has been called. 141 | * 142 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 143 | * vendor specific errors that occur. 144 | * @since 3.0 145 | */ 146 | @Override 147 | void close() throws XMLDBException; 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/modules/XMLResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.modules; 41 | 42 | import org.w3c.dom.Node; 43 | import org.xml.sax.ContentHandler; 44 | import org.xml.sax.SAXNotRecognizedException; 45 | import org.xml.sax.SAXNotSupportedException; 46 | import org.xml.sax.XMLReader; 47 | import org.xmldb.api.base.Resource; 48 | import org.xmldb.api.base.ResourceType; 49 | import org.xmldb.api.base.XMLDBException; 50 | 51 | /** 52 | * Provides access to XML resources stored in the database. An XMLResource can be accessed either as 53 | * text XML or via the DOM or SAX APIs. 54 | * 55 | * The default behavior for getContent and setContent is to work with XML data as text so these 56 | * methods work on {@code String} content. 57 | */ 58 | public interface XMLResource extends Resource { 59 | 60 | @Override 61 | default ResourceType getResourceType() { 62 | return ResourceType.XML_RESOURCE; 63 | } 64 | 65 | /** 66 | * Returns the unique id for the parent document to this {@code Resource} or null if the 67 | * {@code Resource} does not have a parent document. {@code getDocumentId()} is typically used 68 | * with {@code Resource} instances retrieved using a query. It enables accessing the parent 69 | * document of the {@code Resource} even if the {@code Resource} is a child node of the document. 70 | * If the {@code Resource} was not obtained through a query then {@code getId()} and 71 | * {@code getDocumentId()} will return the same id. 72 | * 73 | * @return the id for the parent document of this {@code Resource} or null if there is no parent 74 | * document for this {@code Resource}. 75 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 76 | * vendor specific errors that occur. 77 | */ 78 | String getDocumentId() throws XMLDBException; 79 | 80 | /** 81 | * Returns the content of the {@code Resource} as a DOM Node. 82 | * 83 | * @return The XML content as a DOM {@code Node} 84 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 85 | * vendor specific errors that occur. 86 | */ 87 | Node getContentAsDOM() throws XMLDBException; 88 | 89 | /** 90 | * Sets the content of the {@code Resource} using a DOM Node as the source. 91 | * 92 | * @param content The new content value 93 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 94 | * vendor specific errors that occur. {@code ErrorCodes.INVALID_RESOURCE} if the content 95 | * value provided is null. {@code ErrorCodes.WRONG_CONTENT_TYPE} if the content provided 96 | * in not a valid DOM {@code Node}. 97 | */ 98 | void setContentAsDOM(Node content) throws XMLDBException; 99 | 100 | /** 101 | * Allows you to use a {@code ContentHandler} to parse the XML data from the database for use in 102 | * an application. 103 | * 104 | * @param handler the SAX {@code ContentHandler} to use to handle the {@code Resource} content. 105 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 106 | * vendor specific errors that occur. {@code ErrorCodes.INVALID_RESOURCE} if the 107 | * {@code ContentHandler} provided is null. 108 | */ 109 | void getContentAsSAX(ContentHandler handler) throws XMLDBException; 110 | 111 | /** 112 | * Sets the content of the {@code Resource} using a SAX {@code ContentHandler}. 113 | * 114 | * @return a SAX {@code ContentHandler} that can be used to add content into the {@code Resource}. 115 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 116 | * vendor specific errors that occur. 117 | */ 118 | ContentHandler setContentAsSAX() throws XMLDBException; 119 | 120 | /** 121 | * Sets a SAX feature that will be used when this {@code XMLResource} is used to produce SAX 122 | * events (through the getContentAsSAX() method) 123 | * 124 | * @param feature Feature name. Standard SAX feature names are documented at 125 | * http://sax.sourceforge.net/. 126 | * @param value Set or unset feature 127 | * @throws SAXNotRecognizedException if the feature is not recognized. 128 | * @throws SAXNotSupportedException if the feature is not supported. 129 | */ 130 | void setSAXFeature(String feature, boolean value) 131 | throws SAXNotRecognizedException, SAXNotSupportedException; 132 | 133 | /** 134 | * Returns current setting of a SAX feature that will be used when this {@code XMLResource} is 135 | * used to produce SAX events (through the getContentAsSAX() method) 136 | * 137 | * @param feature Feature name. Standard SAX feature names are documented at 138 | * http://sax.sourceforge.net/. 139 | * @return whether the feature is set 140 | * @throws SAXNotRecognizedException if the feature is not recognized. 141 | * @throws SAXNotSupportedException if the feature is not supported. 142 | */ 143 | boolean getSAXFeature(String feature) throws SAXNotRecognizedException, SAXNotSupportedException; 144 | 145 | /** 146 | * Sets the external XMLReader to use when doing content handler operations. 147 | * 148 | * @param xmlReader the XMLReader 149 | */ 150 | void setXMLReader(XMLReader xmlReader); 151 | } 152 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/security/PermissionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.security; 41 | 42 | import static org.assertj.core.api.Assertions.*; 43 | import static org.xmldb.api.security.Permission.GROUP_EXECUTE; 44 | import static org.xmldb.api.security.Permission.GROUP_READ; 45 | import static org.xmldb.api.security.Permission.GROUP_WRITE; 46 | import static org.xmldb.api.security.Permission.OTHERS_EXECUTE; 47 | import static org.xmldb.api.security.Permission.OTHERS_READ; 48 | import static org.xmldb.api.security.Permission.OTHERS_WRITE; 49 | import static org.xmldb.api.security.Permission.OWNER_EXECUTE; 50 | import static org.xmldb.api.security.Permission.OWNER_READ; 51 | import static org.xmldb.api.security.Permission.OWNER_WRITE; 52 | import static org.xmldb.api.security.Permission.SET_GID; 53 | import static org.xmldb.api.security.Permission.SET_UID; 54 | import static org.xmldb.api.security.Permission.STICKY_BIT; 55 | import static org.xmldb.api.security.Permissions.fromModeString; 56 | import static org.xmldb.api.security.Permissions.fromOctal; 57 | 58 | import org.junit.jupiter.api.Test; 59 | 60 | class PermissionsTest { 61 | 62 | @Test 63 | void fromModeUnixSymbolicAddAll() { 64 | assertThat(fromModeString("a+rwxst")).containsExactly(Permission.values()); 65 | assertThat(fromModeString("+rwxst")).containsExactly(Permission.values()); 66 | assertThat(fromModeString("+r")).containsExactly(OWNER_READ, GROUP_READ, OTHERS_READ); 67 | assertThat(fromModeString("+w")).containsExactly(OWNER_WRITE, GROUP_WRITE, OTHERS_WRITE); 68 | assertThat(fromModeString("+x")).containsExactly(OWNER_EXECUTE, GROUP_EXECUTE, OTHERS_EXECUTE); 69 | } 70 | 71 | @Test 72 | void fromModeUnixSymbolicSetAll() { 73 | assertThat(fromModeString("a=rwxst")).containsExactly(Permission.values()); 74 | assertThat(fromModeString("=rwxst")).containsExactly(Permission.values()); 75 | assertThat(fromModeString("=s")).containsExactly(SET_UID, SET_GID); 76 | assertThat(fromModeString("=t")).containsExactly(STICKY_BIT); 77 | } 78 | 79 | @Test 80 | void fromModeUnixSymbolicRemoveAll() { 81 | assertThat(fromModeString("a-rwxst")).isEmpty(); 82 | assertThat(fromModeString("-rwxst")).isEmpty(); 83 | } 84 | 85 | @Test 86 | void fromModeUnixSymbolicUser() { 87 | assertThat(fromModeString("u=rwx")).containsExactly(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE); 88 | assertThat(fromModeString("u+st")).containsExactly(SET_UID); 89 | assertThat(fromModeString("u-r")).isEmpty(); 90 | } 91 | 92 | @Test 93 | void fromModeUnixSymbolicGroup() { 94 | assertThat(fromModeString("g+rwx")).containsExactly(GROUP_READ, GROUP_WRITE, GROUP_EXECUTE); 95 | assertThat(fromModeString("g=st")).containsExactly(SET_GID); 96 | assertThat(fromModeString("g-w")).isEmpty(); 97 | } 98 | 99 | @Test 100 | void fromModeUnixSymbolicOthers() { 101 | assertThat(fromModeString("o=rwx")).containsExactly(OTHERS_READ, OTHERS_WRITE, OTHERS_EXECUTE); 102 | assertThat(fromModeString("o+st")).containsExactly(STICKY_BIT); 103 | assertThat(fromModeString("o-x")).isEmpty(); 104 | } 105 | 106 | @Test 107 | void fromModeUnixSymbolicUnkownMode() { 108 | assertThatExceptionOfType(IllegalArgumentException.class) 109 | .isThrownBy(() -> fromModeString("a=T")); 110 | } 111 | 112 | @Test 113 | void fromModeSimpleSymbolicNone() { 114 | assertThat(fromModeString("---------")).isEmpty(); 115 | } 116 | 117 | @Test 118 | void fromModeSimpleSymbolicUser() { 119 | assertThat(fromModeString("rwx------")).containsExactly(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE); 120 | assertThat(fromModeString("--S------")).containsExactly(SET_UID); 121 | assertThat(fromModeString("--s------")).containsExactly(OWNER_EXECUTE, SET_UID); 122 | } 123 | 124 | @Test 125 | void fromModeSimpleSymbolicGroup() { 126 | assertThat(fromModeString("---rwx---")).containsExactly(GROUP_READ, GROUP_WRITE, GROUP_EXECUTE); 127 | assertThat(fromModeString("-----S---")).containsExactly(SET_GID); 128 | assertThat(fromModeString("-----s---")).containsExactly(GROUP_EXECUTE, SET_GID); 129 | } 130 | 131 | @Test 132 | void fromModeSimpleSymbolicOthers() { 133 | assertThat(fromModeString("------rwx")).containsExactly(OTHERS_READ, OTHERS_WRITE, 134 | OTHERS_EXECUTE); 135 | assertThat(fromModeString("--------T")).containsExactly(STICKY_BIT); 136 | assertThat(fromModeString("--------t")).containsExactly(OTHERS_EXECUTE, STICKY_BIT); 137 | } 138 | 139 | @Test 140 | void fromModeStringFailureCases() { 141 | assertThatIllegalArgumentException().isThrownBy(() -> fromModeString("u+q")); 142 | } 143 | 144 | @Test 145 | void fromOctalMode() { 146 | assertThat(fromOctal(0700)).containsExactly(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE); 147 | assertThat(fromOctal(04000)).containsExactly(SET_UID); 148 | assertThat(fromOctal(04100)).containsExactly(OWNER_EXECUTE, SET_UID); 149 | 150 | assertThat(fromOctal(0070)).containsExactly(GROUP_READ, GROUP_WRITE, GROUP_EXECUTE); 151 | assertThat(fromOctal(02000)).containsExactly(SET_GID); 152 | assertThat(fromOctal(02010)).containsExactly(GROUP_EXECUTE, SET_GID); 153 | 154 | assertThat(fromOctal(0007)).containsExactly(OTHERS_READ, OTHERS_WRITE, OTHERS_EXECUTE); 155 | assertThat(fromOctal(01000)).containsExactly(STICKY_BIT); 156 | assertThat(fromOctal(01001)).containsExactly(OTHERS_EXECUTE, STICKY_BIT); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/test/java/org/xmldb/api/base/XMLDBExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The XML:DB Initiative Software License, Version 1.0 3 | * 4 | * Copyright (c) 2000-2025 The XML:DB Initiative. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted 7 | * provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions 10 | * and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 13 | * conditions and the following disclaimer in the documentation and/or other materials provided with 14 | * the distribution. 15 | * 16 | * 3. The end-user documentation included with the redistribution, if any, must include the 17 | * following acknowledgment: "This product includes software developed by the XML:DB Initiative 18 | * (http://www.xmldb.org/)." Alternately, this acknowledgment may appear in the software itself, if 19 | * and wherever such third-party acknowledgments normally appear. 20 | * 21 | * 4. The name "XML:DB Initiative" must not be used to endorse or promote products derived from this 22 | * software without prior written permission. For written permission, please contact info@xmldb.org. 23 | * 24 | * 5. Products derived from this software may not be called "XML:DB", nor may "XML:DB" appear in 25 | * their name, without prior written permission of the XML:DB Initiative. 26 | * 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * ================================================================================================= 36 | * This software consists of voluntary contributions made by many individuals on behalf of the 37 | * XML:DB Initiative. For more information on the XML:DB Initiative, please see 38 | * 39 | */ 40 | package org.xmldb.api.base; 41 | 42 | import static org.assertj.core.api.Assertions.assertThat; 43 | import static org.xmldb.api.base.ErrorCodes.COLLECTION_CLOSED; 44 | import static org.xmldb.api.base.ErrorCodes.INVALID_COLLECTION; 45 | import static org.xmldb.api.base.ErrorCodes.INVALID_DATABASE; 46 | import static org.xmldb.api.base.ErrorCodes.INVALID_RESOURCE; 47 | import static org.xmldb.api.base.ErrorCodes.INVALID_URI; 48 | import static org.xmldb.api.base.ErrorCodes.NOT_IMPLEMENTED; 49 | import static org.xmldb.api.base.ErrorCodes.NO_SUCH_DATABASE; 50 | import static org.xmldb.api.base.ErrorCodes.PERMISSION_DENIED; 51 | import static org.xmldb.api.base.ErrorCodes.UNKNOWN_ERROR; 52 | 53 | import java.io.IOException; 54 | 55 | import org.junit.jupiter.api.Test; 56 | import org.junit.jupiter.params.ParameterizedTest; 57 | import org.junit.jupiter.params.provider.CsvSource; 58 | 59 | /** 60 | * Tests the {@link XMLDBException} 61 | */ 62 | class XMLDBExceptionTest { 63 | 64 | @Test 65 | void testXMLDBException() { 66 | XMLDBException ex = new XMLDBException(); 67 | assertThat(ex).hasMessage("Unknown error").satisfies(e -> { 68 | assertThat(e.errorCode).isEqualTo(UNKNOWN_ERROR); 69 | assertThat(e.vendorErrorCode).isZero(); 70 | }); 71 | } 72 | 73 | @Test 74 | void testXMLDBExceptionInt() { 75 | XMLDBException ex = new XMLDBException(COLLECTION_CLOSED); 76 | assertThat(ex).hasMessage("Collection closed").satisfies(e -> { 77 | assertThat(e.errorCode).isEqualTo(COLLECTION_CLOSED); 78 | assertThat(e.vendorErrorCode).isZero(); 79 | }); 80 | } 81 | 82 | @Test 83 | void testXMLDBExceptionIntString() { 84 | XMLDBException ex = new XMLDBException(INVALID_COLLECTION, "message 1"); 85 | assertThat(ex).hasMessage("message 1").satisfies(e -> { 86 | assertThat(e.errorCode).isEqualTo(INVALID_COLLECTION); 87 | assertThat(e.vendorErrorCode).isZero(); 88 | }); 89 | } 90 | 91 | @Test 92 | void testXMLDBExceptionIntInt() { 93 | XMLDBException ex = new XMLDBException(INVALID_DATABASE, 123); 94 | assertThat(ex).hasMessage("Invalid database").satisfies(e -> { 95 | assertThat(e.errorCode).isEqualTo(INVALID_DATABASE); 96 | assertThat(e.vendorErrorCode).isEqualTo(123); 97 | }); 98 | } 99 | 100 | @Test 101 | void testXMLDBExceptionIntIntString() { 102 | XMLDBException ex = new XMLDBException(INVALID_RESOURCE, 234, "message 2"); 103 | assertThat(ex).hasMessage("message 2").satisfies(e -> { 104 | assertThat(e.errorCode).isEqualTo(INVALID_RESOURCE); 105 | assertThat(e.vendorErrorCode).isEqualTo(234); 106 | }); 107 | } 108 | 109 | @Test 110 | void testXMLDBExceptionIntThrowable() { 111 | Throwable cause = new IOException("error 1"); 112 | XMLDBException ex = new XMLDBException(NOT_IMPLEMENTED, cause); 113 | assertThat(ex).hasMessage("Not implemented").hasCause(cause).satisfies(e -> { 114 | assertThat(e.errorCode).isEqualTo(NOT_IMPLEMENTED); 115 | assertThat(e.vendorErrorCode).isZero(); 116 | }); 117 | } 118 | 119 | @Test 120 | void testXMLDBExceptionIntStringThrowable() { 121 | Throwable cause = new IOException("error 2"); 122 | XMLDBException ex = new XMLDBException(INVALID_URI, "message 3", cause); 123 | assertThat(ex).hasMessage("message 3").hasCause(cause).satisfies(e -> { 124 | assertThat(e.errorCode).isEqualTo(INVALID_URI); 125 | assertThat(e.vendorErrorCode).isZero(); 126 | }); 127 | } 128 | 129 | @Test 130 | void testXMLDBExceptionIntIntThrowable() { 131 | Throwable cause = new IOException("error 3"); 132 | XMLDBException ex = new XMLDBException(NO_SUCH_DATABASE, 345, cause); 133 | assertThat(ex).hasMessage("No such database").hasCause(cause).satisfies(e -> { 134 | assertThat(e.errorCode).isEqualTo(NO_SUCH_DATABASE); 135 | assertThat(e.vendorErrorCode).isEqualTo(345); 136 | }); 137 | } 138 | 139 | @Test 140 | void testXMLDBExceptionIntIntStringThrowable() { 141 | Throwable cause = new IOException("error 3"); 142 | XMLDBException ex = new XMLDBException(PERMISSION_DENIED, 456, "message 4", cause); 143 | assertThat(ex).hasMessage("message 4").hasCause(cause).satisfies(e -> { 144 | assertThat(e.errorCode).isEqualTo(PERMISSION_DENIED); 145 | assertThat(e.vendorErrorCode).isEqualTo(456); 146 | }); 147 | } 148 | 149 | @ParameterizedTest 150 | @CsvSource(textBlock = """ 151 | -1, Unknown error code: -1 152 | 0, Unknown error 153 | 1, Vendor error: 4711 154 | 2, Not implemented 155 | 3, Wrong content type 156 | 4, Permission denied 157 | 5, Invalid URI 158 | 100, No such service 159 | 200, No such collection 160 | 201, Invalid collection 161 | 202, Collection closed 162 | 300, No such resource 163 | 301, Invalid resource 164 | 302, Unknown resource type 165 | 400, No such database 166 | 401, Invalid database 167 | 402, Instance name already registered 168 | """) 169 | void testMessageFromErrorCode(final int errorCode, final String expectedMessage) { 170 | XMLDBException ex = new XMLDBException(errorCode, 4711); 171 | assertThat(ex).hasMessage(expectedMessage).satisfies(e -> { 172 | assertThat(e.errorCode).isEqualTo(errorCode); 173 | assertThat(e.vendorErrorCode).isEqualTo(4711); 174 | }); 175 | } 176 | } 177 | --------------------------------------------------------------------------------