// Validate request parameters
for (int i=0; i<tModelVector.size(); i++)
{
// move the TModel into a form we can work with easily
TModel tModel = (TModel)tModelVector.elementAt(i);
String tModelKey = tModel.getTModelKey();
// If a TModelKey was specified then make sure it's a valid one.
if (((tModelKey != null) && (tModelKey.length() > 0)) && (!dataStore.isValidTModelKey(tModelKey)))
throw new InvalidKeyPassedException("save_tModel: "+
"tModelKey="+tModelKey);
// If a TModelKey was specified then make sure 'publisherID' controls it.
if (((tModelKey != null) && (tModelKey.length() > 0)) && !dataStore.isTModelPublisher(tModelKey,publisherID))
throw new UserMismatchException("save_tModel: "+
"userID="+publisherID+", "+
"tModelKey="+tModelKey);
// 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 = tModel.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<tModelVector.size(); i++)
{
// move the TModel into a form we can work with easily
TModel tModel = (TModel)tModelVector.elementAt(i);
String tModelKey = tModel.getTModelKey();
// If the new TModel has a TModelKey then it must already exists
// so delete the old one. It a TModelKey isn't specified then
// this is a new TModel so create a new TModelKey for it.
if ((tModelKey != null) && (tModelKey.length() > 0))
dataStore.deleteTModel(tModelKey);
else
tModel.setTModelKey("uuid:"+uuidgen.uuidgen());
// Everything checks out so let's save it. First store
// 'authorizedName' and 'operator' values in each TModel.
tModel.setAuthorizedName(authorizedName);
tModel.setOperator(Config.getOperator());
dataStore.saveTModel(tModel,publisherID);
}
dataStore.commit();