Skip to content

Commit

Permalink
[#227] Implemented a sanity check for loading of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Grigorev committed Jul 28, 2024
1 parent 5c827bd commit 79cc0dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public Set<String> getGlobalScripts() {
return globalScripts;
}

public boolean doesRegistryContainsEntity(String entityId) {
return moduleRegistry.doesContextContainsEntity(entityId);
}


// id -> contexts
// function id-s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public Set<String> getContexts(String entityId) {
return getResourceUri(entityId, contexts.iterator().next());
}

public boolean doesContextContainsEntity(String entityId) {
return fullName2ContextsMap.containsKey(entityId);
}



private Set<String> getLocalName2Contexts(String localEntityId) {
Expand All @@ -145,6 +149,7 @@ private boolean isLocalNameEntityId(String entityId) {
return !(isPrefixedEntityId(entityId) || isFullNameEntityId(entityId));
}


private boolean isFullNameEntityId(String entityId) {
return entityId.contains("#") || entityId.contains("/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public interface ResourceRegistry {


@NotNull String getResourceUri(@NotNull String entityId) throws ResourceNotFoundException, ResourceNotUniqueException;

@NotNull boolean doesContextContainsEntity(@NotNull String entityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ private Model runModule(final Model inputDataModel, final MultiValueMap<String,
ExecutionEngine engine = createExecutionEngine(configModel);
ContextLoaderHelper.updateContextsIfNecessary(scriptManager);
Module module = null;
try {
if (scriptManager.doesRegistryContainsEntity(id)) {
module = scriptManager.loadModule(id, null, null);
}
catch (Exception e) {
else {
module = PipelineFactory.loadModule(configModel.createResource(id));
}
if (module == null) {
Expand Down

0 comments on commit 79cc0dd

Please sign in to comment.