当前位置: 首页>>代码示例>>Java>>正文


Java PartialResultException类代码示例

本文整理汇总了Java中javax.naming.PartialResultException的典型用法代码示例。如果您正苦于以下问题:Java PartialResultException类的具体用法?Java PartialResultException怎么用?Java PartialResultException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PartialResultException类属于javax.naming包,在下文中一共展示了PartialResultException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query

import javax.naming.PartialResultException; //导入依赖的package包/类
List<Result> query(DirContext ctx, Map<String, String> params) throws NamingException {
  final SearchControls sc = new SearchControls();
  final NamingEnumeration<SearchResult> res;

  sc.setSearchScope(searchScope.scope());
  sc.setReturningAttributes(returnAttributes);
  res = ctx.search(base, pattern.getRawPattern(), pattern.bind(params), sc);
  try {
    final List<Result> r = new ArrayList<>();
    try {
      while (res.hasMore()) {
        r.add(new Result(res.next()));
      }
    } catch (PartialResultException e) {
      // Ignored
    }
    return r;
  } finally {
    res.close();
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:LdapQuery.java

示例2: appendSubStringValues

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Appends a collection of sub-string attribute values to a list.
 * <br/>The sub-attributes are determined by attribute.getAll().
 * <br/>Only sub-attributes of type String will be appended.
 * @param attribute the attribute containing values to append (from)
 * @param values the list of values to populate (to)
 * @throws NamingException if an exception occurs
 */
protected void appendSubStringValues(Attribute attribute, StringSet values)
  throws NamingException {
  NamingEnumeration<?> enAttr = null;
  try {
    if (attribute != null) {
      enAttr = attribute.getAll();
      while (enAttr.hasMore()) {
        Object oAttr = enAttr.next();
        if (oAttr instanceof String) {
          values.add((String)oAttr);
        }
      }
    }
  } catch (PartialResultException pre) {
	 LogUtil.getLogger().finer(pre.toString());
  } catch (LimitExceededException lee) {
	 LogUtil.getLogger().finer(lee.toString());
  } finally {
    closeEnumeration(enAttr);
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:30,代码来源:LdapQueryFunctions.java

示例3: readAttribute

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Reads the attribute values associated with an attribute name.
 * @param dirContext the directory context
 * @param attrubuteName attribute name.
 * @param objectDN the distinguished name of the object
 * @return the list attribute values (strings only are returned)
 * @throws NamingException if an exception occurs
 */
protected StringSet readAttribute(DirContext dirContext,
                                  String objectDN, 
                                  String attrubuteName)
  throws NamingException {
	StringSet values = new StringSet();
	try{	  
	  if ((objectDN.length() > 0) && (attrubuteName.length() > 0)) {
	    String[] aReturn = new String[1];
	    aReturn[0] = attrubuteName;
	    try{
	    Attributes attributes = dirContext.getAttributes(objectDN,aReturn);
	    if (attributes != null) {
	      appendSubStringValues(attributes.get(attrubuteName),values);
	    }
	    }catch(NameNotFoundException nnfe){
	    	LogUtil.getLogger().finer(nnfe.toString());
	    }
	  }	  
    } catch (PartialResultException pre) {
      LogUtil.getLogger().finer(pre.toString());
    } catch (LimitExceededException lee) {
        LogUtil.getLogger().finer(lee.toString());
    }
	return values;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:34,代码来源:LdapQueryFunctions.java

示例4: isFollowReferral

import javax.naming.PartialResultException; //导入依赖的package包/类
private boolean isFollowReferral(ReferralException e)
        throws ReferralException, PartialResultException {
    // ignore referral
    String action = (String) env.get(Context.REFERRAL);
    if (action == null) {
        action = "ignore";
    }

    if ("follow".equals(action)) {
        return true;
    } else if ("throw".equals(action)) {
        return false;

    } else if ("ignore".equals(action)) {
        // ldap.1A=[LDAP: error code 10 - Referral]
        throw new PartialResultException(Messages.getString("ldap.1A"));

    } else {
        throw new IllegalArgumentException(Messages.getString(
                "ldap.30", new Object[] { //$NON-NLS-1$
                env.get(Context.REFERRAL), Context.REFERRAL }));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:LdapContextImpl.java

示例5: addAttributeValues

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Add values of a specified attribute to a list
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the new values
 * @param values ArrayList containing values found so far
 *
 * @exception NamingException if a directory server error occurs
 */
private ArrayList<String> addAttributeValues(String attrId,
                                     Attributes attrs,
                                     ArrayList<String> values)
    throws NamingException{

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving values for attribute " + attrId);
    if (attrId == null || attrs == null)
        return values;
    if (values == null)
        values = new ArrayList<String>();
    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return values;
    NamingEnumeration<?> e = attr.getAll();
    try {
        while(e.hasMore()) {
            String value = (String)e.next();
            values.add(value);
        }
    } catch (PartialResultException ex) {
        if (!adCompat)
            throw ex;
    } finally {
        e.close();
    }
    return values;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:JNDIRealm.java

示例6: search_withPartialResultException

import javax.naming.PartialResultException; //导入依赖的package包/类
@Test
public void search_withPartialResultException() throws Exception {
    // given
    initAttribute(SEARCH_ATTRIBUTES[0], aMock);
    initAttribute(SEARCH_ATTRIBUTES[1], aMock);
    initAttribute(SEARCH_ATTRIBUTES[2], aMock);

    when(Boolean.valueOf(neMock.hasMore())).thenReturn(Boolean.TRUE)
            .thenThrow(new PartialResultException());

    Map<SettingType, String> map = new HashMap<SettingType, String>();
    map.put(SettingType.LDAP_ATTR_UID, SEARCH_ATTRIBUTES[0]);
    map.put(SettingType.LDAP_ATTR_FIRST_NAME, SEARCH_ATTRIBUTES[1]);
    map.put(SettingType.LDAP_ATTR_EMAIL, SEARCH_ATTRIBUTES[2]);

    ILdapResultMapper<VOUserDetails> mapper = new LdapVOUserDetailsMapper(
            null, map);

    List<VOUserDetails> list = new ArrayList<VOUserDetails>();

    // when
    list = bean.search(new Properties(), "baseDN", "filter", mapper, false);

    // then
    assertNotNull(list);
    assertEquals(1, list.size());
    VOUserDetails det = list.get(0);
    assertEquals(SEARCH_ATTRIBUTES[0], det.getRealmUserId());
    assertEquals(SEARCH_ATTRIBUTES[1], det.getFirstName());
    assertEquals(SEARCH_ATTRIBUTES[2], det.getEMail());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:32,代码来源:LdapAccessServiceBeanTest.java

示例7: hasMoreEnum

import javax.naming.PartialResultException; //导入依赖的package包/类
private boolean hasMoreEnum(NamingEnumeration<SearchResult> namingEnum)
        throws NamingException {
    boolean hasMore = true;
    try {
        if (!namingEnum.hasMore()) {
            hasMore = false;
        }
    } catch (PartialResultException e) {
        hasMore = false;
        logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
                LogMessageIdentifier.WARN_LDAP_PARTIAL_EXCEPTION);
    }
    return hasMore;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:15,代码来源:LdapAccessServiceBean.java

示例8: search

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * @return null if there are zero results
 */
private NamingEnumeration<SearchResult> search(DirContext ctx, Name base, String[] returnAttributes, Filter filter,
	boolean recurse)
{
	SearchControls ctls = new SearchControls();
	ctls.setCountLimit(filter.getLimit());
	ctls.setReturningAttributes(returnAttributes);
	ctls.setSearchScope(recurse ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);

	try
	{
		// Search for objects using the filter
		String query = filter.toFilter();
		if( LOGGER.isDebugEnabled() )
		{
			LOGGER.debug("Query:" + query + " Base:" + base);
		}
		NamingEnumeration<SearchResult> ne = ctx.search(base, query, ctls);
		if( ne.hasMore() )
		{
			return ne;
		}
	}
	catch( PartialResultException pre )
	{
		LOGGER.info(pre);
	}
	catch( SizeLimitExceededException slee )
	{
		LOGGER.info(slee);
	}
	catch( Exception e )
	{
		LOGGER.warn(e);
	}

	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:41,代码来源:LDAP.java

示例9: addAttributeValues

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Add values of a specified attribute to a list
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the new values
 * @param values ArrayList containing values found so far
 *
 * @exception NamingException if a directory server error occurs
 */
private ArrayList<String> addAttributeValues(String attrId,
                                     Attributes attrs,
                                     ArrayList<String> values)
    throws NamingException{

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving values for attribute " + attrId);
    if (attrId == null || attrs == null)
        return values;
    if (values == null)
        values = new ArrayList<String>();
    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return (values);
    NamingEnumeration e = attr.getAll();
    try {
        while(e.hasMore()) {
            String value = (String)e.next();
            values.add(value);
        }
    } catch (PartialResultException ex) {
        if (!adCompat)
            throw ex;
    }
    return values;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:JNDIRealm.java

示例10: addAttributeValues

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Add values of a specified attribute to a list
 *
 * @param attrId
 *            Attribute name
 * @param attrs
 *            Attributes containing the new values
 * @param values
 *            ArrayList containing values found so far
 *
 * @exception NamingException
 *                if a directory server error occurs
 */
private ArrayList<String> addAttributeValues(String attrId, Attributes attrs, ArrayList<String> values)
		throws NamingException {

	if (containerLog.isTraceEnabled())
		containerLog.trace("  retrieving values for attribute " + attrId);
	if (attrId == null || attrs == null)
		return values;
	if (values == null)
		values = new ArrayList<String>();
	Attribute attr = attrs.get(attrId);
	if (attr == null)
		return values;
	NamingEnumeration<?> e = attr.getAll();
	try {
		while (e.hasMore()) {
			String value = (String) e.next();
			values.add(value);
		}
	} catch (PartialResultException ex) {
		if (!adCompat)
			throw ex;
	} finally {
		e.close();
	}
	return values;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:JNDIRealm.java

示例11: addAttributeValues

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Add values of a specified attribute to a list
 *
 * @param attrId Attribute name
 * @param attrs Attributes containing the new values
 * @param values ArrayList containing values found so far
 *
 * @exception NamingException if a directory server error occurs
 */
private ArrayList<String> addAttributeValues(String attrId,
                                     Attributes attrs,
                                     ArrayList<String> values)
    throws NamingException{

    if (containerLog.isTraceEnabled())
        containerLog.trace("  retrieving values for attribute " + attrId);
    if (attrId == null || attrs == null)
        return values;
    if (values == null)
        values = new ArrayList<String>();
    Attribute attr = attrs.get(attrId);
    if (attr == null)
        return (values);
    NamingEnumeration<?> e = attr.getAll();
    try {
        while(e.hasMore()) {
            String value = (String)e.next();
            values.add(value);
        }
    } catch (PartialResultException ex) {
        if (!adCompat)
            throw ex;
    }
    return values;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:36,代码来源:JNDIRealm.java

示例12: appendAttributeValues

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Appends attribute values to a map (keyed on attribute id).
 * @param attributes the attributes to append (from)
 * @param values the map of values to populate (to)
 * @param stringsOnly if true, only attributes values of type
 *        String will be appended
 * @throws NamingException if an exception occurs
 */
protected void appendAttributeValues(Attributes attributes,
                                     Map<String,Object> values,
                                     boolean stringsOnly)
  throws NamingException {
  NamingEnumeration<?> enAttr = null;
  try {
    if (attributes != null) {
      enAttr = attributes.getAll();
      while (enAttr.hasMore()) {
        Object oAttr = enAttr.next();
        if (oAttr instanceof Attribute) {
          Attribute attr = (Attribute)oAttr;
          String sId = attr.getID();
          Object oVal = attr.get();
          if (!stringsOnly || (oVal instanceof String)) {
            values.put(sId,oVal);
          } else if (stringsOnly && (oVal == null)) {
            //values.put(sId,"");
          }
          //System.err.println(sId+"="+oVal+" cl="+oVal.getClass().getName());
        }
      }
      enAttr.close();
    }
  }catch (PartialResultException pre) {
	 LogUtil.getLogger().finer(pre.toString());
  } catch (LimitExceededException lee) {
	 LogUtil.getLogger().finer(lee.toString());
  } finally {
    closeEnumeration(enAttr);
  }
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:41,代码来源:LdapQueryFunctions.java

示例13: searchDNs

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Returns a list of distinguished names resulting from a search.
 * <br/>The search is executed with SearchControls.SUBTREE_SCOPE.
 * @param dirContext the directory context
 * @param baseDN the baseBN for the search
 * @param filter the filter for the search
 * @return a collection of distinguished names
 * @throws NamingException if an exception occurs
 */
protected StringSet searchDNs(DirContext dirContext,
                              String baseDN, 
                              String filter) 
  throws NamingException {
  StringSet names = new StringSet(false,false,true);
  NamingEnumeration<SearchResult> enSearch = null;
  try {
    baseDN = Val.chkStr(baseDN);
    filter = Val.chkStr(filter);
    if (filter.length() > 0) {
      SearchControls controls = new SearchControls();
      controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
      enSearch = dirContext.search(baseDN,filter,controls);
      try {
        while (enSearch.hasMore()) {
          SearchResult result = (SearchResult)enSearch.next();
          names.add(buildFullDN(result.getName(),baseDN));
        }
      } catch (PartialResultException pre) {
        LogUtil.getLogger().finer(pre.toString());
      } catch (LimitExceededException lee) {
          LogUtil.getLogger().finer(lee.toString());
      }
    }
  } finally {
    closeEnumeration(enSearch);
  }
  return names;
}
 
开发者ID:GeoinformationSystems,项目名称:GeoprocessingAppstore,代码行数:39,代码来源:LdapQueryFunctions.java

示例14: searchDNs

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Returns a list of distinguished names resulting from a search.
 * <br/>The search is executed with SearchControls.SUBTREE_SCOPE.
 * @param dirContext the directory context
 * @param baseDN the baseBN for the search
 * @param filter the filter for the search
 * @return a collection of distinguished names
 * @throws NamingException if an exception occurs
 */
protected StringSet searchDNs(DirContext dirContext,
                              String baseDN, 
                              String filter) 
  throws NamingException {
  StringSet names = new StringSet(false,false,true);
  NamingEnumeration<SearchResult> enSearch = null;
  try {
    baseDN = Val.chkStr(baseDN);
    filter = Val.chkStr(filter);
    if (filter.length() > 0) {
      SearchControls controls = new SearchControls();
      controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
      enSearch = dirContext.search(baseDN,filter,controls);
      try {
        while (enSearch.hasMore()) {
          SearchResult result = (SearchResult)enSearch.next();
          names.add(buildFullDN(result.getName(),baseDN));
        }
      } catch (PartialResultException pre) {
        LogUtil.getLogger().finer(pre.toString());
      }
    }
  } finally {
    closeEnumeration(enSearch);
  }
  return names;
}
 
开发者ID:usgin,项目名称:usgin-geoportal,代码行数:37,代码来源:LdapQueryFunctions.java

示例15: getRolesRecursive

import javax.naming.PartialResultException; //导入依赖的package包/类
/**
 * Add roles to a user and search for other roles containing them themselves.
 * We search recursively with a limited depth.
 * By default the depth is 0, and we only use direct roles.
 * The search needs to use the distinguished role names,
 * but to return the role names.
 *
 * @param depth Recursion depth, starting at zero
 * @param context The directory context we are searching
 * @param recursiveMap The cumulative result map of role names and DNs.
 * @param recursiveSet The cumulative result set of role names.
 * @param groupName The role name to add to the list.
 * @param groupDName The distinguished name of the role.
 *
 * @exception NamingException if a directory server error occurs
 */
private void getRolesRecursive(int depth, DirContext context, Map<String, String> recursiveMap, Set<String> recursiveSet,
                                 String groupName, String groupDName) throws NamingException {
    if (containerLog.isTraceEnabled())
        containerLog.trace("Recursive search depth " + depth + " for group '" + groupDName + " (" + groupName + ")'");
    // Adding the given group to the result set if not already found
    if (!recursiveSet.contains(groupDName)) {
        recursiveSet.add(groupDName);
        recursiveMap.put(groupDName, groupName);
        if (depth >= roleRecursionLimit) {
            if (roleRecursionLimit > 0)
                containerLog.warn("Terminating recursive role search because of recursion limit " +
                                  roleRecursionLimit + ", results might be incomplete");
            return;
        }
        // Prepare the parameters for searching groups
        String filter = roleFormat.format(new String[] { groupDName });
        SearchControls controls = new SearchControls();
        controls.setSearchScope(roleSubtree ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);
        controls.setReturningAttributes(new String[] { roleName });
        if (containerLog.isTraceEnabled()) {
            containerLog.trace("Recursive search in role base '" + roleBase + "' for attribute '" + roleName + "'" +
                               " with filter expression '" + filter + "'");
        }
        // Searching groups that assign the given group
        NamingEnumeration results = context.search(roleBase, filter, controls);
        if (results != null) {
            // Iterate over the resulting groups
            try {
                while (results.hasMore()) {
                    SearchResult result = (SearchResult) results.next();
                    Attributes attrs = result.getAttributes();
                    if (attrs == null)
                        continue;
                    String dname = getDistinguishedName(context, roleBase, result);
                    String name = getAttributeValue(roleName, attrs);
                    if (name != null && dname != null) {
                       getRolesRecursive(depth+1, context, recursiveMap, recursiveSet, name, dname);
                    }
                }
            } catch (PartialResultException ex) {
                if (!adCompat)
                    throw ex;
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:63,代码来源:JNDIRealm.java


注:本文中的javax.naming.PartialResultException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。