Package speculoos.core

Examples of speculoos.core.MapperException


    if (_filter == null && filter != null) {
      filter.map(input, env);
      _filter = (String) env.get("filter");
    }
    if (_filter == null)
      throw new MapperException(getName()
          + ": No filter definable for this search");
    /* control */
    SearchControls controls = new SearchControls();
    controls.setSearchScope(SearchControls.OBJECT_SCOPE);
    controls.setReturningAttributes(new String[0]);
    controls.setReturningObjFlag(true);
    /* run query */
    try {
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] comparing " + _root + " with "
            + _filter);
      directory.search(_root, _filter, controls);
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] done");
    } catch (NamingException ne) {
      throw new MapperException("Failed to match requested attributes",
          ne);
    }
    return Boolean.TRUE;
  }
View Full Code Here


      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

      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

   *      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

    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

        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

        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

    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

  /* (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

   */
  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

TOP

Related Classes of speculoos.core.MapperException

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.