use of won.protocol.exception.IllegalMessageForAtomStateException in project webofneeds by researchstudio-sat.
the class DeleteAtomMessageFromOwnerProcessor method process.
public void process(final Exchange exchange) throws Exception {
Message message = exchange.getIn();
WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER);
Optional<Atom> atom = atomService.getAtom(wonMessage.getAtomURI());
if (!atom.isPresent()) {
throw new NoSuchAtomException(wonMessage.getAtomURI());
}
if (atom.get().getState() == AtomState.DELETED) {
throw new IllegalMessageForAtomStateException(atom.get().getAtomURI(), "DELETE", atom.get().getState());
}
// the rest of the delete tasks are done in the reaction processor
}
use of won.protocol.exception.IllegalMessageForAtomStateException in project webofneeds by researchstudio-sat.
the class MatcherCLI method run.
@Override
public void run(String... args) throws Exception {
String atom1 = "http://localhost:8080/won/resource/atom/1";
String atom2 = "http://localhost:8080/won/resource/atom/2";
String org = "http://localhost:8080/matcher";
double score = 1;
for (int i = 0; i < args.length; i++) {
switch(args[i]) {
case "-h":
System.out.println("USAGE: java MatcherCLI [-n1 atom1] [-n2 atom2] [-o originator] [-s score] [-h]");
System.exit(0);
case "-n1":
atom1 = args[++i];
break;
case "-n2":
atom2 = args[++i];
break;
case "-o":
org = args[++i];
break;
case "-s":
score = Double.parseDouble(args[++i]);
break;
}
}
try {
// TODO: Add rdf content
client.hint(new URI(atom1), new URI(atom2), score, new URI(org), null, createWonMessage(URI.create(atom1), URI.create(atom2), score, URI.create(org)));
} catch (URISyntaxException e) {
logger.error("Exception caught:", e);
} catch (IllegalMessageForAtomStateException e) {
logger.error("Exception caught:", e);
} catch (NoSuchAtomException e) {
logger.error("Exception caught:", e);
} catch (Exception e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
}
Aggregations