Package org.jdom

Examples of org.jdom.JDOMException


    tunnels.clear();
    files.clear();
   

    if (element.getName().equalsIgnoreCase("launcher")) {
      throw new JDOMException("Launcher element must be <launcher>");
    }
   
    typeName = element.getAttribute("type").getValue();
    if (typeName == null) {
      throw new JDOMException("<launcher> element requires attribute 'type'");
    }
    //
    try {
      String clazz = "com.adito.applications.types." + (
          String.valueOf(typeName.charAt(0)).toUpperCase() + typeName.substring(1) ) + "ApplicationType";
      if (log.isDebugEnabled())
        log.debug("Loading type class " + clazz);
      launcherType = (ExtensionType)Class.forName(clazz).newInstance();
    }
    catch(Throwable t) {
      throw new JDOMException("Failed to load launcher extension for type " + typeName + ".");
    }

    id = (element.getAttribute("launcher").getValue());

    if (id == null) {
      throw new JDOMException("<launcher> element requires attribute 'launcher'");
    }

    name = element.getAttribute("name").getValue();
    if (log.isDebugEnabled())
      log.debug("Launcher name is " + name);  

    if (name == null) {
      throw new JDOMException("<launcher> element requires the attribute 'name'");
    }

    for (Iterator it = element.getChildren().iterator();
         it.hasNext(); ) {
      Element e = (Element) it.next();
      if (e.getName().equalsIgnoreCase("description")) {
        description = e.getText();
      }
      else if (e.getName().equalsIgnoreCase("parameter")) {
        addParameter(e);
      }
      else if (e.getName().equalsIgnoreCase("messages")) {
        ExtensionDescriptorMessageResourcesFactory factory = new ExtensionDescriptorMessageResourcesFactory(e);
        messageResources = factory.createResources("dummy");
        if(messageResources == null) {
          throw new JDOMException("Failed to create message resources.");
        }
      }
      else if (e.getName().equalsIgnoreCase("tunnel")) {
        verifyTunnel(e);
      }
      else if (e.getName().equalsIgnoreCase("files")) {
        verifyFiles(e);
      }
      else {
//        launcherType.load(this, e);
      }
    }
   
    if(messageResources == null) {
      throw new JDOMException("No <messages> element supplied.");
    }
  }
View Full Code Here


  }

  private void verifyTunnel(Element e) throws JDOMException, IOException {
    String name = e.getAttributeValue("name");
    if (name == null || name.equals("")) {
      throw new JDOMException("name attribute required for <tunnel> element");
    }
    String hostname = e.getAttributeValue("hostname");
    if (hostname == null || hostname.equals("")) {
      throw new JDOMException(
          "hostname attribute required for <tunnel> element");
    }
    String port = e.getAttributeValue("port")
    if (port == null || port.equals("")) {
      throw new JDOMException(
          "port attribute required for <tunnel> element");
    }
    boolean usePreferredPort = !("false".equals(e.getAttributeValue("usePreferredPort")));
    tunnels.put(name, new TunnelDescriptor(name, hostname, port, usePreferredPort));
View Full Code Here

      Element e = (Element) it.next();
      if (e.getName().equalsIgnoreCase("if")) {
        verifyFiles(e);
      }
      else if (!e.getName().equalsIgnoreCase("file")) {
        throw new JDOMException("Unexpected element <" + e.getName() +
                                "> found in <files>");
      }
      else {
        processFile(e);
      }
View Full Code Here

            URL u = e.nextElement();
            log.info("Loading context property definitions from " + u);
            SAXBuilder build = new SAXBuilder();
            Element root = build.build(u).getRootElement();
            if (!root.getName().equals("definitions")) {
                throw new JDOMException("Root element in " + u + " should be <definitions>");
            }
            for (Iterator i = root.getChildren().iterator(); i.hasNext();) {
                Element c = (Element) i.next();
                if (c.getName().equals("definition")) {
                    DefaultPropertyDefinition def = new XMLPropertyDefinition(c);
                    contextConfiguration.registerPropertyDefinition(def);
                } else {
                    throw new JDOMException("Expect root element of <definitions> with child elements of <definition>. Got <"
                                    + c.getName() + ">.");
                }
            }
        }
View Full Code Here

        max = children.size();
        for (i = 0; i < max; i++) {
            child = (Element) children.get(i);
            if (child.getName().equals(elementName)) {
                if (found != null) {
                    throw new JDOMException("multiple child elements '" + elementName + "' found.");
                }
                found = child;
            }
        }
        if (found == null) {
            throw new JDOMException("child element '" + elementName + "' not found.");
        }
        return found.getText();
    }
View Full Code Here

                    }
                    else if (E_REMOVE.equals(child.getName())) {
                        propertiesToRemove.add(getPropElement(child));
                    }
                    else {
                        throw new JDOMException("Expected <"+E_SET+"> or <"+E_REMOVE+"> element");
                    }
                }
               
               
            }
View Full Code Here

     */
    private Element getPropElement(Element parent) throws JDOMException {
        List childrenList = parent.getChildren();
        if ( (childrenList.size() != 1) ||
                ( ! E_PROP.equals(((Element)childrenList.get(0)).getName()) ) ) {
            throw new JDOMException("Expected &lt;"+E_PROP+"&gt; element");
        }
        return (Element)childrenList.get(0);
    }
View Full Code Here

        Document document;
        Element root;

        document = parseRequestContent();
        if (document == null) {
            throw new JDOMException("Request content missing");
        }
        root = document.getRootElement();
        if( root == null || !root.getName().equals(rootName) ) {
            Domain.warn( "Root element must be "+rootName );
            throw new JDOMException("Root element must be <"+rootName+">");
        }
        return root;
    }
View Full Code Here

                operationElement = current;
            }
            current = root.getChild(DeltavConstants.E_SET, DNSP);
            if ( current != null) {
                if (operationElement != null) {
                    throw new JDOMException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
                }
                operationElement = current;
            }
            current = root.getChild(DeltavConstants.E_REMOVE, DNSP);
            if ( current != null) {
                if (operationElement != null) {
                    throw new JDOMException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
                }
                operationElement = current;
            }
            if (operationElement == null) {
                throw new JDOMException(LABEL_MUST_CONTAIN_EITHER_ADD_SET_OR_REMOVE);
            }
            operation = operationElement.getName();
           
            Element labelName = operationElement.getChild(DeltavConstants.E_LABEL_NAME, DNSP);
            if ( (labelName == null) ||
                    (labelName.getText() == null) ||
                    (labelName.getText().length() == 0) ) {
                throw new JDOMException(LABEL_MISSING);
            }
            label = labelName.getText();
        }
        catch (IOException  e){
            int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
View Full Code Here

                content.clear();
            }
            catch (Exception e) {
                // should not happen since the StringReader does not
                // perform any "real" I/O
                throw new JDOMException(e.getMessage());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jdom.JDOMException

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.