Search in sources :

Example 1 with InvalidPropertiesFormatException

use of java.util.InvalidPropertiesFormatException in project OpenAM by OpenRock.

the class BasicClientTypesManager method initManager.

/**
     * Initializes the <code>ClientTypesManager</code>.
     */
public void initManager() {
    Properties clientProps = new Properties();
    InputStream is = null;
    try {
        is = this.getClass().getResourceAsStream(PROPS_FILE);
        clientProps.load(is);
    } catch (Exception ex) {
        debug.error(CLASS_NAME + " unable to load properties file" + PROPS_FILE, ex);
    } finally {
        try {
            is.close();
        } catch (IOException ioe) {
            debug.error(CLASS_NAME + " unable to close property file");
        }
    }
    if (clientProps != null && !clientProps.isEmpty()) {
        try {
            processProps(clientProps);
        } catch (InvalidPropertiesFormatException ipfe) {
            debug.error(CLASS_NAME + " init unable to process properties file", ipfe);
            return;
        }
    }
    if (debug.messageEnabled()) {
        debug.message(CLASS_NAME + " basic CDM framework loaded with " + clientsData);
    }
}
Also used : InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) ClientException(com.iplanet.services.cdm.ClientException) SSOException(com.iplanet.sso.SSOException)

Example 2 with InvalidPropertiesFormatException

use of java.util.InvalidPropertiesFormatException in project OpenAM by OpenRock.

the class BasicClientTypesManager method processProps.

/**
     * Utility method used to parse the properties file that configures this client
     * types manager.
     * A simple entry in the properties file would look like this:
     *
     * <code>
     * clients=genericHtml,...
     * genericHtml_name=Generic HTML
     * genericHtml_attributes=filePath=html,contentType=text/html,cookieSupport=true,genericHtml=true,...
     * </code>
     *
     * The clients are the names of the different client types
     * For each client type, there is a list of attributes;
     *
     * _attributes is a comma delimited list of attributes for the client type
     *
     * @param props The properties file to parse
     * @throws InvalidPropertiesFormatException
     */
protected void processProps(Properties props) throws InvalidPropertiesFormatException {
    String statGroupsNames = props.getProperty(CLIENTS);
    if (statGroupsNames == null) {
        throw new InvalidPropertiesFormatException("Unable to find " + CLIENTS + " property.");
    }
    StringTokenizer st = new StringTokenizer(statGroupsNames, COMMA);
    while (st.hasMoreTokens()) {
        populateClient(st.nextToken(), props);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException)

Example 3 with InvalidPropertiesFormatException

use of java.util.InvalidPropertiesFormatException in project jdk8u_jdk by JetBrains.

the class PropertiesDefaultHandler method load.

public void load(Properties props, InputStream in) throws IOException, InvalidPropertiesFormatException, UnsupportedEncodingException {
    this.properties = props;
    try {
        SAXParser parser = new SAXParserImpl();
        parser.parse(in, this);
    } catch (SAXException saxe) {
        throw new InvalidPropertiesFormatException(saxe);
    }
/**
         * String xmlVersion = propertiesElement.getAttribute("version"); if
         * (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) throw new
         * InvalidPropertiesFormatException( "Exported Properties file format
         * version " + xmlVersion + " is not supported. This java installation
         * can read" + " versions " + EXTERNAL_XML_VERSION + " or older. You" +
         * " may need to install a newer version of JDK.");
         */
}
Also used : SAXParserImpl(jdk.internal.util.xml.impl.SAXParserImpl) InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) SAXException(jdk.internal.org.xml.sax.SAXException)

Example 4 with InvalidPropertiesFormatException

use of java.util.InvalidPropertiesFormatException in project traccar by tananaev.

the class Config method load.

void load(String file) throws IOException {
    try {
        Properties mainProperties = new Properties();
        try (InputStream inputStream = new FileInputStream(file)) {
            mainProperties.loadFromXML(inputStream);
        }
        String defaultConfigFile = mainProperties.getProperty("config.default");
        if (defaultConfigFile != null) {
            try (InputStream inputStream = new FileInputStream(defaultConfigFile)) {
                properties.loadFromXML(inputStream);
            }
        }
        // override defaults
        properties.putAll(mainProperties);
        useEnvironmentVariables = Boolean.parseBoolean(System.getenv("CONFIG_USE_ENVIRONMENT_VARIABLES")) || Boolean.parseBoolean(properties.getProperty("config.useEnvironmentVariables"));
    } catch (InvalidPropertiesFormatException e) {
        throw new RuntimeException("Configuration file is not a valid XML document", e);
    }
}
Also used : InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream)

Example 5 with InvalidPropertiesFormatException

use of java.util.InvalidPropertiesFormatException in project traccar by traccar.

the class Config method load.

void load(String file) throws IOException {
    try {
        Properties mainProperties = new Properties();
        try (InputStream inputStream = new FileInputStream(file)) {
            mainProperties.loadFromXML(inputStream);
        }
        String defaultConfigFile = mainProperties.getProperty("config.default");
        if (defaultConfigFile != null) {
            try (InputStream inputStream = new FileInputStream(defaultConfigFile)) {
                properties.loadFromXML(inputStream);
            }
        }
        // override defaults
        properties.putAll(mainProperties);
        useEnvironmentVariables = Boolean.parseBoolean(System.getenv("CONFIG_USE_ENVIRONMENT_VARIABLES")) || Boolean.parseBoolean(properties.getProperty("config.useEnvironmentVariables"));
    } catch (InvalidPropertiesFormatException e) {
        throw new RuntimeException("Configuration file is not a valid XML document", e);
    }
}
Also used : InvalidPropertiesFormatException(java.util.InvalidPropertiesFormatException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream)

Aggregations

InvalidPropertiesFormatException (java.util.InvalidPropertiesFormatException)18 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 Properties (java.util.Properties)6 FileInputStream (java.io.FileInputStream)3 InputStreamReader (java.io.InputStreamReader)2 LineNumberReader (java.io.LineNumberReader)2 SQLException (java.sql.SQLException)2 SAXException (jdk.internal.org.xml.sax.SAXException)2 SAXParserImpl (jdk.internal.util.xml.impl.SAXParserImpl)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 SAXException (org.xml.sax.SAXException)2 ClientException (com.iplanet.services.cdm.ClientException)1 SSOException (com.iplanet.sso.SSOException)1 SMSException (com.sun.identity.sm.SMSException)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1