Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:velo.entity.Resource.java

public ResourceDescriptor factoryResourceDescriptor() throws ResourceDescriptorException {

    try {//from   www.j  a  v  a 2 s .c  om
        ResourceDescriptor rd = new ResourceDescriptor();
        rd.loadResourceXmlConfiguration(getConfiguration());

        return rd;
    } catch (ConfigurationException e) {
        throw new ResourceDescriptorException(e.getMessage());
    }

    /* OLD VIA DIGESTER
    //ResourceDescriptorReader tsDescriptorReader = new ResourceDescriptorReader();
    try {
    //   Parse the configuration
       tsDescriptorReader.parse(getConfiguration());
       //System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^CONF: " + getConfiguration());
       //System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^DESCR: " + tsDescriptorReader.getResourceDescriptor());
       //System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ADAPTER: " + tsDescriptorReader.getResourceDescriptor().getResourceDescriptorAdapter());
    return tsDescriptorReader.getResourceDescriptor();
    } catch (IOException ioe) {
    throw new ResourceDescriptorException(ioe.getMessage());
    } catch(SAXException saxe) {
    throw new ResourceDescriptorException(saxe.getMessage());
    }
    */
}

From source file:velo.resource.resourceDescriptor.ResourceDescriptor.java

public void loadResourceXmlConfiguration(String xml) throws ConfigurationException {
    try {//from  www .  j  a va  2 s  .c  o  m
        Reader reader = new StringReader(xml);
        //xmlConf.setDelimiterParsingDisabled(true);
        //xmlConf.setListDelimiter("|".charAt(0));
        //xmlConf.setDelimiter("|".charAt(0));
        config.load(reader);

    } catch (ConfigurationException e) {
        log.error("Could not load resource descriptor via xml data: " + e.getMessage() + "");
    }
}

From source file:xc.mst.manager.processingDirective.DefaultServicesService.java

public void updateService(String name, Service service, boolean reprocessingRequired)
        throws DataException, IndexException, IOException, ConfigFileException {
    // Reload the service and confirm that it's not currently running.
    // Throw an error if it is
    service = getServiceDAO().getById(service.getId());
    if (service.getStatus().equals(Status.RUNNING) || service.getStatus().equals(Status.PAUSED)) {
        throw new DataException("Cannot update a service while it is running.");
        // TODO propagate to UI
    }/*  ww w .  j a  va2  s  . co m*/

    String perviousVersion = service.getVersion();

    PropertiesConfiguration props = null;

    try {

        props = new PropertiesConfiguration(MSTConfiguration.getUrlPath() + "/services/" + name
                + "/META-INF/classes/xc/mst/services/custom.properties");

        String logFileName = getLogDAO().getById(Constants.LOG_ID_SERVICE_MANAGEMENT).getLogFileLocation();

        // The version of the service, which must appear in the second line of the configuration file
        String version = props.getString("service.version");
        if (version == null || version.length() == 0) {
            LogWriter.addError(logFileName,
                    "Error adding a new service: The second line of the service configuration file must be the service's version.");
            throw new ConfigFileException(
                    "The second line of the service configuration file must be the service's version.");
        }

        // The name of the service's class, which must appear in the fourth line of the configuration file
        String className = props.getString("service.classname");
        if (className == null || className.length() == 0) {
            LogWriter.addError(logFileName,
                    "Error adding a new service: The fourth line of the service configuration file must be the service's class name.");
            throw new ConfigFileException(
                    "The fourth line of the service configuration file must be the service's class name.");
        }

        // Populate the service BO
        service.setName(name);
        service.setVersion(version);
        service.setClassName(className);
        LOG.debug(
                "**** DefaultServicesService.updateService, about to see if need to setServicesServiceLastModified!");
        if (doesServiceFileTimeNeedUpdate(service)) {
            updateServiceLastModifiedTime(name, service);
            // TODO SHOULD we force reprocessing?
        }
        service.setHarvestOutLogFileName("logs" + MSTConfiguration.FILE_SEPARATOR + "harvestOut"
                + MSTConfiguration.FILE_SEPARATOR + name + ".txt");
        service.setServicesLogFileName("logs" + MSTConfiguration.FILE_SEPARATOR + "service"
                + MSTConfiguration.FILE_SEPARATOR + name + ".txt");
        service.getInputFormats().clear();
        service.getOutputFormats().clear();

        String[] temp = new String[] { "input", "output" };
        for (int j = 0; j < temp.length; j++) {

            String[] formatNames = props.getStringArray(temp[j] + ".format.name");
            String[] formatSchemas = props.getStringArray(temp[j] + ".format.schemaLocation");
            String[] formatNamespaces = props.getStringArray(temp[j] + ".format.namespace");

            if (getUtil().arraysEqualInLength(formatNames, formatSchemas, formatNames)) {
                for (int i = 0; i < formatNames.length; i++) {
                    Format format = getFormatDAO().getByName(formatNames[i]);

                    // If the format was not in the database, get it from the configuration file
                    if (format == null) {
                        format = new Format();
                        format.setName(formatNames[i]);
                        format.setSchemaLocation(formatSchemas[i]);
                        format.setNamespace(formatNamespaces[i]);
                        getFormatDAO().insert(format);
                    }
                    // Otherwise check whether or not the configuration file provided the same schema location and namespace for the format.
                    // Log a warning if not
                    else {
                        if (!format.getSchemaLocation().equals(formatSchemas[i]))
                            LogWriter.addWarning(logFileName,
                                    "The configuration file specified a schema location for the "
                                            + formatNames[i]
                                            + " format that differed from the one in the database. "
                                            + "The current schema location of " + format.getSchemaLocation()
                                            + " will be used " + "and the schema location " + formatSchemas[i]
                                            + " from the configuration file will be ignored.");

                        if (!format.getNamespace().equals(formatNamespaces[i]))
                            LogWriter.addWarning(logFileName,
                                    "The configuration file specified a namespace for the " + formatNames[i]
                                            + " format that differed from the one in the database. "
                                            + "The current namespace of " + format.getNamespace()
                                            + " will be used " + "and the namespace " + formatNamespaces[i]
                                            + " from the configuration file will be ignored.");
                    }

                    // Add the format we just parsed as an input format for the new service
                    if (temp[j].equals("input")) {
                        service.addInputFormat(format);
                    } else if (temp[j].equals("output")) {
                        service.addOutputFormat(format);
                    }
                }
            } else {
                throw new ConfigFileException(temp[j] + ".formats don't match in length");
            }
        }

        // Insert the service
        getServiceDAO().update(service);

        String[] errorCodes = props.getStringArray("error.code");
        String[] errorDescriptionFiles = props.getStringArray("error.descriptionFile");

        if (getUtil().arraysEqualInLength(errorCodes, errorDescriptionFiles)) {
            for (int i = 0; i < errorCodes.length; i++) {

                ErrorCode errorCode = getErrorCodeDAO().getByErrorCodeAndService(errorCodes[i], service);
                if (errorCode == null) {
                    errorCode = new ErrorCode();
                    errorCode.setErrorCode(errorCodes[i]);
                    errorCode.setErrorDescriptionFile(errorDescriptionFiles[i]);
                    errorCode.setService(service);
                    getErrorCodeDAO().insert(errorCode);
                } else {
                    errorCode.setErrorDescriptionFile(errorDescriptionFiles[i]);
                    getErrorCodeDAO().update(errorCode);
                }

            }
        } else {
            throw new ConfigFileException("error codes don't match in length");
        }

        // getRepositoryDAO().createRepository(service);
        MetadataService ms = getMetadataService(service);
        ms.getRepository().installOrUpdateIfNecessary(perviousVersion, version);
        ms.install();

        // TODO what does below line do? Is it necessary? Should it be here or moved to Service Reprocess thread?
        ServiceUtil.getInstance().checkService(service.getId(), Status.NOT_RUNNING, true);

        // Schedule a job to reprocess records through new service
        if (reprocessingRequired)
            reprocessService(service);
    } catch (ConfigurationException e) {
        LOG.error("ConfigFileException while adding a service: ", e);
        throw new ConfigFileException(e.getMessage());
    }
}

From source file:za.co.ashleagardens.coc.panels.AboutPanel.java

/**
 * Creates new form AboutPanel/*from w  ww  .ja v  a  2 s .  c  o m*/
 */
public AboutPanel() {
    initComponents();

    try {
        for (Map.Entry<String, String> entry : PROPERTY_UTIL.getApplicationBuildProperties().entrySet()) {
            if (VERSION_KEY.equals(entry.getKey())) {
                APP_BUILD_VERSION += entry.getValue();
            } else {
                APP_BUILD_VERSION_DATE += entry.getValue();
            }
        }
    } catch (ConfigurationException ex) {
        LOGGER.error(CLASS_NAME + ":AboutPanel: " + ex.getMessage());
    }

    appVersionLabel.setText(APP_BUILD_VERSION);
    appVersionDateLabel.setText(APP_BUILD_VERSION_DATE);
    this.setVisible(true);
}