Examples of EmpireException


Examples of com.clarkparsia.empire.EmpireException

   * @param theClass the class to validate.
   * @throws com.clarkparsia.empire.EmpireException if
   */
  public static void assertValid(final Class theClass) throws EmpireException {
    if (!isEmpireCompatible(theClass)) {
      throw new EmpireException("Missing a required annotation (Entity & RdfsClass) or does not implement SupportsRdfId");
    }

    Collection<AccessibleObject> aAccessors = new HashSet<AccessibleObject>();
    aAccessors.addAll(getAnnotatedFields(theClass));
    aAccessors.addAll(getAnnotatedGetters(theClass, true));

    for (AccessibleObject aObj : aAccessors) {
      if (aObj.getAnnotation(OneToMany.class) != null ||
        aObj.getAnnotation(ManyToMany.class) != null) {
        Class aType = aObj instanceof Field
                ? ((Field)aObj).getType()
                : ((Method)aObj).getReturnType();

        if (!Collection.class.isAssignableFrom(aType)) {
          throw new EmpireException("Using OneToMany or ManyToMany annotation on a non-collection field : " + theClass + "." + aType);
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.empire.EmpireException

        info.errType   = errType;
        info.errParams = params;
        info.errSource =(source!=null) ? source.getClass().getName() : getClass().getName();
        // Use Exceptions
        if (exceptionsEnabled)
            throw new EmpireException(this);
        // return Error Status
        return false;
    }
View Full Code Here

Examples of org.apache.empire.EmpireException

        int index = cmdParams.indexOf(param);
        if (index < paramUsageCount)
        {   // Error: parameter probably used twice in statement!
            String msg = "A parameter may only be used once in a command.";
            error(Errors.Internal, msg);
            throw new EmpireException(this);
        }
        if (index > paramUsageCount)
        {   // Correct parameter order
            cmdParams.remove(index);
            cmdParams.insertElementAt(param, paramUsageCount);
View Full Code Here

Examples of org.apache.empire.EmpireException

        info.errType   = errType;
        info.errParams = params;
        info.errSource =(source!=null) ? source.getClass().getName() : getClass().getName();
        // Use Exceptions
        if (exceptionsEnabled)
            throw new EmpireException(this);
        // return Error Status
        return false;
    }
View Full Code Here

Examples of org.apache.empire.exceptions.EmpireException

   
    public String getExceptionMessage(Exception e)
    {
        if (e instanceof EmpireException)
        {
            EmpireException ee = (EmpireException)e;
            String key = ee.getErrorType().getKey();
            // get Pattern
            String pattern;
            if (resBundle.containsKey(key))
            {   // Get Pattern
                pattern = resBundle.getString(key);
            }
            else
            {   // No error message pattern provided. Using default
                pattern = ee.getErrorType().getMessagePattern();
                log.error("Error resolving error messsage pattern: {}", key);
            }
            // get Params and translate
            String[] params = ee.getErrorParams();
            if (params!=null)
            {   for (int i=0; i<params.length; i++)
                    params[i] = resolveText(params[i]);
            }
            // Format message
            return EmpireException.formatErrorMessage(ee.getErrorType(), pattern, params);
        }
        else
        {   // Other exception try to resolve by class name
            String key = "exception."+e.getClass().getName();
            if (resBundle.containsKey(key))
View Full Code Here

Examples of org.apache.empire.exceptions.EmpireException

   
    public String getExceptionMessage(Exception e)
    {
        if (e instanceof EmpireException)
        {
            EmpireException ee = (EmpireException)e;
            String key = ee.getErrorType().getKey();
            // get Pattern
            String pattern;
            if (resBundle.containsKey(key))
            {   // Get Pattern
                pattern = resBundle.getString(key);
            }
            else
            {   // No error message pattern provided. Using default
                pattern = ee.getErrorType().getMessagePattern();
                log.error("Error resolving error messsage pattern: {}", key);
            }
            // get Params
            String[] params = ee.getErrorParams();
            Object[] values = null;
            if (params!=null)
            {   values = new Object[params.length];
                for (int i=0; i<params.length; i++)
                    values[i] = resolveText(params[i]);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.