if (state != null && state.length() > 0 && !state.equals(container.getRegistry().getServiceAssemblyState(result[i]))) {
if (state != null && state.length() > 0 && !state.equals(sa.getCurrentState())) {
    public String listServiceAssemblies(String state, String componentName, String serviceAssemblyName) throws Exception {        String[] result = null;        if (null != serviceAssemblyName && serviceAssemblyName.length() > 0) {            result = new String[]{serviceAssemblyName};        } else if (null != componentName && componentName.length() > 0) {            result = container.getRegistry().getDeployedServiceAssembliesForComponent(componentName);        } else {            result = container.getRegistry().getDeployedServiceAssemblies();        }        List components = new ArrayList();        for (int i = 0; i < result.length; i++) {            // Check status            if (state != null && state.length() > 0 && !state.equals(container.getRegistry().getServiceAssemblyState(result[i]))) {                continue;            }            components.add(result[i]);        }        StringBuffer buffer = new StringBuffer();        buffer.append("<?xml version='1.0'?>\n");        buffer.append("<service-assembly-info-list xmlns='http://java.sun.com/xml/ns/jbi/component-info-list' version='1.0'>\n");        for (Iterator iter = components.iterator(); iter.hasNext();) {            String name = (String) iter.next();            buffer.append("\t<service-assembly-info");            buffer.append(" name='" + name + "'");            buffer.append(" state='" + container.getRegistry().getServiceAssemblyState(name) + "'/>");            buffer.append(" <description>" + container.getRegistry().getServiceAssemblyDesc(name) + "</description>");            buffer.append("\t</service-assembly-info>\n");            String[] serviceUnitList = container.getRegistry().getSADeployedServiceUnitList(name);            for (int i = 0; i < serviceUnitList.length; i++) {                buffer.append("\t<service-unit-info");                buffer.append(" name='" + serviceUnitList[i] + "'");                buffer.append(" state='" + container.getRegistry().getSADeployedServiceUnitDesc(name, serviceUnitList[i]) + "/>");                buffer.append("\t</service-unit-info");            }        }        buffer.append("</service-assembly-info-list>");        return buffer.toString();    }