Skip to content

Commit 864ad9e

Browse files
authored
MCR-3339 ensure usage of MCRResourceResolver (#2424)
1 parent 02ce317 commit 864ad9e

File tree

32 files changed

+150
-59
lines changed

32 files changed

+150
-59
lines changed

mycore-base/src/main/java/org/mycore/common/MCRCoreVersion.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static String getVersion() {
5252
return VERSION;
5353
}
5454

55+
@SuppressWarnings("PMD.MCR.ResourceResolver")
5556
private static Properties loadVersionProperties() {
5657
Properties props = new Properties();
5758
URL gitPropURL = MCRCoreVersion.class.getResource("/org/mycore/git.properties");

mycore-base/src/main/java/org/mycore/common/config/MCRComponent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* @since 2013.12
4242
* @see MCRRuntimeComponentDetector
4343
*/
44+
@SuppressWarnings("PMD.MCR.ResourceResolver")
4445
public class MCRComponent implements Comparable<MCRComponent> {
4546

4647
private static final Logger LOGGER = LogManager.getLogger();

mycore-base/src/main/java/org/mycore/common/config/MCRConfigurationInputStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
* @author Robert Stephan
5454
* @since 2013.12
5555
*/
56+
@SuppressWarnings("PMD.MCR.ResourceResolver")
5657
public class MCRConfigurationInputStream extends InputStream {
5758

5859
private static final String MYCORE_PROPERTIES = "mycore.properties";

mycore-base/src/main/java/org/mycore/common/config/MCRDefaultConfigurationLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @author Thomas Scheffler (yagee)
3838
* @since 2013.12
3939
*/
40+
@SuppressWarnings("PMD.MCR.ResourceResolver")
4041
public class MCRDefaultConfigurationLoader implements MCRConfigurationLoader {
4142

4243
MCRProperties properties;

mycore-base/src/main/java/org/mycore/common/config/MCRRuntimeComponentDetector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* @author Thomas Scheffler (yagee)
5050
* @since 2013.12
5151
*/
52+
@SuppressWarnings("PMD.MCR.ResourceResolver")
5253
public class MCRRuntimeComponentDetector {
5354

5455
private static final Logger LOGGER = LogManager.getLogger();

mycore-base/src/main/java/org/mycore/common/events/MCRServletContainerInitializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
/**
4040
* @author Thomas Scheffler (yagee)
4141
*/
42+
@SuppressWarnings("PMD.MCR.ResourceResolver")
4243
public class MCRServletContainerInitializer implements ServletContainerInitializer {
4344

4445
/* (non-Javadoc)

mycore-base/src/main/java/org/mycore/common/xml/MCREntityResolver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
* @author Thomas Scheffler (yagee)
5959
* @since 2013.10
6060
*/
61+
@SuppressWarnings("PMD.MCR.ResourceResolver")
6162
public final class MCREntityResolver implements EntityResolver2, LSResourceResolver {
6263

6364
private static final Logger LOGGER = LogManager.getLogger();

mycore-base/src/main/java/org/mycore/common/xsl/MCRXSLInfoServlet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
*
6565
* @author Frank Lützenkirchen
6666
*/
67+
@SuppressWarnings("PMD.MCR.ResourceResolver")
6768
public final class MCRXSLInfoServlet extends MCRServlet {
6869

6970
@Serial

mycore-base/src/main/java/org/mycore/datamodel/metadata/validator/MCREditorOutValidator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,16 @@ private void updateConditionsValueAttribute(Element rootbool) {
451451
}
452452

453453
private Document loadDefaultAclDocument() throws IOException, JDOMException {
454-
String resourcetype = "/editor_default_acls_" + id.getTypeId() + ".xml";
455-
String resourcebase = "/editor_default_acls_" + id.getBase() + ".xml";
456-
InputStream aclxml = MCREditorOutValidator.class.getResourceAsStream(resourcebase);
454+
String resourcetype = "editor_default_acls_" + id.getTypeId() + ".xml";
455+
String resourcebase = "editor_default_acls_" + id.getBase() + ".xml";
456+
InputStream aclxml = MCRResourceHelper.getResourceAsStream(resourcebase);
457457
if (aclxml == null) {
458-
aclxml = MCREditorOutValidator.class.getResourceAsStream(resourcetype);
458+
aclxml = MCRResourceHelper.getResourceAsStream(resourcetype);
459459
if (aclxml == null) {
460460
LOGGER.warn("Can't find default object ACL file {} or {}",
461-
() -> resourcebase.substring(1), () -> resourcetype.substring(1));
462-
String resource = "/editor_default_acls.xml"; // fallback
463-
aclxml = MCREditorOutValidator.class.getResourceAsStream(resource);
461+
resourcebase, resourcetype);
462+
String resource = "editor_default_acls.xml"; // fallback
463+
aclxml = MCRResourceHelper.getResourceAsStream(resource);
464464
if (aclxml == null) {
465465
return null;
466466
}

mycore-base/src/main/java/org/mycore/frontend/cli/MCRBasicCommands.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.jdom2.input.SAXBuilder;
4545
import org.jdom2.output.Format;
4646
import org.jdom2.output.XMLOutputter;
47-
import org.mycore.common.MCRClassTools;
4847
import org.mycore.common.config.MCRComponent;
4948
import org.mycore.common.config.MCRConfiguration2;
5049
import org.mycore.common.config.MCRConfigurationDir;
@@ -54,6 +53,7 @@
5453
import org.mycore.common.xml.MCRXMLParserFactory;
5554
import org.mycore.frontend.cli.annotation.MCRCommand;
5655
import org.mycore.frontend.cli.annotation.MCRCommandGroup;
56+
import org.mycore.resource.MCRResourceHelper;
5757

5858
/**
5959
* This class contains the basic commands for MyCoRe Command Line and WebCLI.
@@ -224,7 +224,6 @@ private static boolean createDirectory(File directory) {
224224
}
225225

226226
private static void createSampleConfigFile(String path) throws IOException {
227-
ClassLoader classLoader = MCRClassTools.getClassLoader();
228227
Path configurationDirectory = MCRConfigurationDir.getConfigurationDirectory().toPath();
229228
Path targetFile = configurationDirectory.resolve(path);
230229
if (Files.exists(targetFile)) {
@@ -237,7 +236,7 @@ private static void createSampleConfigFile(String path) throws IOException {
237236
throw new IOException("Could not create directory for file: " + targetFile);
238237
}
239238
}
240-
try (InputStream templateResource = classLoader.getResourceAsStream("configdir.template/" + path)) {
239+
try (InputStream templateResource = MCRResourceHelper.getResourceAsStream("configdir.template/" + path)) {
241240
if (templateResource == null) {
242241
throw new IOException("Could not find template for " + path);
243242
}
@@ -301,6 +300,7 @@ private static boolean updatePersistenceH2JdbcUrl(Document persistenceDoc) {
301300
* @return true, if the mappings changed
302301
* @throws IOException
303302
*/
303+
@SuppressWarnings("PMD.MCR.ResourceResolver")
304304
private static boolean updatePersistenceMappings(Document persistenceDoc) throws IOException {
305305
Namespace nsPersistence = persistenceDoc.getRootElement().getNamespace();
306306
Element ePersistenceUnit = persistenceDoc.getRootElement().getChild("persistence-unit", nsPersistence);

0 commit comments

Comments
 (0)