Skip to content

Commit

Permalink
^Changed order
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Mar 6, 2024
1 parent b18b9be commit 10f3267
Showing 1 changed file with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,6 @@ public IValidationExecutor <IValidationSourceXML> loadXSD (@Nonnull final IRepoS
return null;
}

if (aCatalogEntries.isNotEmpty ())
{
// TODO implement catalog support
final String sMsg = "XSD resource type '" + sResourceType + "' does not yet support catalog entries";
LOGGER.warn (sMsg);
aErrorList.add (SingleError.builderWarn ().errorText (sMsg).build ());
}
if (aPrecondition != null)
{
// TODO implement precondition support
Expand Down Expand Up @@ -324,48 +317,69 @@ protected IReadableResource internalResolveResource (@Nonnull @Nonempty final St
sBaseURI +
"'");

if (StringHelper.hasText (sRelativeSystemId))
{
// Matches in ZIP have precedence
final NonBlockingByteArrayOutputStream aZIPResolved = aZIPContent.get (sRelativeSystemId);
if (aZIPResolved != null)
{
LOGGER.info (" Successfully resolved '" + sRelativeSystemId + "' to ZIP file content");
return new ReadableResourceInputStream (sRelativeSystemId, aZIPResolved.getAsInputStream ());
}
LOGGER.warn (" Failed to resolve System ID '" + sRelativeSystemId + "' in ZIP content");
}

// Then check in catalog
// Catalog has precedence
if (aCatalogEntries.isNotEmpty ())
{
// Check public entries first
if (StringHelper.hasText (sNamespaceURI))
{
final VESCatalogEntry aEntry = aCatalogEntries.findEntryByUri (sNamespaceURI);
if (aEntry != null)
{
final VESID aCatalogVESID = aEntry.getRepoStorageKey ().getVESID ();
final VESID aTargetVESID = aEntry.getRepoStorageKey ().getVESID ();

// Load referenced catalog resource
final IRepoStorageReadItem aLoadedCatalogRes = aAsyncLoader.loadResource (aCatalogVESID,
final IRepoStorageReadItem aLoadedCatalogRes = aAsyncLoader.loadResource (aTargetVESID,
"." + RESOURCE_TYPE_XSD);
if (aLoadedCatalogRes != null)
{
LOGGER.info (" Successfully resolved namespace URI '" +
sNamespaceURI +
"' to Catalog entry pointing to '" +
aCatalogVESID.getAsSingleID () +
"' to Catalog Entry pointing to '" +
aTargetVESID.getAsSingleID () +
"'");
return new ReadableResourceInputStream (sRelativeSystemId,
aLoadedCatalogRes.getContent ().getInputStream ());
}
LOGGER.warn (" Failed to resolve referenced catalog entry '" + aCatalogVESID.getAsSingleID () + "'");
LOGGER.warn (" Failed to resolve Catalog Entry pointing to '" + aTargetVESID.getAsSingleID () + "'");
}
else
{
LOGGER.warn (" Found no catalog entry for namespace URI '" + sNamespaceURI + "'");
LOGGER.warn (" Found no Catalog Entry for namespace URI '" + sNamespaceURI + "'");
}
}

if (StringHelper.hasText (sPublicId))
{
// TODO implement catalog support
final String sMsg = "XSD resource type '" +
sResourceType +
"' does not yet support catalog entries for PUBLIC ID";
LOGGER.warn (sMsg);
aErrorList.add (SingleError.builderWarn ().errorText (sMsg).build ());
}

if (StringHelper.hasText (sSystemId))
{
// TODO implement catalog support
final String sMsg = "XSD resource type '" +
sResourceType +
"' does not yet support catalog entries for SYSTEM ID";
LOGGER.warn (sMsg);
aErrorList.add (SingleError.builderWarn ().errorText (sMsg).build ());
}
}

if (StringHelper.hasText (sRelativeSystemId))
{
// Matches in ZIP are the default
final NonBlockingByteArrayOutputStream aZIPResolved = aZIPContent.get (sRelativeSystemId);
if (aZIPResolved != null)
{
LOGGER.info (" Successfully resolved '" + sRelativeSystemId + "' to ZIP file content");
return new ReadableResourceInputStream (sRelativeSystemId, aZIPResolved.getAsInputStream ());
}
LOGGER.warn (" Failed to resolve System ID '" + sRelativeSystemId + "' in ZIP content");
}

LOGGER.warn (" Failed to resolve '" +
Expand Down

0 comments on commit 10f3267

Please sign in to comment.