├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── gradle.yml ├── .gitignore ├── AUTHORS ├── LICENSE ├── README.adoc ├── benchmarks ├── build.gradle ├── gradle.properties ├── gradle ├── LICENSE_HEADER ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── xmldb-api-style.xml └── xmldb-api.importorder ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── jmh └── java │ └── org │ └── xmldb │ └── api │ ├── DatabaseManagerBenchmark.java │ ├── DatabaseState.java │ └── RegistedDatabaseState.java ├── main └── java │ └── org │ └── xmldb │ └── api │ ├── DatabaseManager.java │ ├── base │ ├── Collection.java │ ├── CompiledExpression.java │ ├── Configurable.java │ ├── Database.java │ ├── DatabaseAction.java │ ├── ErrorCodes.java │ ├── Identifier.java │ ├── Resource.java │ ├── ResourceIterator.java │ ├── ResourceSet.java │ ├── ResourceType.java │ ├── Service.java │ ├── ServiceProvider.java │ ├── ServiceProviderCache.java │ ├── XMLDBException.java │ └── package-info.java │ ├── modules │ ├── BinaryResource.java │ ├── CollectionManagementService.java │ ├── DatabaseInstanceService.java │ ├── TransactionService.java │ ├── XMLResource.java │ ├── XPathQueryService.java │ ├── XQueryService.java │ ├── XUpdateQueryService.java │ └── package-info.java │ ├── package-info.java │ └── security │ ├── AccountPrincipal.java │ ├── AclEntry.java │ ├── AclEntryFlag.java │ ├── AclEntryPermission.java │ ├── AclEntryType.java │ ├── Attributes.java │ ├── GroupPrincipal.java │ ├── Permission.java │ ├── PermissionManagementService.java │ ├── Permissions.java │ ├── UserPrincipal.java │ ├── UserPrincipalLookupService.java │ └── package-info.java ├── test └── java │ └── org │ └── xmldb │ └── api │ ├── DatabaseManagerTest.java │ ├── base │ ├── ResourceIteratorTest.java │ ├── ResourceTypeTest.java │ ├── ServiceProviderCacheTest.java │ └── XMLDBExceptionTest.java │ ├── modules │ ├── BinaryResourceTest.java │ └── XMLResourceTest.java │ └── security │ ├── AclEntryFlagTest.java │ ├── AclEntryPermissionTest.java │ ├── AclEntryTest.java │ ├── AclEntryTypeTest.java │ └── PermissionsTest.java └── testFixtures └── java └── org └── xmldb └── api ├── ConfigurableImpl.java ├── TestBaseResource.java ├── TestBinaryResource.java ├── TestCollection.java ├── TestCollectionData.java ├── TestDatabase.java ├── TestResourceIterator.java └── TestXMLResource.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: reinhapa 2 | patreon: reinhapa 3 | liberapay: reinhapa 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "gradle" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" 11 | -------------------------------------------------------------------------------- /.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 ] 10 | pull_request: 11 | branches: [ main ] 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@v4 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', '22'] 31 | os: [ubuntu-latest] 32 | steps: 33 | - uses: actions/checkout@v4 34 | with: 35 | fetch-depth: 0 36 | - name: Set up JDK ${{ matrix.jdk }} 37 | uses: actions/setup-java@v4 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@v4 58 | with: 59 | fetch-depth: 0 60 | - name: Set up JDK 61 | uses: actions/setup-java@v4 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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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://oss.sonatype.org/content/repositories/snapshots/net/sf/xmldb-org/xmldb-api/[https://oss.sonatype.org/content/repositories/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] -------------------------------------------------------------------------------- /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.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 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmldb-org/xmldb-api/de483640425c0e8ddbfb06046f03153149f72e66/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 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 | -------------------------------------------------------------------------------- /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 '0.19.2' 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/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(RegistedDatabaseState state) throws XMLDBException { 57 | DatabaseManager.registerDatabase(state.database); 58 | } 59 | 60 | @Benchmark 61 | public void getCollection(RegistedDatabaseState state, Blackhole bh) throws XMLDBException { 62 | bh.consume(DatabaseManager.getCollection("xmldb:testdatabase:testcollection")); 63 | } 64 | 65 | @Benchmark 66 | public void deregisterDatabase(RegistedDatabaseState state) throws XMLDBException { 67 | DatabaseManager.deregisterDatabase(state.database); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /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/jmh/java/org/xmldb/api/RegistedDatabaseState.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.xmldb.api.base.XMLDBException; 47 | 48 | @State(Scope.Benchmark) 49 | public class RegistedDatabaseState extends DatabaseState { 50 | TestCollection collection; 51 | 52 | @Override 53 | @Setup(Level.Trial) 54 | public void up() throws XMLDBException { 55 | super.up(); 56 | collection = database.addCollection("testdatabase:testcollection"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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/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 | public interface DatabaseAction { 45 | /** 46 | * Method called by {@linkplain DatabaseManager#deregisterDatabase(Database) } to notify the 47 | * Database that it was de-registered. 48 | *

49 | * The {@code deregister} method is intended only to be used by database and not by applications. 50 | * Databases are recommended to not implement {@code DatabaseAction} in a public class. If there 51 | * are active connections to the database at the time that the {@code deregister} method is 52 | * called, it is implementation specific as to whether the connections are closed or allowed to 53 | * continue. Once this method is called, it is implementation specific as to whether the database 54 | * may limit the ability to open collections of a database, invoke other {@code Database} methods 55 | * or throw a {@code XMLDBException}. Consult your database's documentation for additional 56 | * information on its behavior. 57 | * 58 | * @see DatabaseManager#registerDatabase(Database, DatabaseAction) 59 | * @see DatabaseManager#deregisterDatabase(Database) 60 | * @since 3 61 | */ 62 | void deregister(); 63 | } 64 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | * {@code Resource} is a container for data stored within the database. Raw resources are not 47 | * particulary useful. It is necessary to have a resource implementation that provides handling for 48 | * a specific content type before anything useful can be done. 49 | */ 50 | public interface Resource extends AutoCloseable { 51 | 52 | /** 53 | * Returns the resource type for this Resource. 54 | * 55 | * XML:DB defined resource types are: XMLResource - all XML data stored in the database 56 | * BinaryResource - Binary blob data stored in the database 57 | * 58 | * @return the resource type for the Resource. 59 | */ 60 | ResourceType getResourceType(); 61 | 62 | /** 63 | * Returns the {@code Collection} instance that this resource is associated with. All resources 64 | * must exist within the context of a {@code collection}. 65 | * 66 | * @return the collection associated with the resource. 67 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 68 | * vendor specific errors that occur. 69 | */ 70 | Collection getParentCollection() throws XMLDBException; 71 | 72 | /** 73 | * Returns the unique id for this {@code Resource} or null if the {@code Resource} is anonymous. 74 | * The {@code Resource} will be anonymous if it is obtained as the result of a query. 75 | * 76 | * @return the id for the Resource or null if no id exists. 77 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 78 | * vendor specific errors that occur. 79 | */ 80 | String getId() throws XMLDBException; 81 | 82 | /** 83 | * Retrieves the content from the resource. The type of the content varies depending what type of 84 | * resource is being used. 85 | * 86 | * @return the content of the resource. 87 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 88 | * vendor specific errors that occur. 89 | */ 90 | Object getContent() throws XMLDBException; 91 | 92 | /** 93 | * Retrieves the content from the resource. The type of the content varies depending what type of 94 | * resource is being used. 95 | * 96 | * @param stream the output stream to write the resource content to 97 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 98 | * vendor specific errors that occur. 99 | */ 100 | void getContentAsStream(OutputStream stream) throws XMLDBException; 101 | 102 | /** 103 | * Sets the content for this resource. The type of content that can be set depends on the type of 104 | * resource being used. 105 | * 106 | * @param value the content value to set for the resource. 107 | * @throws XMLDBException with expected error codes. {@code ErrorCodes.VENDOR_ERROR} for any 108 | * vendor specific errors that occur. 109 | */ 110 | void setContent(Object value) throws XMLDBException; 111 | 112 | /** 113 | * Returns whenever the current resource has been closed or not. 114 | * 115 | * @return {@code true} when the resource has been closed, {@code false} otherwise. 116 | */ 117 | boolean isClosed(); 118 | 119 | /** 120 | * Releases all resources consumed by the {@code Resource}. The {@code close} method must always 121 | * be called when use of a {@code Resource} is complete. It is not safe to use a {@code Resource} 122 | * after the {@code close} method has been called. 123 | * 124 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 125 | * vendor specific errors that occur. 126 | */ 127 | @Override 128 | void close() throws XMLDBException; 129 | 130 | /** 131 | * Returns the time of creation of the resource. 132 | * 133 | * @return the creation date of the current resource 134 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 135 | * vendor specific errors that occur. 136 | */ 137 | Instant getCreationTime() throws XMLDBException; 138 | 139 | /** 140 | * Returns the time of last modification of the resource. 141 | * 142 | * @return the last modification date of the current resource 143 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#VENDOR_ERROR} for any 144 | * vendor specific errors that occur. 145 | */ 146 | Instant getLastModificationTime() throws XMLDBException; 147 | } 148 | -------------------------------------------------------------------------------- /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/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 | BINARY_RESOURCE("BinaryResource"), XML_RESOURCE("XMLResource"); 49 | 50 | private final String name; 51 | 52 | private ResourceType(String name) { 53 | this.name = name; 54 | } 55 | 56 | /** 57 | * Returns the old style resource type name from XML:DB API version 1.0 constant. 58 | * 59 | * @return the classic type name 60 | */ 61 | public String typeName() { 62 | return 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 | @Override 71 | public String toString() { 72 | return typeName(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /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/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 | * Checks if a service of the given serviceType is available. This method will return 56 | * {@code false} in case of the specified service can not be provided for any reason. 57 | * 58 | * @return {@code true} if the given service type is supported, {@code false otherwise} 59 | * 60 | * @since 2.0 61 | */ 62 | boolean hasService(Class serviceType); 63 | 64 | /** 65 | * Returns optional {@code Service} instance for the requested {@code serviceType}. If no 66 | * {@code Service} exists or can be provided an empty optional is returned. 67 | * 68 | * @param the type of service 69 | * @param serviceType the type of service to return 70 | * @return a optional instance of the given service type 71 | * 72 | * @since 2.0 73 | */ 74 | Optional findService(Class serviceType); 75 | 76 | /** 77 | * Returns a {@code Service} instance for the requested {@code serviceType}. If no {@code Service} 78 | * exists a {@link XMLDBException} with {@link ErrorCodes#NO_SUCH_SERVICE} is thrown. 79 | * 80 | * @param the type of service 81 | * @param serviceType the type of service to return 82 | * @return a instance of the given service type 83 | * @throws XMLDBException with expected error codes. {@link ErrorCodes#NO_SUCH_SERVICE} if the 84 | * service does not exist, {@link ErrorCodes#VENDOR_ERROR} for any vendor specific errors 85 | * that occur. {@link ErrorCodes#COLLECTION_CLOSED} if the {@code close} method has been 86 | * called on the {@code Collection} 87 | * 88 | * @since 2.0 89 | */ 90 | default S getService(Class serviceType) throws XMLDBException { 91 | return findService(serviceType) 92 | .orElseThrow(() -> new XMLDBException(NO_SUCH_SERVICE, "Unknown service: " + serviceType)); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /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 the given service supplier for the given service type. 160 | * 161 | * @param serviceType the service type 162 | * @param serviceSupplier the supplier for the implementation instance 163 | */ 164 | void add(Class serviceType, Supplier serviceSupplier); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/main/java/org/xmldb/api/base/XMLDBException.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 | * XMLDBException is thrown for all errors in the XML:DB API. It contains two error codes one an 44 | * XML:DB error code as defined in ErrorCodes and one vendor specific. If the error being thrown is 45 | * only vendor specific then errorCode MUST be set to ErrorCodes.VENDOR_ERROR. 46 | * 47 | * @see org.xmldb.api.base.ErrorCodes 48 | */ 49 | public final class XMLDBException extends Exception { 50 | private static final long serialVersionUID = 8841586061740517362L; 51 | 52 | public final int errorCode; 53 | public final int vendorErrorCode; 54 | 55 | public XMLDBException() { 56 | this(ErrorCodes.UNKNOWN_ERROR); 57 | } 58 | 59 | public XMLDBException(int errorCode) { 60 | this(errorCode, 0, null, null); 61 | } 62 | 63 | public XMLDBException(int errorCode, String message) { 64 | this(errorCode, 0, message, null); 65 | } 66 | 67 | public XMLDBException(int errorCode, int vendorErrorCode) { 68 | this(errorCode, vendorErrorCode, null, null); 69 | } 70 | 71 | public XMLDBException(int errorCode, int vendorErrorCode, String message) { 72 | this(errorCode, vendorErrorCode, message, null); 73 | } 74 | 75 | public XMLDBException(int errorCode, Throwable cause) { 76 | this(errorCode, 0, null, cause); 77 | } 78 | 79 | public XMLDBException(int errorCode, String message, Throwable cause) { 80 | this(errorCode, 0, message, cause); 81 | } 82 | 83 | public XMLDBException(int errorCode, int vendorErrorCode, Throwable cause) { 84 | this(errorCode, vendorErrorCode, null, cause); 85 | } 86 | 87 | public XMLDBException(int errorCode, int vendorErrorCode, String message, Throwable cause) { 88 | super(messageFromErrorCode(message, errorCode, vendorErrorCode), cause); 89 | this.errorCode = errorCode; 90 | this.vendorErrorCode = vendorErrorCode; 91 | } 92 | 93 | static String messageFromErrorCode(final String message, final int errorCode, 94 | final int vendorErrorCode) { 95 | if (message != null) { 96 | return message; 97 | } else if (ErrorCodes.VENDOR_ERROR == errorCode) { 98 | return "Vendor error: " + vendorErrorCode; 99 | } else { 100 | return ErrorCodes.defaultMessage(errorCode); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /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/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 | 45 | /** 46 | * Resource for encapsulation of binary data that is stored in the data base. Support for 47 | * BinaryResources is optional. 48 | * 49 | * The standard {@code getContent} method returns a {@code byte[]} and the standard setContent 50 | * expects an {@code byte[]}. 51 | */ 52 | public interface BinaryResource extends Resource { 53 | 54 | @Override 55 | default ResourceType getResourceType() { 56 | return ResourceType.BINARY_RESOURCE; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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 | ALLOW, DENY 49 | } 50 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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.verify; 43 | import static org.mockito.Mockito.when; 44 | 45 | import java.util.function.Consumer; 46 | 47 | import org.junit.jupiter.api.Test; 48 | import org.mockito.Mock; 49 | import org.mockito.Spy; 50 | import org.mockito.junit.jupiter.MockitoSettings; 51 | import org.xmldb.api.TestResourceIterator; 52 | 53 | @MockitoSettings 54 | class ResourceIteratorTest { 55 | @Spy 56 | TestResourceIterator 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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/testFixtures/java/org/xmldb/api/ConfigurableImpl.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.HashMap; 43 | import java.util.Map; 44 | 45 | import org.xmldb.api.base.Configurable; 46 | import org.xmldb.api.base.XMLDBException; 47 | 48 | public class ConfigurableImpl implements Configurable { 49 | private final Map properties; 50 | 51 | public ConfigurableImpl() { 52 | properties = new HashMap<>(); 53 | } 54 | 55 | @Override 56 | public final String getProperty(String name) throws XMLDBException { 57 | return properties.get(name); 58 | } 59 | 60 | @Override 61 | public String getProperty(String name, String defaultValue) throws XMLDBException { 62 | return properties.getOrDefault(name, defaultValue); 63 | } 64 | 65 | @Override 66 | public final void setProperty(String name, String value) throws XMLDBException { 67 | properties.put(name, value); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/testFixtures/java/org/xmldb/api/TestBaseResource.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 static org.xmldb.api.base.ErrorCodes.NOT_IMPLEMENTED; 43 | 44 | import java.io.OutputStream; 45 | import java.time.Instant; 46 | 47 | import org.xmldb.api.base.Collection; 48 | import org.xmldb.api.base.Resource; 49 | import org.xmldb.api.base.XMLDBException; 50 | 51 | public abstract class TestBaseResource implements Resource { 52 | private final Collection parentCollection; 53 | private final Instant creation; 54 | 55 | private boolean closed; 56 | 57 | protected TestBaseResource(Collection parentCollection) { 58 | this.parentCollection = parentCollection; 59 | creation = Instant.now(); 60 | } 61 | 62 | @Override 63 | public Collection getParentCollection() throws XMLDBException { 64 | return parentCollection; 65 | } 66 | 67 | @Override 68 | public String getId() throws XMLDBException { 69 | return null; 70 | } 71 | 72 | @Override 73 | public Object getContent() throws XMLDBException { 74 | throw new XMLDBException(NOT_IMPLEMENTED); 75 | } 76 | 77 | @Override 78 | public void getContentAsStream(OutputStream stream) throws XMLDBException { 79 | throw new XMLDBException(NOT_IMPLEMENTED); 80 | } 81 | 82 | @Override 83 | public void setContent(Object value) throws XMLDBException { 84 | throw new XMLDBException(NOT_IMPLEMENTED); 85 | } 86 | 87 | @Override 88 | public boolean isClosed() { 89 | return closed; 90 | } 91 | 92 | @Override 93 | public void close() throws XMLDBException { 94 | closed = true; 95 | } 96 | 97 | @Override 98 | public Instant getCreationTime() throws XMLDBException { 99 | return creation; 100 | } 101 | 102 | @Override 103 | public Instant getLastModificationTime() throws XMLDBException { 104 | return creation; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/testFixtures/java/org/xmldb/api/TestBinaryResource.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.xmldb.api.base.Collection; 43 | import org.xmldb.api.modules.BinaryResource; 44 | 45 | public class TestBinaryResource extends TestBaseResource implements BinaryResource { 46 | public TestBinaryResource() { 47 | this(null); 48 | } 49 | 50 | public TestBinaryResource(Collection parentCollection) { 51 | super(parentCollection); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/testFixtures/java/org/xmldb/api/TestCollection.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 static java.util.Collections.emptyList; 43 | import static org.xmldb.api.base.ErrorCodes.NOT_IMPLEMENTED; 44 | 45 | import java.time.Instant; 46 | import java.util.List; 47 | import java.util.Optional; 48 | import java.util.concurrent.ConcurrentHashMap; 49 | import java.util.concurrent.ConcurrentMap; 50 | 51 | import org.xmldb.api.base.Collection; 52 | import org.xmldb.api.base.Resource; 53 | import org.xmldb.api.base.Service; 54 | import org.xmldb.api.base.XMLDBException; 55 | 56 | public class TestCollection extends ConfigurableImpl implements Collection { 57 | private final TestCollectionData data; 58 | private final ConcurrentMap childCollections; 59 | 60 | private boolean closed; 61 | private Collection parent; 62 | 63 | public TestCollection(final TestCollectionData data) { 64 | this(data, null); 65 | } 66 | 67 | public TestCollection(final TestCollectionData data, final Collection parent) { 68 | this.data = data; 69 | this.parent = parent; 70 | childCollections = new ConcurrentHashMap<>(); 71 | } 72 | 73 | public static TestCollection create(String name) { 74 | return new TestCollection(new TestCollectionData(name)); 75 | } 76 | 77 | @Override 78 | public final String getName() throws XMLDBException { 79 | return data.name(); 80 | } 81 | 82 | @Override 83 | public boolean hasService(Class serviceType) { 84 | return false; 85 | } 86 | 87 | @Override 88 | public Optional findService(Class serviceType) { 89 | return Optional.empty(); 90 | } 91 | 92 | @Override 93 | public S getService(Class serviceType) throws XMLDBException { 94 | throw new XMLDBException(NOT_IMPLEMENTED); 95 | } 96 | 97 | @Override 98 | public int getChildCollectionCount() throws XMLDBException { 99 | return childCollections.size(); 100 | } 101 | 102 | @Override 103 | public List listChildCollections() throws XMLDBException { 104 | return childCollections.keySet().stream().toList(); 105 | } 106 | 107 | @Override 108 | public Collection getChildCollection(String collectionName) throws XMLDBException { 109 | return new TestCollection( 110 | childCollections.computeIfAbsent(collectionName, TestCollectionData::new), this); 111 | } 112 | 113 | @Override 114 | public Collection getParentCollection() throws XMLDBException { 115 | return parent; 116 | } 117 | 118 | @Override 119 | public int getResourceCount() throws XMLDBException { 120 | return 0; 121 | } 122 | 123 | @Override 124 | public List listResources() throws XMLDBException { 125 | return emptyList(); 126 | } 127 | 128 | @Override 129 | public R createResource(String id, Class type) throws XMLDBException { 130 | throw new XMLDBException(NOT_IMPLEMENTED); 131 | } 132 | 133 | @Override 134 | public void removeResource(Resource res) throws XMLDBException { 135 | throw new XMLDBException(NOT_IMPLEMENTED); 136 | } 137 | 138 | @Override 139 | public void storeResource(Resource res) throws XMLDBException { 140 | throw new XMLDBException(NOT_IMPLEMENTED); 141 | } 142 | 143 | @Override 144 | public Resource getResource(String id) throws XMLDBException { 145 | throw new XMLDBException(NOT_IMPLEMENTED); 146 | } 147 | 148 | @Override 149 | public String createId() throws XMLDBException { 150 | throw new XMLDBException(NOT_IMPLEMENTED); 151 | } 152 | 153 | @Override 154 | public boolean isOpen() throws XMLDBException { 155 | return !closed; 156 | } 157 | 158 | @Override 159 | public void close() throws XMLDBException { 160 | closed = true; 161 | } 162 | 163 | @Override 164 | public Instant getCreationTime() throws XMLDBException { 165 | return data.creation(); 166 | } 167 | 168 | @Override 169 | public String toString() { 170 | return "/%s".formatted(data.name()); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/testFixtures/java/org/xmldb/api/TestCollectionData.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.time.Instant; 43 | import java.util.Objects; 44 | 45 | public record TestCollectionData(String name, Instant creation) { 46 | public TestCollectionData(String name) { 47 | this(name, Instant.now()); 48 | } 49 | 50 | public TestCollectionData { 51 | Objects.requireNonNull(name); 52 | Objects.requireNonNull(creation); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/testFixtures/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.HashMap; 43 | import java.util.Map; 44 | import java.util.Properties; 45 | 46 | import org.xmldb.api.base.Collection; 47 | import org.xmldb.api.base.Database; 48 | import org.xmldb.api.base.XMLDBException; 49 | 50 | public class TestDatabase extends ConfigurableImpl implements Database { 51 | private static final String DETAULT_NAME = "testdatabase"; 52 | 53 | private final String name; 54 | private final Map collections; 55 | 56 | public TestDatabase() { 57 | this(null); 58 | } 59 | 60 | public TestDatabase(String name) { 61 | if (name == null || name.isEmpty()) { 62 | this.name = DETAULT_NAME; 63 | } else { 64 | this.name = name; 65 | } 66 | collections = new HashMap<>(); 67 | } 68 | 69 | @Override 70 | public final String getName() throws XMLDBException { 71 | return name; 72 | } 73 | 74 | public TestCollection addCollection(String collectionName) { 75 | return collections.computeIfAbsent(collectionName, TestCollection::create); 76 | } 77 | 78 | @Override 79 | public Collection getCollection(String uri, Properties info) throws XMLDBException { 80 | return collections.get(uri); 81 | } 82 | 83 | @Override 84 | public boolean acceptsURI(String uri) { 85 | return uri.startsWith(DatabaseManager.URI_PREFIX + "test"); 86 | } 87 | 88 | @Override 89 | public String getConformanceLevel() throws XMLDBException { 90 | return "0"; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/testFixtures/java/org/xmldb/api/TestResourceIterator.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.xmldb.api.base.Resource; 43 | import org.xmldb.api.base.ResourceIterator; 44 | import org.xmldb.api.base.XMLDBException; 45 | 46 | public class TestResourceIterator implements ResourceIterator { 47 | 48 | @Override 49 | public boolean hasMoreResources() throws XMLDBException { 50 | return false; 51 | } 52 | 53 | @Override 54 | public Resource nextResource() throws XMLDBException { 55 | return null; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/testFixtures/java/org/xmldb/api/TestXMLResource.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 static org.xmldb.api.base.ErrorCodes.NOT_IMPLEMENTED; 43 | 44 | import org.w3c.dom.Node; 45 | import org.xml.sax.ContentHandler; 46 | import org.xml.sax.SAXNotRecognizedException; 47 | import org.xml.sax.SAXNotSupportedException; 48 | import org.xml.sax.XMLReader; 49 | import org.xmldb.api.base.Collection; 50 | import org.xmldb.api.base.XMLDBException; 51 | import org.xmldb.api.modules.XMLResource; 52 | 53 | public class TestXMLResource extends TestBaseResource implements XMLResource { 54 | public TestXMLResource() { 55 | this(null); 56 | } 57 | 58 | public TestXMLResource(Collection parentCollection) { 59 | super(parentCollection); 60 | } 61 | 62 | @Override 63 | public String getDocumentId() throws XMLDBException { 64 | throw new XMLDBException(NOT_IMPLEMENTED); 65 | } 66 | 67 | @Override 68 | public Node getContentAsDOM() throws XMLDBException { 69 | throw new XMLDBException(NOT_IMPLEMENTED); 70 | } 71 | 72 | @Override 73 | public void setContentAsDOM(Node content) throws XMLDBException { 74 | throw new XMLDBException(NOT_IMPLEMENTED); 75 | } 76 | 77 | @Override 78 | public void getContentAsSAX(ContentHandler handler) throws XMLDBException { 79 | throw new XMLDBException(NOT_IMPLEMENTED); 80 | } 81 | 82 | @Override 83 | public ContentHandler setContentAsSAX() throws XMLDBException { 84 | throw new XMLDBException(NOT_IMPLEMENTED); 85 | } 86 | 87 | @Override 88 | public void setSAXFeature(String feature, boolean value) 89 | throws SAXNotRecognizedException, SAXNotSupportedException { 90 | throw new SAXNotSupportedException(); 91 | } 92 | 93 | @Override 94 | public boolean getSAXFeature(String feature) 95 | throws SAXNotRecognizedException, SAXNotSupportedException { 96 | return false; 97 | } 98 | 99 | @Override 100 | public void setXMLReader(XMLReader xmlReader) { 101 | // no action 102 | } 103 | } 104 | --------------------------------------------------------------------------------