protected static String getRootPartition(TModel rootTModelKeyGen) throws JAXBException, IOException, DispositionReportFaultMessage {
String result = rootTModelKeyGen.getTModelKey().substring(0, rootTModelKeyGen.getTModelKey().lastIndexOf(KeyGenerator.PARTITION_SEPARATOR));
if (result == null || result.length() == 0)
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result));
// Must validate the root partition. The first component should be a domain key and the any following
// tokens should be a valid KSS.
result = result.trim();
if (result.endsWith(KeyGenerator.PARTITION_SEPARATOR) || result.startsWith(KeyGenerator.PARTITION_SEPARATOR))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result));
StringTokenizer tokenizer = new StringTokenizer(result.toLowerCase(), KeyGenerator.PARTITION_SEPARATOR);
for(int count = 0; tokenizer.hasMoreTokens(); count++) {
String nextToken = tokenizer.nextToken();
if (count == 0) {
if(!ValidateUDDIKey.isValidDomainKey(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result));
}
else {
if (!ValidateUDDIKey.isValidKSS(nextToken))
throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", result));
}
}
return result;
}