lass".equals(mkey)) filter.and(new EqualsFilter(mkey, (String) map.get(mkey))); } return filter; } /** * 构造查询实体UUID方法 * @param t * @return * @创建人 PengBo * @创建时间 2013-7-7 下午7:00:49 */ private Name buildDn(T t) { String a = t.getDN(); DistinguishedName dn = new DistinguishedName(a); if(StringUtils.isNotBlank(t.getUuid())){ dn.add("uid", t.getUuid()); } return dn; } /** * 构造查找组织的dn * @param t * @return * @创建人 PengBo * @创建时间 2013-7-16 上午9:45:57 */ public String findDn(T t) { Name dn= buildDn( t); return dn.toString(); } /** * 查询获得实体属性构造器 * @param t * @return * @创建人 PengBo * @创建时间 2013-7-7 下午7:01:12 */ private ContextMapper getContextMapper(final T t) { return new ParameterizedContextMapper() { @Override public T mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; T newT=null; try { newT = (T) t.getClass().newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } Map map= t.getMap(); Map smap=new HashMap(); for(String mkey:map.keySet()){ if (!"objectclass".equals(mkey)) { if(!"userPassword".equals(mkey)){ if (StringUtils.isNotBlank(adapter.getStringAttribute(mkey))) { smap.put(mkey, adapter.getStringAttribute(mkey)); }else { smap.put(mkey, null); } } } } newT.setMap(smap); return newT; } }; } }
|