use of won.protocol.exception.ConnectionAlreadyExistsException in project webofneeds by researchstudio-sat.
the class CommentUnrestrictedFacet method connectFromNeed.
@Override
public void connectFromNeed(Connection con, Model content, WonMessage wonMessage) throws NoSuchNeedException, IllegalMessageForNeedStateException, ConnectionAlreadyExistsException {
super.connectFromNeed(con, content, wonMessage);
/* send a connect back */
try {
// TODO: use new system
// needFacingConnectionClient.open(con, content, null);
Need need = needRepository.findOneByNeedURI(con.getNeedURI());
Model needContent = need.getDatatsetHolder().getDataset().getDefaultModel();
PrefixMapping prefixMapping = PrefixMapping.Factory.create();
// prefixMapping.setNsPrefix(SIOC.getURI(),"sioc");
needContent.withDefaultMappings(prefixMapping);
needContent.setNsPrefix("sioc", SIOC.getURI());
Resource post = needContent.createResource(con.getNeedURI().toString(), SIOC.POST);
Resource reply = needContent.createResource(con.getRemoteNeedURI().toString(), SIOC.POST);
needContent.add(needContent.createStatement(needContent.getResource(con.getNeedURI().toString()), SIOC.HAS_REPLY, needContent.getResource(con.getRemoteNeedURI().toString())));
// add WON node link
logger.debug("linked data:" + RdfUtils.toString(needContent));
need.getDatatsetHolder().getDataset().setDefaultModel(needContent);
needRepository.save(need);
// } catch (NoSuchConnectionException e) {
// e.printStackTrace();
// } catch (IllegalMessageForConnectionStateException e) {
// e.printStackTrace();
} catch (Exception e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
/* when connected change linked data*/
}
Aggregations