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

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

Introduction

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

Prototype

public ConfigurationException(Throwable cause) 

Source Link

Document

Constructs a new ConfigurationException with specified nested Throwable.

Usage

From source file:org.apache.juddi.v3.client.config.UDDIClerk.java

/**
 * Gets the details of a specific service binding key
 *
 * @param bindingKey/*from   w ww . j  av  a 2 s .  com*/
 * @param node
 * @return null if not found, or error, or the details of the binding
 * @throws DispositionReportFaultMessage
 * @throws RemoteException
 * @throws TransportException
 * @throws ConfigurationException
 */
public BindingTemplate getServiceBindingDetail(String bindingKey, Node node)
        throws DispositionReportFaultMessage, RemoteException, TransportException, ConfigurationException {
    GetBindingDetail getBindingDetail = new GetBindingDetail();
    getBindingDetail.getBindingKey().add(bindingKey);
    getBindingDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));
    try {
        BindingDetail bd = getUDDINode().getTransport().getUDDIInquiryService(node.getInquiryUrl())
                .getBindingDetail(getBindingDetail);
        List<BindingTemplate> bindingTemplateList = bd.getBindingTemplate();
        if (bindingTemplateList.size() == 0) {
            throw new ConfigurationException("Could not find ServiceBinding with key=" + bindingKey);
        }
        return bindingTemplateList.get(0);
    } catch (DispositionReportFaultMessage dr) {
        DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
        checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);
    } catch (SOAPFaultException sfe) {
        DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
        checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);
    } catch (UndeclaredThrowableException ute) {
        DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
        checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);
    }
    return null;
}

From source file:org.apache.juddi.v3.client.config.UDDIClient.java

/**
 * Returns the transport defined for the node with the given nodeName.
 * Note: this will always return a new instance of Transport
 *
 * @param nodeName/*from w  w w .ja v  a2s.  co m*/
 * @return a transport object
 * @throws ConfigurationException
 */
public Transport getTransport(String nodeName) throws ConfigurationException {
    try {
        String clazz = clientConfig.getUDDINode(nodeName).getProxyTransport();
        String managerName = clientConfig.getClientName();
        Class<?> transportClass = ClassUtil.forName(clazz, UDDIClient.class);
        if (transportClass != null) {
            Transport transport = (Transport) transportClass.getConstructor(String.class, String.class)
                    .newInstance(managerName, nodeName);
            return transport;
        } else {
            throw new ConfigurationException(
                    "ProxyTransport was not defined in the " + clientConfig.getConfigurationFile());
        }
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage(), e);
    }
}

From source file:org.apache.juddi.v3.client.config.UDDIClientContainer.java

public static UDDIClient getUDDIClient(String clientName) throws ConfigurationException {

    if (clientName != null) {
        if (clients.containsKey(clientName)) {
            return (clients.get(clientName));
        } else {/*from w ww  .  j av a  2s  .  com*/
            throw new ConfigurationException("No client by name " + clientName + " was found. "
                    + " Please check your client uddi.xml files, and make sure this client was started");
        }
    } else
        throw new IllegalArgumentException("clientName is a required argument");
}

From source file:org.apache.juddi.v3.client.config.UDDIClientContainer.java

public static void removeClerkManager(String clientName) throws ConfigurationException {
    if (clients.containsKey(clientName)) {
        clients.remove(clientName);//from   w ww  .ja  va2  s. c om
    } else if (clients.size() == 1 && clientName == null) {
        String name = clients.keySet().iterator().next();
        log.info("Removing " + name + " from UDDIClient.");
        clients.remove(name);
    } else {
        throw new ConfigurationException("Could not remove UDDIClient for name " + clientName);
    }
}

From source file:org.apache.juddi.v3.client.config.WebHelper.java

/**
 * Checks the servlet context for the manager defined in the web context. Optionally, in your 
 * web.xml you can specify either the manager name if you want to use an existing manager 
 * called 'uddi-portlet-manager':/*  www .  ja va2 s.c o m*/
 * <pre>
 * &lt;context-param&gt;
 *   &lt;param-name&gt;uddi.client.manager.name&lt;/param-name&gt;
 *   &lt;param-value&gt;uddi-portlet-manager&lt;/param-value&gt;
 * &lt;/context-param&gt;
 * </pre>
 * or, if you don't want to use the default META-INF/uddi.xml file path, but 'META-INF/my-uddi.xml' instead,
 * then you can set:
 * <pre>
 * &lt;context-param&gt;
 *   &lt;param-name&gt;uddi.client.config.path&lt;/param-name&gt;
 *   &lt;param-value&gt;META-INF/my-uddi.xml&lt;/param-value&gt;
 * &lt;/context-param&gt;
 * </pre>
 * @param servletContext
 * @return a UDDI Client instance
 * @throws ConfigurationException
 */
public static UDDIClient getUDDIClient(ServletContext servletContext) throws ConfigurationException {
    if (servletContext.getAttribute(JUDDI_CLIENT_NAME) != null) {
        String clientName = String.valueOf(servletContext.getAttribute(JUDDI_CLIENT_NAME));
        return UDDIClientContainer.getUDDIClient(clientName);
    } else {
        String clientName = servletContext.getInitParameter(UDDI_CLIENT_NAME);
        if (clientName != null) {
            try {
                UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
                logger.info("Client " + clientName + " was already started.");
                servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName);
                return client;
            } catch (ConfigurationException ce) {
                logger.debug("Client " + clientName + " is not yet started.");
            }
        }
        String clientConfigFile = servletContext.getInitParameter(UDDI_CLIENT_CONFIG_FILE);
        if (clientConfigFile == null)
            clientConfigFile = ClientConfig.DEFAULT_UDDI_CONFIG;

        logger.info("Reading the clientName from the clientConfig file " + clientConfigFile);
        UDDIClient client = new UDDIClient(clientConfigFile);
        if (clientConfigFile == null && client.getName() == null) {
            logger.warn(
                    "Deprecated, client name set to 'default', however it should be provided in the uddi.xml");
            clientName = "default";
        }
        if (client.getName() != null) {
            logger.info("Starting Client " + client.getName() + "...");
        } else {
            throw new ConfigurationException("A client name needs to be specified in the client config file.");
        }

        client.start();
        servletContext.setAttribute(JUDDI_CLIENT_NAME, clientName);
        return client;
    }
}

From source file:org.apache.juddi.v3.client.mapping.ServiceLocator.java

/**
 * Creates a new UDDIServiceCache, which brings up a new WebService Endpoint. This
 * EndPoint will be called by the UDDI server if any service changes. A callback
 * will result in cleaning the cache. //from w w w  .  ja v  a2  s. c om
 * 
 * @param baseCallbackURL
 * @throws ConfigurationException
 */
private UDDIServiceCache initCache(URL baseCallbackURL) throws ConfigurationException {
    if (clerk == null)
        throw new ConfigurationException("The UDDIClerk is needed to use the UDDIServiceCache and is null");
    if (urlLocalizer == null)
        urlLocalizer = new URLLocalizerDefaultImpl(baseCallbackURL);
    try {
        log.info("Creating a UDDICLientCache");
        return new UDDIServiceCache(clerk, urlLocalizer, properties);
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage(), e);
    }
}

From source file:org.apache.juddi.v3.client.mapping.wadl.WADL2UDDI.java

public WADL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties)
        throws ConfigurationException {
    super();/* w  w  w .  j  a v  a 2 s . c o m*/
    this.clerk = clerk;
    this.urlLocalizer = urlLocalizer;
    this.properties = properties;

    if (clerk != null) {
        if (!properties.containsKey("keyDomain")) {
            throw new ConfigurationException("Property keyDomain is a required property when using WADL2UDDI.");
        }
        if (!properties.containsKey("businessKey") && !properties.containsKey("businessName")) {
            throw new ConfigurationException(
                    "Either property businessKey, or businessName, is a required property when using WADL2UDDI.");
        }
        if (!properties.containsKey("nodeName")) {
            if (properties.containsKey("serverName") && properties.containsKey("serverPort")) {
                String nodeName = properties.getProperty("serverName") + "_"
                        + properties.getProperty("serverPort");
                properties.setProperty("nodeName", nodeName);
            } else {
                throw new ConfigurationException(
                        "Property nodeName is not defined and is a required property when using WADL2UDDI.");
            }
        }
    }

    //Obtaining values from the properties
    this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
    if (properties.contains(Property.BUSINESS_KEY)) {
        this.businessKey = properties.getProperty(Property.BUSINESS_KEY);
    } else {
        //using the BusinessKey Template, and the businessName to construct the key 
        this.businessKey = UDDIKeyConvention.getBusinessKey(properties);
    }
    this.lang = properties.getProperty(Property.LANG, Property.DEFAULT_LANG);
}

From source file:org.apache.juddi.v3.client.mapping.wsdl.WSDL2UDDI.java

/**
 * Required Properties are: businessName, for example: 'Apache'
 * nodeName, for example: 'uddi.example.org_80' keyDomain, for example:
 * juddi.apache.org// w  ww . ja  v a 2s . c o  m
 *
 * Optional Properties are: lang: for example: 'nl'
 *
 * @param clerk - can be null if register/unregister methods are not
 * used.
 * @param urlLocalizer - A reference to an custom
 * @param properties - required values keyDomain, businessKey, nodeName
 * @throws ConfigurationException
 */
public WSDL2UDDI(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties)
        throws ConfigurationException {
    super();
    if (properties == null) {
        throw new IllegalArgumentException("properties");
    }
    this.clerk = clerk;
    this.urlLocalizer = urlLocalizer;
    this.properties = properties;

    if (clerk != null) {
        if (!properties.containsKey("keyDomain")) {
            throw new ConfigurationException("Property keyDomain is a required property when using WSDL2UDDI.");
        }
        if (!properties.containsKey("businessKey") && !properties.containsKey("businessName")) {
            throw new ConfigurationException(
                    "Either property businessKey, or businessName, is a required property when using WSDL2UDDI.");
        }
        if (!properties.containsKey("nodeName")) {
            if (properties.containsKey("serverName") && properties.containsKey("serverPort")) {
                String nodeName = properties.getProperty("serverName") + "_"
                        + properties.getProperty("serverPort");
                properties.setProperty("nodeName", nodeName);
            } else {
                throw new ConfigurationException(
                        "Property nodeName is not defined and is a required property when using WSDL2UDDI.");
            }
        }
    }

    //Obtaining values from the properties
    this.keyDomainURI = "uddi:" + properties.getProperty("keyDomain") + ":";
    if (properties.contains(Property.BUSINESS_KEY)) {
        this.businessKey = properties.getProperty(Property.BUSINESS_KEY);
    } else {
        //using the BusinessKey Template, and the businessName to construct the key 
        this.businessKey = UDDIKeyConvention.getBusinessKey(properties);
    }
    this.lang = properties.getProperty(Property.LANG, Property.DEFAULT_LANG);
}

From source file:org.apache.log.extractor.App.java

private App() throws IOException, ConfigurationException {
    logger.info("***Starting App***");
    initConfiguration();//from   w ww  . j  a v a  2 s.  c o  m
    final String[] logLocations = config.getStringArray("log.oozie.location");
    if (ArrayUtils.isEmpty(logLocations)) {
        throw new ConfigurationException("Please set property: " + "log.oozie.location");
    }
    logFiles = getLogFiles(logLocations);
    if (logFiles.size() > config.getInt("log.oozie.max.files")) {
        logger.error("Too many log files: " + logFiles);
        return;
    }
    String writeMayBe = config.getString("log.oozie.write.location");
    if (StringUtils.isEmpty(writeMayBe)) {
        if (logLocations.length == 1 && new File(logLocations[0]).isDirectory()) {
            writeLocation = logLocations[0] + "/oozie_logs/";
        } else {
            throw new ConfigurationException("Please set property: " + "log.oozie.write.location");
        }
    } else {
        writeLocation = writeMayBe;
    }
}

From source file:org.apache.marmotta.platform.core.services.config.ConfigurationServiceImpl.java

protected void saveSecure(final PropertiesConfiguration conf) throws ConfigurationException {
    final File file = conf.getFile();
    try {//  w  ww.  j  av a2  s.c  o m
        if (file == null) {
            throw new ConfigurationException("No file name has been set!");
        } else if ((file.createNewFile() || true) && !file.canWrite()) {
            throw new IOException("Cannot write to file " + file.getAbsolutePath() + ". Is it read-only?");
        }
    } catch (IOException e) {
        throw new ConfigurationException(e.getMessage(), e);
    }
    log.debug("Saving {}", file.getAbsolutePath());

    final String fName = file.getName();
    try {
        int lastDot = fName.lastIndexOf('.');
        lastDot = lastDot > 0 ? lastDot : fName.length();

        final Path configPath = file.toPath();
        // Create a tmp file next to the original
        final Path tmp = Files.createTempFile(configPath.getParent(), fName.substring(0, lastDot) + ".",
                fName.substring(lastDot));
        try {
            Files.copy(configPath, tmp, StandardCopyOption.COPY_ATTRIBUTES,
                    StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException iox) {
            log.error("Could not create temp-file {}: {}", tmp, iox.getMessage());
            throw iox;
        }
        log.trace("using temporary file: {}", tmp);
        // Save the config to the tmp file
        conf.save(tmp.toFile());

        log.trace("tmp saved, now replacing the original file: {}", configPath);
        // Replace the original with the tmp file
        try {
            try {
                Files.move(tmp, configPath, StandardCopyOption.REPLACE_EXISTING,
                        StandardCopyOption.ATOMIC_MOVE);
            } catch (AtomicMoveNotSupportedException amnx) {
                log.trace("atomic move not available: {}, trying without", amnx.getMessage());
                Files.move(tmp, configPath, StandardCopyOption.REPLACE_EXISTING);
            }
        } catch (IOException iox) {
            log.error("Could not write to {}, a backup was created in {}", configPath, tmp);
            throw iox;
        }
        log.info("configuration successfully saved to {}", configPath);
    } catch (final Throwable t) {
        throw new ConfigurationException("Unable to save the configuration to the file " + fName, t);
    }
}