return leadResourceDoc;
}
private String getWorkflowTemplateID(LEADresourceDocument resourceDocument) {
// Check if the templateID is set in the metadata.
LEADResourceType resource = resourceDocument.getLEADresource();
DataType data = resource.getData();
IdinfoBase idInfo = data.getIdinfo();
KeywordsType keywords = idInfo.getKeywords();
ThemeType[] themes = keywords.getThemeArray();
String templateID = null;
for (ThemeType theme : themes) {
String themekt = theme.getThemekt();
if (WORKFLOW_TEMPLATE_ID_THEMEKT.equals(themekt)) {
// Has only one key.
templateID = theme.getThemekeyArray(0);
break;
}
}
if (templateID == null) {
logger.warning("The LEAD metadata doesn't have workflow ID."
+ " Use resource ID as workflow ID instead.");
// This happends with the metadata created by XBaya older than
// 2.5.5.
String resourceID = resource.getResourceID();
templateID = resourceID;
}
return templateID;
}