// 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("save_binding: "+
"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("save_binding: "+
"publisherID="+publisherID+", "+
"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("save_binding: "+
"bindingKey="+bindingKey);
// Normally, a valid tModelKey MUST be specified for the keyedReference
// to be valid. However, in the case of a keyedReference that is used in
// a categoryBag, the tModelKey may be omitted or specified as a
// zero-length string to indicate that the taxonomy being used is
// uddi-org:general_keywords. When it is omitted in this manner, the UDDI
// registry will insert the proper key during the save_xx operation.
// - UDDI Programmers API v2.04 Section 4.3.5.1 Specifying keyedReferences
//
CategoryBag categoryBag = binding.getCategoryBag();
if (categoryBag != null)
{
Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
if (keyedRefVector != null)
{
int vectorSize = keyedRefVector.size();
if (vectorSize > 0)
{
for (int j=0; j<vectorSize; j++)
{
KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(j);
String key = keyedRef.getTModelKey();
// A null or zero-length tModelKey is treated as
// though the tModelKey for uddiorg:general_keywords
// had been specified.
//
if ((key == null) || (key.trim().length() == 0))
keyedRef.setTModelKey(TModel.GENERAL_KEYWORDS_TMODEL_KEY);
}
}
}
}
}
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);
}