Package org.dbwiki.exception.data

Examples of org.dbwiki.exception.data.WikiSchemaException


   
    SchemaNodeList children = this.children();
    while (tokens.hasMoreTokens()) {
      SchemaNode schema = children.get(tokens.nextToken());
      if (schema == null) {
        throw new WikiSchemaException(WikiSchemaException.UnknownSchemaNode, this.path() + "/" + path);
      }
      if (tokens.hasMoreTokens()) {
        if (schema.isGroup()) {
          children = ((GroupSchemaNode)schema).children();
        } else {
          throw new WikiSchemaException(WikiSchemaException.UnknownSchemaNode, this.path() + "/" + path);
        }
      } else {
        return schema;
      }
    }
    throw new WikiSchemaException(WikiSchemaException.UnknownSchemaNode, this.path() + "/" + path);
  }
View Full Code Here


      _root = (GroupSchemaNode)schema;
    }
   
    assert(_idMap.size() > 0);
    if (!isValidName(schema.label())) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid entry name " + _root.label());
    }
    String key = schema.path();
    if (_pathMap.containsKey(key)) {
      throw new WikiFatalException("Schema node with duplicate path(" + key + ") added to database schema.");
    }
View Full Code Here

    if ((path.length() > 1) && (path.endsWith(SchemaNode.SchemaPathSeparator))) {
      key = key.substring(0, key.length() - SchemaNode.SchemaPathSeparator.length());
    }
    SchemaNode schema = _pathMap.get(key);
    if (schema == null) {
      throw new WikiSchemaException(WikiSchemaException.UnknownSchemaNode, path);
    } else {
      return schema;
    }
  }
View Full Code Here

        _hasAttributes = true;
      } else {
        _hasElements = true;
      }
    } else {
      throw new WikiSchemaException(WikiSchemaException.DuplicateSchemaNode, key);
    }
  }
View Full Code Here

      while ((line = in.readLine()) != null) {
        text = text + line.trim();
      }
      in.close();
    } catch (java.io.IOException ioException) {
      throw new WikiSchemaException(ioException);
    }
    return this.parse(text);
  }
View Full Code Here

  }
 
  private GroupSchemaNode parseElement(String text, GroupSchemaNode parent, DatabaseSchema schema) throws org.dbwiki.exception.WikiException {
    // $name {
    if (!((text.startsWith(elementIndicator)) && (text.endsWith(closeElement)))) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Element expected in " + text);
    }
   
    String elementDefinition = text.substring(elementIndicator.length(), text.length() - closeElement.length());
   
    int pos = elementDefinition.indexOf(openElement);
    if (pos == -1) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Missing open bracket in element definition " + text);
    }

    String elementName = elementDefinition.substring(0, pos).trim();
    String elementBody = elementDefinition.substring(pos + openElement.length()).trim();
   
    GroupSchemaNode schemaNode = new GroupSchemaNode(schema.size(), elementName, parent);
    if (!DatabaseSchema.isValidName(schemaNode.label())) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid element name " + elementName);
    }
    schema.add(schemaNode);

    this.parseElementBody(elementBody, schemaNode, schema);
View Full Code Here

 
  private void parseElementBody(String text, GroupSchemaNode parent, DatabaseSchema schema) throws org.dbwiki.exception.WikiException {
    String elementBody = text;
   
    if (elementBody.length() == 0) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Empty element definition for " + parent.label());
    }
    while (elementBody.length() > 0) {
      if (elementBody.startsWith(attributeIndicator)) {
        int posDelim = elementBody.indexOf(attributeDelimiter);
        String attributeName = null;
        if (posDelim != -1) {
          attributeName = elementBody.substring(attributeIndicator.length(), posDelim).trim();
          elementBody = elementBody.substring(posDelim + attributeDelimiter.length()).trim();
          if (elementBody.length() == 0) {
            throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Empty element definition in " + text);
          }
        } else {
          attributeName = elementBody.substring(attributeIndicator.length()).trim();
          elementBody = "";
        }
        AttributeSchemaNode attribute = new AttributeSchemaNode(schema.size(), attributeName, parent);
        if (!DatabaseSchema.isValidName(attribute.label())) {
          throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid attribute name " + attributeName + " in " + text);
        }
        schema.add(attribute);
      } else if (elementBody.startsWith(elementIndicator)) {
        int posDelim = this.findEndOfElement(elementBody);
        if (posDelim != -1) {
          this.parseElement(elementBody.substring(0, posDelim + closeElement.length()), parent, schema);
          elementBody = elementBody.substring(posDelim + closeElement.length()).trim();
        } else {
          throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid element body " + text);
        }
      } else {
        throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid element body " + text);
      }
    }
  }
View Full Code Here

   */
  private void parseEntry(String text, DatabaseSchema schema) throws org.dbwiki.exception.WikiException {
    // $name {...}
   
    if (!((text.startsWith(entryIndicator)) && (text.endsWith(closeElement)))) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Entry expected in " + text);
    }
   
    String entryDefinition = text.substring(entryIndicator.length(), text.length() - closeElement.length());
   
    int pos = entryDefinition.indexOf(openElement);
    if (pos == -1) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Missing open bracket in entry definition " + text);
    }

    String entryName = entryDefinition.substring(0, pos).trim();
    String entryBody = entryDefinition.substring(pos + openElement.length()).trim();
   
    GroupSchemaNode schemaNode = new GroupSchemaNode(schema.size(), entryName, null);
    if (!DatabaseSchema.isValidName(DatabaseSchema.getSchemaNodeName(schemaNode.label()))) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid entry name " + entryName);
    }
    schema.add(schemaNode);
   
    this.parseElementBody(entryBody, schemaNode, schema);

View Full Code Here

    return nodeIdentifier;
  }
 
  public synchronized void insertSchemaNode(GroupSchemaNode parent, String name, byte type, User user) throws org.dbwiki.exception.WikiException {
    if (!DatabaseSchema.isValidName(name)) {
      throw new WikiSchemaException(WikiSchemaException.SyntaxError, "Invalid element name " + name);
    }
   
    Version version = _versionIndex.getNextVersion(new ProvenanceUnknown(user));
   
    SchemaNode schema = null;
    if (type == SchemaNodeTypeAttribute) {
      if (_schema.size() == 0) {
        throw new WikiSchemaException(WikiSchemaException.InvalidSchemaType, "Schema root cannot be an attribute");
      }
      schema = new AttributeSchemaNode(_schema.size(), name, parent, new TimeSequence(version));
    } else if (type == SchemaNodeTypeGroup) {
      schema = new GroupSchemaNode(_schema.size(), name, parent, new TimeSequence(version));
    } else {
      throw new WikiSchemaException(WikiSchemaException.InvalidSchemaType, String.valueOf(type));
    }
   
    try {
      Connection con = _connector.getConnection();
      con.setAutoCommit(false);
View Full Code Here

        if ((results.getInt(RelSchemaColType) == RelSchemaColTypeValAttribute) && (parent != null)) {
          schema = new AttributeSchemaNode(id, label, parent);
        } else if (results.getInt(RelSchemaColType) == RelSchemaColTypeValGroup) {
          schema = new GroupSchemaNode(id, label, parent);
        } else {
          throw new WikiSchemaException(WikiSchemaException.InvalidSchemaType, "Database value " + results.getInt(RelSchemaColType));
        }
      }

      // load the time interval - if any
      int end = RelTimestampColEndValOpen;
View Full Code Here

TOP

Related Classes of org.dbwiki.exception.data.WikiSchemaException

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.