Package com.xmultra.util

Examples of com.xmultra.util.InvalidConfigFileFormatException


        String propertyFileName = this.strings.getGroup(1);
        propertyFileName = fileUtils.addRoot(propertyFileName);
        File propertyFile = new File(propertyFileName);

        if (!propertyFile.isFile()) {
            throw new InvalidConfigFileFormatException(
                "Could not find properties file: " + propertyFile);
        }

        // Create the hashmap and list where properties will be stored.
        HashMap<String,String> propsMap = new HashMap<String,String>();
        List<String> propsList = new ArrayList<String>();

        boolean result = xmlParseUtils.readProperties(propertyFile,
                                                      propsList,
                                                      propsMap);

        // If error reading the properties file, throw exception.
        if (!result) {
            throw new InvalidConfigFileFormatException(
                "Error reading Properties file: " + propertyFile + "; also see warning log.");
        }

        // Step through all properties and replace them.
        for (int i = 0; i < propsList.size(); i++) {
            String propName = propsList.get(i);
            String propValue = propsMap.get(propName);

            // Create the pattern and substitute.
            String propPattern = "%%" + propName + "%%";
            // Dollar signs in value must be escaped.
            propValue = propValue.replace("$", "\\$");

            cfgFileStr = this.strings.substitute(propPattern,
                                            propValue,
                                            cfgFileStr);
        }

        // See if there are any undefined properties.
        if (this.strings.matches("\"%%[^\"\n%]+?%%\"", cfgFileStr)) {

            throw new InvalidConfigFileFormatException(
                this.strings.getGroup(0) + " property reference in GetMessage file " +
                "was not found in properties file \"" + propertyFile + "\"");
        }
        return cfgFileStr;
    }
View Full Code Here


                characterNodeList.item(i), CHAR_MARK);

            // If the open mark is null or empty, we don't have a pattern.
            if (charSearchPattern == null ||
                    charSearchPattern.equals(Strings.EMPTY_STRING)) {
                throw new InvalidConfigFileFormatException(
                    "\"" + charName + "\" element needs a value in the \"" +
                    CHAR_MARK + "\" attribute.");
            }

            // Create a pended mark if pending is turned on.
            if (CHAR_MARK_PENDING_ON.equals(pendingSetting)) {
                charSearchPattern = markPrePend + charSearchPattern +
                                        markPostPend;              
            }

            // Convert any Character specified with Unicode (\u0097 for
            // example) to a single character.
            try {
                charSearchPattern = strings.convertStringWithEscapedCode(
                        charSearchPattern);
            }
            catch (NumberFormatException e) {
                throw new InvalidConfigFileFormatException("Invalid value in \"" +
                            charName + "\" element: " + e.getMessage());
            }

            // Get mark pattern if any, for previous instances of this element.
            charSearchPatternList = (List)charSearchPatternsMap.get(charName);
View Full Code Here

                String replacement = new DateTimePattern(parameters).getDateTime();
                str = str.replaceAll(XmultraConfig.DATE_TIME_FORMAT_PATTERN, replacement);
            }
            catch (Exception e) {
                throw new InvalidConfigFileFormatException("Unable to replace date-time format in \"" + str + "\"");
            }
        }
        return str;
    }
View Full Code Here

            // Create and initialize the Class which will write the data
            // to the destination locations.
            destWriter = new DestinationWriter();
            try {
                if (!destWriter.init(this.initMapHolder, super.aProcessorNode, new DateUtils())) {
                    throw new InvalidConfigFileFormatException();
                }
            }
            catch (InvalidConfigFileFormatException e) {
                this.errEntry.setThrowable(e);
                this.errEntry.setAppContext("initializeDestWriter()");
View Full Code Here

        // See if it is a directory that exists.
        if (!oldDirectory.isDirectory()) {

            // Doesn't exist...
            throw new InvalidConfigFileFormatException(
                    "'" + oldDirectory + "' directory \n" +
                    "is not an existing directory.\n" +
                    "Directory defined in '" +
                    XmultraConfig.OLD_DIRECTORY_ATTRIBUTE +
                    "' attribute of a '" +
View Full Code Here

        // Get the Max file size.
        String fileSizeStr = xmlParseUtils.getAttributeValueFromNode(
                logNode, XmultraConfig.MAX_FILE_SIZE_ATTRIBUTE);
        if (fileSizeStr == null) {
            throw new InvalidConfigFileFormatException(
                    "In '" +  logNode.getNodeName() + "' element, " +
                    "the '" + XmultraConfig.MAX_FILE_SIZE_ATTRIBUTE +
                    "' is not defined."
            );
        }

        try {
            // Convert to float. Could be .1 or 10.2.
            fileSize = XmultraConfig.convertStringToLong(fileSizeStr);

            if (fileSize <= 0) {
                throw new NumberFormatException();
            }
        }
        catch (NumberFormatException nfe) {
            throw new InvalidConfigFileFormatException(
                "'" + fileSizeStr + "' not a valid file size. Should be like " +
                "1.23, 123k, or .12m only.\n" +
                "File size is defined in '" +
                XmultraConfig.MAX_FILE_SIZE_ATTRIBUTE +  "' attribute " +
                "of '" + logNode.getNodeName() + "' element."
View Full Code Here

            if (prefix == null) prefix = "";

            logFile = constructLogFile(logFileDir,logNodeName,prefix);

            if (logFile== null) {
                throw new InvalidConfigFileFormatException(
                        "In a '" + logsNode.getNodeName() + "' element, " +
                        " the '" + XmultraConfig.DIRECTORY_ATTRIBUTE +
                        "' is not defined."
                );
            }
            logNode = logsNode;
        }
        else {
            // Get the error log file.
            String logFileStr = xmlParseUtils.getAttributeValueFromNode(
                            logNode, XmultraConfig.FILE_NAME_ATTRIBUTE);

            if (logFileStr == null) {
                throw new InvalidConfigFileFormatException(
                        "In an '" + logNode.getNodeName() + "' element, " +
                        "the '" + XmultraConfig.FILE_NAME_ATTRIBUTE +
                        "' is not defined."
                );
            }

            logFile = new File(fileUtils.addRoot(logFileStr));

        }

        // Make sure log directory exists.
        File logFileParent = logFile.getParentFile();
        if (!logFileParent.exists()) {

            throw new InvalidConfigFileFormatException(
                    "'" + logFileParent +
                    "' is not an existing directory. " +
                    "Directory defined in the '" +
                    logNode.getNodeName() + "' element."
            );
        }

        // See if this log file already exists. Every log file must occur only
        // once in the config file.
        String logFileName = logFile.toString();
        if (logRegistry.containsKey(logFileName)) {

            throw new InvalidConfigFileFormatException(
                   "The '" + logFileName +
                    "' log file already exists."
            );
        }
View Full Code Here

            // Create and initialize the class that writes the destination locations.
            this.destWriter = new DestinationWriter();
            try {
                if (!destWriter.init(this.initMapHolder, super.aProcessorNode, new DateUtils())) {
                    throw new InvalidConfigFileFormatException();
                }
            }
            catch (InvalidConfigFileFormatException e) {
                this.errEntry.setThrowable(e);
                this.errEntry.setAppContext("initializeDestWriter()");
View Full Code Here

        emailLogDirectory = getEmailLogAttribute(
                                XmultraConfig.DIRECTORY_ATTRIBUTE);

        File emailLogDirFile = new File(fileUtils.addRoot(emailLogDirectory));
        if (emailLogDirFile == null || !emailLogDirFile.isDirectory()) {
            throw new InvalidConfigFileFormatException("The directory '" +
                emailLogDirectory + "' in the '" +
                XmultraConfig.DIRECTORY_ATTRIBUTE + "' attribute of the '" +
                XmultraConfig.EMAIL_LOG_ELEMENT + "' element does not exist.");
        }

        String maxEmailsPerHourStr = getEmailLogAttribute(
                XmultraConfig.EMAIL_MAX_EMAILS_PER_HOUR_ATTR);
        if (maxEmailsPerHourStr.equalsIgnoreCase(XmultraConfig.NO_LIMIT)) {
            maxEmailsPerHour = Integer.MAX_VALUE;  // Set to no limit.
        } else {
            try {
                maxEmailsPerHour = Integer.parseInt(maxEmailsPerHourStr);
            }
            catch (NumberFormatException e) {
                throw new InvalidConfigFileFormatException("The '" +
                    XmultraConfig.EMAIL_MAX_EMAILS_PER_HOUR_ATTR +
                    "' attribute in the '" + XmultraConfig.EMAIL_LOG_ELEMENT +
                    "' element has an \ninvalid value of '" + maxEmailsPerHourStr +
                    "'. It must be 'NoLimit' or a positive number."
                );
View Full Code Here

        attrValue = xmlParseUtils.getAttributeValueFromNode(emailNode,
                                                            attrName);

        if (attrValue == null || attrValue.equals("")) {
            throw new InvalidConfigFileFormatException(
                "The '" + attrName + "' must be specified in the '" +
                XmultraConfig.EMAIL_LOG_ELEMENT + "' element.");
        }
        return attrValue;
    }
View Full Code Here

TOP

Related Classes of com.xmultra.util.InvalidConfigFileFormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.