Search in sources :

Example 76 with KettleXMLException

use of org.pentaho.di.core.exception.KettleXMLException in project pentaho-kettle by pentaho.

the class LDAPOutputMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        useAuthentication = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "useauthentication"));
        Host = XMLHandler.getTagValue(stepnode, "host");
        userName = XMLHandler.getTagValue(stepnode, "username");
        setPassword(Encr.decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(stepnode, "password")));
        port = XMLHandler.getTagValue(stepnode, "port");
        dnFieldName = XMLHandler.getTagValue(stepnode, "dnFieldName");
        failIfNotExist = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "failIfNotExist"));
        operationType = getOperationTypeByCode(Const.NVL(XMLHandler.getTagValue(stepnode, "operationType"), ""));
        multiValuedSeparator = XMLHandler.getTagValue(stepnode, "multivaluedseparator");
        searchBase = XMLHandler.getTagValue(stepnode, "searchBase");
        referralType = getReferralTypeByCode(Const.NVL(XMLHandler.getTagValue(stepnode, "referralType"), ""));
        derefAliasesType = getDerefAliasesTypeByCode(Const.NVL(XMLHandler.getTagValue(stepnode, "derefAliasesType"), ""));
        oldDnFieldName = XMLHandler.getTagValue(stepnode, "oldDnFieldName");
        newDnFieldName = XMLHandler.getTagValue(stepnode, "newDnFieldName");
        deleteRDN = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "deleteRDN"));
        Node fields = XMLHandler.getSubNode(stepnode, "fields");
        int nrFields = XMLHandler.countNodes(fields, "field");
        allocate(nrFields);
        for (int i = 0; i < nrFields; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            updateLookup[i] = XMLHandler.getTagValue(fnode, "name");
            updateStream[i] = XMLHandler.getTagValue(fnode, "field");
            if (updateStream[i] == null) {
                // default: the same name!
                updateStream[i] = updateLookup[i];
            }
            String updateValue = XMLHandler.getTagValue(fnode, "update");
            if (updateValue == null) {
                // default TRUE
                update[i] = Boolean.TRUE;
            } else {
                if (updateValue.equalsIgnoreCase("Y")) {
                    update[i] = Boolean.TRUE;
                } else {
                    update[i] = Boolean.FALSE;
                }
            }
        }
        protocol = XMLHandler.getTagValue(stepnode, "protocol");
        trustStorePath = XMLHandler.getTagValue(stepnode, "trustStorePath");
        trustStorePassword = Encr.decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(stepnode, "trustStorePassword"));
        trustAllCertificates = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "trustAllCertificates"));
        useCertificate = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "useCertificate"));
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "LDAPOutputMeta.UnableToLoadFromXML"), e);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

Example 77 with KettleXMLException

use of org.pentaho.di.core.exception.KettleXMLException in project pentaho-kettle by pentaho.

the class LoadFileInputMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        includeFilename = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, INCLUDE));
        filenameField = XMLHandler.getTagValue(stepnode, INCLUDE_FIELD);
        addresultfile = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, ADDRESULTFILE));
        IsIgnoreEmptyFile = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, IS_IGNORE_EMPTY_FILE));
        IsIgnoreMissingPath = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, IS_IGNORE_MISSING_PATH));
        includeRowNumber = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, ROWNUM));
        rowNumberField = XMLHandler.getTagValue(stepnode, ROWNUM_FIELD);
        encoding = XMLHandler.getTagValue(stepnode, ENCODING);
        Node filenode = XMLHandler.getSubNode(stepnode, FILE);
        Node fields = XMLHandler.getSubNode(stepnode, FIELDS);
        int nrFiles = XMLHandler.countNodes(filenode, NAME);
        int nrFields = XMLHandler.countNodes(fields, "field");
        allocate(nrFiles, nrFields);
        for (int i = 0; i < nrFiles; i++) {
            Node filenamenode = XMLHandler.getSubNodeByNr(filenode, NAME, i);
            Node filemasknode = XMLHandler.getSubNodeByNr(filenode, FILEMASK, i);
            Node excludefilemasknode = XMLHandler.getSubNodeByNr(filenode, EXCLUDE_FILEMASK, i);
            Node fileRequirednode = XMLHandler.getSubNodeByNr(filenode, FILE_REQUIRED, i);
            Node includeSubFoldersnode = XMLHandler.getSubNodeByNr(filenode, INCLUDE_SUBFOLDERS, i);
            fileName[i] = XMLHandler.getNodeValue(filenamenode);
            fileMask[i] = XMLHandler.getNodeValue(filemasknode);
            excludeFileMask[i] = XMLHandler.getNodeValue(excludefilemasknode);
            fileRequired[i] = XMLHandler.getNodeValue(fileRequirednode);
            includeSubFolders[i] = XMLHandler.getNodeValue(includeSubFoldersnode);
        }
        for (int i = 0; i < nrFields; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            LoadFileInputField field = new LoadFileInputField(fnode);
            inputFields[i] = field;
        }
        // Is there a limit on the number of rows we process?
        rowLimit = Const.toLong(XMLHandler.getTagValue(stepnode, LIMIT), 0L);
        fileinfield = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, IS_IN_FIELDS));
        DynamicFilenameField = XMLHandler.getTagValue(stepnode, DYNAMIC_FILENAME_FIELD);
        shortFileFieldName = XMLHandler.getTagValue(stepnode, SHORT_FILE_FIELD_NAME);
        pathFieldName = XMLHandler.getTagValue(stepnode, PATH_FIELD_NAME);
        hiddenFieldName = XMLHandler.getTagValue(stepnode, HIDDEN_FIELD_NAME);
        lastModificationTimeFieldName = XMLHandler.getTagValue(stepnode, LAST_MODIFICATION_TIME_FIELD_NAME);
        uriNameFieldName = XMLHandler.getTagValue(stepnode, URI_NAME_FIELD_NAME);
        rootUriNameFieldName = XMLHandler.getTagValue(stepnode, ROOT_URI_NAME_FIELD_NAME);
        extensionFieldName = XMLHandler.getTagValue(stepnode, EXTENSION_FIELD_NAME);
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "LoadFileInputMeta.Exception.ErrorLoadingXML", e.toString()));
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 78 with KettleXMLException

use of org.pentaho.di.core.exception.KettleXMLException in project pentaho-kettle by pentaho.

the class MappingMeta method loadXML.

public void loadXML(Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore) throws KettleXMLException {
    try {
        String method = XMLHandler.getTagValue(stepnode, "specification_method");
        specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode(method);
        String transId = XMLHandler.getTagValue(stepnode, "trans_object_id");
        transObjectId = Utils.isEmpty(transId) ? null : new StringObjectId(transId);
        transName = XMLHandler.getTagValue(stepnode, "trans_name");
        fileName = XMLHandler.getTagValue(stepnode, "filename");
        directoryPath = XMLHandler.getTagValue(stepnode, "directory_path");
        // Backward compatibility check for object specification
        // 
        checkObjectLocationSpecificationMethod();
        Node mappingsNode = XMLHandler.getSubNode(stepnode, "mappings");
        inputMappings.clear();
        outputMappings.clear();
        if (mappingsNode != null) {
            // Read all the input mapping definitions...
            // 
            Node inputNode = XMLHandler.getSubNode(mappingsNode, "input");
            int nrInputMappings = XMLHandler.countNodes(inputNode, MappingIODefinition.XML_TAG);
            for (int i = 0; i < nrInputMappings; i++) {
                Node mappingNode = XMLHandler.getSubNodeByNr(inputNode, MappingIODefinition.XML_TAG, i);
                MappingIODefinition inputMappingDefinition = new MappingIODefinition(mappingNode);
                inputMappings.add(inputMappingDefinition);
            }
            Node outputNode = XMLHandler.getSubNode(mappingsNode, "output");
            int nrOutputMappings = XMLHandler.countNodes(outputNode, MappingIODefinition.XML_TAG);
            for (int i = 0; i < nrOutputMappings; i++) {
                Node mappingNode = XMLHandler.getSubNodeByNr(outputNode, MappingIODefinition.XML_TAG, i);
                MappingIODefinition outputMappingDefinition = new MappingIODefinition(mappingNode);
                outputMappings.add(outputMappingDefinition);
            }
            // Load the mapping parameters too..
            // 
            Node mappingParametersNode = XMLHandler.getSubNode(mappingsNode, MappingParameters.XML_TAG);
            mappingParameters = new MappingParameters(mappingParametersNode);
        } else {
            // backward compatibility...
            // 
            Node inputNode = XMLHandler.getSubNode(stepnode, "input");
            Node outputNode = XMLHandler.getSubNode(stepnode, "output");
            int nrInput = XMLHandler.countNodes(inputNode, "connector");
            int nrOutput = XMLHandler.countNodes(outputNode, "connector");
            // null means: auto-detect
            // 
            MappingIODefinition inputMappingDefinition = new MappingIODefinition();
            inputMappingDefinition.setMainDataPath(true);
            for (int i = 0; i < nrInput; i++) {
                Node inputConnector = XMLHandler.getSubNodeByNr(inputNode, "connector", i);
                String inputField = XMLHandler.getTagValue(inputConnector, "field");
                String inputMapping = XMLHandler.getTagValue(inputConnector, "mapping");
                inputMappingDefinition.getValueRenames().add(new MappingValueRename(inputField, inputMapping));
            }
            // null means: auto-detect
            // 
            MappingIODefinition outputMappingDefinition = new MappingIODefinition();
            outputMappingDefinition.setMainDataPath(true);
            for (int i = 0; i < nrOutput; i++) {
                Node outputConnector = XMLHandler.getSubNodeByNr(outputNode, "connector", i);
                String outputField = XMLHandler.getTagValue(outputConnector, "field");
                String outputMapping = XMLHandler.getTagValue(outputConnector, "mapping");
                outputMappingDefinition.getValueRenames().add(new MappingValueRename(outputMapping, outputField));
            }
            // Don't forget to add these to the input and output mapping
            // definitions...
            // 
            inputMappings.add(inputMappingDefinition);
            outputMappings.add(outputMappingDefinition);
            // The default is to have no mapping parameters: the concept didn't
            // exist before.
            // 
            mappingParameters = new MappingParameters();
        }
        String multiInput = XMLHandler.getTagValue(stepnode, "allow_multiple_input");
        allowingMultipleInputs = Utils.isEmpty(multiInput) ? inputMappings.size() > 1 : "Y".equalsIgnoreCase(multiInput);
        String multiOutput = XMLHandler.getTagValue(stepnode, "allow_multiple_output");
        allowingMultipleOutputs = Utils.isEmpty(multiOutput) ? outputMappings.size() > 1 : "Y".equalsIgnoreCase(multiOutput);
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "MappingMeta.Exception.ErrorLoadingTransformationStepFromXML"), e);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 79 with KettleXMLException

use of org.pentaho.di.core.exception.KettleXMLException in project pentaho-kettle by pentaho.

the class AddSequenceMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        valuename = XMLHandler.getTagValue(stepnode, "valuename");
        useDatabase = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_database"));
        String conn = XMLHandler.getTagValue(stepnode, "connection");
        database = DatabaseMeta.findDatabase(databases, conn);
        schemaName = XMLHandler.getTagValue(stepnode, "schema");
        sequenceName = XMLHandler.getTagValue(stepnode, "seqname");
        useCounter = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_counter"));
        counterName = XMLHandler.getTagValue(stepnode, "counter_name");
        startAt = XMLHandler.getTagValue(stepnode, "start_at");
        incrementBy = XMLHandler.getTagValue(stepnode, "increment_by");
        maxValue = XMLHandler.getTagValue(stepnode, "max_value");
    // TODO startAt = Const.toLong(XMLHandler.getTagValue(stepnode, "start_at"), 1);
    // incrementBy = Const.toLong(XMLHandler.getTagValue(stepnode, "increment_by"), 1);
    // maxValue = Const.toLong(XMLHandler.getTagValue(stepnode, "max_value"), 999999999L);
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "AddSequenceMeta.Exception.ErrorLoadingStepInfo"), e);
    }
}
Also used : KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 80 with KettleXMLException

use of org.pentaho.di.core.exception.KettleXMLException in project pentaho-kettle by pentaho.

the class ChangeFileEncodingMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        filenamefield = XMLHandler.getTagValue(stepnode, "filenamefield");
        targetfilenamefield = XMLHandler.getTagValue(stepnode, "targetfilenamefield");
        sourceencoding = XMLHandler.getTagValue(stepnode, "sourceencoding");
        targetencoding = XMLHandler.getTagValue(stepnode, "targetencoding");
        addsourceresultfilenames = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "addsourceresultfilenames"));
        addtargetresultfilenames = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "addtargetresultfilenames"));
        createparentfolder = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "createparentfolder"));
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "ChangeFileEncodingMeta.Exception.UnableToReadStepInfo"), e);
    }
}
Also used : KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException)

Aggregations

KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)286 KettleException (org.pentaho.di.core.exception.KettleException)209 Node (org.w3c.dom.Node)164 KettleStepException (org.pentaho.di.core.exception.KettleStepException)150 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)25 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)23 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)20 Document (org.w3c.dom.Document)13 IOException (java.io.IOException)10 KettleValueException (org.pentaho.di.core.exception.KettleValueException)10 StringObjectId (org.pentaho.di.repository.StringObjectId)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)7 FileNotFoundException (java.io.FileNotFoundException)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)5 InputStream (java.io.InputStream)4 MalformedURLException (java.net.MalformedURLException)4 ParseException (java.text.ParseException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)4