Search in sources :

Example 1 with PortType

use of javax.wsdl.PortType in project tesb-studio-se by Talend.

the class LocalWSDLEditor method saveModel.

private void saveModel() throws CoreException {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Definition definition = WSDLUtils.getDefinition(serviceItem);
    // changed for TDI-18005
    Map<String, String> portNameIdMap = new HashMap<String, String>();
    Map<String, EMap<String, String>> portAdditionalMap = new HashMap<String, EMap<String, String>>();
    Map<String, String> operNameIdMap = new HashMap<String, String>();
    Map<String, String> operJobMap = new HashMap<String, String>();
    EList<ServicePort> oldServicePorts = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    // get old service port item names and operation names under them
    HashMap<String, ArrayList<String>> oldPortItemNames = new HashMap<String, ArrayList<String>>();
    for (ServicePort servicePort : oldServicePorts) {
        // keep id
        portNameIdMap.put(servicePort.getName(), servicePort.getId());
        // keep additional infos
        portAdditionalMap.put(servicePort.getId(), servicePort.getAdditionalInfo());
        EList<ServiceOperation> operations = servicePort.getServiceOperation();
        ArrayList<String> operationNames = new ArrayList<String>();
        for (ServiceOperation operation : operations) {
            operNameIdMap.put(operation.getName(), operation.getId());
            operationNames.add(operation.getLabel());
            // record assigned job
            operJobMap.put(operation.getId(), operation.getReferenceJobId());
        }
        oldPortItemNames.put(servicePort.getName(), operationNames);
    }
    ((ServiceConnection) serviceItem.getConnection()).getServicePort().clear();
    for (Object obj : definition.getAllPortTypes().values()) {
        PortType portType = (PortType) obj;
        if (portType.isUndefined()) {
            continue;
        }
        ServicePort port = ServicesFactory.eINSTANCE.createServicePort();
        String portName = portType.getQName().getLocalPart();
        port.setName(portName);
        // set port id
        String id = portNameIdMap.get(portName);
        if (id != null) {
            port.setId(id);
            // restore additional infos
            port.getAdditionalInfo().putAll(portAdditionalMap.get(id));
        } else {
            port.setId(factory.getNextId());
        }
        @SuppressWarnings("unchecked") List<Operation> list = portType.getOperations();
        for (Operation operation : list) {
            if (operation.isUndefined()) {
                // means the operation has been removed already ,why ?
                continue;
            }
            ServiceOperation serviceOperation = ServicesFactory.eINSTANCE.createServiceOperation();
            serviceOperation.setName(operation.getName());
            Iterator<String> operationIterator = operNameIdMap.keySet().iterator();
            while (operationIterator.hasNext()) {
                String oldOperationName = operationIterator.next();
                String operationId = operNameIdMap.get(oldOperationName);
                if (oldOperationName.equals(operation.getName())) {
                    serviceOperation.setId(operationId);
                    // re-assign job
                    String jobId = operJobMap.get(operationId);
                    if (jobId != null) {
                        serviceOperation.setReferenceJobId(jobId);
                    }
                }
            }
            if (serviceOperation.getId() == null || serviceOperation.getId().equals("")) {
                serviceOperation.setId(factory.getNextId());
            }
            if (operation.getDocumentationElement() != null) {
                serviceOperation.setDocumentation(operation.getDocumentationElement().getTextContent());
            }
            boolean hasAssignedjob = false;
            ArrayList<String> operationNames = oldPortItemNames.get(portName);
            String referenceJobId = serviceOperation.getReferenceJobId();
            if (operationNames != null && referenceJobId != null) {
                IRepositoryViewObject repObj = null;
                try {
                    repObj = factory.getLastVersion(referenceJobId);
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
                if (repObj != null) {
                    for (String name : operationNames) {
                        if (name.equals(operation.getName() + '-' + repObj.getLabel())) {
                            serviceOperation.setLabel(name);
                            hasAssignedjob = true;
                            break;
                        }
                    }
                }
            }
            if (!hasAssignedjob) {
                serviceOperation.setLabel(operation.getName());
            }
            serviceOperation.setInBinding(WSDLUtils.isOperationInBinding(definition, portName, operation.getName()));
            port.getServiceOperation().add(serviceOperation);
        }
        ((ServiceConnection) serviceItem.getConnection()).getServicePort().add(port);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) Operation(javax.wsdl.Operation) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) EMap(org.eclipse.emf.common.util.EMap) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) PortType(javax.wsdl.PortType)

Example 2 with PortType

use of javax.wsdl.PortType in project tesb-studio-se by Talend.

the class WSDLUtils method isOperationInBinding.

public static boolean isOperationInBinding(Definition definition, String portTypeName, String operationName) throws CoreException {
    Collection<?> services = definition.getServices().values();
    for (Object s : services) {
        Service service = (Service) s;
        Collection<?> ports = service.getPorts().values();
        for (Object p : ports) {
            Port port = (Port) p;
            Binding binding = port.getBinding();
            if (binding == null) {
                continue;
            }
            PortType portType = binding.getPortType();
            if (portType == null || !portTypeName.equals(portType.getQName().getLocalPart())) {
                continue;
            }
            List<?> bindingOperations = binding.getBindingOperations();
            for (Object o : bindingOperations) {
                BindingOperation bo = (BindingOperation) o;
                if (operationName.equals(bo.getName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) ServicePort(org.talend.repository.services.model.services.ServicePort) Port(javax.wsdl.Port) Service(javax.wsdl.Service) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PortType(javax.wsdl.PortType)

Example 3 with PortType

use of javax.wsdl.PortType in project tesb-studio-se by Talend.

the class OpenWSDLPage method populateModelFromWsdl.

@SuppressWarnings({ "unchecked" })
private static void populateModelFromWsdl(IProxyRepositoryFactory factory, Definition definition, ServiceItem serviceItem, RepositoryNode serviceRepositoryNode) throws CoreException {
    serviceRepositoryNode.getChildren().clear();
    ((ServiceConnection) serviceItem.getConnection()).getServicePort().clear();
    for (PortType portType : (Collection<PortType>) definition.getAllPortTypes().values()) {
        ServicePort port = ServicesFactory.eINSTANCE.createServicePort();
        port.setId(factory.getNextId());
        port.setName(portType.getQName().getLocalPart());
        for (Operation operation : (Collection<Operation>) portType.getOperations()) {
            String operationName = operation.getName();
            ServiceOperation serviceOperation = ServicesFactory.eINSTANCE.createServiceOperation();
            serviceOperation.setId(factory.getNextId());
            RepositoryNode operationNode = new RepositoryNode(new RepositoryViewObject(serviceItem.getProperty()), serviceRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
            operationNode.setProperties(EProperties.LABEL, serviceItem.getProperty().getLabel());
            operationNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.SERVICESOPERATION);
            serviceOperation.setName(operationName);
            if (operation.getDocumentationElement() != null) {
                serviceOperation.setDocumentation(operation.getDocumentationElement().getTextContent());
            }
            serviceOperation.setLabel(operationName);
            serviceOperation.setInBinding(WSDLUtils.isOperationInBinding(definition, port.getName(), operationName));
            port.getServiceOperation().add(serviceOperation);
        }
        ((ServiceConnection) serviceItem.getConnection()).getServicePort().add(port);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) Collection(java.util.Collection) Operation(javax.wsdl.Operation) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) RepositoryNode(org.talend.repository.model.RepositoryNode) PortType(javax.wsdl.PortType) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 4 with PortType

use of javax.wsdl.PortType in project tomee by apache.

the class WsdlVisitor method walkTree.

public void walkTree() {
    begin();
    try {
        visit(definition);
        for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iterator.next();
            String namespaceURI = (String) entry.getKey();
            List importsForNamespace = (List) entry.getValue();
            for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) {
                Import anImport = (Import) iterator1.next();
                visit(anImport);
            }
        }
        visit(definition.getTypes());
        Collection messages = definition.getMessages().values();
        for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
            Message message = (Message) iterator.next();
            visit(message);
            Collection parts = message.getParts().values();
            for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) {
                Part part = (Part) iterator2.next();
                visit(part);
            }
        }
        Collection services = definition.getServices().values();
        for (Iterator iterator = services.iterator(); iterator.hasNext(); ) {
            Service service = (Service) iterator.next();
            visit(service);
            Collection ports = service.getPorts().values();
            for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) {
                Port port = (Port) iterator1.next();
                visit(port);
                Binding binding = port.getBinding();
                visit(binding);
                List bindingOperations = binding.getBindingOperations();
                for (int i = 0; i < bindingOperations.size(); i++) {
                    BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
                    visit(bindingOperation);
                    visit(bindingOperation.getBindingInput());
                    visit(bindingOperation.getBindingOutput());
                    Collection bindingFaults = bindingOperation.getBindingFaults().values();
                    for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) {
                        BindingFault bindingFault = (BindingFault) iterator2.next();
                        visit(bindingFault);
                    }
                }
                PortType portType = binding.getPortType();
                visit(portType);
                List operations = portType.getOperations();
                for (int i = 0; i < operations.size(); i++) {
                    Operation operation = (Operation) operations.get(i);
                    visit(operation);
                    {
                        Input input = operation.getInput();
                        visit(input);
                    }
                    {
                        Output output = operation.getOutput();
                        visit(output);
                    }
                    Collection faults = operation.getFaults().values();
                    for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) {
                        Fault fault = (Fault) iterator2.next();
                        visit(fault);
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    } finally {
        end();
    }
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) Message(javax.wsdl.Message) BindingFault(javax.wsdl.BindingFault) Port(javax.wsdl.Port) Service(javax.wsdl.Service) BindingFault(javax.wsdl.BindingFault) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) Iterator(java.util.Iterator) Collection(java.util.Collection) List(java.util.List) Map(java.util.Map) PortType(javax.wsdl.PortType)

Aggregations

PortType (javax.wsdl.PortType)4 Operation (javax.wsdl.Operation)3 ServicePort (org.talend.repository.services.model.services.ServicePort)3 Collection (java.util.Collection)2 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 Port (javax.wsdl.Port)2 Service (javax.wsdl.Service)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 BindingFault (javax.wsdl.BindingFault)1 BindingInput (javax.wsdl.BindingInput)1 BindingOutput (javax.wsdl.BindingOutput)1 Definition (javax.wsdl.Definition)1 Fault (javax.wsdl.Fault)1