Package org.osgi.service.cm

Examples of org.osgi.service.cm.ConfigurationException


    @Override
    public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws Exception {

        final String value = configuration.get(IDENTIFICATION_PROPERTY_VALUE);
        if (value == null || value.equals("")) {
            throw new ConfigurationException(IDENTIFICATION_PROPERTY_VALUE, "Missing a valid identification value");
        }
        Identification impl = new Identification() {

            @Override
            public String getID() {
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    public synchronized void updated(String pid, Dictionary dict) throws ConfigurationException {
        String name = (String) dict.get(RepositoryConstants.REPOSITORY_NAME);
        if ((name == null) || "".equals(name)) {
            throw new ConfigurationException(RepositoryConstants.REPOSITORY_NAME, "Repository name has to be specified.");
        }

        String customer = (String) dict.get(RepositoryConstants.REPOSITORY_CUSTOMER);
        if ((customer == null) || "".equals(customer)) {
            throw new ConfigurationException(RepositoryConstants.REPOSITORY_CUSTOMER, "Repository customer has to be specified.");
        }

        String master = (String) dict.get(RepositoryConstants.REPOSITORY_MASTER);
        if (!("false".equalsIgnoreCase(master.trim()) || "true".equalsIgnoreCase(master.trim()))) {
            throw new ConfigurationException(RepositoryConstants.REPOSITORY_MASTER, "Have to specify whether the repository is the master or a slave.");
        }
        boolean isMaster = Boolean.parseBoolean(master);

        String initialContents = (String) dict.get(RepositoryConstants.REPOSITORY_INITIAL_CONTENT);

        if (m_prefs == null) {
            m_prefs = m_prefsService.getSystemPreferences();
        }

        String[] nodes;
        try {
            nodes = m_prefs.childrenNames();
        }
        catch (BackingStoreException e) {
            throw new ConfigurationException("none", "Internal error while validating configuration.");
        }
        for (int i = 0; i < nodes.length; i++) {
            Preferences node = m_prefs.node(nodes[i]);
            if (name.equalsIgnoreCase(node.get(RepositoryConstants.REPOSITORY_NAME, "")) && name.equalsIgnoreCase(node.get(RepositoryConstants.REPOSITORY_CUSTOMER, ""))) {
                throw new ConfigurationException("name and customer", "Name and customer combination already exists");
            }
        }

        Preferences node = m_prefs.node(pid);
        node.put(RepositoryConstants.REPOSITORY_NAME, name);
View Full Code Here

    public void updated(Dictionary settings) throws ConfigurationException {
        if (settings != null) {
            String useAuthString = (String) settings.get(KEY_USE_AUTHENTICATION);
            if (useAuthString == null
                || !("true".equalsIgnoreCase(useAuthString) || "false".equalsIgnoreCase(useAuthString))) {
                throw new ConfigurationException(KEY_USE_AUTHENTICATION, "Missing or invalid value!");
            }
            boolean useAuth = Boolean.parseBoolean(useAuthString);

            m_useAuth = useAuth;
        }
View Full Code Here

     */
    public void updated(Dictionary dictionary) throws ConfigurationException {
        if (dictionary != null) {
            String usernameLookupKey = (String) dictionary.get(PROPERTY_USERNAME_LOOKUPKEY);
            if (usernameLookupKey == null || "".equals(usernameLookupKey.trim())) {
                throw new ConfigurationException(PROPERTY_USERNAME_LOOKUPKEY, "Missing property");
            }

            String usernameMatchPolicy = (String) dictionary.get(PROPERTY_USERNAME_MATCH_POLICY);
            if (usernameMatchPolicy == null || "".equals(usernameMatchPolicy.trim())) {
                throw new ConfigurationException(PROPERTY_USERNAME_MATCH_POLICY, "Missing property");
            }
           
            Object verifyCertValidity = dictionary.get(PROPERTY_VERIFY_CERT_VALIDITY);
            if (verifyCertValidity == null || !("true".equals(verifyCertValidity) || "false".equals(verifyCertValidity))) {
                throw new ConfigurationException(PROPERTY_VERIFY_CERT_VALIDITY, "Missing or invalid property!");
            }

            m_nameLookupKey = usernameLookupKey;
            m_nameMatchPolicy = usernameMatchPolicy;
            m_verifyCertValidity = Boolean.parseBoolean((String) verifyCertValidity);
View Full Code Here

    public void updated(Dictionary settings) throws ConfigurationException {
        if (settings != null) {
            String useAuthString = (String) settings.get(KEY_USE_AUTHENTICATION);
            if (useAuthString == null
                || !("true".equalsIgnoreCase(useAuthString) || "false".equalsIgnoreCase(useAuthString))) {
                throw new ConfigurationException(KEY_USE_AUTHENTICATION, "Missing or invalid value!");
            }
            boolean useAuth = Boolean.parseBoolean(useAuthString);

            m_useAuth = useAuth;
        }
View Full Code Here

    public void updated(Dictionary settings) throws ConfigurationException {
        if (settings != null) {
            String useAuthString = (String) settings.get(KEY_USE_AUTHENTICATION);
            if (useAuthString == null
                || !("true".equalsIgnoreCase(useAuthString) || "false".equalsIgnoreCase(useAuthString))) {
                throw new ConfigurationException(KEY_USE_AUTHENTICATION, "Missing or invalid value!");
            }
            boolean useAuth = Boolean.parseBoolean(useAuthString);
            m_useAuth = useAuth;
           
            m_servletEndpoint = (String) settings.get("org.apache.ace.server.servlet.endpoint");
View Full Code Here

            if(dictionary != null) {
                setURL(new URL((String) dictionary.get(DiscoveryConstants.DISCOVERY_URL_KEY)));
            }
        }
        catch (MalformedURLException e) {
            throw new ConfigurationException(DiscoveryConstants.DISCOVERY_URL_KEY, "Malformed URL", e);
        }
    }
View Full Code Here

    public void updated(String pid, Dictionary dict) throws ConfigurationException {
        String ma = (String) dict.get(MA_NAME);
        String id = (String) dict.get(DiscoveryConstants.DISCOVERY_URL_KEY);
       
        if (id == null) {
            throw new ConfigurationException(DiscoveryConstants.DISCOVERY_URL_KEY, "Must be specified");
        }

        boolean needToAddComponent = false;
        Component component;
        synchronized (m_instances) {
            component = (Component) m_instances.get(pid);
            if (component == null) {
                Properties props = new Properties();
                if ((ma != null) && (ma.length() > 0)) {
                    props.put(MA_NAME, ma);
                }
                props.put(DiscoveryConstants.DISCOVERY_URL_KEY, id);
                component = m_manager.createComponent()
                    .setInterface(Discovery.class.getName(), props)
                    .setImplementation(new PropertyBasedDiscovery(id))
                    .add(createServiceDependency()
                        .setService(LogService.class)
                        .setRequired(false)
                    );
                m_instances.put(pid, component);
                needToAddComponent = true;
            }
        }
        if (needToAddComponent) {
            m_manager.add(component);
        }
        else {
            Object service = component.getService();
            if (service instanceof PropertyBasedDiscovery) {
                PropertyBasedDiscovery identification = (PropertyBasedDiscovery) service;
                try {
                    identification.setURL(id);
                }
                catch (MalformedURLException e) {
                    throw new ConfigurationException(DiscoveryConstants.DISCOVERY_URL_KEY, "Malformed URL", e);
                }
            }
        }
    }
View Full Code Here

    public void updated(Dictionary settings) throws ConfigurationException {
        if (settings != null) {
            String baseDirectoryName = getNotNull(settings, DIRECTORY_NAME, "The base directory cannot be null");
            File baseDirectory = new File(baseDirectoryName);
            if (!baseDirectory.exists() || !baseDirectory.isDirectory()) {
                throw new ConfigurationException(DIRECTORY_NAME, "The directory called '" + baseDirectoryName + "' " + (baseDirectory.exists() ? "is no directory." : "doesn't exist."));
            }
            m_baseDirectory = baseDirectory;

            String defaultDirectoryName = (String) settings.get(DEFAULT_DIRECTORY_NAME);
            if (defaultDirectoryName != null) {
View Full Code Here

     * Convenience method for getting settings from a configuration dictionary.
     */
    private String getNotNull(Dictionary settings, String id, String errorMessage) throws ConfigurationException {
        String result = (String) settings.get(id);
        if (result == null) {
            throw new ConfigurationException(id, errorMessage);
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.ConfigurationException

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.