Package org.apache.avalon.framework.configuration

Examples of org.apache.avalon.framework.configuration.ConfigurationException


        }

        try {
            envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
        } catch (Exception e) {
            throw new ConfigurationException("Resolving page envelope failed: ", e);
        }

        return envelope;
    }
View Full Code Here


            } else if (name.equals(PageEnvelope.SSL_PREFIX)) {
                value = envelope.getPublication().getSSLPrefix();
            } else if (name.equals(PageEnvelope.DOCUMENT_TYPE)) {
                value = getDocumentType(objectModel, envelope);
            } else {
                throw new ConfigurationException("The attribute [" + name + "] is not supported!");
            }
        } catch (ConfigurationException e) {
            throw e;
        } catch (Exception e) {
            throw new ConfigurationException(
                "Getting attribute for name [" + name + "] failed: ",
                e);
        }

        if (getLogger().isDebugEnabled()) {
View Full Code Here

            setupPolicyManager(conf);
            setupAuthenticator();
        } catch (ConfigurationException e) {
            throw e;
        } catch (Exception e) {
            throw new ConfigurationException("Configuration failed: ", e);
        }
    }
View Full Code Here

                value = siteTree.getNode(document.getId()).getLabel(document.getLanguage()).getHref();
                if (value == null) value = "";
            }

        } catch (Exception e) {
            throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
        }

        return value;
    }
View Full Code Here

        // Get parameters
        final String[] attributes = name.split(":");

        if (attributes.length < 3) {
            throw new ConfigurationException("Invalid number of parameters: " + attributes.length
                    + ". Expected area, document-id, language.");
        }

        final String area = attributes[0];
        final String documentId = attributes[1];
        final String language = attributes[2];

        String value = null;
        try {
            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Publication publication = envelope.getPublication();

            DocumentBuilder builder = publication.getDocumentBuilder();

            // Create canonical URL
            String canonicalUrl = builder
                    .buildCanonicalUrl(publication, area, documentId, language);

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Created canonicalURL: " + canonicalUrl);
            }

            // Get proxy for document
            serviceSelector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
                    + "Selector");
            acResolver = (AccessControllerResolver) serviceSelector
                    .select(AccessControllerResolver.DEFAULT_RESOLVER);

            AccessController accessController = acResolver.resolveAccessController(canonicalUrl);
            if (accessController instanceof DefaultAccessController) {
                DefaultAccessController defaultAccessController = (DefaultAccessController) accessController;
                accreditableManager = defaultAccessController.getAccreditableManager();
                Authorizer[] authorizers = defaultAccessController.getAuthorizers();
                for (int i = 0; i < authorizers.length; i++) {
                    if (authorizers[i] instanceof PolicyAuthorizer) {
                        PolicyAuthorizer policyAuthorizer = (PolicyAuthorizer) authorizers[i];
                        policyManager = policyAuthorizer.getPolicyManager();
                    }
                }
            }

            Policy policy = policyManager.getPolicy(accreditableManager, canonicalUrl);

            Document doc = builder.buildDocument(publication, canonicalUrl);

            Proxy proxy = doc.getPublication().getProxy(doc, policy.isSSLProtected());

            if (proxy != null) {
                value = proxy.getURL(doc);
            } else {
                // Take server name and port from request.
                Request request = ObjectModelHelper.getRequest(objectModel);
                value = "http://" + request.getServerName() + ":" + request.getServerPort()
                        + request.getContextPath() + doc.getCompleteURL();
            }

        } catch (Exception e) {
            throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
        }
        return value;
    }
View Full Code Here

        Request request = ObjectModelHelper.getRequest(objectModel);
        Session session = request.getSession();
        Object value = null;

        if (!Arrays.asList(PARAMETER_NAMES).contains(name)) {
            throw new ConfigurationException("The attribute [" + name + "] is not supported!");
        }

        if (session != null) {
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());
            if (identity != null) {
                if (name.equals(USER_ID)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getId();
                    }
                } else if (name.equals(USER_NAME)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getName();
                    }
                } else if (name.equals(USER_EMAIL)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getEmail();
                    }
                } else if (name.equals(IP_ADDRESS)) {
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        value = machine.getIp();
                    }
                } else if (name.equals(ROLE_IDS)) {
                    try {
                        Role[] roles = PolicyAuthorizer.getRoles(request);
                        StringBuffer roleIds = new StringBuffer();
                        for (int i = 0; i < roles.length; i++) {
                            if (i > 0) {
                                roleIds.append(",");
                            }
                            roleIds.append(roles[i].getId());
                        }
                        value = roleIds;
                    } catch (AccessControlException e) {
                        throw new ConfigurationException(
                            "Obtaining value for attribute [" + name + "] failed: ", e);
                    }
                }
            }
        }
View Full Code Here

            } else if (name.equals(IP_RANGE_MANAGER)) {
                itemManager = accreditableManager.getIPRangeManager();
            }

        } catch (Exception e) {
            throw new ConfigurationException("Obtaining item manager failed: ", e);
        } finally {
            if (selector != null) {
                if (resolver != null) {
                    if (accessController != null) {
                        resolver.release(accessController);
View Full Code Here

    try {
      setNetworkAddress(networkAddress);
      setSubnetMask(subnetMask);
    } catch (AccessControlException e) {
      throw new ConfigurationException("Configuring IP range [" + getId() + "] failed: ", e);
    }

  }
View Full Code Here

            String public_href = publics[i].getValue(null);

            try {
                public_matchers[i] = preparePattern(public_href);
            } catch (PatternException pe) {
                throw new ConfigurationException("invalid pattern for public hrefs", pe);
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("CONFIGURATION: public: " + public_href);
            }
View Full Code Here

            String taskId = taskConfigurations[i].getAttribute(TaskManager.TASK_ID_ATTRIBUTE);

            try {
                tasks[i] = taskManager.getTask(taskId);
            } catch (ExecutionException e) {
                throw new ConfigurationException("Sequence initialization failed: ", e);
            }

            log.debug("Adding task '" + taskId + "' to sequence.");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.configuration.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.