Package de.iritgo.aktera.persist

Examples of de.iritgo.aktera.persist.PersistenceException


    {
      oneReserved = (String) allReserved.next();

      if (oneReserved.equalsIgnoreCase(word))
      {
        throw new PersistenceException(
                "You cannot have a field or table name of '"
                        + word
                        + "'.  It is a reserved word for this database type.  Check database documentation for a full list.");
      }
    }
View Full Code Here


  {
    PersistentField oneField = (PersistentField) allFields.get(fieldName);

    if (oneField == null)
    {
      throw new PersistenceException("(" + getName() + ") Field " + fieldName
              + " is not defined as a field in persistent '" + getSchemaName() + "." + getName() + "'");
    }

    return oneField;
  }
View Full Code Here

  {
    PersistentField oneField = (PersistentField) allFields.get(keyFieldName);

    if (oneField == null)
    {
      throw new PersistenceException("(" + getName() + ") Field " + keyFieldName
              + " is not defined as a field in this Persistent - cannot add " + "to key for persistent "
              + getName() + " in schema " + getSchemaName());
    }

    if (oneField.allowsNull())
    {
      throw new PersistenceException("(" + getName() + ") Field " + keyFieldName
              + " allows null - not suitable for inclusion " + "in key for persistent " + getName()
              + " in schema " + getSchemaName());
    }

    if (oneField.isVirtual())
    {
      throw new PersistenceException("(" + getName() + ") Field " + keyFieldName
              + " is a virtual field - not suitable for " + "inclusion in key for persistent "
              + getName() + " in schema " + getSchemaName());
    }

    oneField.setKey(true);
View Full Code Here

  {
    PersistentField oneField = (PersistentField) allFields.get(fieldName);

    if (oneField == null)
    {
      throw new PersistenceException("No such field '" + fieldName + "'" + " in object '" + getName() + "'");
    }

    return oneField.getDescription();
  } /* getDescription(String) */
 
View Full Code Here

  {
    SuperString.assertNotBlank(fieldName, "Field name may not be blank");

    if (allFields.size() == 0)
    {
      throw new PersistenceException("Object " + getSchemaName() + "." + getName() + "'");
    }

    PersistentField oneField = (PersistentField) allFields.get(fieldName);

    if (oneField == null)
    {
      throw new PersistenceException("No such field as '" + fieldName + "' in object '" + getSchemaName() + "."
              + getName() + "'");
    }

    return oneField;
  } /* getPersistentField(String) */
 
View Full Code Here

  {
    PersistentField oneField = getPersistentField(fieldName);

    if (oneField == null)
    {
      throw new PersistenceException("No such field '" + fieldName + "'" + "' in object '" + getName() + "'");
    }

    return oneField.isReadOnly();
  } /* isReadOnly(String) */
 
View Full Code Here

  {
    try
    {
      if (myConfig == null)
      {
        throw new PersistenceException("Configuration may not be null here");
      }

      /* top-level items should be a "persistent" element */
      if (! myConfig.getName().equals("persistent"))
      {
        throw new PersistenceException("Configuration must be from 'persistent' element, not '"
                + myConfig.getName() + "'. Check config file format.");
      }

      setName(myConfig.getAttribute("name"));

      id = myConfig.getAttribute("id", "");

      authMgrBypassAllowed = myConfig.getAttributeAsBoolean("am-bypass-allowed", false);

      helperClassName = myConfig.getAttribute("helper", null);
      implClassName = myConfig.getAttribute("class", null);

      pageSize = myConfig.getAttributeAsInteger("page-size", 0);
      name = SuperString.notNull(myConfig.getAttribute("name"));

      if (name.equals(""))
      {
        throw new PersistenceException("persistent element must have a name attribute");
      }

      tableName = SuperString.notNull(myConfig.getAttribute("table"));

      if (tableName.equals(""))
      {
        throw new PersistenceException("persistent '" + name + "' must have a table attribute");
      }

      objectDescription = myConfig.getAttribute("descrip", getName());

      //added by Santanu Dutt for Securable persistent Objects
      if (myConfig.getAttributeAsBoolean("securable", false))
      {
        setSecurable(true);
      }

      if (myConfig.getAttributeAsBoolean("row-securable", false))
      {
        setSecurable(true);
        rowSecurable = true;
      }

      int fieldCount = 0;
      Configuration[] children = myConfig.getChildren();
      Configuration oneChild = null;

      for (int i = 0; i < children.length; i++)
      {
        oneChild = children[i];

        if (oneChild.getName().equals("field"))
        {
          fieldCount++;
          configureField(oneChild);
        }
        else if (oneChild.getName().equals("detail"))
        {
          /* Configure a detail relation from this persistent to another */
          DefaultRelation r = new DefaultRelation(Relation.DETAIL, oneChild.getAttribute("name"), getName(),
                  oneChild.getAttribute("persistent"));
          String fromString = oneChild.getAttribute("fromFields");
          String toString = oneChild.getAttribute("toFields");
          StringTokenizer stk = new StringTokenizer(fromString, ",");

          while (stk.hasMoreTokens())
          {
            r.addFromField(stk.nextToken().trim());
          }

          stk = new StringTokenizer(toString, ",");

          while (stk.hasMoreTokens())
          {
            r.addToField(stk.nextToken().trim());
          }

          relations.put(oneChild.getAttribute("name"), r);
        }
        else if (oneChild.getName().equals("relation"))
        {
          DefaultRelation r = new DefaultRelation(Relation.OTHER, oneChild.getAttribute("name"), getName(),
                  oneChild.getAttribute("persistent"));
          String fromString = oneChild.getAttribute("fromFields");
          String toString = oneChild.getAttribute("toFields");
          StringTokenizer stk = new StringTokenizer(fromString, ",");

          while (stk.hasMoreTokens())
          {
            r.addFromField(stk.nextToken().trim());
          }

          stk = new StringTokenizer(toString, ",");

          while (stk.hasMoreTokens())
          {
            r.addToField(stk.nextToken().trim());
          }

          relations.put(oneChild.getAttribute("name"), r);
        }
        else if (oneChild.getName().equals("default-data"))
        {
          /* Do nothing - we don't deal with default-data here, it's only read */
          /* at the time the table is created */
        }
        else if (oneChild.getName().equals("index"))
        {
          /* records fields to be indexed. */
          String indexName = oneChild.getAttribute("name");
          boolean isUnique = new Boolean(oneChild.getAttribute("is-unique")).booleanValue();
          boolean createWithTable = new Boolean(oneChild.getAttribute("create-with-table")).booleanValue();
          Configuration[] indexedFields = oneChild.getChildren();
          String fieldNames = "";

          for (int j = 0; j < indexedFields.length; j++)
          {
            String columnName = indexedFields[j].getAttribute("name");

            fieldNames += columnName;

            if (j + 1 != indexedFields.length)
            {
              fieldNames += ",";
            }
          }

          Index index = addIndex(indexName, fieldNames, isUnique);

          indicies.add(index);
          index.setCreateWithTable(createWithTable);
        }
        else
        {
          log.warn("Unknown child of 'persistent' element '" + name + "', '" + oneChild.getName()
                  + "' was ignored");
        }
      }

      if (fieldCount == 0)
      {
        throw new ConfigurationException("No fields in persistent '" + name + "' for schema '"
                + getSchemaName() + "', id '" + id
                + "', and persistent does not use 'use-factory' option.");
      }

      if (isSecurable())
      {
        String amHint = myConfig.getAttribute("am", defaultAmHint);

        try
        {
          authMgr = (AuthorizationManager) getService(AuthorizationManager.ROLE, amHint);
        }
        catch (Exception e)
        {
          log.error("Could not get service " + AuthorizationManager.ROLE + "/" + amHint);
          throw new PersistenceException(e);
        }
      }
    }
    catch (ConfigurationException ce)
    {
      throw new PersistenceException(ce);
    }
  }
View Full Code Here

    String fieldName = config.getAttribute("name");

    if (fieldName.equals(""))
    {
      throw new PersistenceException("Field element must have a name attribute");
    }

    String dbFieldName = config.getAttribute("db-name", "");

    /* If we don't specify a db-name, then the name is used as both the internal name and the database name */
    if (dbFieldName.equals(""))
    {
      dbFieldName = fieldName;
    }

    if (reservedWords.contains(dbFieldName))
    {
      throw new PersistenceException("Field '" + fieldName + "' cannot use '" + dbFieldName
              + "' as a database column/field name, as it is a reserved word in this type of database");
    }

    String fieldType = config.getAttribute("type");

    if (fieldType.equals(""))
    {
      throw new PersistenceException("Field '" + fieldName + "' must have a valid type specified");
    }

    /* Check for a valid type */
    short theType;

    try
    {
      theType = JDBCDatabaseType.stringToType(fieldType);
    }
    catch (IllegalArgumentException pe)
    {
      throw new PersistenceException("Unable to use type '" + fieldType + "' for field '" + fieldName
              + "' in persistent '" + getName() + "'", pe);
    }

    addField(fieldName, dbFieldName, theType, config.getAttributeAsInteger("length", 0), config
            .getAttributeAsInteger("precision", 0), config.getAttributeAsBoolean("null-allowed", true),
View Full Code Here

  {
    PersistentField oneField = (PersistentField) allFields.get(fieldName);

    if (oneField == null)
    {
      throw new PersistenceException("No such field '" + fieldName + "'" + " in object '" + getName() + "'");
    }

    Map returnMap = oneField.getValidValues();

    if (returnMap == null)
View Full Code Here

    PersistentField oneField = (PersistentField) allFields.get(fieldName);
    boolean returnValue = false;

    if (oneField == null)
    {
      throw new PersistenceException("No such field '" + fieldName + "'" + " in object '" + getName() + "'");
    }

    String listName = oneField.getListNameForValidValues();

    if (listName != null)
View Full Code Here

TOP

Related Classes of de.iritgo.aktera.persist.PersistenceException

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.