Package org.apache.slide.util.conf

Examples of org.apache.slide.util.conf.Configuration


           
            Namespace namespace = new Namespace();
            namespace.setName(configuration.getAttribute("name"));
            namespace.setLogger(namespaceLogger);
           
            Configuration namespaceConfigurationDefinition =
                configuration.getConfiguration("configuration");
            namespace.loadParameters(namespaceConfigurationDefinition);
           
            Configuration namespaceDefinition =
                configuration.getConfiguration("definition");
            namespace.loadDefinition(namespaceDefinition);
            addNamespace(namespace);
            try {
                Configuration namespaceBaseDataDefinition =
                    configuration.getConfiguration("data");
                namespace.loadBaseData(namespaceBaseDataDefinition);
            } catch (ConfigurationException e) {
                info("No basedata found for the namespace");
            }
           
            namespace.loadConfiguration(namespaceConfigurationDefinition);
           
           
           
           
            // preparation to add services, please ignore now
            try {
                Configuration services = configuration.getConfiguration("services");
                Enumeration s = services.getConfigurations("service");
                while (s.hasMoreElements()) {
                    Configuration service = (Configuration)s.nextElement();
                    System.out.println("&&&&&&Name       = " + service.getName());
                    System.out.println("&&&&&&className = " + service.getAttribute("classname"));
                    System.out.println("&&&&&&serviceName  = " + service.getAttribute("name"));
                    Enumeration s_pars = service.getConfigurations("parameter");
                    while (s_pars.hasMoreElements()) {
                        Configuration s_par = (Configuration)s_pars.nextElement();
                        System.out.println("&&&&&&PAR Name       = " + s_par.getName());
                        System.out.println("&&&&&&PAR Name       = " + s_par.getAttribute("name"));
                        System.out.println("&&&&&&Par Val        = " + s_par.getValue());
                    }
                }
            }
            catch (ConfigurationException e){
                // silently ignore it ==> no services
View Full Code Here


            // We've made sure that the object exists.
            // We now parse the permissions definition list, adding each
            // permission to the object's permission list.
            while (permissionDefinitions.hasMoreElements()) {
               
                Configuration permissionDefinition =
                    (Configuration) permissionDefinitions.nextElement();
                // Create the NodePermission object matching the Castor object
               
                String subjectUri =
                    permissionDefinition.getAttribute("subject");
               
                if (accessToken.getNamespaceConfig().getUsersPath().equals(subjectUri)) {
                    subjectUri = SubjectNode.ALL_URI;
                }
                else if (SubjectNode.ALL_URI.equals(subjectUri)) {
                    subjectUri = SubjectNode.ALL_URI;
                }
                else if (SubjectNode.OWNER_URI.equals(subjectUri)) {
                    subjectUri = SubjectNode.OWNER_URI;
                }
                else if (SubjectNode.UNAUTHENTICATED_URI.equals(subjectUri)) {
                    subjectUri = SubjectNode.UNAUTHENTICATED_URI;
                }
                else if (SubjectNode.AUTHENTICATED_URI.equals(subjectUri)) {
                    subjectUri = SubjectNode.AUTHENTICATED_URI;
                }
                else if (SubjectNode.SELF_URI.equals(subjectUri)) {
                    subjectUri = SubjectNode.SELF_URI;
                }
               
                String actionUri =
                    permissionDefinition.getAttribute("action");
               
                if (accessToken.getNamespaceConfig().getActionsPath().equals(actionUri)) {
                    actionUri = ActionNode.ALL_URI;
                }
                else if (ActionNode.ALL_URI.equals(actionUri)) {
                    actionUri = ActionNode.ALL_URI;
                }
               
                boolean inheritable = true;
               
                try {
                    if (permissionDefinition.getAttribute("inheritable")
                        .equals("false")) {
                        inheritable = false;
                    }
                } catch (ConfigurationException e) {
                }
               
                boolean negative = false;
               
                try {
                    if (permissionDefinition.getAttribute("negative")
                        .equals("true")) {
                        negative = true;
                    }
                } catch (ConfigurationException e) {
                }
               
                NodePermission permission = new NodePermission
                    (uri, subjectUri, actionUri, inheritable, negative);
               
                // Adding the NodePermission to the ObjectNode
                accessToken.getSecurityHelper()
                    .grantPermission(token, permission);
               
            }
           
            // Retrieve the list of revisions of the object
            Enumeration revisionDefinitions =
                objectDefinition.getConfigurations("revision");
            boolean revisionDefinitionsFound = false;
           
            // We parse the revision definition list
            while (revisionDefinitions.hasMoreElements()) {
               
                revisionDefinitionsFound = true;
                Configuration revisionDefinition =
                    (Configuration) revisionDefinitions.nextElement();
                loadObjectRevision(accessToken, token, uri,
                                   revisionDefinition);
               
            }
           
            if (!revisionDefinitionsFound) {
                loadDefaultObjectRevision(accessToken, token, uri);
            }
           
           
        } catch (ObjectNotFoundException e) {
            // Should NEVER happen
            accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
            accessToken.getLogger().log
                (e.toString(),LOG_CHANNEL,Logger.WARNING);
        } catch (LinkedObjectNotFoundException e) {
            // Icorrect link
            accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
            accessToken.getLogger().log
                ("Incorrect link found while creating " + uri,
                 LOG_CHANNEL,Logger.WARNING);
        } catch (AccessDeniedException e) {
            // Security exception
            accessToken.getLogger().log
                ("Insufficient credentials to create object",
                 LOG_CHANNEL,Logger.INFO);
        } catch (ObjectLockedException e) {
            // Lock exception
            accessToken.getLogger().log
                ("Lock-Token required",
                 LOG_CHANNEL,Logger.INFO);
        }
       
       
        Enumeration childConfigurations =
            objectDefinition.getConfigurations("objectnode");
       
        while(childConfigurations.hasMoreElements()) {
            Configuration childConfiguration =
                (Configuration) childConfigurations.nextElement();
            loadObjectNode(accessToken, token, childConfiguration);
        }
       
    }
View Full Code Here

            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(false);
            factory.setValidating(false);
            SAXParser parser = factory.newSAXParser();
            Populate pop = new Populate();
            Configuration slideConfiguration =
                new ConfigurationElement(
                pop.load(
                                            new InputSource(
                            new StringReader("<revision/>")), parser.getXMLReader()));
            loadObjectRevision(accessToken, token, uri, slideConfiguration);
View Full Code Here

        if (revisionDescriptor == null) {
            revisionDescriptor = new NodeRevisionDescriptor(0);
        }
       
        while (propertyDefinitions.hasMoreElements()) {
            Configuration propertyDefinition =
                (Configuration) propertyDefinitions.nextElement();
            String propertyName = propertyDefinition.getAttribute("name");
            String propertyValue = propertyDefinition.getValue();
            String propertyNamespace = propertyDefinition.getAttribute
                ("namespace", NodeProperty.DEFAULT_NAMESPACE);
            NodeProperty property = revisionDescriptor.getProperty
                (propertyName, propertyNamespace);
            if (property == null)
                revisionDescriptor.setProperty(propertyName, propertyNamespace,
View Full Code Here

            factory.setNamespaceAware(false);
            factory.setValidating(false);
            SAXParser parser = factory.newSAXParser();
           
            Populate pop = new Populate();
            Configuration configuration = new ConfigurationElement
                (pop.load(new InputSource(reader), parser.getXMLReader()));
           
            importData(token, configuration);
           
        } catch (javax.xml.parsers.FactoryConfigurationError e) {
View Full Code Here

       
        parameters = new Hashtable();
        Enumeration parametersDef = config.getConfigurations("parameter");
        try {
            while (parametersDef.hasMoreElements()) {
                Configuration parameter =
                    (Configuration) parametersDef.nextElement();
                addParameter(parameter.getAttribute("name"),
                             parameter.getValue());
            }
        } catch (ConfigurationException e) {
            throw new InvalidNamespaceConfigurationException
                (namespace, e.getMessage());
        }
       
        // Add basic role mappings
        addRoleMapping(NOBODY, NOBODY_ROLE);
        addRoleMapping(NOBODY, LINK_ROLE);
        addRoleMapping(NOBODY, ACTION_ROLE);
        // Note : the base role should be the last one.
        addRoleMapping(NOBODY, BASE_ROLE);
        Enumeration roleMappingsDef = config.getConfigurations("role");
        try {
            while (roleMappingsDef.hasMoreElements()) {
                Configuration roleMappingDef =
                    (Configuration) roleMappingsDef.nextElement();
                addRoleMapping(roleMappingDef.getAttribute("name"),
                               roleMappingDef.getValue());
            }
        } catch (ConfigurationException e) {
            throw new InvalidNamespaceConfigurationException
                (namespace, e.getMessage());
        }
       
        defaultProperties = new Hashtable();
        Enumeration defaultPropertiesDef =
            config.getConfigurations("default-property");
        try {
            while (defaultPropertiesDef.hasMoreElements()) {
                Configuration defaultProperty =
                    (Configuration) defaultPropertiesDef.nextElement();
                String name = defaultProperty.getAttribute("name");
                String value = defaultProperty.getAttribute("value", "");
                String propertyNamespace = defaultProperty.getAttribute
                    ("namespace", NodeProperty.DEFAULT_NAMESPACE);
                String role = defaultProperty.getAttribute("role");
                addDefaultProperty(role, name, value, propertyNamespace);
            }
        } catch (ConfigurationException e) {
            throw new InvalidNamespaceConfigurationException
                (namespace, e.getMessage());
        }
       
        Enumeration contentInteceptorsDef =
            config.getConfigurations("content-interceptor");
        try {
            while (contentInteceptorsDef.hasMoreElements()) {
                Configuration contentInterceptorDef =
                    (Configuration) contentInteceptorsDef.nextElement();
                String classname = contentInterceptorDef.getAttribute("class");
                try {
                    Class contentInterceptorClass =
                        Class.forName(classname);
                    ContentInterceptor contentInterceptor =
                        (ContentInterceptor)
View Full Code Here

       
        parameters = new Hashtable();
        Enumeration parametersDef = config.getConfigurations("parameter");
        try {
            while (parametersDef.hasMoreElements()) {
                Configuration parameter =
                    (Configuration) parametersDef.nextElement();
                addParameter(parameter.getAttribute("name"),
                             parameter.getValue());
            }
        } catch (ConfigurationException e) {
            throw new InvalidNamespaceConfigurationException
                (namespace, e.getMessage());
        }
       
        // Add basic role mappings
        addRoleMapping(NOBODY, NOBODY_ROLE);
        addRoleMapping(NOBODY, LINK_ROLE);
        addRoleMapping(NOBODY, ACTION_ROLE);
        // Note : the base role should be the last one.
        addRoleMapping(NOBODY, BASE_ROLE);
        Enumeration roleMappingsDef = config.getConfigurations("role");
        try {
            while (roleMappingsDef.hasMoreElements()) {
                Configuration roleMappingDef =
                    (Configuration) roleMappingsDef.nextElement();
                addRoleMapping(roleMappingDef.getAttribute("name"),
                               roleMappingDef.getValue());
            }
        } catch (ConfigurationException e) {
            throw new InvalidNamespaceConfigurationException
                (namespace, e.getMessage());
        }
       
        defaultProperties = new Hashtable();
        Enumeration defaultPropertiesDef =
            config.getConfigurations("default-property");
        try {
            while (defaultPropertiesDef.hasMoreElements()) {
                Configuration defaultProperty =
                    (Configuration) defaultPropertiesDef.nextElement();
                String name = defaultProperty.getAttribute("name");
                String value = defaultProperty.getAttribute("value", "");
                String propertyNamespace = defaultProperty.getAttribute
                    ("namespace", NodeProperty.DEFAULT_NAMESPACE);
                String role = defaultProperty.getAttribute("role");
                addDefaultProperty(role, name, value, propertyNamespace);
            }
        } catch (ConfigurationException e) {
            throw new InvalidNamespaceConfigurationException
                (namespace, e.getMessage());
View Full Code Here

            // We've made sure that the object exists.
            // We now parse the permissions definition list, adding each
            // permission to the object's permission list.
            while (permissionDefinitions.hasMoreElements()) {
               
                Configuration permissionDefinition =
                    (Configuration) permissionDefinitions.nextElement();
                // Create the NodePermission object matching the Castor object
               
                String subjectUri =
                    permissionDefinition.getAttribute("subject");
               
                String actionUri =
                    permissionDefinition.getAttribute("action");
               
                boolean inheritable = true;
               
                try {
                    if (permissionDefinition.getAttribute("inheritable")
                        .equals("false")) {
                        inheritable = false;
                    }
                } catch (ConfigurationException e) {
                }
               
                boolean negative = false;
               
                try {
                    if (permissionDefinition.getAttribute("negative")
                        .equals("true")) {
                        negative = true;
                    }
                } catch (ConfigurationException e) {
                }
               
                NodePermission permission = new NodePermission
                    (uri, subjectUri, actionUri, inheritable, negative);
               
                // Adding the NodePermission to the ObjectNode
                accessToken.getSecurityHelper()
                    .grantPermission(token, permission);
               
            }
           
            // Retrieve the list of revisions of the object
            Enumeration revisionDefinitions =
                objectDefinition.getConfigurations("revision");
           
            // We parse the revision definition list
            while (revisionDefinitions.hasMoreElements()) {
               
                Configuration revisionDefinition =
                    (Configuration) revisionDefinitions.nextElement();
                loadObjectRevision(accessToken, token, uri,
                                   revisionDefinition);
               
            }
           
        } catch (ObjectNotFoundException e) {
            // Should NEVER happen
            Domain.log(e,LOG_CHANNEL,Logger.WARNING);
            Domain.log(e.toString(),LOG_CHANNEL,Logger.WARNING);
        } catch (LinkedObjectNotFoundException e) {
            // Icorrect link
            Domain.log(e,LOG_CHANNEL,Logger.WARNING);
            Domain.log("Incorrect link found while creating " + uri,LOG_CHANNEL,Logger.WARNING);
        } catch (AccessDeniedException e) {
            // Security exception
            Domain.log("Insufficient credentials to create object",LOG_CHANNEL,Logger.INFO);
        }
       
        Enumeration childConfigurations =
            objectDefinition.getConfigurations("objectnode");
       
        while(childConfigurations.hasMoreElements()) {
            Configuration childConfiguration =
                (Configuration) childConfigurations.nextElement();
            loadObjectNode(accessToken, token, childConfiguration);
        }
       
    }
View Full Code Here

        if (revisionDescriptor == null) {
            revisionDescriptor = new NodeRevisionDescriptor(0);
        }
       
        while (propertyDefinitions.hasMoreElements()) {
            Configuration propertyDefinition =
                (Configuration) propertyDefinitions.nextElement();
            String propertyName = propertyDefinition.getAttribute("name");
            String propertyValue = propertyDefinition.getValue();
            String propertyNamespace = propertyDefinition.getAttribute
                ("namespace", NodeProperty.DEFAULT_NAMESPACE);
            NodeProperty property = revisionDescriptor.getProperty
                (propertyName, propertyNamespace);
            if (property == null)
                revisionDescriptor.setProperty(propertyName, propertyNamespace,
View Full Code Here

        storesClass.put(storeName, storeClass);
       
        // Load descriptor store parameters
        Hashtable storeParameters = new Hashtable();
        while (storeParametersDefinitions.hasMoreElements()) {
            Configuration parameterDefinition = (Configuration)
                storeParametersDefinitions.nextElement();
            String parameterName = parameterDefinition.getAttribute("name");
            String parameterValue = parameterDefinition.getValue();
            storeParameters.put(parameterName, parameterValue);
        }
       
        storesParameters.put(storeName, storeParameters);
       
        // Now reading the "child" stores
       
        Hashtable currentStoreChildStores = new Hashtable();
       
        // Loading node store (if any)
        try {
            Configuration nodeStoreDefinition =
                storeDefinition.getConfiguration(NODE_STORE);
            try {
                Configuration referenceDefinition =
                    storeDefinition.getConfiguration(REFERENCE);
                currentStoreChildStores.put
                    (NODE_STORE, referenceDefinition.getAttribute("store"));
                getLogger().log("Node store references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
            } catch (ConfigurationException ex) {
                getLogger().log("Node store: " + nodeStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
                NodeStore nodeStore =
                    (NodeStore) loadChildStore(nodeStoreDefinition,
                                               storeParameters);
                if (nodeStore != null) {
                    currentStoreChildStores.put(NODE_STORE, nodeStore);
                }
            }
        } catch (Exception e) {
        }
       
        // Loading security store (if any)
        try {
            Configuration securityStoreDefinition =
                storeDefinition.getConfiguration(SECURITY_STORE);
            try {
                Configuration referenceDefinition =
                    securityStoreDefinition.getConfiguration(REFERENCE);
                currentStoreChildStores.put
                    (SECURITY_STORE,
                     referenceDefinition.getAttribute("store"));
                getLogger().log("Security store references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
            } catch (ConfigurationException ex) {
                getLogger().log("Security store: " + securityStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
                SecurityStore securityStore =
                    (SecurityStore) loadChildStore(securityStoreDefinition,
                                                   storeParameters);
                if (securityStore != null) {
                    currentStoreChildStores.put(SECURITY_STORE, securityStore);
                }
            }
        } catch (Exception e) {
        }
       
        // Loading lock store (if any)
        try {
            Configuration lockStoreDefinition =
                storeDefinition.getConfiguration(LOCK_STORE);
            try {
                Configuration referenceDefinition =
                    lockStoreDefinition.getConfiguration(REFERENCE);
                currentStoreChildStores.put
                    (LOCK_STORE, referenceDefinition.getAttribute("store"));
                getLogger().log("Lock store store references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
            } catch (ConfigurationException ex) {
                getLogger().log("Lock store store: " + lockStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
                LockStore lockStore =
                    (LockStore) loadChildStore(lockStoreDefinition,
                                               storeParameters);
                if (lockStore != null) {
                    currentStoreChildStores.put(LOCK_STORE, lockStore);
                }
            }
        } catch (Exception e) {
        }
       
        // Loading revision descriptors store (if any)
        try {
            Configuration revisionDescriptorsStoreDefinition =
                storeDefinition.getConfiguration
                (REVISION_DESCRIPTORS_STORE);
            try {
                Configuration referenceDefinition =
                    revisionDescriptorsStoreDefinition
                    .getConfiguration(REFERENCE);
                currentStoreChildStores.put
                    (REVISION_DESCRIPTORS_STORE,
                     referenceDefinition.getAttribute("store"));
                getLogger().log("Revision descriptors store references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
            } catch (ConfigurationException ex) {
                getLogger().log("Revision descriptors store: " + revisionDescriptorsStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
                RevisionDescriptorsStore revisionDescriptorsStore =
                    (RevisionDescriptorsStore) loadChildStore
                    (revisionDescriptorsStoreDefinition, storeParameters);
                if (revisionDescriptorsStore != null) {
                    currentStoreChildStores.put(REVISION_DESCRIPTORS_STORE,
                                                revisionDescriptorsStore);
                }
            }
        } catch (Exception e) {
        }
       
        // Loading revision descriptor store (if any)
        try {
            Configuration revisionDescriptorStoreDefinition =
                storeDefinition.getConfiguration(REVISION_DESCRIPTOR_STORE);
            try {
                Configuration referenceDefinition =
                    revisionDescriptorStoreDefinition
                    .getConfiguration(REFERENCE);
                currentStoreChildStores.put
                    (REVISION_DESCRIPTOR_STORE,
                     referenceDefinition.getAttribute("store"));
                getLogger().log("Revision descriptor store references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
            } catch (ConfigurationException ex) {
                getLogger().log("Revision descriptor store: " + revisionDescriptorStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
                RevisionDescriptorStore revisionDescriptorStore =
                    (RevisionDescriptorStore) loadChildStore
                    (revisionDescriptorStoreDefinition, storeParameters);
                if (revisionDescriptorStore != null) {
                    currentStoreChildStores.put(REVISION_DESCRIPTOR_STORE,
                                                revisionDescriptorStore);
                }
            }
        } catch (Exception e) {
        }
       
        // Loading content store (if any)
        try {
            Configuration contentStoreDefinition =
                storeDefinition.getConfiguration(CONTENT_STORE);
            try {
                Configuration referenceDefinition =
                    contentStoreDefinition.getConfiguration(REFERENCE);
                currentStoreChildStores.put
                    (CONTENT_STORE, referenceDefinition.getAttribute("store"));
                getLogger().log("Content store references " + referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
            } catch (ConfigurationException ex) {
                getLogger().log("Content store: " + contentStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
                ContentStore contentStore =
                    (ContentStore) loadChildStore(contentStoreDefinition,
                                                  storeParameters);
View Full Code Here

TOP

Related Classes of org.apache.slide.util.conf.Configuration

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.