Search in sources :

Example 1 with FakeNode

use of org.talend.repository.model.migration.EncryptPasswordInComponentsMigrationTask.FakeNode in project tdi-studio-se by Talend.

the class UnifyPasswordEncryption4ParametersInJobMigrationTask method checkNodes.

protected boolean checkNodes(Item item, ProcessType processType) throws Exception {
    boolean modified = checkNodesFromEmf(item, processType);
    if (!modified) {
        // some versions of the job doesn't have any field type saved in the job, so we will check from the existing
        // component field type
        ComponentCategory category = ComponentCategory.getComponentCategoryFromItem(item);
        for (Object nodeObjectType : processType.getNode()) {
            NodeType nodeType = (NodeType) nodeObjectType;
            IComponent component = ComponentsFactoryProvider.getInstance().get(nodeType.getComponentName(), category.getName());
            if (component == null) {
                continue;
            }
            FakeNode fNode = new FakeNode(component);
            for (Object paramObjectType : nodeType.getElementParameter()) {
                ElementParameterType param = (ElementParameterType) paramObjectType;
                IElementParameter paramFromEmf = fNode.getElementParameter(param.getName());
                if (paramFromEmf != null) {
                    if (EParameterFieldType.PASSWORD.equals(paramFromEmf.getFieldType()) && param.getValue() != null) {
                        param.setField(EParameterFieldType.PASSWORD.getName());
                        if (reencryptValueIfNeeded(param)) {
                            modified = true;
                        }
                    }
                }
            }
        }
    }
    return modified;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) IComponent(org.talend.core.model.components.IComponent) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IElementParameter(org.talend.core.model.process.IElementParameter) ComponentCategory(org.talend.core.model.components.ComponentCategory) FakeNode(org.talend.repository.model.migration.EncryptPasswordInComponentsMigrationTask.FakeNode)

Aggregations

ComponentCategory (org.talend.core.model.components.ComponentCategory)1 IComponent (org.talend.core.model.components.IComponent)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)1 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)1 FakeNode (org.talend.repository.model.migration.EncryptPasswordInComponentsMigrationTask.FakeNode)1