use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class GenericContextUtilTest method createContextParameterType.
private ContextParameterType createContextParameterType(String paramName, String paramValue) {
ContextParameterType contextParameter = TalendFileFactoryImpl.eINSTANCE.createContextParameterType();
contextParameter.setName(paramName);
contextParameter.setRawValue(paramValue);
return contextParameter;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method createContextType.
private ContextType createContextType(String contextName, String[] paramNames) {
ContextType context = TalendFileFactory.eINSTANCE.createContextType();
context.setName(contextName);
for (String paramName : paramNames) {
ContextParameterType param = TalendFileFactory.eINSTANCE.createContextParameterType();
param.setName(paramName);
param.setType("id_String");
context.getContextParameter().add(param);
}
return context;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class UnifyPasswordEncryption4ParametersInJobMigrationTask method checkContext.
/**
*
* same as UnifyPasswordEncryption4ContextMigrationTask to change the encryption.
*/
@SuppressWarnings("deprecation")
protected boolean checkContext(Item item, ProcessType processType) throws Exception {
boolean modified = false;
// context
EList contextList = processType.getContext();
for (Object o : contextList) {
if (o instanceof ContextType) {
List<ContextParameterType> paramTypes = ((ContextType) o).getContextParameter();
if (paramTypes != null) {
for (ContextParameterType param : paramTypes) {
String value = param.getValue();
if (value != null && (PasswordEncryptUtil.isPasswordType(param.getType()) || PasswordEncryptUtil.isPasswordField(param.getName()))) {
try {
String rawPassword = PasswordEncryptUtil.decryptPassword(value);
param.setRawValue(rawPassword);
} catch (Exception e) {
param.setRawValue(value);
}
modified = true;
}
}
}
}
}
return modified;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class UpdateJobletContextInJobMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
List<ContextType> contexts = processItem.getProcess().getContext();
if (contexts.size() > 1) {
boolean isModified = false;
for (ContextType context1 : contexts) {
List<ContextParameterType> params1 = context1.getContextParameter();
for (ContextParameterType param1 : params1) {
String id = param1.getRepositoryContextId();
if (id != null) {
for (ContextType context2 : contexts) {
if (context2 != context1) {
List<ContextParameterType> params2 = context2.getContextParameter();
for (ContextParameterType param2 : params2) {
if (param2.getName().equals(param1.getName()) && param2.getRepositoryContextId() == null) {
param2.setRepositoryContextId(id);
isModified = true;
break;
}
}
}
}
}
}
}
if (isModified) {
try {
ProxyRepositoryFactory.getInstance().save(item, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType in project tdi-studio-se by Talend.
the class UnifyPasswordEncryption4ContextMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof ContextItem) {
List<ContextType> contextTypeList = ((ContextItem) item).getContext();
boolean modify = false;
if (contextTypeList != null) {
for (ContextType type : contextTypeList) {
List<ContextParameterType> paramTypes = type.getContextParameter();
if (paramTypes != null) {
for (ContextParameterType param : paramTypes) {
try {
String value = param.getValue();
if (value != null && PasswordEncryptUtil.isPasswordType(param.getType())) {
String rawPassword = PasswordEncryptUtil.decryptPassword(value);
param.setRawValue(rawPassword);
modify = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
if (modify) {
try {
factory.save(item, true);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations