logger.info("Sending saveSubscriptions request..");
try {
//before sending this we need to ready the listener node
UDDIClerkManager manager = WebHelper.getUDDIClerkManager(session.getServletContext());
UDDINode homeNode = WebHelper.getUDDIHomeNode(session.getServletContext());
UDDIClerk clerk = manager.getClientConfig().getUDDIClerks().get(modelSubscription.getFromClerkName());
UDDIClerk toClerk = manager.getClientConfig().getUDDIClerks().get(modelSubscription.getToClerkName());
if (toClerk==null) {
String publisher = (String) session.getAttribute("UserName");
Map<String, UDDIClerk> clerks = manager.getClientConfig().getUDDIClerks();
for (UDDIClerk uddiClerk : clerks.values()) {
if (publisher.equals(uddiClerk.getPublisher())
&& homeNode.getName().equals(uddiClerk.getUDDINode().getName())) {
toClerk = uddiClerk;
}
}
}
logger.info("Updating homeNode server using jUDDI specific API..");
Transport defaultTransport = WebHelper.getTransport(session.getServletContext());
JUDDIApiPortType juddiApiService = defaultTransport.getJUDDIApiService();
//making sure our node info is there and up to date.
SaveNode saveNode = new SaveNode();
saveNode.setAuthInfo(userAuthToken);
saveNode.getNode().add(clerk.getApiClerk().getNode());
juddiApiService.saveNode(saveNode);
//making sure our clerk info is there and up to date
SaveClerk saveClerk = new SaveClerk();
saveClerk.setAuthInfo(userAuthToken);
saveClerk.getClerk().add(clerk.getApiClerk());
juddiApiService.saveClerk(saveClerk);
//making sure our node info is there and up to date.
SaveNode saveToNode = new SaveNode();
saveToNode.setAuthInfo(userAuthToken);
saveToNode.getNode().add(toClerk.getApiClerk().getNode());
juddiApiService.saveNode(saveToNode);
//making sure our clerk info is there and up to date
SaveClerk saveToClerk = new SaveClerk();
saveToClerk.setAuthInfo(userAuthToken);
saveToClerk.getClerk().add(toClerk.getApiClerk());
juddiApiService.saveClerk(saveToClerk);
logger.debug("Updating default UDDI server completed.");
SaveClientSubscriptionInfo saveClientSubscriptionInfo = new SaveClientSubscriptionInfo();
saveClientSubscriptionInfo.setAuthInfo(userAuthToken);
ClientSubscriptionInfo clientSubscriptionInfo = new ClientSubscriptionInfo();
clientSubscriptionInfo.setSubscriptionKey(modelSubscription.getSubscriptionKey());
clientSubscriptionInfo.setFromClerk(clerk.getApiClerk());
clientSubscriptionInfo.setToClerk(toClerk.getApiClerk());
saveClientSubscriptionInfo.getClientSubscriptionInfo().add(clientSubscriptionInfo);
//save clientSubscription to the listening UDDI default server.
juddiApiService.saveClientSubscriptionInfo(saveClientSubscriptionInfo);
logger.debug("Saved ClientSubscriptionInfo to the default UDDI server");