Package speculoos.core

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


    /* instanciate fitler */
    String _filter = (String) env.get("filter");
    boolean relative = true;
    if (_filter == null && filter != null) {
      if (input == null)
        throw new MapperException(getName()
            + ": The input object cannot be null if used as filter");
      input = filter.map(input, env);
      _filter = (String) env.get("filter");
    }
    if (_filter == null) {
      if (log.isInfoEnabled()) {
        log
            .info("["
                + getName()
                + "] no filter defined. Will try lookup using only root "
                + _root);
      }
      relative = false;
    }
    /* instanciate controls */
    instanciateControls(env);
    /* run query */
    try {
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] searching " + _root + " for "
            + _filter + " with controls " + controls);
      List ret = new ArrayList();
      if (_filter != null) {
        NamingEnumeration enumeration = null;
        enumeration = directory.search(_root, _filter, controls);
        /* create list of search results */
        while (enumeration.hasMore()) {
          SearchResult res = (SearchResult) enumeration.next();
          ret.add(res);
        }
      } else {
        Attributes attrs = directory.getAttributes(_root, controls
            .getReturningAttributes());
        SearchResult sr = new SearchResult(_root.toString(),null,attrs);
        sr.setRelative(relative);
        ret.add(sr);
      }
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] done");

      /* output list of objects */
      return output.map(ret, env);
    } catch (NamingException e) {
      throw new MapperException("Exception in JNDI mapping "
          + e.getLocalizedMessage(), e);
    }
  }
View Full Code Here

   * @see speculoos.core.core.spi.Source#release(speculoos.core.core.Mapper)
   */
  public void release(Mapper mapper) throws MapperException {
    JNDIMapper jm = (JNDIMapper) mapper;
    if (!mapperMatrix.containsKey(jm.getName()))
      throw new MapperException("[" + name + "] unknown mapper " + jm
          + " in this source ");
    jm.getDirectory().close();
    /* clean state of object */
    jm.clearDirectory();
    /* clear environment */
 
View Full Code Here

            + _nrdn);
      directory.rename(_root, _nrdn);
      if (log.isDebugEnabled())
        log.debug("[" + getName() + "] done renaming");
    } catch (NamingException ne) {
      throw new MapperException("Error in modificaiton operation", ne);
    }
    return input;
  }
View Full Code Here

        return null;
      }

        };
        mocksrc.expects(once()).method("start").with(ANYTHING);
        mocksrc.expects(once()).method("release").with(same(m)).will(throwException(new MapperException("")));
         manager.start();
        try {
            manager.release(m);
            fail("Should have thrown exceptin");
        } catch (MapperException 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.