Examples of MapperException


Examples of speculoos.core.MapperException

      directory.destroySubcontext(_root);
      if(log.isDebugEnabled())
        log.debug("["+getName()+"] done");
      return input;
    } catch (NamingException e) {
      throw new MapperException("Exception in JNDI deleting "
          + e.getLocalizedMessage(), e);
    }  }
View Full Code Here

Examples of speculoos.core.MapperException

      AttributeAndOperation ao = (AttributeAndOperation) e.getKey();
      List l = (List) e.getValue();
      /* find item in output map */
      String aname = (String) outputMap.get(ao.attr);
      if (aname == null)
        throw new MapperException(getName() + " : attribute " + ao.attr
            + " is not mapped to directory");
      /* create attribute */
      BasicAttribute ba = new BasicAttribute(aname);
      for (Iterator j = l.iterator(); j.hasNext();) {
        Object val = j.next();
        if (val instanceof VariableString) {
          String strVal = ((VariableString) val ).instance(param);
          if (strVal != null && !"".equals(strVal))
            ba.add(strVal);
        } else if (val instanceof String) {
          Object mapVal = param.get(val);
          if (mapVal == null) {
            throw new MapperException("Key : " + val + " not found in env.");
          } else if (! (mapVal instanceof Collection)) {
            throw new MapperException("Object found in env with key : " + val + " is not a Collection.");
          } else {
            Iterator it = ((Collection) mapVal).iterator();
            while (it.hasNext()) {
              ba.add(it.next());
            }
View Full Code Here

Examples of speculoos.core.MapperException

   *      java.util.Map)
   */
  protected Object doMap(Object input, Map env) throws MapperException {
    /* consistency check */
    if (joinAttribute == null || "".equals(joinAttribute))
      throw new MapperException(
          "May not use a null or empty attribute name as join");
    if (joinedAttribute == null || "".equals(joinedAttribute))
      throw new MapperException(
          "May not use a null or empty attribute name as joined attribute");
    if (left == null || right == null)
      throw new MapperException("No left and right mapper defined");
    /* result */
    List res = new ArrayList();
    /* first search */
    List first = left.search(input, env);
    /* collection of joined objects */
 
View Full Code Here

Examples of speculoos.core.MapperException

    sb.append("(&");
    BeanInfo info;
    try {
      info = Introspector.getBeanInfo(input.getClass());
    } catch (IntrospectionException e) {
      throw new MapperException(getName()
          + ": cannot access fields info from Introspector", e);
    }
    PropertyDescriptor[] props = info.getPropertyDescriptors();
    for (int i = 0; i < props.length; i++) {
      PropertyDescriptor p = props[i];
View Full Code Here

Examples of speculoos.core.MapperException

        mods[i] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
            (Attribute) ne.next());
      }
      return mods;
    } catch (ClassCastException e) {
      throw new MapperException(getName() + ": invalid type "
          + input.getClass()
          + ", expected javax.naming.directory.Attributes");
    } catch (NamingException e) {
      throw new MapperException(getName()
          + ": error in retrieving attributes", e);
    }
  }
View Full Code Here

Examples of speculoos.core.MapperException

        mods = (ModificationItem[]) transform.map(input, env);
      else if (operations != null) {
        /* defined operations */
        mods = (ModificationItem[]) operations.map(null, env);
      } else
        throw new MapperException(getName()
            + ": No transformation defined");
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] modifiying " + _root + " with "
            + input);
      directory.modifyAttributes(_root, mods);
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] done");
    } catch (NamingException ne) {
      throw new speculoos.core.MapperException(
          "Error in modification operation", ne);
    } catch (ClassCastException e) {
      throw new MapperException(getName() + ": invalid input type "
          + input.getClass() + ", expected ModificationItem[]");
    }
    return input;
  }
View Full Code Here

Examples of speculoos.core.MapperException

    TypeHelper th = TypeHelper.instance;
    BeanInfo info;
    try {
      info = Introspector.getBeanInfo(input.getClass());
    } catch (IntrospectionException e) {
      throw new MapperException(getName()
          + ": cannot access fields info from Introspector", e);
    }
    Attributes attributes = new BasicAttributes(isCaseIgnore());
    PropertyDescriptor[] props = info.getPropertyDescriptors();
    for (int i = 0; i < props.length; i++) {
View Full Code Here

Examples of speculoos.core.MapperException

  /* (non-Javadoc)
   * @see speculoos.jndi.mappers.JNDIMapper#doMap(java.lang.Object, java.util.Map)
   */
  protected Object doMap(Object input, Map env) throws MapperException {
    if(attributesFromInput == null)
      throw new MapperException(getName()+": Undefined transformation mapper");
    try {
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] adding root=" + _root
            + " with attributes=" + input);
      /* transform */
      Attributes attrs = (Attributes) attributesFromInput.map(input,env);
      directory.createSubcontext(_root, attrs);
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] done");
    } catch (NamingException e) {
      throw new MapperException("Exception in JNDI adding "
          + e.getLocalizedMessage(), e);
    }
    return input;
  }
View Full Code Here

Examples of speculoos.core.MapperException

   */
  public Object map(Object input, Map param) throws MapperException {
    try {
      return makeObject((SearchResult) input, param);
    } catch (NamingException ex) {
      throw new MapperException(getName() + ": JNDI error ", ex);
    } catch (InstantiationException e) {
      throw new MapperException(getName() + ": Cannot instantiate "
          + klass, e);
    } catch (IllegalAccessException e) {
      throw new MapperException(getName()
          + ": Cannot access empty contsructor for " + klass, e);
    }
  }
View Full Code Here

Examples of speculoos.core.MapperException

      /* handling of multiple values */
      if (attr.size() > 1 || Collection.class.isAssignableFrom(fcls)) {
        try {
          Collection c = (Collection) th.get(ret, n);
          if (c == null) {
            throw new MapperException(getName()
                + ": collection field '" + n
                + "' is not initialized in " + klass);
          }
          /* corresponding field must be a collection */
          for (NamingEnumeration ne = attr.getAll(); ne.hasMore();) {
            c.add(ne.next());
          }
        } catch (ClassCastException ex) {
          throw new MapperException(getName() + ": field " + n
              + " is not a collection in " + klass);
        }
      } else
        th.setString(ret, n, (String) attr.get());
    }
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.