Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.ConfigurationException


    String path = null;
    if ("vfsfile".equals(url.getProtocol())) {
      try {
        path = url.toURI().getPath() ;
      } catch (URISyntaxException e) {
        throw new ConfigurationException(e);
      }
    } else {
      path = url.getPath();
    }
   
    File dir = new File(path);
    String rootPublisherStr = config.getString(Property.JUDDI_ROOT_PUBLISHER);
    if (dir.exists()) {
      log.debug("Discovering the Publisher XML data files in directory: " + path);
      File[] files = dir.listFiles(new PublisherFileFilter());
        for (File f : files)
        { 
            String publisher = f.getName().substring(0,f.getName().indexOf(FILE_PUBLISHER));
            if (! rootPublisherStr.equalsIgnoreCase(publisher)) {
              publishers.add(publisher);
            }
        }
    } else {
      String[] paths = {};
      Enumeration<JarEntry> en = null;
      try {

        if (path.indexOf("!") > 0) {
          paths = path.split("!");
          en = new JarFile(new File(new URI(paths[0]))).entries();
        } else {
          // Handle Windows / jboss-5.1.0 case
          if (path.indexOf(".jar") > 0) {
            paths = path.split(".jar");
            paths[0] = paths[0] + ".jar";
            en = new JarFile(new File(paths[0])).entries();
          }
        }
        if (paths.length > 0) {
          log.debug("Discovering the Publisher XML data files in jar: " + paths[0]);
          while (en.hasMoreElements()) {
            String name = en.nextElement().getName();
            if (name.startsWith(basePath)&& name.endsWith(FILE_PUBLISHER)) {
              log.debug("Found publisher file=" + name);
              String publisher = name.substring(basePath.length(),name.indexOf(FILE_PUBLISHER));
                  if (! rootPublisherStr.equalsIgnoreCase(publisher)) {
                    publishers.add(publisher);
                  }
            }
          }
        } else {
          log.info("No custom configuration files where found in " + path);
        }
      } catch (IOException e) {
        throw new ConfigurationException(e);
      } catch (URISyntaxException e) {
        throw new ConfigurationException(e);
      }
    }
    return publishers;
  }
View Full Code Here


        resourceStream = url.openStream();
      }
      // If file still does not exist then return null;
      if (url ==null || resourceStream == null) {
        if (fileName.endsWith(FILE_PUBLISHER)) {
          throw new ConfigurationException("Could not locate " + JUDDI_INSTALL_DATA_DIR + fileName);
        } else {
          log.debug("Could not locate: " + url);
        }
        return null;
      }
View Full Code Here

      return new StringSelector(path);
    }
    if (path.startsWith(RESPECTIVE_DESTINATION_REFERENCE)) {
      return new DestinationReferenceSelector(path);
    }
    throw new ConfigurationException(
        "Cannot create data selector: Path must start with \"@\", \"/\" or \"$\", but is: " + path);
  }
View Full Code Here

    List<String> arguments = Arrays.asList(command.split("\\s+"));
    String operator;
    try {
      operator = arguments.get(1);
    } catch (IndexOutOfBoundsException e) {
      throw new ConfigurationException("Missing operator (second argument) in line: " + command);
    }
    Class<? extends DataCopyrule> ruleClass = AVAILABLE_RULES.get(operator);
    if (ruleClass == null) {
      throw new ConfigurationException("Unknown operator: " + operator);
    }
    DataCopyrule ruleImplementation;
    try {
      ruleImplementation = ruleClass.newInstance();
    } catch (InstantiationException e) {
      throw new RuntimeException(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    ruleImplementation.setSubject(arguments.get(0));
    if (ruleImplementation.getMaxObjects() > 0) {
      List<String> objects = arguments.subList(2, arguments.size());
      if (objects.size() < ruleImplementation.getMinObjects()) {
        throw new ConfigurationException("Too few arguments in line: " + command);
      }
      if (objects.size() > ruleImplementation.getMaxObjects()) {
        throw new ConfigurationException("Too many arguments in line: " + command);
      }
      ruleImplementation.setObjects(objects);
    }
    return ruleImplementation;
  }
View Full Code Here

        return new LocalMetadataSelector(path.substring(1));
      } else {
        return new MetadataPathSelector(path);
      }
    }
    throw new ConfigurationException(
        "Cannot create metadata selector: Path must start with \"@\" or \"/\", but is: " + path);
  }
View Full Code Here

      docStructType = pathSelectorHasElementSelector.group(1);
      String indexSymbol = pathSelectorHasElementSelector.group(2);
      try {
        index = getIndexValue(indexSymbol);
        if (index instanceof Integer && ((Integer) index).intValue() < 0) {
          throw new ConfigurationException("Negative element count is not allowed, in path: " + path);
        }
      } catch (NumberFormatException e) {
        throw new ConfigurationException("Cannot create metadata path selector: " + e.getMessage(), e);
      }
    } else {
      docStructType = pathSegment;
      index = null;
    }
View Full Code Here

   *             if the path cannot be parsed
   */
  private final String matchCurrentPathSegment(String path) throws ConfigurationException {
    Matcher metadataPathSplitter = METADATA_SPLIT_PATH_SCHEME.matcher(path);
    if (!metadataPathSplitter.find()) {
      throw new ConfigurationException(
          "Cannot create metadata path selector: Path must contain path segment, but is: " + path);
    }
    return metadataPathSplitter.group(1);
  }
View Full Code Here

   *             if the path is syntactically wrong
   */
  public DestinationReferenceSelector(String path) throws ConfigurationException {
    Matcher pathSplitter = DESTINATION_REFERENCE_SELECTOR_SCHEME.matcher(path);
    if (!pathSplitter.find()) {
      throw new ConfigurationException("Invalid destination reference selector: " + path);
    }
    this.index = Integer.parseInt(pathSplitter.group(1));
    this.nextSelector = MetadataSelector.create(pathSplitter.group(2));
  }
View Full Code Here

   * @throws ConfigurationException
   *             if the metadata path doesn’t start with an “@” character
   */
  public LocalMetadataSelector(String path) throws ConfigurationException {
    if (!path.startsWith(METADATA_SEPARATOR)) {
      throw new ConfigurationException(
          "Cannot create local metadata selector: Path must start with \"@\", but is: " + path);
    }
    selector.setName(path.substring(1));
  }
View Full Code Here

   * @throws ConfigurationException
   *             if the string isn’t enclosed in quotes
   */
  public StringSelector(String text) throws ConfigurationException {
    if (!text.endsWith("\"")) {
      throw new ConfigurationException("String must be enclosed in double quotes (\"\"), but is: " + text);
    }
    this.text = text.substring(1, text.length() - 1);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.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.