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));
}
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);
}
}
}
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);
}
}
}
}
}
}
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;
}
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"));
}
Aggregations