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("permissions"))) {
Iterator permissionIterator = itemEl.getChildElements();
while (permissionIterator.hasNext()) {
OMElement permissionItemEl = (OMElement) permissionIterator.next();
if (permissionItemEl.getQName().equals(new QName("permission"))) {
String action = permissionItemEl.getAttributeValue(
new QName("action"));
if (action.toLowerCase().equals(PROMOTE)) {
promoteRoles = permissionItemEl.getAttributeValue(
new QName("roles"));
} else if (action.toLowerCase().equals(DEMOTE)) {
demoteRoles = permissionItemEl.getAttributeValue(
new QName("roles"));
}
}
}
} 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"))) {
String lifecycleScript = "";
String lifecycleScriptCommand = "";
Iterator consoleScriptElementIterator = scriptItemEl.getChildElements();
while (consoleScriptElementIterator.hasNext()) {
OMElement consoleScriptItemEl = (OMElement)consoleScriptElementIterator.next();
if (consoleScriptItemEl.getQName().equals(new QName("script"))) {
lifecycleScript += consoleScriptItemEl.toString() + "\n";
}
}
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.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);
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.getText();
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);
}
}
}
}
}
if (promoteRoles.equals("#") && demoteRoles.equals("#")) {
distributedActionPermissions.add("#");
} else {
distributedActionPermissions.add(promoteRoles + ":" + demoteRoles);
}
}
} catch (XMLStreamException e) {
throw new RegistryException(
"Resource does not contain a valid XML configuration: "
+ e.toString());
}
resource.setProperty(stateProperty, states.get(0));