OMElement itemEl = (OMElement)checkListIterator.next();
if (itemEl.getQName().equals(new QName("checkitem"))) {
List<String> items = new ArrayList<String>();
String itemName = itemEl.getText();
if (itemName == null)
throw new RegistryException("Checklist items should have a name!");
items.add("status:" + name);
items.add("name:" + itemName);
items.add("value:false");
if (itemEl.getAttribute(new QName("order")) != null) {
items.add("order:" + itemEl.getAttributeValue(new QName("order")));
}
else {
items.add("order:" + checklistItemOrder);
}
String resourcePropertyNameForItem
= "registry.custom_lifecycle.checklist.option" + propertyOrder + ".item";
resource.setProperty(resourcePropertyNameForItem, items);
checklistItemOrder++;
propertyOrder++;
} else if (itemEl.getQName().equals(new QName("js"))) {
Iterator scriptElementIterator = itemEl.getChildElements();
while (scriptElementIterator.hasNext()) {
OMElement scriptItemEl = (OMElement)scriptElementIterator.next();
if (scriptItemEl.getQName().equals(new QName("console"))) {
StringBuffer lifecycleScript = new StringBuffer();
String lifecycleScriptCommand = "";
Iterator consoleScriptElementIterator = scriptItemEl.getChildElements();
while (consoleScriptElementIterator.hasNext()) {
OMElement consoleScriptItemEl = (OMElement)consoleScriptElementIterator.next();
if (consoleScriptItemEl.getQName().equals(new QName("script"))) {
lifecycleScript.append(consoleScriptItemEl.toString()).append("\n");
}
}
if (scriptItemEl.getAttribute(new QName("demoteFunction")) != null) {
lifecycleScriptCommand =
scriptItemEl.getAttributeValue(new QName("demoteFunction"));
List<String> items = new ArrayList<String>();
items.add(lifecycleScript.toString());
items.add(lifecycleScriptCommand);
String resourcePropertyNameForItem =
"registry.custom_lifecycle.checklist.js.script.console." +
name + "." + DEMOTE;
resource.setProperty(resourcePropertyNameForItem, items);
}
if (scriptItemEl.getAttribute(new QName("promoteFunction")) != null) {
lifecycleScriptCommand =
scriptItemEl.getAttributeValue(new QName("promoteFunction"));
List<String> items = new ArrayList<String>();
items.add(lifecycleScript.toString());
items.add(lifecycleScriptCommand);
String resourcePropertyNameForItem =
"registry.custom_lifecycle.checklist.js.script.console." +
name + "." + PROMOTE;
resource.setProperty(resourcePropertyNameForItem, items);
}
} else if (scriptItemEl.getQName().equals(new QName("server"))) {
String lifecycleScript = "";
String lifecycleScriptCommand = "";
Iterator serverScriptElementIterator = scriptItemEl.getChildElements();
if (serverScriptElementIterator.hasNext()) {
OMElement serverScriptItemEl = (OMElement)serverScriptElementIterator.next();
if (serverScriptItemEl.getQName().equals(new QName("script"))) {
lifecycleScript += serverScriptItemEl.toString();
lifecycleScript = lifecycleScript.trim();
}
}
if (scriptItemEl.getAttribute(new QName("demoteFunction")) != null) {
lifecycleScriptCommand =
scriptItemEl.getAttributeValue(new QName("demoteFunction"));
List<String> items = new ArrayList<String>();
items.add(lifecycleScript);
items.add(lifecycleScriptCommand);
String resourcePropertyNameForItem =
"registry.custom_lifecycle.checklist.js.script.server." +
name + "." + DEMOTE;
resource.setProperty(resourcePropertyNameForItem, items);
}
if (scriptItemEl.getAttribute(new QName("promoteFunction")) != null) {
lifecycleScriptCommand =
scriptItemEl.getAttributeValue(new QName("promoteFunction"));
List<String> items = new ArrayList<String>();
items.add(lifecycleScript);
items.add(lifecycleScriptCommand);
String resourcePropertyNameForItem =
"registry.custom_lifecycle.checklist.js.script.server." +
name + "." + PROMOTE;
resource.setProperty(resourcePropertyNameForItem, items);
}
}
}
}
}
}
}
catch (XMLStreamException e) {
throw new RegistryException("Resource does not contain valid XML configuration: " + e.toString());
}
resource.setProperty(stateProperty, states.get(0));
resource.setProperty(lifecycleProperty, aspectName);
}