SyncSubscription body) throws DispositionReportFaultMessage,
RemoteException {
//validate
SyncSubscriptionDetail syncSubscriptionDetail = new SyncSubscriptionDetail();
Map<String,org.apache.juddi.api_v3.ClientSubscriptionInfo> clientSubscriptionInfoMap
= new HashMap<String,org.apache.juddi.api_v3.ClientSubscriptionInfo>();
//find the clerks to go with these subscriptions
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
this.getEntityPublisher(em, body.getAuthInfo());
for (GetSubscriptionResults getSubscriptionResult : body.getGetSubscriptionResultsList()) {
String subscriptionKey = getSubscriptionResult.getSubscriptionKey();
org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo =
em.find(org.apache.juddi.model.ClientSubscriptionInfo.class, subscriptionKey);
if (modelClientSubscriptionInfo == null) {
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.SubscripKeyNotFound", subscriptionKey));
}
org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo = new org.apache.juddi.api_v3.ClientSubscriptionInfo();
MappingModelToApi.mapClientSubscriptionInfo(modelClientSubscriptionInfo, apiClientSubscriptionInfo);
clientSubscriptionInfoMap.put(apiClientSubscriptionInfo.getSubscriptionKey(),apiClientSubscriptionInfo);
}
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
for (GetSubscriptionResults getSubscriptionResult : body.getGetSubscriptionResultsList()) {
try {
String subscriptionKey = getSubscriptionResult.getSubscriptionKey();
Clerk fromClerk = clientSubscriptionInfoMap.get(subscriptionKey).getFromClerk();
Clerk toClerk = clientSubscriptionInfoMap.get(subscriptionKey).getToClerk();
String clazz = fromClerk.getNode().getProxyTransport();
Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());
Transport transport = (Transport) transportClass.getConstructor(String.class).newInstance(fromClerk.getNode().getName());
UDDISubscriptionPortType subscriptionService = transport.getUDDISubscriptionService(fromClerk.getNode().getSubscriptionUrl());
SubscriptionResultsList list = subscriptionService.getSubscriptionResults(getSubscriptionResult);
JAXBContext context = JAXBContext.newInstance(list.getClass());
Marshaller marshaller = context.createMarshaller();
StringWriter sw = new StringWriter();
marshaller.marshal(list, sw);
log.info("Notification received by UDDISubscriptionListenerService : " + sw.toString());
NotificationList<String> nl = NotificationList.getInstance();
nl.getNotifications().add(sw.toString());
//update the registry with the notification list.
XRegisterHelper.handle(fromClerk, toClerk, list);
syncSubscriptionDetail.getSubscriptionResultsList().add(list);
} catch (Exception ce) {
log.error(ce.getMessage(),ce);
if (ce instanceof DispositionReportFaultMessage) {
throw (DispositionReportFaultMessage) ce;
}