Search in sources :

Example 1 with IProjectMigrationTask

use of org.talend.migration.IProjectMigrationTask in project tesb-studio-se by Talend.

the class ReplaceDefaultProxyIPMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    IProjectMigrationTask task = this;
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    // $NON-NLS-1$
    String[] componentsName = new String[] { "tESBConsumer", "tRESTClient" };
    for (String name : componentsName) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            boolean modified = ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                public void transform(NodeType node) {
                    ElementParameterType useProxy = ComponentUtilities.getNodeProperty(node, "USE_PROXY");
                    if (useProxy == null) {
                        // $NON-NLS-1$
                        return;
                    }
                    ElementParameterType proxyHost = // $NON-NLS-1$
                    ComponentUtilities.getNodeProperty(node, "PROXY_HOST");
                    if (useProxy.getValue().equals("false") && "\"61.163.92.4\"".equals(proxyHost.getValue())) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$
                        proxyHost.setValue("\"127.0.0.1\"");
                        generateReportRecord(new MigrationReportRecorder(task, MigrationReportRecorder.MigrationOperationType.MODIFY, item, node, "PROXY_HOST", "\"61.163.92.4\"", "\"127.0.0.1\""));
                    }
                }
            }));
            if (modified) {
                return ExecutionResult.SUCCESS_WITH_ALERT;
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) MigrationReportRecorder(org.talend.migration.MigrationReportRecorder) IProjectMigrationTask(org.talend.migration.IProjectMigrationTask) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

PersistenceException (org.talend.commons.exception.PersistenceException)1 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)1 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)1 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)1 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)1 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)1 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)1 IProjectMigrationTask (org.talend.migration.IProjectMigrationTask)1 MigrationReportRecorder (org.talend.migration.MigrationReportRecorder)1