Package com.xmultra.util

Examples of com.xmultra.util.InvalidConfigFileFormatException


            try {
                if (!manager.init(mgrNode, Xmultra.getXmultraRootDir(),
                    manager.getStartingManagersSyncFlag())) {

                    // There is an error so throw exception.
                    throw new InvalidConfigFileFormatException();
                }
            }
            catch (InvalidConfigFileFormatException e) {
                msgEntry.setAppContext("reloadProcessorConfigFile()");
                msgEntry.setDocInfo(origConfigFile.toString());
                msgEntry.setMessageText("Error in new config file. " +
                        "Reverting to previous config file. " +
                        "Bad config file moved to 'old' location.");
                msgEntry.setError(e.getMessage());
                logger.logWarning(msgEntry);

                // Restore the original file.
                restoreOriginalConfigFile(oldFile, origConfigFile, newConfigFile);

                // Try to reload again.
                try {
                    // Remove this manager from the list of managers.
                    // It will get added back in during manager.init().
                    callbackRegistry.removeFromManagerList(manager, this);

                    // Re-initialize the manager with original cfg file.
                    // If no sucess, give up.
                    if (!manager.init(mgrNode, Xmultra.getXmultraRootDir(),
                        manager.getStartingManagersSyncFlag())) {

                        // There is an error so throw exception.
                        throw new InvalidConfigFileFormatException();
                    }
                }
                catch (InvalidConfigFileFormatException ie) {

                    // Couldn't even reload the old config file.
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()");
                this.errEntry.setAppMessage("Error reading a DestinationLocation directory");
View Full Code Here

        // Get the 'systemLogs' node.
        NodeList systemLogsNodelist = xmultraConfigDocument.getElementsByTagName(
            XmultraConfig.SYSTEM_LOGS_ELEMENT);
        Node systemLogsNode = systemLogsNodelist.item(0);
        if (systemLogsNode == null) {
            throw new InvalidConfigFileFormatException("'SystemsLog' node missing in Xmultra's config file.");
        }

        // Set the description for the logs to empty.
        // (will get filled in by Logger).
        initMapHolder.setEntry(this, InitMapHolder.MANAGER_DESCRIPTION, "");
View Full Code Here

        String propertyFileName = 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 = strings.substitute(propPattern,
                                            propValue,
                                            cfgFileStr);
        }

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

            throw new InvalidConfigFileFormatException(
                strings.getGroup(0) + " property reference in system config " +
                "file was not found in properties file \"" +
                propertyFile + "\"");
        }
        return cfgFileStr;
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

            }
        } catch (NumberFormatException e) {
            //throw numberException(e);
            String error = "JcronAlarm error. The following must be a number: " +
                                intsWithRange;
            throw new InvalidConfigFileFormatException(error);
        } catch (NegativeArraySizeException e) {
            //throw numberException(e);
            String error = "JcronAlarm error. \"Start=" + startNum + "\" and \"End="
                + endNum + "\" but \"End\" can't be smaller \"Start\" value.";
            throw new InvalidConfigFileFormatException(error);
        }
        return ints;
    }
View Full Code Here

                msgEntry.setError("PastDateException - ignore on startup of Xmultra");
                logger.logWarning(msgEntry);
            }
        } else {
            // Error -- out of scope
            throw new InvalidConfigFileFormatException(
                "Must be JcronAlarm or RelativeJcronAlarm");
        }
        return true;
    }
View Full Code Here

                // is "None" the empty string will be appended.
                openMark = "";

                if (!markType.equals(NewsPreParserConfig.MARK_TYPE_NONE)) {

                    throw new InvalidConfigFileFormatException("\"" +
                            componentName +
                            "\" element needs a value in the \"" +
                                               NewsPreParserConfig.OPEN_MARK +
                                               "\" attribute.");
                }
            }

            /*
             * Retrieve and build the close mark.
             */

            // If matched type, just use the open mark.
            if (markType.equals(NewsPreParserConfig.MARK_TYPE_MATCHED)) {
                closeMark = openMark;
            }
            else if (markType.equals(NewsPreParserConfig.MARK_TYPE_UNMATCHED)) {

                // Retrieve the close mark.
                closeMark = xmlParseUtils.getAttributeValueFromNode(
                        componentNode, NewsPreParserConfig.CLOSE_MARK);

                // If empty, use the default close mark.
                if (closeMark == null || closeMark.equals("")) {
                    closeMark = defaultCloseMark;
                }
            }

            /*
             * Add the pending if turned on.
             */

            // Find out what the pending setting is.
            pendingSetting = xmlParseUtils.getAttributeValueFromNode(
                    componentNode, NewsPreParserConfig.PENDING);

            // Add it if turned on.
            if (pendingSetting.equals(NewsPreParserConfig.PENDING_ON)) {
                openMark = openMarkPrePend + openMark + openMarkPostPend;
                closeMark = closeMarkPrePend + closeMark + closeMarkPostPend;
            }

            /*
             * Retrieve and build the content pattern
             * (its the stuff between the marks).
             */
            content = xmlParseUtils.getAttributeValueFromNode(
                    componentNode, NewsPreParserConfig.CONTENT);

            if (content == null) {
                content = "";

                // If type is Matched or Unmatched, but content is empty,
                // use default. If OpenOnly is mark types, will only use
                // the content from the element, if any supplied.
            }
            if ( (markType.equals(NewsPreParserConfig.MARK_TYPE_MATCHED) ||
                  markType.equals(NewsPreParserConfig.MARK_TYPE_UNMATCHED)) &&
                content.equals("")) {
                content = defaultContent;
            }

            // Get mark pattern if any, for previous instances of this element.
            patternList = (List) patternListMap.get(componentName);

            // If not previously entered (it's null) initialize it.
            if (patternList == null) {

                // If null, we need to initialize it to empty string.
                patternList = new LinkedList();

                // Add that list pattern to the map.
                patternListMap.put(componentName, patternList);
            }

            if (markType.equals(NewsPreParserConfig.MARK_TYPE_OPEN)) {

                // The mark type says there should be no pending.
                newMarkPattern = openMark + content;
            }
            else if (markType.equals(NewsPreParserConfig.MARK_TYPE_NONE)) {
                newMarkPattern = content;
            }
            else {
                newMarkPattern = openMark + content + closeMark;
            }

            // Change the &lt; entity to <.
            newMarkPattern = strings.substitute(LT_ENTITY, "<", newMarkPattern);

            // Convert any escaped Unicode strings to literal value
            // (i.e. \u0041 to A).
            try {
                newMarkPattern =
                        strings.convertStringWithEscapedCode(newMarkPattern);
            }
            catch (NumberFormatException e) {
                throw new InvalidConfigFileFormatException(
                        "Invalid value in \"" +
                        componentName + "\" element: " + e.getMessage());
            }

            // Add the new pattern to the list.
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.