Skip to content

Commit

Permalink
Renamed to "aLoadingErrors"
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Mar 4, 2024
1 parent 2a6b963 commit fcf501b
Showing 1 changed file with 75 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ private static LoadedVES.OutputType _wrap (@Nullable final VesOutputType aOutput
public LoadedVES convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
@Nonnull final VesType aVES,
@Nonnull final VESLoaderStatus aLoaderStatus,
@Nonnull final ErrorList aErrorList) throws VESLoadingException
@Nonnull final ErrorList aLoadingErrors) throws VESLoadingException
{
ValueEnforcer.notNull (aStatus, "Status");
ValueEnforcer.notNull (aVES, "VES");
ValueEnforcer.notNull (aLoaderStatus, "LoaderStatus");
ValueEnforcer.notNull (aErrorList, "ErrorList");
ValueEnforcer.notNull (aLoadingErrors, "LoadingErrors");

final EVESSyntax eSyntax = aVES.getXsd () != null ? EVESSyntax.XSD : aVES.getSchematron () != null
? EVESSyntax.SCHEMATRON
Expand Down Expand Up @@ -321,14 +321,14 @@ public LoadedVES convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
// Recursive load required artefact; required to have this in scope
final LoadedVES aLoadedRequirement = loadVESFromRepo (aRequirement.getRequiredVESID (),
aLoaderStatus,
aErrorList);
aLoadingErrors);
if (aLoadedRequirement == null)
{
aErrorList.add (SingleError.builderError ()
.errorText ("Failed to load required VESID '" +
aRequirement.getRequiredVESID ().getAsSingleID () +
"' [eager]")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("Failed to load required VESID '" +
aRequirement.getRequiredVESID ().getAsSingleID () +
"' [eager]")
.build ());
return null;
}

Expand Down Expand Up @@ -360,76 +360,76 @@ public LoadedVES convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
// XSD
final IVESLoaderXSD aLoader = getLoaderXSD ();
if (aLoader != null)
ret.setExecutor (aLoader.loadXSD (m_aRepo, aVES.getXsd (), aErrorList));
ret.setExecutor (aLoader.loadXSD (m_aRepo, aVES.getXsd (), aLoadingErrors));
else
aErrorList.add (SingleError.builderError ()
.errorText ("The VES contains an XSD element, but no XSD loader is present")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("The VES contains an XSD element, but no XSD loader is present")
.build ());
}
else
if (aVES.getSchematron () != null)
{
// Schematron
final IVESLoaderSchematron aLoader = getLoaderSchematron ();
if (aLoader != null)
ret.setExecutor (aLoader.loadSchematron (m_aRepo, aVES.getSchematron (), aErrorList));
ret.setExecutor (aLoader.loadSchematron (m_aRepo, aVES.getSchematron (), aLoadingErrors));
else
aErrorList.add (SingleError.builderError ()
.errorText ("The VES contains a Schematron element, but no Schematron loader is present")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("The VES contains a Schematron element, but no Schematron loader is present")
.build ());
}
else
if (aVES.getEdifact () != null)
{
// EDIFACT
final IVESLoaderEdifact aLoader = getLoaderEdifact ();
if (aLoader != null)
ret.setExecutor (aLoader.loadEdifact (m_aRepo, aVES.getEdifact (), aErrorList));
ret.setExecutor (aLoader.loadEdifact (m_aRepo, aVES.getEdifact (), aLoadingErrors));
else
aErrorList.add (SingleError.builderError ()
.errorText ("The VES contains an Edifact element, but no Edifact loader is present")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("The VES contains an Edifact element, but no Edifact loader is present")
.build ());
}
else
throw new IllegalStateException ("Unsupported base syntax");

if (!ret.hasExecutor ())
{
aErrorList.add (SingleError.builderError ()
.errorText ("The loaded VES contains no Validation Executor and is therefore not usable")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("The loaded VES contains no Validation Executor and is therefore not usable")
.build ());
return null;
}

return ret;
}

@Nullable
public LoadedVES loadVESDirect (@Nonnull final IReadableResource aVESRes, @Nonnull final ErrorList aErrorList)
public LoadedVES loadVESDirect (@Nonnull final IReadableResource aVESRes, @Nonnull final ErrorList aLoadingErrors)
{
return loadVESDirect (Status.createUndefined (), aVESRes, new VESLoaderStatus (), aErrorList);
return loadVESDirect (Status.createUndefined (), aVESRes, new VESLoaderStatus (), aLoadingErrors);
}

@Nullable
public LoadedVES loadVESDirect (@Nonnull final LoadedVES.Status aStatus,
@Nonnull final IReadableResource aVESRes,
@Nonnull final VESLoaderStatus aLoaderStatus,
@Nonnull final ErrorList aErrorList)
@Nonnull final ErrorList aLoadingErrors)
{
ValueEnforcer.notNull (aStatus, "Status");
ValueEnforcer.notNull (aVESRes, "VESRes");
ValueEnforcer.notNull (aLoaderStatus, "LoaderStatus");
ValueEnforcer.notNull (aErrorList, "ErrorList");
ValueEnforcer.notNull (aLoadingErrors, "LoadingErrors");

// Read VES as XML
final VesType aVES = new VES1Marshaller ().setCollectErrors (aErrorList).read (aVESRes);
final VesType aVES = new VES1Marshaller ().setCollectErrors (aLoadingErrors).read (aVESRes);
if (aVES == null)
{
// Error in XML
aErrorList.add (SingleError.builderError ()
.errorFieldName (aVESRes.getPath ())
.errorText ("Failed to read VES as XML.")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorFieldName (aVESRes.getPath ())
.errorText ("Failed to read VES as XML.")
.build ());
return null;
}

Expand All @@ -441,17 +441,17 @@ public LoadedVES loadVESDirect (@Nonnull final LoadedVES.Status aStatus,
// Ensure the VESID is not yet in the loader chain
if (aLoaderStatus.addVESID (aVESID).isFailure ())
{
aErrorList.add (SingleError.builderError ()
.errorText ("The VESID '" +
aVESID.getAsSingleID () +
"' was already loaded. It seems like you have a circular dependency: " +
aLoaderStatus.getDepedencyChain (aVESID))
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("The VESID '" +
aVESID.getAsSingleID () +
"' was already loaded. It seems like you have a circular dependency: " +
aLoaderStatus.getDepedencyChain (aVESID))
.build ());
return null;
}

// Convert to loaded VES
return convertToLoadedVES (aStatus, aVES, aLoaderStatus, aErrorList);
return convertToLoadedVES (aStatus, aVES, aLoaderStatus, aLoadingErrors);
}

/**
Expand All @@ -460,14 +460,14 @@ public LoadedVES loadVESDirect (@Nonnull final LoadedVES.Status aStatus,
*
* @param aVESID
* The VESID to load. May not be <code>null</code>.
* @param aErrorList
* The error list to be filled. May not be <code>null</code>.
* @param aLoadingErrors
* The loading error list to be filled. May not be <code>null</code>.
* @return <code>null</code> if loading failed
*/
@Nullable
public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID, @Nonnull final ErrorList aErrorList)
public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID, @Nonnull final ErrorList aLoadingErrors)
{
return loadVESFromRepo (aVESID, new VESLoaderStatus (), aErrorList);
return loadVESFromRepo (aVESID, new VESLoaderStatus (), aLoadingErrors);
}

/**
Expand All @@ -479,18 +479,18 @@ public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID, @Nonnull final Er
* @param aLoaderStatus
* The internal loader status to be used, to make sure no cycles etc.
* are contained
* @param aErrorList
* The error list to be filled. May not be <code>null</code>.
* @param aLoadingErrors
* The loading error list to be filled. May not be <code>null</code>.
* @return <code>null</code> if loading failed
*/
@Nullable
public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID,
@Nonnull final VESLoaderStatus aLoaderStatus,
@Nonnull final ErrorList aErrorList)
@Nonnull final ErrorList aLoadingErrors)
{
ValueEnforcer.notNull (aVESID, "VESID");
ValueEnforcer.notNull (aLoaderStatus, "LoaderStatus");
ValueEnforcer.notNull (aErrorList, "ErrorList");
ValueEnforcer.notNull (aLoadingErrors, "LoadingErrors");

final boolean bIsRoot = aLoaderStatus.m_aLoaded.isEmpty ();

Expand All @@ -503,12 +503,12 @@ public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID,
if (aLoaderStatus.addVESID (aVESID).isFailure ())
{
// This is a circular dependency
aErrorList.add (SingleError.builderError ()
.errorText ("The VESID '" +
aVESID.getAsSingleID () +
"' was already loaded. It seems like you have a circular dependency: " +
aLoaderStatus.getDepedencyChain (aVESID))
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorText ("The VESID '" +
aVESID.getAsSingleID () +
"' was already loaded. It seems like you have a circular dependency: " +
aLoaderStatus.getDepedencyChain (aVESID))
.build ());
return null;
}

Expand All @@ -522,16 +522,16 @@ public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID,
if (aRepoContentStatus != null)
{
// Read VES Status as XML
final VesStatusType aVESStatus = new VESStatus1Marshaller ().setCollectErrors (aErrorList)
final VesStatusType aVESStatus = new VESStatus1Marshaller ().setCollectErrors (aLoadingErrors)
.read (new RepoStorageReadableResource (aRepoKeyStatus,
aRepoContentStatus.getContent ()));
if (aVESStatus == null)
{
// Error in Status XML - breaking error
aErrorList.add (SingleError.builderError ()
.errorFieldName (aRepoKeyStatus.getPath ())
.errorText ("Failed to read VES Status as XML.")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorFieldName (aRepoKeyStatus.getPath ())
.errorText ("Failed to read VES Status as XML.")
.build ());
return null;
}

Expand All @@ -557,29 +557,29 @@ public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID,
final IRepoStorageReadItem aRepoContentVES = m_aRepo.read (aRepoKeyVES);
if (aRepoContentVES == null)
{
aErrorList.add (SingleError.builderError ()
.errorFieldName (aRepoKeyVES.getPath ())
.errorText ("Failed to resolve provied VES from repository.")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorFieldName (aRepoKeyVES.getPath ())
.errorText ("Failed to resolve provied VES from repository.")
.build ());
return null;
}

// Read VES as XML
final VesType aVES = new VES1Marshaller ().setCollectErrors (aErrorList)
final VesType aVES = new VES1Marshaller ().setCollectErrors (aLoadingErrors)
.read (new RepoStorageReadableResource (aRepoKeyVES,
aRepoContentVES.getContent ()));
if (aVES == null)
{
// Error in XML
aErrorList.add (SingleError.builderError ()
.errorFieldName (aRepoKeyVES.getPath ())
.errorText ("Failed to read VES as XML.")
.build ());
aLoadingErrors.add (SingleError.builderError ()
.errorFieldName (aRepoKeyVES.getPath ())
.errorText ("Failed to read VES as XML.")
.build ());
return null;
}

// Now read into data model
ret = convertToLoadedVES (aStatus, aVES, aLoaderStatus, aErrorList);
ret = convertToLoadedVES (aStatus, aVES, aLoaderStatus, aLoadingErrors);
return ret;
}
finally
Expand Down Expand Up @@ -617,9 +617,9 @@ static RepoStorageKeyOfArtefact createRepoStorageKey (@Nonnull final VesResource
* The VESID of the artefacts to load. Must not be <code>null</code>.
* @param aValidationSource
* The data to be validated. Must not be <code>null</code>.
* @param aErrorList
* The error list to be filled, containing the loading errors.
* Validation errors will be returned in a separate
* @param aLoadingErrors
* The loading error list to be filled. Contains only the loading
* errors - validation errors will be returned in a separate
* {@link ValidationResultList}. Must not be <code>null</code>.
* @return The validation result
* @throws VESLoadingException
Expand All @@ -629,12 +629,12 @@ static RepoStorageKeyOfArtefact createRepoStorageKey (@Nonnull final VesResource
public static VESValidationResult loadVESAndApplyValidation (@Nonnull final IRepoStorageBase aRepo,
@Nonnull final VESID aVESID,
@Nonnull final IValidationSource aValidationSource,
@Nonnull final ErrorList aErrorList) throws VESLoadingException
@Nonnull final ErrorList aLoadingErrors) throws VESLoadingException
{
ValueEnforcer.notNull (aRepo, "RepoChain");
ValueEnforcer.notNull (aVESID, "VESID");
ValueEnforcer.notNull (aValidationSource, "ValidationSource");
ValueEnforcer.notNull (aErrorList, "ErrorList");
ValueEnforcer.notNull (aLoadingErrors, "LoadingErrors");

// Remember start date time
final OffsetDateTime aStartDT = PDTFactory.getCurrentOffsetDateTime ();
Expand All @@ -645,15 +645,15 @@ public static VESValidationResult loadVESAndApplyValidation (@Nonnull final IRep

final StopWatch aSWLoad = StopWatch.createdStarted ();
final LoadedVES aLoadedVES = new VESLoader (aRepo).setUseEagerRequirementLoading (true)
.loadVESFromRepo (aVESID, aErrorList);
.loadVESFromRepo (aVESID, aLoadingErrors);
aSWLoad.stop ();
if (aLoadedVES == null)
{
throw new VESLoadingException ("Failed to load VES '" +
aVESID.getAsSingleID () +
"': " +
StringHelper.getImplodedMapped ("\n ",
aErrorList,
aLoadingErrors,
x -> x.getAsString (Locale.ENGLISH)));
}

Expand Down

0 comments on commit fcf501b

Please sign in to comment.