* @throws RegistryException
* @throws ServiceNotFoundException
*/
public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
//first find the ServiceBindings for this service
Connection connection = JAXRConnectionSingleton.getConnection(jaxrConnectionFactory);
Service service = null;
try {
service = findService(category, serviceName);
if (service==null) {
throw new ServiceNotFoundException("No such Service found for service with category= "
+ category + " and name = " + serviceName);
}
Collection serviceBindings = findServiceBindings(service);
String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
for (Iterator i=serviceBindings.iterator();i.hasNext();){
ServiceBinding serviceBinding = (ServiceBinding) i.next();
String eprXML = serviceBinding.getAccessURI().trim();
// for backwards compatibility still have the decoder if
// unmarchalling fails
try {
EPRHelper.fromXMLString(eprXML);
} catch (UnmarshalException unme) {
try {
eprXML = URLDecoder.decode(eprXML, "UTF-8").trim();
} catch (UnsupportedEncodingException ue) {
logger.error(unme.getMessage(), unme);
logger.error(ue.getMessage(), ue);
}
}
if (eprXML.equals(toBeDeletedEPRXml)) {
RegistryService rs = connection.getRegistryService();
BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
Collection<Key> serviceBindingKeys = new ArrayList<Key>();
serviceBindingKeys.add(serviceBinding.getKey());
blm.deleteServiceBindings(serviceBindingKeys);
return;