Package org.jdom

Examples of org.jdom.JDOMException


   * @throws JDOMException
   *             if parsing the request failed or if the request is not valid.
   */
  private void parseLockScope(Element lockScopeElement) throws JDOMException {
    if (lockScopeElement == null) {
      throw new JDOMException("Expected <" + E_LOCKSCOPE + "> element");
    }

    List children = lockScopeElement.getChildren();
    if (children.size() != 1) {
      throw new JDOMException("<" + E_LOCKSCOPE
          + "> must have exactly one child element");
    }

    lockInfo_lockScope = ((Element) children.get(0)).getName();
    if (!(E_EXCLUSIVE.equals(lockInfo_lockScope)
        || E_SHARED.equals(lockInfo_lockScope) || E_LOCAL
        .equals(lockInfo_lockScope))) {
      throw new JDOMException("<" + E_LOCKSCOPE
          + "> can only contain one of <" + E_EXCLUSIVE + "> or <"
          + E_SHARED + "> or <" + E_LOCAL + ">");
    }
  }
View Full Code Here


   *             if parsing the request failed or if the request is not valid.
   */
  private void parseLockType(Element lockTypeElement) throws JDOMException {

    if (lockTypeElement == null) {
      throw new JDOMException("Expected <" + E_LOCKTYPE + "> element");
    }

    List children = lockTypeElement.getChildren();
    if (children.size() != 1) {
      throw new JDOMException("<" + E_LOCKTYPE
          + "> must have exactly one child element");
    }
    String lockTypeName = ((Element) children.get(0)).getName();
    if (!E_WRITE.equals(lockTypeName)
        && !E_TRANSACTION.equals(lockTypeName)) {
      throw new JDOMException(
          "Only write and transaction locks are supported");
    }
    lockInfo_lockType = ((Element) children.get(0)).getName();
  }
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

        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

                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

        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

        Iterator i = parseRequestContent(E_UPDATE).getChildren().iterator();
        while( i.hasNext() ) {
            Element e = (Element)i.next();
            if( e.getName().equals(E_VERSION) ) {
                if( updateSourcePath != null ) {
                    throw new JDOMException("At most one &lt;"+E_VERSION+"&gt; element allowed" );
                }
                if (updateLabelName != null) {
                    throw new JDOMException("Either a &lt;"+E_VERSION+"&gt; OR a &lt;"+E_LABEL_NAME+"&gt; element allowed");
                }
                // get the href element
                ve = e;
                try {
                    Element hre = (Element)ve.getChildren().get(0);
                    if( hre == null || !hre.getName().equals(E_HREF) )
                        throw new Exception();
                    updateSourcePath = getSlidePath( hre.getText() );
                }
                catch( Exception x ) {
                    throw new JDOMException("&lt;"+E_VERSION+"&gt; element must contain &lt;"+E_HREF+"&gt; element" );
                }
            }
            if( e.getName().equals(E_PROP) ) {
                if( requestedProps != null ) {
                    throw new JDOMException("At most one "+E_PROP+" element allowed" );
                }
                requestedProps = new RequestedPropertiesImpl( e );
            }
            if( e.getName().equals(E_LABEL_NAME) ) {
                if (updateSourcePath != null) {
                    throw new JDOMException("Either a &lt;"+E_VERSION+"&gt; OR a &lt;"+E_LABEL_NAME+"&gt; element allowed");
                }
                if( updateLabelName != null ) {
                    throw new JDOMException("At most one &lt;"+E_LABEL_NAME+"&gt; element allowed" );
                }
                updateLabelName = e.getText();
            }
        }
    }
View Full Code Here

                                throw new Exception();
                            existingVersionPath = getSlidePath( hre.getText() );
                        }
                        catch( Exception x ) {
                            Domain.warn( E_VERSION+" element must contain "+E_HREF+" element" );
                            throw new JDOMException("<"+E_VERSION+"> element must contain <"+E_HREF+"> element" );
                        }
                        break;
                    }
                }
            }
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

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.