// validate request parameters
for (int i=0; i<bindingVector.size(); i++)
{
// move the BindingTemplate into a form we can work with easily
BindingTemplate binding = (BindingTemplate)bindingVector.elementAt(i);
String serviceKey = binding.getServiceKey();
String bindingKey = binding.getBindingKey();
// Confirm that the 'BusinessService' that this binding belongs to
// really exists. If not then throw an InvalidKeyPassedException.
if ((serviceKey == null) || (serviceKey.length() == 0) || (!dataStore.isValidServiceKey(serviceKey)))
throw new InvalidKeyPassedException("ServiceKey: "+serviceKey);
// Confirm that 'publisherID' controls the BusinessService that this
// binding template belongs to. If not then throw a UserMismatchException.
if (!dataStore.isServicePublisher(serviceKey,publisherID))
throw new UserMismatchException("ServiceKey: "+serviceKey);
// If a BindingKey was specified then make sure it's a valid one.
if ((bindingKey != null) && (bindingKey.length() > 0) && (!dataStore.isValidBindingKey(bindingKey)))
throw new InvalidKeyPassedException("BindingKey: "+bindingKey);
}
for (int i=0; i<bindingVector.size(); i++)
{
// move the BindingTemplate data into a form we can work with easily
BindingTemplate binding = (BindingTemplate)bindingVector.elementAt(i);
String bindingKey = binding.getBindingKey();
// If the new BindingTemplate has a BindingKey then it must already
// exists so delete the old one. It a BindingKey isn't specified then
// this is a new BindingTemplate so create a new BindingKey for it.
if ((bindingKey != null) && (bindingKey.length() > 0))
dataStore.deleteBinding(bindingKey);
else
binding.setBindingKey(uuidgen.uuidgen());
// everything checks out so let's save it.
dataStore.saveBinding(binding);
}