forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 2
Fix saxon configuration issue in dspace oai module #1041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
milanmajchrak
merged 9 commits into
dtq-dev
from
fix-saxon-configuration-issue-in-dspace-oai-module
Aug 18, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e55c9ea
used static, shared isntance of the sazon processor and document builder
Paurikova2 2de4cbc
fix problem xith saxon, works
Paurikova2 23a0781
remvoed updated and stashed notes
Paurikova2 c172bd7
removed synchronization, checkstyle
Paurikova2 80fbeee
more readable code
Paurikova2 2fbc99b
fix array usagage, checkstyle
Paurikova2 d914148
added volatile to shared sazon processor
Paurikova2 9d33d55
checkstyle violations, created final class from saxon
Paurikova2 f7e1505
fix doc for saxon, check if array exists before if it contains values
Paurikova2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
dspace-oai/src/main/java/org/dspace/xoai/services/impl/resources/SharedSaxonProcessor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /** | ||
| * The contents of this file are subject to the license and copyright | ||
| * detailed in the LICENSE and NOTICE files at the root of the source | ||
| * tree and available online at | ||
| * | ||
| * http://www.dspace.org/license/ | ||
| */ | ||
| package org.dspace.xoai.services.impl.resources; | ||
|
|
||
| import javax.xml.transform.TransformerFactory; | ||
|
|
||
| import net.sf.saxon.jaxp.SaxonTransformerFactory; | ||
| import net.sf.saxon.s9api.Processor; | ||
|
|
||
| /** | ||
| * Utility class to provide a shared Saxon Processor and TransformerFactory instance. | ||
| * | ||
| * This class maintains a singleton Processor and SaxonTransformerFactory to avoid | ||
| * configuration incompatibility issues between different Saxon processors. | ||
| * | ||
| * Initialization must be done once by calling {@link #initialize(TransformerFactory)}. | ||
| * The class is thread-safe: the shared instances are lazily initialized with synchronization. | ||
| * | ||
| * @author Michaela Stefancova (dspace at dataquest.sk) | ||
| */ | ||
| public final class SharedSaxonProcessor { | ||
| private SharedSaxonProcessor() { | ||
| // utility class | ||
| } | ||
|
|
||
| private static volatile SaxonTransformerFactory saxonTransformerFactory; | ||
| private static volatile Processor sharedProcessor; | ||
|
|
||
| /** | ||
| * Initialize the shared processor with the given TransformerFactory. | ||
| * Must be called once before accessing any shared processor or builder. | ||
| * | ||
| * Synchronized to prevent race conditions if multiple threads attempt initialization. | ||
| * | ||
| * @param transformerFactory the Saxon TransformerFactory to use | ||
| * @throws IllegalArgumentException if transformerFactory is null or not a SaxonTransformerFactory | ||
| */ | ||
| public static synchronized void initialize(TransformerFactory transformerFactory) { | ||
| if (saxonTransformerFactory == null) { | ||
Paurikova2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (transformerFactory == null) { | ||
| throw new IllegalArgumentException("TransformerFactory cannot be null"); | ||
| } | ||
| if (!(transformerFactory instanceof SaxonTransformerFactory)) { | ||
| throw new IllegalArgumentException("TransformerFactory must be an instance of SaxonTransformerFactory"); | ||
| } | ||
| saxonTransformerFactory = (SaxonTransformerFactory) transformerFactory; | ||
| sharedProcessor = saxonTransformerFactory.getProcessor(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the shared Saxon Processor instance. | ||
| * | ||
| * @return the shared Processor | ||
| * @throws IllegalStateException if initialize() has not been called yet | ||
| */ | ||
| public static Processor getProcessor() { | ||
| if (sharedProcessor == null) { | ||
| throw new IllegalStateException("SharedSaxonProcessor has not been initialized. Call initialize() first."); | ||
| } | ||
| return sharedProcessor; | ||
| } | ||
|
|
||
| /** | ||
| * Get the shared Saxon TransformerFactory instance. | ||
| * | ||
| * @return the shared SaxonTransformerFactory | ||
| * @throws IllegalStateException if initialize() has not been called yet | ||
| */ | ||
| public static SaxonTransformerFactory getTransformerFactory() { | ||
| if (saxonTransformerFactory == null) { | ||
| throw new IllegalStateException("SharedSaxonProcessor has not been initialized. Call initialize() first."); | ||
| } | ||
| return saxonTransformerFactory; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.