diff --git a/java/org/slub/rosetta/dps/repository/plugin/XmlFormatValidationPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/XmlFormatValidationPlugin.java index 60b7d115a0394e1f21003bd6f48fe6f92a16ca61..5a1bfd01e5aafa69635d6defc98e1eb5c6314eb8 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/XmlFormatValidationPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/XmlFormatValidationPlugin.java @@ -90,12 +90,12 @@ public class XmlFormatValidationPlugin implements FormatValidationPlugin { resultHandle.error("invalid entry(" + i + ") in namespace schema map file " + namespaceSchemaMapFile); } } - } catch (ParserConfigurationException | SAXException | IOException | URISyntaxException e) { + } catch (ParserConfigurationException | SAXException | IOException | URISyntaxException | SchemaCatalogException e) { resultHandle.error("parsing expection parsing namespace schema map file " + namespaceSchemaMapFile + " ," + e.getMessage()); } } - private void addtoNamespaceSchemaMap(String namespaceSchemaMapFile, String attr_type, String namespace, String sUri) throws URISyntaxException, SAXException { + private void addtoNamespaceSchemaMap(String namespaceSchemaMapFile, String attr_type, String namespace, String sUri) throws URISyntaxException, SAXException, SchemaCatalogException { ValidationSchemaType schematype = ValidationSchemaType.nothing; switch (attr_type) { case "schema" -> schematype = ValidationSchemaType.schema; @@ -116,12 +116,12 @@ public class XmlFormatValidationPlugin implements FormatValidationPlugin { } - private ValidationSchema getValidationSchemaIfPresent(String namespaceSchemaMapFile, String namespace, String sUri, ValidationSchemaType schematype) throws URISyntaxException, SAXException { - ValidationSchema v; - if ( - isWrongFileUri(sUri) - ) { - resultHandle.error("attribute schemauri should be start with: 'http://$server/path', 'https://$server/path' or 'file://localhost/path' to ensure coorect working, got: " + sUri); + private ValidationSchema getValidationSchemaIfPresent(String namespaceSchemaMapFile, String namespace, String sUri, ValidationSchemaType schematype) throws URISyntaxException, SAXException, SchemaCatalogException { + if ( null == sUri || sUri.isBlank()) { + throw new SchemaCatalogException("for namespace " + namespace + "attribute schemauri is empty or non-existent!"); + } + if ( isWrongFileUri(sUri) ) { + throw new SchemaCatalogException("for namespace " + namespace + "attribute schemauri should be start with: 'http://$server/path', 'https://$server/path' or 'file://localhost/path' to ensure coorect working, got: " + sUri); } URI uri; if ( @@ -132,10 +132,11 @@ public class XmlFormatValidationPlugin implements FormatValidationPlugin { uri = remapUri(namespaceSchemaMapFile, sUri); resultHandle.debug("SCHEMACATALOG, remap " + sUri + " to URI: " + uri); } - v = new ValidationSchema(namespace, schematype, uri); + ValidationSchema v = new ValidationSchema(namespace, schematype, uri); return v; } + private static boolean isNonRelativeUri(String sUri) { return (sUri.startsWith("http://")) || (sUri.startsWith("https://"))