Java 类javax.naming.SizeLimitExceededException 实例源码

项目:Equella    文件:LDAP.java   
/**
 * @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;
}
项目:Equella    文件:LDAP.java   
public <T> List<T> search(DirContext ctx, Name base, Filter filter, HitsCollector<T> collector, boolean recurse)
{
    collector.setup(ctx, this);

    NamingEnumeration<SearchResult> ne = search(ctx, base, collector.getReturnAttributes(), filter, recurse);
    try
    {
        while( ne != null && ne.hasMore() )
        {
            SearchResult sr = ne.next();
            collector.addResult(sr, base);
        }
    }
    catch( PartialResultException pre )
    {
        LOGGER.info(pre);
    }
    catch( SizeLimitExceededException slee )
    {
        LOGGER.info(slee);
    }
    catch( Exception e )
    {
        LOGGER.error("Error searching", e);
    }

    return collector.getResults();
}
项目:command4j    文件:CommandDemux.java   
public static List<Command> commandsDemux(Profile profile, Command command) throws SizeLimitExceededException{
    boolean isRegex = command.containsRegex();
    if (isRegex) {
        List<Command> demuxCommands = new ArrayList<Command>();
        List<CommandOptionDemux> regexOptions = command.containedRegex();
        List<Set<String>> regexList = new ArrayList<Set<String>>();

        for(CommandOptionDemux regexOption : regexOptions){
            Command ls = CommandBuilder.command(Ls.class).options(Arrays.asList(Ls.absolutePath(regexOption.getOptionCommand()))).build();
            Set<String> matchingFiles = new TreeSet<String>();
            String response = Command4j.execute(profile, ls).toString();
            if (!response.trim().isEmpty()) {
                matchingFiles.addAll(aListOf(response).stream().parallel().map(it -> convert(it)).collect(Collectors.toList()));
            }
            matchingFiles.remove(StringSymbol.EMPTY.toString());
            regexList.add(matchingFiles);
        }
        Set<List<String>> cartesiansRegex = Sets.cartesianProduct(regexList);
        for(List<String> commandRegexToReplace : cartesiansRegex){
            List<Option<Command>> optionsToReplace = commandRegexToReplace.
                    stream().
                    map(s -> Command.path(s)).
                    collect(Collectors.toList());
            demuxCommands.add(SerializationUtils.clone(command).replaceRegex(optionsToReplace));
            if(optionsToReplace.size()!=0) throw new SizeLimitExceededException("The optionsToReplace should be empty at this point");
        }

        return demuxCommands;
    } else {
        return Collections.singletonList(command);
    }
}
项目:taulukko-commons-util    文件:EZip.java   
public void atach(String path) throws SizeLimitExceededException,
        IOException
{
    File file = new File(path);

    if (!file.exists())
    {
        throw new FileNotFoundException();
    }

    if (file.length() > Integer.MAX_VALUE)
    {
        throw new SizeLimitExceededException();
    }

    // Cria um buffer para ler os dados do arquivo
    byte[] buf = new byte[this.getSizeBuffer()];

    // Comprime o arquivo
    FileInputStream in = new FileInputStream(file.getAbsolutePath());

    // Adiciona o arquivo ao fluxo de sa�da
    _out.putNextEntry(new ZipEntry(file.getAbsolutePath()));

    // transfere dados do arquivo para o arquivo zip
    int len;
    while ((len = in.read(buf)) > 0)
    {
        _out.write(buf, 0, len);
    }

    // Finaliza a entrada
    _out.closeEntry();
    in.close();
}
项目:taulukko-commons-util    文件:EAbstractFile.java   
public void toZip(String path) throws SizeLimitExceededException, IOException {
    if (javaFile.length() > Integer.MAX_VALUE) {
        throw new SizeLimitExceededException();
    }
    int size = (int) javaFile.length();
    // Cria um buffer para ler os dados do arquivo
    byte[] buf = new byte[size];

    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(path));

    // Comprime o arquivo
    FileInputStream in = new FileInputStream(javaFile.getAbsolutePath());

    // Adiciona o arquivo ao fluxo de sada
    out.putNextEntry(new ZipEntry(javaFile.getAbsolutePath()));

    // transfere dados do arquivo para o arquivo zip
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }

    // Finaliza a entrada
    out.closeEntry();
    in.close();

    // Completa o arquivo zip
    out.close();

}
项目:ldapchai    文件:OpenLDAPModifyPasswordRequest.java   
/**
 * Creates a new <code>OpenLDAPUser</code> instance.
 *
 * @param dn       the dn whose password is to change
 * @param password the new password
 * @param chaiConfiguration appropriate chaiConfiguration
 * @throws NullPointerException                    if dn or password is null
 * @throws javax.naming.SizeLimitExceededException when the dn or password
 *                                                 is too long
 */
public OpenLDAPModifyPasswordRequest( final String dn, final String password, final ChaiConfiguration chaiConfiguration )
        throws NullPointerException, SizeLimitExceededException
{
    this.chaiConfiguration = chaiConfiguration;

    if ( dn == null )
    {
        throw new NullPointerException( "dn cannot be null" );
    }

    if ( password == null )
    {
        throw new NullPointerException( "password cannot be null" );
    }

    final int dnlen = dn.length();
    final int passlen = password.length();
    final int totallen = 4 + dnlen + passlen;

    if ( dnlen <= 0 )
    {
        throw new SizeLimitExceededException( "dn cannot be 0 length" );
    }

    if ( dnlen > 0xFF )
    {
        throw new SizeLimitExceededException( "dn cannot be larger then 255 characters" );
    }

    if ( passlen <= 0 )
    {
        throw new SizeLimitExceededException( "password cannot be 0 length" );
    }

    if ( passlen > 0xFF )
    {
        throw new SizeLimitExceededException( "password cannot be larger then 255 characters" );
    }

    if ( totallen > 0xFF )
    {
        throw new SizeLimitExceededException( "the length of the dn + the lengh of the password cannot"
                        + " exceed 251 characters" );
    }

    modifyDn = dn;
    modifyPassword = password;
}
项目:teiid    文件:LDAPQueryExecution.java   
/**
 * Fetch the next batch of data from the LDAP searchEnumerationr result.
 * @return the next Batch of results.
 */
// GHH 20080326 - set all batches as last batch after an exception
// is thrown calling a method on the enumeration.  Per Javadoc for
// javax.naming.NamingEnumeration, enumeration is invalid after an
// exception is thrown - by setting last batch indicator we prevent
// it from being used again.
// GHH 20080326 - also added return of explanation for generic
// NamingException
public List<?> next() throws TranslatorException {
    try {
        // The search has been executed, so process up to one batch of
        // results.
        List<?> result = null;
        while (result == null && searchEnumeration != null && searchEnumeration.hasMore())
        {
            SearchResult searchResult = (SearchResult) searchEnumeration.next();
            result = getRow(searchResult);
        }

        if (result == null && this.executionFactory.usePagination()) {
            byte[] cookie = null;
            Control[] controls = ldapCtx.getResponseControls();
            if (controls != null) {
                for (int i = 0; i < controls.length; i++) {
                    if (controls[i] instanceof PagedResultsResponseControl) {
                        PagedResultsResponseControl prrc = (PagedResultsResponseControl)controls[i];
                        cookie = prrc.getCookie();
                    }
                }
            }

            if (cookie == null) {
                return null;
            }

            setRequestControls(cookie);
            executeSearch();
            return next();
        }

        if (result != null) {
            resultCount++;
        }
        return result;
    } catch (SizeLimitExceededException e) {
        if (resultCount != searchDetails.getCountLimit()) {
            String msg = LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12008);
            TranslatorException te = new TranslatorException(e, msg);
            if (executionFactory.isExceptionOnSizeLimitExceeded()) {
                throw te;
            }
            this.executionContext.addWarning(te);
            LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg); 
        }
        return null; // GHH 20080326 - if size limit exceeded don't try to read more results
    } catch (NamingException ne) {
        throw new TranslatorException(ne, LDAPPlugin.Util.gs("ldap_error")); //$NON-NLS-1$
    }
}