Package org.wso2.carbon.registry.common.ui.utils

Examples of org.wso2.carbon.registry.common.ui.utils.TreeNode


   
    protected static SVGImpl generateSVGImpl(java.io.InputStream is) throws java.io.IOException {
      byte[] b=new byte[is.available()];
      is.read(b);
   
      BPELInterface bpel = new BPELImpl();
        OMElement bpelStr = bpel.load(new String(b));
       
        bpel.processBpelString(bpelStr);

        LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here


   * @param transformer The optional image transformer
   * @throws java.io.IOException Failed to generate the representation
   */
    public static void generate(java.io.InputStream is, java.io.OutputStream os,
                SVGImageTransformer transformer) throws java.io.IOException {
        SVGImpl svg = generateSVGImpl(is);
       
        if (transformer == null) {
          String str=svg.getHeaders()+svg.generateSVGString();
          os.write(str.getBytes());
        } else {
          transformer.transform(svg, os);
        }
    }
View Full Code Here

        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

    }
    public TreeNode buildTree() throws Exception{
        String schemaName = RegistryUtils.getResourceName(schemaPath);
        List<String> attributeList = new ArrayList<String>();
        attributeList.add(SchemaConstants.NAME);
        TreeNode root = new TreeNode(TreeNodeBuilderUtil.generateKeyName(SchemaConstants.SCHEMA, schemaName));
        /* Adding namespace information in to the tree struction */
        addSchemaDataToTreeWithHyperlink(SchemaConstants.XPATH_TARGETNAMESPACE,
                SchemaConstants.TARGETNAMESPACE, root,
                schemaElement, false);
        /* Adding Elements*/
 
View Full Code Here

    }

    public void addSchemaDataToTree(String xPath, String headingName, TreeNode root, OMElement scope,
                                    List<String> attributes) throws Exception{
        List<OMElement> list = TreeNodeBuilderUtil.evaluateXPathToElements(xPath,scope);
        TreeNode nodes = new TreeNode(headingName);
        for(OMElement element:list){
            Iterator attributeIt = attributes.iterator();
            String elementValue = "";
            while(attributeIt.hasNext()){
                String attributeName = (String)attributeIt.next();
                if(element.getAttributeValue(new QName(attributeName)) != null){
                    elementValue = elementValue + attributeName + ":" + element.getAttributeValue(new QName(attributeName));
                    TreeNode elementNode = new TreeNode(elementValue);
                    nodes.addChild(elementNode);
                }

            }
        }
View Full Code Here

        }
    }
    public void addSchemaDataWithAttributesToTree(String xPath, String headingName, TreeNode root, OMElement scope,
                                    List<String> attributes) throws Exception{
        List<OMAttribute> list = TreeNodeBuilderUtil.evaluateXPathToAttributes(xPath, scope);
        TreeNode nodes = new TreeNode(headingName);
        for(OMAttribute element:list){
            Iterator attributeIt = attributes.iterator();
            String elementValue = "";
            while(attributeIt.hasNext()){
                String attributeName = (String)attributeIt.next();
                if(element.getQName().equals(new QName(attributeName))){
                    elementValue = elementValue + attributeName + ":" + element.getAttributeValue();
                    TreeNode elementNode = new TreeNode(elementValue);
                    nodes.addChild(elementNode);
                }

            }
        }
View Full Code Here

    public void addSchemaDataToTreeWithHyperlink(String xPath, String headingName, TreeNode root,
                                                 OMElement element, boolean isLink)
            throws Exception{
        List<String> list = TreeNodeBuilderUtil.evaluateXPathToValues(xPath,
                element);
        TreeNode nodes = new TreeNode(headingName);
        for(String urls:list){
            String registryUrl;
            if (isLink) {
                registryUrl = TreeNodeBuilderUtil.calculateAbsolutePath(schemaPath, urls);
                registryUrl = "<a href='" + SchemaConstants.RESOURCE_JSP_PAGE + "?" +
                        SchemaConstants.PATH_REQ_PARAMETER + "=" +
                        registryUrl + "'>" + urls + "</a>";
            } else {
                registryUrl = urls;
            }
            TreeNode elementNode = new TreeNode(registryUrl);
            nodes.addChild(elementNode);
        }
        if(nodes.getChildNodes() != null){
            root.addChild(nodes);
        }
View Full Code Here

    }

    public TreeNode buildTree() throws Exception {
        // prepare the root tree node.
        String wsdlName = RegistryUtils.getResourceName(wsdlPath);
        TreeNode root = new TreeNode(TreeNodeBuilderUtil.generateKeyName(WSDLConstants.WSDL, wsdlName));
        // adding the documentation
        OMElement wsdlDocElement = TreeNodeBuilderUtil.evaluateXPathToElement(WSDLConstants.WSDL_DOCUMENTATION_EXPR,
                wsdlElement);
        if (wsdlDocElement != null) {
            OMNode wsdlDocChild = wsdlDocElement.getFirstOMChild();
            if (wsdlDocChild instanceof OMText) {
                String documentationText = ((OMText)wsdlDocChild).getText();
                if (documentationText != null) {
                    documentationText = documentationText.replace('\n', ' ').trim();
                    root.addChild(new TreeNode(WSDLConstants.WSDL_DOCUMENTATION, documentationText));
                }
            }
        }

        // adding the version
        String wsdlVersion = getWSDLVersion(wsdlElement);
        root.addChild(new TreeNode(WSDLConstants.WSDL_VERSION, wsdlVersion));

        if (wsdlVersion.equals(WSDLConstants.WSDL_VERSION_VALUE_11)) {
            buildWSDL11Services(root);

            // adding the schema imports
            List<String> wsdlImports = TreeNodeBuilderUtil.evaluateXPathToValues(WSDLConstants.WSDL_IMPORTS_EXPR, wsdlElement);
            if (wsdlImports.size() != 0) {
                TreeNode wsdlImportNode = new TreeNode(WSDLConstants.WSDL_IMPORTS);
                root.addChild(wsdlImportNode);
                for (String wsdlImport: wsdlImports) {
                    String wsdImportAbsolutePath;
                    if (actualWsdlPath != null) {
                            wsdImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(actualWsdlPath, wsdlImport);
                    } else {
                        wsdImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(wsdlPath, wsdlImport);
                    }
                    String wsdlImportEntry = "<a href='" + WSDLConstants.RESOURCE_JSP_PAGE + "?" +
                            WSDLConstants.PATH_REQ_PARAMETER + "=" +
                            wsdImportAbsolutePath + "'>" + wsdlImport + "</a>";
                    wsdlImportNode.addChild(wsdlImportEntry);
                }
            }     
        } else {
            String msg = "Unknown WSDL Version.";
            throw new Exception(msg);           
        }

        List<String> schemaImports = TreeNodeBuilderUtil.evaluateXPathToValues(WSDLConstants.SCHEMA_IMPORTS_EXPR, wsdlElement);
        if (schemaImports.size() != 0) {
            TreeNode schemaImportsNode = new TreeNode(WSDLConstants.SCHEMA_IMPORTS);
            root.addChild(schemaImportsNode);
            for (String schemaImport: schemaImports) {
                if (schemaImport.indexOf(";version:") > 0) {
                    schemaImport = schemaImport.substring(0, schemaImport.lastIndexOf(";version:"));
                }
                String schemaImportAbsolutePath;
                if (actualWsdlPath != null) {
                    schemaImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(actualWsdlPath, schemaImport);
                } else {
                    schemaImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(wsdlPath, schemaImport);
                }
                String schemaImportEntry = "<a href='" + WSDLConstants.RESOURCE_JSP_PAGE + "?" +
                        WSDLConstants.PATH_REQ_PARAMETER + "=" +
                        schemaImportAbsolutePath + "'>" + schemaImport + "</a>";
                schemaImportsNode.addChild(schemaImportEntry);
            }
        }
       

        return root;
View Full Code Here

        // start with services.
        List<OMElement> serviceElements = TreeNodeBuilderUtil.evaluateXPathToElements(WSDLConstants.SERVICE_EXPR, wsdlElement);
        for (OMElement serviceElement: serviceElements) {
            String serviceName = serviceElement.getAttributeValue(new QName(WSDLConstants.SERVICE_NAME_ATTRIBUTE));
            String serviceNamespace = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.TARGET_NAMESPACE, serviceElement);
            TreeNode serviceNode = new TreeNode(TreeNodeBuilderUtil.generateKeyName(WSDLConstants.WSDL_SERVICE,
                    TreeNodeBuilderUtil.convertQNameToString(serviceName, serviceNamespace)));
            root.addChild(serviceNode);

            // now build the ports for each service nodes.
            if (buildPorts(serviceNode, serviceElement)) {
                // until there are valid ports, we don't mark the service is found.
                servicesFound = true;
            }
        }
        if (!servicesFound) {
            // we will iterate through the bindings and fill the data to the wsdl root node
            boolean bindingsFound = false;
            List<OMElement> bindingElements = TreeNodeBuilderUtil.evaluateXPathToElements(WSDLConstants.BINDING_EXPR, wsdlElement);
            for (OMElement bindingElement: bindingElements) {
                bindingsFound = true;
                String bindingName = bindingElement.getAttributeValue(new QName(WSDLConstants.BINDING_NAME_ATTRIBUTE));
                String bindingNamespace = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.TARGET_NAMESPACE, bindingElement);
                TreeNode bindingNode = new TreeNode(TreeNodeBuilderUtil.generateKeyName(WSDLConstants.BINDING,
                        TreeNodeBuilderUtil.convertQNameToString(bindingName, bindingNamespace)));
                root.addChild(bindingNode);
                fillBinding(bindingNode, bindingElement);
            }

            if (!bindingsFound) {
                // ok hope there are port types, if not we just give up.
                List<OMElement> portTypeElements = TreeNodeBuilderUtil.evaluateXPathToElements(WSDLConstants.PORT_TYPE_EXPR, wsdlElement);
                for (OMElement portTypeElement: portTypeElements) {
                    String portTypeName = portTypeElement.getAttributeValue(new QName(WSDLConstants.POR_TYPE_NAME_ATTRIBUTE));
                    String portTypeNamespace = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.TARGET_NAMESPACE, portTypeElement);
                    TreeNode portTypeNode = new TreeNode(TreeNodeBuilderUtil.generateKeyName(WSDLConstants.PORT_TYPE,
                            TreeNodeBuilderUtil.convertQNameToString(portTypeName, portTypeNamespace)));
                    root.addChild(portTypeNode);
                    fillPortType(portTypeNode, portTypeElement);
                }
            }
View Full Code Here

        List<OMElement> portElements = TreeNodeBuilderUtil.evaluateXPathToElements(WSDLConstants.PORT_EXPR, serviceElement);
        boolean portTypesFound = false;
        for (OMElement portElement: portElements) {
            String portName = portElement.getAttributeValue(new QName(WSDLConstants.PORT_NAME_ATTRIBUTE));
            String portNamespace = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.TARGET_NAMESPACE, portElement);
            TreeNode portNode = new TreeNode(TreeNodeBuilderUtil.generateKeyName(WSDLConstants.SERVICE_PORT,
                    TreeNodeBuilderUtil.convertQNameToString(portName, portNamespace)));
            serviceNode.addChild(portNode);
           
            // finding the bindings for the port.
            String bindingName = portElement.getAttributeValue(new QName(WSDLConstants.BINDING_ATTRIBUTE));
            if (bindingName == null) {
                continue;
            }

            String bindingNamespace = TreeNodeBuilderUtil.getNamespaceURI(bindingName, portElement);
            String bindingLocalName = TreeNodeBuilderUtil.getLocalName(bindingName);

            // so we cruising for the binding with that name.
            String bindingExpression = "/wsdl:definitions/wsdl:binding[@name='" + bindingLocalName +
                    "' and ancestor::*[@targetNamespace='" + bindingNamespace + "']]";
            // get the first bindingElement.
            OMElement bindingElement = TreeNodeBuilderUtil.evaluateXPathToElement(bindingExpression, wsdlElement);

            if (bindingElement != null) {
                // until there is a bound binding elements, we doesn't mark the existence of port type
                portTypesFound = true;
                // now check for the soap binding
                OMElement bindingProtocolElement = TreeNodeBuilderUtil.evaluateXPathToElement(WSDLConstants.SOAP_BINDING_EXPR, bindingElement);

                if (bindingProtocolElement != null) {
                    // so it is soap 1.1
                    String endpoint = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.SOAP_11_ENDPOINT_EXPR, portElement);
                    portNode.addChild(new TreeNode(WSDLConstants.SOAP_11_ENDPOINT, endpoint));
                    portNode.addChild(new TreeNode(WSDLConstants.SOAP_VERSION, WSDLConstants.SOAP_11));
                } else {
                    bindingProtocolElement = TreeNodeBuilderUtil.evaluateXPathToElement(WSDLConstants.SOAP12_BINDING_EXPR, bindingElement);
                    if (bindingProtocolElement != null) {
                        // it is soap 1.2
                        String endpoint = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.SOAP_12_ENDPOINT_EXPR, portElement);
                        portNode.addChild(new TreeNode(WSDLConstants.SOAP_12_ENDPOINT, endpoint));
                        portNode.addChild(new TreeNode(WSDLConstants.SOAP_VERSION, WSDLConstants.SOAP_12));
                    }
                }

                if (bindingProtocolElement != null) {
                    // We found this is SOAP (either 1.1. or 1.2), now we will get the transport and style info
                    String style = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.BINDING_STYLE_EXPR, bindingProtocolElement);
                    portNode.addChild(new TreeNode(WSDLConstants.BINDING_STYLE, style));

                    String transport = bindingProtocolElement.getAttributeValue(new QName(WSDLConstants.BINDING_TRANSPORT_ATTRIBUTE));
                    if (transport.equals(WSDLConstants.HTTP_TRANSPORT_ATTRIBUTE_VALUE)) {
                        portNode.addChild(new TreeNode(WSDLConstants.BINDING_TRANSPORT,
                                WSDLConstants.HTTP_TRANSPORT_VALUE));
                    } else {
                        portNode.addChild(new TreeNode(WSDLConstants.BINDING_TRANSPORT,
                                WSDLConstants.NON_HTTP_TRANSPORT_VALUE));
                    }

                }

                if (bindingProtocolElement == null) {
                    // expecting this to be http
                    bindingProtocolElement = TreeNodeBuilderUtil.evaluateXPathToElement(WSDLConstants.HTTP_BINDING_EXPR, bindingElement);
                    if (bindingProtocolElement != null) {
                        String endpoint = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.HTTP_ENDPOINT_EXPR, portElement);
                        portNode.addChild(new TreeNode(WSDLConstants.HTTP_ENDPOINT, endpoint));
                        portNode.addChild(new TreeNode(WSDLConstants.HTTP_BINDING, WSDLConstants.HTTP_BINDING_TRUE));

                        String verb = bindingProtocolElement.getAttributeValue(new QName(WSDLConstants.BINDING_VERB_ATTRIBUTE));
                        portNode.addChild(new TreeNode(WSDLConstants.BINDING_VERB, verb));
                    }
                }
                // Here we don't create a special node for bindingNode, so bindingNode = portNode
                fillBinding(portNode, bindingElement);
            } else {
                // even if the binding element is not present, we probably can find the endpoint from the 'address'
                // element
                String endpoint = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.SOAP_11_ENDPOINT_EXPR, portElement);
                if (endpoint != null) {
                    portNode.addChild(new TreeNode(WSDLConstants.SOAP_11_ENDPOINT, endpoint));
                    portNode.addChild(new TreeNode(WSDLConstants.SOAP_VERSION, WSDLConstants.SOAP_11));
                } else {
                    endpoint = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.SOAP_12_ENDPOINT_EXPR, portElement);
                    if (endpoint != null) {
                        portNode.addChild(new TreeNode(WSDLConstants.SOAP_12_ENDPOINT, endpoint));
                        portNode.addChild(new TreeNode(WSDLConstants.SOAP_VERSION, WSDLConstants.SOAP_12));
                    }
                }
                if (endpoint == null) {
                    // then we can assume it is http
                    endpoint = TreeNodeBuilderUtil.evaluateXPathToValue(WSDLConstants.HTTP_ENDPOINT_EXPR, portElement);
                    if (endpoint != null) {
                        portNode.addChild(new TreeNode(WSDLConstants.HTTP_ENDPOINT, endpoint));
                        portNode.addChild(new TreeNode(WSDLConstants.HTTP_BINDING, WSDLConstants.HTTP_BINDING_TRUE));
                    }
                }
            }
            portNode.addChild(new TreeNode(WSDLConstants.BINDING, TreeNodeBuilderUtil.convertQNameToString(bindingLocalName,
                    bindingNamespace)));
        }
        return portTypesFound;
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.common.ui.utils.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.