Skip to content

Commit

Permalink
A few updates on how KnowledgeNotFoundException is constructed and
Browse files Browse the repository at this point in the history
reacted to in tasks.
  • Loading branch information
keznikl committed Dec 3, 2013
1 parent 3e96f0f commit 54a019a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public ValueSet get(Collection<KnowledgePath> knowledgePaths)
ValueSet result = new ValueSet();
Object value;
for (KnowledgePath kp : knowledgePaths) {
try {
value = getKnowledge(kp.getNodes());
} catch (KnowledgeNotFoundException knfe) {
throw new KnowledgeNotFoundException(kp);
}
if (knowledge.equals(value))
for (KnowledgePath rootKP : knowledge.keySet())
result.setValue(rootKP, knowledge.get(rootKP));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
package cz.cuni.mff.d3s.deeco.knowledge;

import cz.cuni.mff.d3s.deeco.model.runtime.api.KnowledgePath;

/**
* @author Michal Kit <kit@d3s.mff.cuni.cz>
*
*/
public class KnowledgeNotFoundException extends Exception {
private static final long serialVersionUID = -999702030030889941L;

KnowledgePath notFoundPath;

KnowledgeNotFoundException() {}

public KnowledgeNotFoundException(KnowledgePath notFoundPath) {
this.notFoundPath = notFoundPath;
}

public KnowledgePath getNotFoundPath() {
return notFoundPath;
}



}
14 changes: 12 additions & 2 deletions jdeeco-core/src/cz/cuni/mff/d3s/deeco/task/EnsembleTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ private void performExchange(PathRoot localRole, ReadOnlyKnowledgeManager shadow
absoluteKnowledgePathAndRoot = getAbsoluteStrippedPath(formalParam.getKnowledgePath(), shadowKnowledgeManager, localKnowledgeManager);
}
} catch (KnowledgeNotFoundException e) {
throw new TaskInvocationException("Knowledge path in knowledge exchange could not be resolved.", e);
//throw new TaskInvocationException("Knowledge path in knowledge exchange could not be resolved.", e);
Log.i(String.format(
"Knowledge exchange of %s could not be performed: missing knowledge path (%s)",
ensembleController.getEnsembleDefinition().getName(), e.getNotFoundPath()));
return;
}

allPathsWithRoots.add(absoluteKnowledgePathAndRoot);
Expand All @@ -371,7 +375,13 @@ private void performExchange(PathRoot localRole, ReadOnlyKnowledgeManager shadow
localKnowledge = localKnowledgeManager.get(localPaths);
shadowKnowledge = shadowKnowledgeManager.get(shadowPaths);
} catch (KnowledgeNotFoundException e) {
throw new TaskInvocationException("Input knowledge of a knowledge exchange not found in the knowledge manager.", e);
// throw new TaskInvocationException(
// String.format("Input knowledge (%s) of a knowledge exchange in %s not found in the knowledge manager.",
// e.getNotFoundPath(), ensembleController.getEnsembleDefinition().getName())
// , e);
Log.i(String.format("Input knowledge (%s) of a knowledge exchange in %s not found in the knowledge manager.",
e.getNotFoundPath(), ensembleController.getEnsembleDefinition().getName()));
return;
}

// Construct the parameters for the process method invocation
Expand Down
7 changes: 5 additions & 2 deletions jdeeco-core/src/cz/cuni/mff/d3s/deeco/task/ProcessTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void invoke(Trigger trigger) throws TaskInvocationException {
try {
absoluteKnowledgePath = KnowledgePathHelper.getAbsolutePath(formalParam.getKnowledgePath(), knowledgeManager);
} catch (KnowledgeNotFoundException e) {
throw new TaskInvocationException("Knowledge path could not be resolved.", e);
throw new TaskInvocationException(
String.format("Knowledge path (%s) could not be resolved.", e.getNotFoundPath()), e);
}

if (paramDir == ParameterDirection.IN || paramDir == ParameterDirection.INOUT) {
Expand All @@ -110,7 +111,9 @@ public void invoke(Trigger trigger) throws TaskInvocationException {
try {
inKnowledge = knowledgeManager.get(inPaths);
} catch (KnowledgeNotFoundException e) {
throw new TaskInvocationException("Input knowledge of a component process not found in the knowledge manager.", e);
throw new TaskInvocationException(
String.format("Input knowledge (%s) of a component process (%s) not found in the knowledge manager.",
e.getNotFoundPath(), componentProcess.getName()), e);
}

// Construct the parameters for the process method invocation
Expand Down

0 comments on commit 54a019a

Please sign in to comment.