Search in sources :

Example 6 with ServicePort

use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.

the class ServiceExportManager method createBlueprint.

@SuppressWarnings("unchecked")
public void createBlueprint(File outputFile, Map<ServicePort, Map<String, String>> ports, Map<String, String> additionalInfo, IFile wsdl, String studioServiceName) throws IOException, CoreException {
    // TODO: support multiport!!!
    Entry<ServicePort, Map<String, String>> studioPort = ports.entrySet().iterator().next();
    // TODO: do this in looooooooop!!!
    Definition def = WSDLUtils.getDefinition(wsdl);
    QName serviceQName = null;
    String endpointAddress = null;
    String endpointName = null;
    Map<QName, Service> services = def.getServices();
    ServicePort servicePort = studioPort.getKey();
    for (Entry<QName, Service> serviceEntry : services.entrySet()) {
        // TODO: support multi-services
        Service service = serviceEntry.getValue();
        // TODO: support multi-ports
        Collection<Port> servicePorts = service.getPorts().values();
        for (Port port : servicePorts) {
            if (servicePort.getName().equals(port.getBinding().getPortType().getQName().getLocalPart())) {
                serviceQName = serviceEntry.getKey();
                endpointName = port.getName();
                endpointAddress = WSDLUtils.getPortAddress(port);
                if (null != endpointAddress) {
                    // http://jira.talendforge.org/browse/TESB-3638
                    final URI uri = URI.create(endpointAddress);
                    endpointAddress = uri.getPath();
                    if (endpointAddress == null) {
                        endpointAddress = uri.getRawSchemeSpecificPart();
                        int interrogationMark = endpointAddress.indexOf('?');
                        if (interrogationMark > 0) {
                            endpointAddress = endpointAddress.substring(0, interrogationMark);
                        }
                    }
                    if (endpointAddress.equals("/services/") || endpointAddress.equals("/services")) {
                        // pass as is
                        endpointAddress = endpointAddress;
                    } else if (endpointAddress.startsWith("/services/")) {
                        // remove forwarding "/services/" context as required by runtime
                        // leave
                        endpointAddress = endpointAddress.substring("/services/".length() - 1);
                    // forwarding
                    // slash
                    } else if (endpointAddress.length() == 1) {
                        // empty path
                        endpointAddress += studioServiceName;
                    }
                }
                break;
            }
        }
    }
    Map<String, Object> endpointInfo = new HashMap<String, Object>();
    //$NON-NLS-1$
    endpointInfo.put("namespace", serviceQName.getNamespaceURI());
    //$NON-NLS-1$
    endpointInfo.put("service", serviceQName.getLocalPart());
    //$NON-NLS-1$
    endpointInfo.put("port", endpointName);
    //$NON-NLS-1$
    endpointInfo.put("address", endpointAddress);
    //$NON-NLS-1$
    endpointInfo.put("studioName", studioServiceName);
    //$NON-NLS-1$
    endpointInfo.put("wsdlLocation", wsdl.getName());
    Map<String, String> operation2job = new HashMap<String, String>();
    for (Map.Entry<ServicePort, Map<String, String>> port : ports.entrySet()) {
        // TODO: actual port work
        for (Map.Entry<String, String> operation : port.getValue().entrySet()) {
            operation2job.put(operation.getKey(), operation.getValue());
        }
    }
    //$NON-NLS-1$
    endpointInfo.put("operation2job", operation2job);
    boolean isStudioEEVersion = isStudioEEVersion();
    boolean useRegistry = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SERVICE_REGISTRY));
    boolean useSL = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SL));
    boolean useSAM = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SAM));
    boolean useSecurityToken = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_BASIC));
    boolean useSecuritySAML = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_SAML));
    boolean useAuthorization = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.AUTHORIZATION));
    boolean useEncryption = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.ENCRYPTION));
    boolean logMessages = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.LOG_MESSAGES));
    boolean wsdlSchemaValidation = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.WSDL_SCHEMA_VALIDATION));
    boolean useBusinessCorrelation = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION));
    //$NON-NLS-1$
    endpointInfo.put("useSL", useSL);
    //$NON-NLS-1$
    endpointInfo.put("useSAM", useSAM);
    //$NON-NLS-1$
    endpointInfo.put("useSecurityToken", useSecurityToken);
    //$NON-NLS-1$
    endpointInfo.put("useSecuritySAML", useSecuritySAML);
    //$NON-NLS-1$
    endpointInfo.put("useAuthorization", useAuthorization);
    //$NON-NLS-1$
    endpointInfo.put("useEncryption", useEncryption);
    //$NON-NLS-1$
    endpointInfo.put("useServiceRegistry", useRegistry);
    //$NON-NLS-1$
    endpointInfo.put("logMessages", logMessages);
    //$NON-NLS-1$
    endpointInfo.put("useWsdlSchemaValidation", wsdlSchemaValidation);
    //$NON-NLS-1$
    endpointInfo.put("useBusinessCorrelation", useBusinessCorrelation);
    Map<String, String> slCustomProperties = new HashMap<String, String>();
    if (useSL) /*&& !useRegistry*/
    {
        for (Map.Entry<String, String> prop : additionalInfo.entrySet()) {
            if (prop.getKey().startsWith(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX)) {
                slCustomProperties.put(prop.getKey().substring(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX.length()), prop.getValue());
            }
        }
    }
    //$NON-NLS-1$
    endpointInfo.put("slCustomProps", slCustomProperties);
    //$NON-NLS-1$
    endpointInfo.put(//$NON-NLS-1$
    "samlConfig", //$NON-NLS-1$
    serviceQName.toString().replaceAll("\\W+", "_").substring(1));
    //$NON-NLS-1$
    TemplateProcessor.processTemplate(//$NON-NLS-1$
    "DATA_SERVICE_BLUEPRINT_CONFIG", endpointInfo, outputFile, getClass().getResourceAsStream(TEMPLATE_BLUEPRINT));
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ServicePort(org.talend.repository.services.model.services.ServicePort) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) IBrandingService(org.talend.core.ui.branding.IBrandingService) Service(javax.wsdl.Service) URI(java.net.URI) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HashMap(java.util.HashMap) Map(java.util.Map) EnumMap(java.util.EnumMap)

Example 7 with ServicePort

use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.

the class ServiceExportWithMavenManager method analysisMavenModule.

@Override
protected void analysisMavenModule(Item item) {
    if (item != null && item instanceof ServiceItem) {
        try {
            ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            List<String> mavenModules = getMavenModules();
            ServiceItem serviceItem = (ServiceItem) item;
            ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
            EList<ServicePort> listPort = connection.getServicePort();
            for (ServicePort port : listPort) {
                List<ServiceOperation> listOperation = port.getServiceOperation();
                for (ServiceOperation operation : listOperation) {
                    if (StringUtils.isNotEmpty(operation.getReferenceJobId())) {
                        IRepositoryViewObject repObj = factory.getLastVersion(operation.getReferenceJobId());
                        if (repObj != null) {
                            String jobName = repObj.getLabel();
                            if (jobName != null && !mavenModules.contains(jobName)) {
                                mavenModules.add(OPERATIONS_PATH + jobName);
                            }
                        }
                    }
                }
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation)

Example 8 with ServicePort

use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.

the class ESBRepositoryContentHandler method addContents.

@Override
public void addContents(Collection<EObject> collection, Resource resource) {
    if (collection != null && collection.size() > 0) {
        for (EObject object : collection) {
            if (object instanceof ServiceConnection) {
                ServiceConnection serviceConnection = (ServiceConnection) object;
                List<ServicePort> listPort = serviceConnection.getServicePort();
                for (ServicePort port : listPort) {
                    resource.getContents().add(port);
                    List<ServiceOperation> listOperation = port.getServiceOperation();
                    for (ServiceOperation operation : listOperation) {
                        resource.getContents().add(operation);
                    }
                }
            }
        }
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) EObject(org.eclipse.emf.ecore.EObject) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation)

Example 9 with ServicePort

use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.

the class ESBRepositoryContentHandler method save.

private Resource save(ServiceItem item) {
    Resource itemResource = xmiResourceManager.getItemResource(item);
    itemResource.getContents().clear();
    itemResource.getContents().add(item.getConnection());
    for (ServicePort port : ((ServiceConnection) item.getConnection()).getServicePort()) {
        itemResource.getContents().add(port);
        for (ServiceOperation operation : port.getServiceOperation()) {
            itemResource.getContents().add(operation);
        }
    }
    return itemResource;
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) Resource(org.eclipse.emf.ecore.resource.Resource) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation)

Example 10 with ServicePort

use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.

the class ServiceExportForESBRuntimeManager method createBlueprint.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.services.ui.scriptmanager.ServiceExportManager#createBlueprint(java.io.File,
     * java.util.Map, java.util.Map, org.eclipse.core.resources.IFile, java.lang.String)
     */
@Override
public void createBlueprint(File outputFile, Map<ServicePort, Map<String, String>> ports, Map<String, String> additionalInfo, IFile wsdl, String studioServiceName) throws IOException, CoreException {
    // TODO: support multiport!!!
    Entry<ServicePort, Map<String, String>> studioPort = ports.entrySet().iterator().next();
    // TODO: do this in looooooooop!!!
    Definition def = WSDLUtils.getDefinition(wsdl);
    QName serviceQName = null;
    String endpointAddress = null;
    String endpointName = null;
    Map<QName, Service> services = def.getServices();
    ServicePort servicePort = studioPort.getKey();
    for (Entry<QName, Service> serviceEntry : services.entrySet()) {
        // TODO: support multi-services
        Service service = serviceEntry.getValue();
        // TODO: support multi-ports
        Collection<Port> servicePorts = service.getPorts().values();
        for (Port port : servicePorts) {
            if (servicePort.getName().equals(port.getBinding().getPortType().getQName().getLocalPart())) {
                serviceQName = serviceEntry.getKey();
                endpointName = port.getName();
                endpointAddress = WSDLUtils.getPortAddress(port);
                if (null != endpointAddress) {
                    // http://jira.talendforge.org/browse/TESB-3638
                    final URI uri = URI.create(endpointAddress);
                    endpointAddress = uri.getPath();
                    if (endpointAddress == null) {
                        endpointAddress = uri.getRawSchemeSpecificPart();
                        int interrogationMark = endpointAddress.indexOf('?');
                        if (interrogationMark > 0) {
                            endpointAddress = endpointAddress.substring(0, interrogationMark);
                        }
                    }
                    if (endpointAddress.equals("/services/") || endpointAddress.equals("/services")) {
                        // pass as is
                        endpointAddress = endpointAddress;
                    } else if (endpointAddress.startsWith("/services/")) {
                        // remove forwarding "/services/" context as required by runtime
                        // leave
                        endpointAddress = endpointAddress.substring("/services/".length() - 1);
                    // forwarding
                    // slash
                    } else if (endpointAddress.length() == 1) {
                        // empty path
                        endpointAddress += studioServiceName;
                    }
                }
                break;
            }
        }
    }
    Map<String, Object> endpointInfo = new HashMap<String, Object>();
    //$NON-NLS-1$
    endpointInfo.put("namespace", serviceQName.getNamespaceURI());
    //$NON-NLS-1$
    endpointInfo.put("service", serviceQName.getLocalPart());
    //$NON-NLS-1$
    endpointInfo.put("port", endpointName);
    //$NON-NLS-1$
    endpointInfo.put("address", endpointAddress);
    //$NON-NLS-1$
    endpointInfo.put("studioName", studioServiceName);
    //$NON-NLS-1$
    endpointInfo.put("wsdlLocation", wsdl.getName());
    Map<String, String> operation2job = new HashMap<String, String>();
    for (Map.Entry<ServicePort, Map<String, String>> port : ports.entrySet()) {
        // TODO: actual port work
        for (Map.Entry<String, String> operation : port.getValue().entrySet()) {
            operation2job.put(operation.getKey(), operation.getValue());
        }
    }
    //$NON-NLS-1$
    endpointInfo.put("operation2job", operation2job);
    boolean isStudioEEVersion = isStudioEEVersion();
    boolean useRegistry = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SERVICE_REGISTRY));
    boolean useSL = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SL));
    boolean useSAM = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SAM));
    boolean useSecurityToken = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_BASIC));
    boolean useSecuritySAML = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_SAML));
    boolean useAuthorization = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.AUTHORIZATION));
    boolean useEncryption = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.ENCRYPTION));
    boolean logMessages = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.LOG_MESSAGES));
    boolean wsdlSchemaValidation = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.WSDL_SCHEMA_VALIDATION));
    boolean useBusinessCorrelation = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION));
    //$NON-NLS-1$
    endpointInfo.put("useSL", useSL);
    //$NON-NLS-1$
    endpointInfo.put("useSAM", useSAM);
    //$NON-NLS-1$
    endpointInfo.put("useSecurityToken", useSecurityToken);
    //$NON-NLS-1$
    endpointInfo.put("useSecuritySAML", useSecuritySAML);
    //$NON-NLS-1$
    endpointInfo.put("useAuthorization", useAuthorization);
    //$NON-NLS-1$
    endpointInfo.put("useEncryption", useEncryption);
    //$NON-NLS-1$
    endpointInfo.put("useServiceRegistry", useRegistry);
    //$NON-NLS-1$
    endpointInfo.put("logMessages", logMessages);
    //$NON-NLS-1$
    endpointInfo.put("useWsdlSchemaValidation", wsdlSchemaValidation);
    //$NON-NLS-1$
    endpointInfo.put("useBusinessCorrelation", useBusinessCorrelation);
    Map<String, String> slCustomProperties = new HashMap<String, String>();
    if (useSL) /* && !useRegistry */
    {
        for (Map.Entry<String, String> prop : additionalInfo.entrySet()) {
            if (prop.getKey().startsWith(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX)) {
                slCustomProperties.put(prop.getKey().substring(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX.length()), prop.getValue());
            }
        }
    }
    //$NON-NLS-1$
    endpointInfo.put("slCustomProps", slCustomProperties);
    //$NON-NLS-1$
    endpointInfo.put(//$NON-NLS-1$
    "samlConfig", //$NON-NLS-1$
    serviceQName.toString().replaceAll("\\W+", "_").substring(1));
    //$NON-NLS-1$
    TemplateProcessor.processTemplate(//$NON-NLS-1$
    "DATA_SERVICE_BLUEPRINT_CONFIG", endpointInfo, outputFile, ServiceExportManager.class.getResourceAsStream("/resources/blueprint-template.xml"));
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ServiceExportManager(org.talend.repository.services.ui.scriptmanager.ServiceExportManager) ServicePort(org.talend.repository.services.model.services.ServicePort) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) URI(java.net.URI) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ServicePort (org.talend.repository.services.model.services.ServicePort)28 ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)26 ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)25 ServiceItem (org.talend.repository.services.model.services.ServiceItem)17 PersistenceException (org.talend.commons.exception.PersistenceException)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ProcessItem (org.talend.core.model.properties.ProcessItem)5 HashMap (java.util.HashMap)4 IFile (org.eclipse.core.resources.IFile)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 Item (org.talend.core.model.properties.Item)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 ArrayList (java.util.ArrayList)3 Definition (javax.wsdl.Definition)3 CoreException (org.eclipse.core.runtime.CoreException)3 INode (org.talend.core.model.process.INode)3 IProcess2 (org.talend.core.model.process.IProcess2)3 IOException (java.io.IOException)2