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