// an empty ServiceList (aka "a zero match result set").
if(((serviceKey == null) || (serviceKey.length() == 0)) &&
((categoryBag == null) || (categoryBag.size() == 0)) &&
((tModelBag == null) || (tModelBag.size() == 0)))
{
BindingDetail detail = new BindingDetail();
detail.setGeneric(generic);
detail.setBindingTemplateVector(null);
detail.setOperator(Config.getOperator());
detail.setTruncated(false);
return detail;
}
// Validate CategoryBag and (if neccessary) add TModelKey for: uddiorg:general_keywords
if (categoryBag != null)
{
Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
if (keyedRefVector != null)
{
int vectorSize = keyedRefVector.size();
if (vectorSize > 0)
{
for (int i=0; i<vectorSize; i++)
{
KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
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);
}
}
}
}
// aquire a jUDDI datastore instance
DataStore dataStore = DataStoreFactory.getDataStore();
try
{
dataStore.beginTrans();
// a find_binding request MUST include a service_key attribute
if ((serviceKey == null) || (serviceKey.length() == 0))
throw new InvalidKeyPassedException("find_binding: "+
"serviceKey="+serviceKey);
// validate the 'qualifiers' parameter as much as possible up-front before
// calling into the data layer for relational validation.
if (qualifiers != null)
{
Vector qVector = qualifiers.getFindQualifierVector();
if ((qVector!=null) && (qVector.size() > 0))
{
for (int i=0; i<qVector.size(); i++)
{
FindQualifier qualifier = (FindQualifier)qVector.elementAt(i);
String qValue = qualifier.getValue();
if ((!qValue.equals(FindQualifier.EXACT_NAME_MATCH)) &&
(!qValue.equals(FindQualifier.CASE_SENSITIVE_MATCH)) &&
(!qValue.equals(FindQualifier.OR_ALL_KEYS)) &&
(!qValue.equals(FindQualifier.OR_LIKE_KEYS)) &&
(!qValue.equals(FindQualifier.AND_ALL_KEYS)) &&
(!qValue.equals(FindQualifier.SORT_BY_NAME_ASC)) &&
(!qValue.equals(FindQualifier.SORT_BY_NAME_DESC)) &&
(!qValue.equals(FindQualifier.SORT_BY_DATE_ASC)) &&
(!qValue.equals(FindQualifier.SORT_BY_DATE_DESC)) &&
(!qValue.equals(FindQualifier.SERVICE_SUBSET)) &&
(!qValue.equals(FindQualifier.COMBINE_CATEGORY_BAGS)))
throw new UnsupportedException("find_binding: "+
"findQualifier="+qValue);
}
}
}
Vector bindingVector = null;
boolean truncatedResults = false;
// perform the search for matching binding templates (return only keys in requested order)
Vector keyVector = dataStore.findBinding(serviceKey,categoryBag,tModelBag,qualifiers);
if ((keyVector != null) && (keyVector.size() > 0))
{
// if a maxRows value has been specified and it's less than
// the number of rows we are about to return then only return
// maxRows specified.
int rowCount = keyVector.size();
if ((maxRows > 0) && (maxRows < rowCount))
{
rowCount = maxRows;
truncatedResults = true;
}
// iterate through the binding templates keys fetching
// each associated BindingTemplate in sequence.
bindingVector = new Vector(rowCount);
for (int i=0; i<rowCount; i++)
bindingVector.addElement(dataStore.fetchBinding((String)keyVector.elementAt(i)));
}
dataStore.commit();
// create a new BindingDetail instance and stuff
// the new bindingTemplateVector into it.
BindingDetail detail = new BindingDetail();
detail.setBindingTemplateVector(bindingVector);
detail.setGeneric(generic);
detail.setOperator(Config.getOperator());
detail.setTruncated(truncatedResults);
return detail;
}
catch(InvalidKeyPassedException keyex)
{
try { dataStore.rollback(); } catch(Exception e) { }