use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.
the class RouteJavaScriptOSGIForESBManager method collectRouteInfo.
private Map<String, Object> collectRouteInfo(ProcessItem processItem, IProcess process) {
Map<String, Object> routeInfo = new HashMap<String, Object>();
// route name and class name
//$NON-NLS-1$
routeInfo.put("name", processItem.getProperty().getLabel());
String className = getClassName(processItem);
String idName = className;
String suffix = getOsgiServiceIdSuffix();
if (suffix != null && suffix.length() > 0) {
idName += suffix;
}
//$NON-NLS-1$
routeInfo.put("className", className);
//$NON-NLS-2$
routeInfo.put("idName", idName);
boolean useSAM = false;
boolean hasCXFUsernameToken = false;
boolean hasCXFSamlConsumer = false;
boolean hasCXFSamlProvider = false;
boolean hasCXFRSSamlProviderAuthz = false;
Collection<NodeType> cSOAPs = EmfModelUtils.getComponentsByName(processItem, "cSOAP");
boolean hasCXFComponent = !cSOAPs.isEmpty();
cSOAPs.addAll(EmfModelUtils.getComponentsByName(processItem, "cREST"));
if (!cSOAPs.isEmpty()) {
Set<String> consumerNodes = new HashSet<String>();
@SuppressWarnings("unchecked") List<ConnectionType> connections = processItem.getProcess().getConnection();
for (ConnectionType conn : connections) {
consumerNodes.add(conn.getTarget());
}
boolean isEEVersion = isStudioEEVersion();
for (NodeType node : cSOAPs) {
boolean nodeUseSAM = false;
boolean nodeUseSaml = false;
boolean nodeUseAuthz = false;
boolean nodeUseRegistry = false;
// http://jira.talendforge.org/browse/TESB-3850
//$NON-NLS-1$
String format = EmfModelUtils.computeTextElementValue("DATAFORMAT", node);
if (!useSAM && !"RAW".equals(format)) {
//$NON-NLS-1$
nodeUseSAM = //$NON-NLS-1$
EmfModelUtils.computeCheckElementValue("ENABLE_SAM", node) || //$NON-NLS-1$
EmfModelUtils.computeCheckElementValue("SERVICE_ACTIVITY_MONITOR", node);
}
// security is disable in case CXF_MESSAGE or RAW dataFormat
if (!"CXF_MESSAGE".equals(format) && !"RAW".equals(format)) {
//$NON-NLS-1$ //$NON-NLS-2$
if (isEEVersion && EmfModelUtils.computeCheckElementValue("ENABLE_REGISTRY", node)) {
//$NON-NLS-1$
nodeUseRegistry = true;
// https://jira.talendforge.org/browse/TESB-10725
nodeUseSAM = false;
} else if (EmfModelUtils.computeCheckElementValue("ENABLE_SECURITY", node)) {
//$NON-NLS-1$
//$NON-NLS-1$
String securityType = EmfModelUtils.computeTextElementValue("SECURITY_TYPE", node);
if ("USER".equals(securityType)) {
//$NON-NLS-1$
hasCXFUsernameToken = true;
} else if ("SAML".equals(securityType)) {
//$NON-NLS-1$
nodeUseSaml = true;
nodeUseAuthz = isEEVersion && EmfModelUtils.computeCheckElementValue("USE_AUTHORIZATION", node);
}
}
}
useSAM |= nodeUseSAM;
if (consumerNodes.contains(ElementParameterParser.getUNIQUENAME(node))) {
hasCXFSamlConsumer |= nodeUseSaml | nodeUseRegistry;
} else {
hasCXFSamlProvider |= nodeUseSaml | nodeUseRegistry;
hasCXFRSSamlProviderAuthz |= nodeUseAuthz;
}
}
}
//$NON-NLS-1$
routeInfo.put("useSAM", useSAM);
//$NON-NLS-1$
routeInfo.put("hasCXFUsernameToken", hasCXFUsernameToken);
//$NON-NLS-1$
routeInfo.put("hasCXFSamlConsumer", hasCXFSamlConsumer);
//$NON-NLS-1$
routeInfo.put("hasCXFSamlProvider", hasCXFSamlProvider);
//$NON-NLS-1$
routeInfo.put("hasCXFRSSamlProviderAuthz", hasCXFRSSamlProviderAuthz && !hasCXFComponent);
//$NON-NLS-1$
routeInfo.put("hasCXFComponent", hasCXFComponent);
// route OSGi DataSources
//$NON-NLS-1$
routeInfo.put("dataSources", DataSourceConfig.getAliases(process));
//$NON-NLS-1$
routeInfo.put("routelets", routelets);
return routeInfo;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.
@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
if (!EmfModelUtils.isComponentActive(node)) {
continue;
}
final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
if (null != routeletId) {
final IRepositoryNode referencedRouteletNode;
try {
referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
// getRouteletRepositoryNode(routeletId);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
String idSuffix = "-" + routeName;
if (!routelets.add(className + idSuffix)) {
continue;
}
String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
routeletVersion = referencedRouteletNode.getObject().getVersion();
}
final File routeletFile;
try {
routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
new File(getTempDir()));
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String routeletName = referencedRouteletNode.getObject().getLabel();
String routeletBundleName = routeName + "_" + routeletName;
String routeletBundleSymbolicName = routeletBundleName;
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
}
}
BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
if (featuresModel.addBundle(routeletModel)) {
exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.
the class CamelDesignerUtil method checkRouteInputExistInJob.
public static boolean checkRouteInputExistInJob(ProcessItem pi) {
if (pi == null) {
return false;
}
EList<?> nodes = pi.getProcess().getNode();
Iterator<?> iterator = nodes.iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
if (!(next instanceof NodeType)) {
continue;
}
NodeType nt = (NodeType) next;
if (!EmfModelUtils.isComponentActive(nt) && !EmfModelUtils.computeCheckElementValue("ACTIVATE", nt)) {
continue;
}
String componentName = nt.getComponentName();
if ("tRouteInput".equals(componentName)) {
return true;
} else if (service != null) {
ProcessType jobletProcess = service.getJobletProcess(nt);
if (jobletProcess == null) {
continue;
}
if (checkRouteInputExistInJoblet(jobletProcess)) {
return true;
}
}
}
return false;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tesb-studio-se by Talend.
the class LocalESBRunContainerServiceTest method testCreateJavaProcessor.
/**
* Test method for
* {@link org.talend.designer.esb.runcontainer.core.LocalESBRunContainerService#createJavaProcessor(org.talend.core.model.process.IProcess, Property, boolean)}
*/
@Test
public void testCreateJavaProcessor() {
IESBRunContainerService service = (IESBRunContainerService) GlobalServiceRegister.getDefault().getService(IESBRunContainerService.class);
String[] esbComponents = { "tESBProviderRequest", "tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer", "tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse" };
for (String esbComponent : esbComponents) {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setVersion("0.1");
property.setId("property1");
property.setLabel("ESBArtifact");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
property.setItem(processItem);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
processItem.setProcess(process);
NodeType node = TalendFileFactory.eINSTANCE.createNodeType();
process.getNode().add(node);
node.setComponentName(esbComponent);
IComponent tESBComponent = ComponentsFactoryProvider.getInstance().get(esbComponent, ComponentCategory.CATEGORY_4_DI.getName());
Process esbJob = new Process(property);
Node tESBComponent_1 = new Node(tESBComponent, esbJob);
esbJob.addNodeContainer(new NodeContainer(tESBComponent_1));
Assert.assertNotNull(service.createJavaProcessor(esbJob, property, false));
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class JobJavaScriptOSGIForESBManager method collectJobInfo.
private Map<String, Object> collectJobInfo(ProcessItem processItem, IProcess process) {
// velocity template context
Map<String, Object> jobInfo = new HashMap<String, Object>();
String name = processItem.getProperty().getLabel();
String className = getPackageName(processItem) + PACKAGE_SEPARATOR + name;
boolean isTalendStepTemplate = isTalendStepTemplate(processItem);
// job name and class name
String jobName = name;
if (!EmfModelUtils.getComponentsByName(processItem, "tRouteInput").isEmpty()) {
//$NON-NLS-1$
jobName = className;
}
jobInfo.put("name", jobName);
//$NON-NLS-1$
jobInfo.put("version", getBundleVersion());
//$NON-NLS-1$
jobInfo.put("className", className);
// additional Talend job interfaces (ESB related)
boolean isESBJob = isTalendESBJob(processItem);
//$NON-NLS-1$
jobInfo.put("isESBJob", isESBJob);
//$NON-NLS-1$
jobInfo.put("isESBJobFactory", isESBJob && isTalendESBJobFactory(processItem));
//$NON-NLS-1$
jobInfo.put("isTalendStepTemplate", isTalendStepTemplate);
// job components use SAM / use SAML
boolean useSAM = false;
for (NodeType node : EmfModelUtils.getComponentsByName(processItem, "tRESTClient")) {
//$NON-NLS-1$
if (!useSAM && EmfModelUtils.computeCheckElementValue("SERVICE_ACTIVITY_MONITOR", node)) {
//$NON-NLS-1$
useSAM = true;
break;
}
}
//$NON-NLS-1$
jobInfo.put("useSAM", useSAM);
// job OSGi DataSources
//$NON-NLS-1$
jobInfo.put("dataSources", DataSourceConfig.getAliases(process));
jobInfo.put("hasDestroyMethod", ERepositoryObjectType.PROCESS_MR != ERepositoryObjectType.getItemType(processItem));
return jobInfo;
}
Aggregations