for (int i = 0; i < permissions.getLength(); i++) { Element permission = (Element) permissions.item(i);
for (int i = 0; i < permissions.size(); i++) { Element permission = (Element) permissions.get(i);
    protected void init(Element step) {        try {            setId(Integer.parseInt(step.getAttribute("id")));        } catch (Exception ex) {            throw new IllegalArgumentException("Invalid step id value " + step.getAttribute("id"));        }        name = step.getAttribute("name");        NodeList children = step.getChildNodes();        for (int i = 0; i < children.getLength(); i++) {            Node child = (Node) children.item(i);            if (child.getNodeName().equals("meta")) {                Element meta = (Element) child;                String value = XMLUtil.getText(meta);                this.metaAttributes.put(meta.getAttribute("name"), value);            }        }        // set up pre-functions - OPTIONAL        Element pre = XMLUtil.getChildElement(step, "pre-functions");        if (pre != null) {            NodeList preFunctions = pre.getElementsByTagName("function");            for (int k = 0; k < preFunctions.getLength(); k++) {                Element preFunction = (Element) preFunctions.item(k);                FunctionDescriptor functionDescriptor = new FunctionDescriptor(preFunction);                functionDescriptor.setParent(this);                this.preFunctions.add(functionDescriptor);            }        }        // set up permissions - OPTIONAL        Element p = XMLUtil.getChildElement(step, "external-permissions");        if (p != null) {            NodeList permissions = p.getElementsByTagName("permission");            for (int i = 0; i < permissions.getLength(); i++) {                Element permission = (Element) permissions.item(i);                PermissionDescriptor permissionDescriptor = new PermissionDescriptor(permission);                permissionDescriptor.setParent(this);                this.permissions.add(permissionDescriptor);            }        }        // set up actions - OPTIONAL        Element a = XMLUtil.getChildElement(step, "actions");        if (a != null) {            hasActions = true;            NodeList actions = a.getElementsByTagName("action");            for (int i = 0; i < actions.getLength(); i++) {                Element action = (Element) actions.item(i);                ActionDescriptor actionDescriptor = new ActionDescriptor(action);                actionDescriptor.setParent(this);                this.actions.add(actionDescriptor);            }            // look for common-action elements            NodeList commonActions = a.getElementsByTagName("common-action");            for (int i = 0; i < commonActions.getLength(); i++) {                Element commonAction = (Element) commonActions.item(i);                WorkflowDescriptor workflowDescriptor = (WorkflowDescriptor) (getParent());                try {                    Integer actionId = new Integer(commonAction.getAttribute("id"));                    ActionDescriptor commonActionReference = (ActionDescriptor) workflowDescriptor.getCommonActions().get(actionId);                    if (commonActionReference != null) {                        this.actions.add(commonActionReference);                    }                    this.commonActions.add(actionId);                } catch (Exception ex) {                    //log.warn("Invalid common actionId:" + ex);                }            }        }        // set up post-functions - OPTIONAL        Element post = XMLUtil.getChildElement(step, "post-functions");        if (post != null) {            NodeList postFunctions = post.getElementsByTagName("function");            for (int k = 0; k < postFunctions.getLength(); k++) {                Element postFunction = (Element) postFunctions.item(k);                FunctionDescriptor functionDescriptor = new FunctionDescriptor(postFunction);                functionDescriptor.setParent(this);                this.postFunctions.add(functionDescriptor);            }        }    }