本文整理汇总了Java中org.apache.directory.api.ldap.model.message.controls.PagedResults类的典型用法代码示例。如果您正苦于以下问题:Java PagedResults类的具体用法?Java PagedResults怎么用?Java PagedResults使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PagedResults类属于org.apache.directory.api.ldap.model.message.controls包,在下文中一共展示了PagedResults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadStockControls
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Loads the Controls implement out of the box in the codec.
*/
private void loadStockControls()
{
ControlFactory<Cascade> cascadeFactory = new CascadeFactory( this );
controlFactories.put( cascadeFactory.getOid(), cascadeFactory );
LOG.info( "Registered pre-bundled control factory: {}", cascadeFactory.getOid() );
ControlFactory<EntryChange> entryChangeFactory = new EntryChangeFactory( this );
controlFactories.put( entryChangeFactory.getOid(), entryChangeFactory );
LOG.info( "Registered pre-bundled control factory: {}", entryChangeFactory.getOid() );
ControlFactory<ManageDsaIT> manageDsaItFactory = new ManageDsaITFactory( this );
controlFactories.put( manageDsaItFactory.getOid(), manageDsaItFactory );
LOG.info( "Registered pre-bundled control factory: {}", manageDsaItFactory.getOid() );
ControlFactory<ProxiedAuthz> proxiedAuthzFactory = new ProxiedAuthzFactory( this );
controlFactories.put( proxiedAuthzFactory.getOid(), proxiedAuthzFactory );
LOG.info( "Registered pre-bundled control factory: {}", proxiedAuthzFactory.getOid() );
ControlFactory<PagedResults> pageResultsFactory = new PagedResultsFactory( this );
controlFactories.put( pageResultsFactory.getOid(), pageResultsFactory );
LOG.info( "Registered pre-bundled control factory: {}", pageResultsFactory.getOid() );
ControlFactory<PersistentSearch> persistentSearchFactory = new PersistentSearchFactory( this );
controlFactories.put( persistentSearchFactory.getOid(), persistentSearchFactory );
LOG.info( "Registered pre-bundled control factory: {}", persistentSearchFactory.getOid() );
ControlFactory<Subentries> subentriesFactory = new SubentriesFactory( this );
controlFactories.put( subentriesFactory.getOid(), subentriesFactory );
LOG.info( "Registered pre-bundled control factory: {}", subentriesFactory.getOid() );
ControlFactory<SortRequest> sortRequestFactory = new SortRequestFactory( this );
controlFactories.put( sortRequestFactory.getOid(), sortRequestFactory );
LOG.info( "Registered pre-bundled control factory: {}", sortRequestFactory.getOid() );
ControlFactory<SortResponse> sortResponseFactory = new SortResponseFactory( this );
controlFactories.put( sortResponseFactory.getOid(), sortResponseFactory );
LOG.info( "Registered pre-bundled control factory: {}", sortResponseFactory.getOid() );
}
示例2: decorate
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Decorate the PageResult control
*
* @param control The PageResult control instance
*/
public void decorate( PagedResults control )
{
if ( control instanceof PagedResultsDecorator )
{
this.control = ( PagedResultsDecorator ) control;
}
else
{
this.control = new PagedResultsDecorator( codec, control );
}
}
示例3: equals
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* @see Object#equals(Object)
*/
@Override
public boolean equals( Object o )
{
if ( !super.equals( o ) )
{
return false;
}
PagedResults otherControl = ( PagedResults ) o;
return ( getSize() == otherControl.getSize() ) && Arrays.equals( getCookie(), otherControl.getCookie() );
}
示例4: testEncodePagedSearchControl
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Test encoding of a PagedSearchControl.
*/
@Test
public void testEncodePagedSearchControl() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0B );
bb.put( new byte[]
{
0x30, 0x09, // realSearchControlValue ::= SEQUENCE {
0x02,
0x01,
0x20, // size INTEGER,
0x04,
0x04,
't',
'e',
's',
't' // cookie OCTET STRING,
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
PagedResults pagedSearch = ( PagedResults ) decorator.decode( bb.array() );
assertEquals( 32, pagedSearch.getSize() );
assertTrue( Arrays.equals( Strings.getBytesUtf8( "test" ),
pagedSearch.getCookie() ) );
bb.flip();
PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
ctrl.setSize( 32 );
ctrl.setCookie( Strings.getBytesUtf8( "test" ) );
ByteBuffer buffer = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) );
String decoded = Strings.dumpBytes( buffer.array() );
String expected = Strings.dumpBytes( bb.array() );
assertEquals( expected, decoded );
}
示例5: testEncodePagedSearchControlNegativeSize
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Test encoding of a PagedSearchControl with a negative size
*/
@Test
public void testEncodePagedSearchControlNegativeSize() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x0b );
bb.put( new byte[]
{
0x30, 0x09, // realSearchControlValue ::= SEQUENCE {
0x02,
0x01,
( byte ) 0xFF, // size INTEGER,
0x04,
0x04,
't',
'e',
's',
't' // cookie OCTET STRING,
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
PagedResults pagedSearch = ( PagedResults ) decorator.decode( bb.array() );
assertEquals( Integer.MAX_VALUE, pagedSearch.getSize() );
assertTrue( Arrays.equals( Strings.getBytesUtf8( "test" ),
pagedSearch.getCookie() ) );
bb.flip();
PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
ctrl.setSize( -1 );
ctrl.setCookie( Strings.getBytesUtf8( "test" ) );
ByteBuffer buffer = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) );
String decoded = Strings.dumpBytes( buffer.array() );
String expected = Strings.dumpBytes( bb.array() );
assertEquals( expected, decoded );
}
示例6: testEncodePagedSearchControlEmptyCookie
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Test encoding of a PagedSearchControl with a empty cookie
*/
@Test
public void testEncodePagedSearchControlEmptyCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 0x07 );
bb.put( new byte[]
{
0x30, 0x05, // realSearchControlValue ::= SEQUENCE {
0x02,
0x01,
0x20, // size INTEGER,
0x04,
0x00 // cookie OCTET STRING,
} );
bb.flip();
PagedResultsDecorator decorator = new PagedResultsDecorator( codec );
PagedResults pagedSearch = ( PagedResults ) decorator.decode( bb.array() );
assertEquals( 32, pagedSearch.getSize() );
assertNull( pagedSearch.getCookie() );
PagedResultsDecorator ctrl = new PagedResultsDecorator( codec );
ctrl.setSize( 32 );
ctrl.setCookie( null );
ByteBuffer buffer = ctrl.encode( ByteBuffer.allocate( ctrl.computeLength() ) );
String decoded = Strings.dumpBytes( buffer.array() );
String expected = Strings.dumpBytes( bb.array() );
assertEquals( expected, decoded );
}
示例7: abandonPagedSearch
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Manage the abandoned Paged Search (when paged size = 0). We have to
* remove the cookie and its associated cursor from the session.
*/
private SearchResultDone abandonPagedSearch( LdapSession session, SearchRequest req ) throws Exception
{
PagedResults pagedSearchControl = ( PagedResults ) req.getControls().get( PagedResults.OID );
byte[] cookie = pagedSearchControl.getCookie();
if ( !Strings.isEmpty( cookie ) )
{
// If the cookie is not null, we have to destroy the associated
// cursor stored into the session (if any)
int cookieValue = pagedSearchControl.getCookieValue();
PagedSearchContext psCookie = session.removePagedSearchContext( cookieValue );
pagedSearchControl.setCookie( psCookie.getCookie() );
pagedSearchControl.setSize( 0 );
pagedSearchControl.setCritical( true );
// Close the cursor
EntryFilteringCursor cursor = psCookie.getCursor();
if ( cursor != null )
{
cursor.close();
}
}
else
{
pagedSearchControl.setSize( 0 );
pagedSearchControl.setCritical( true );
}
// and return
// DO NOT WRITE THE RESPONSE - JUST RETURN IT
LdapResult ldapResult = req.getResultResponse().getLdapResult();
ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
req.getResultResponse().addControl( pagedSearchControl );
return req.getResultResponse();
}
示例8: abandonPagedSearch
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Manage the abandoned Paged Search (when paged size = 0). We have to
* remove the cookie and its associated cursor from the session.
*/
private SearchResultDone abandonPagedSearch( LdapSession session, SearchRequest req ) throws Exception
{
PagedResults pagedSearchControl = ( PagedResults ) req.getControls().get( PagedResults.OID );
byte[] cookie = pagedSearchControl.getCookie();
if ( !Strings.isEmpty( cookie ) )
{
// If the cookie is not null, we have to destroy the associated
// cursor stored into the session (if any)
int cookieValue = pagedSearchControl.getCookieValue();
PagedSearchContext psCookie = session.removePagedSearchContext( cookieValue );
pagedSearchControl.setCookie( psCookie.getCookie() );
pagedSearchControl.setSize( 0 );
pagedSearchControl.setCritical( true );
// Close the cursor
Cursor<Entry> cursor = psCookie.getCursor();
if ( cursor != null )
{
cursor.close();
}
}
else
{
pagedSearchControl.setSize( 0 );
pagedSearchControl.setCritical( true );
}
// and return
// DO NOT WRITE THE RESPONSE - JUST RETURN IT
LdapResult ldapResult = req.getResultResponse().getLdapResult();
ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
req.getResultResponse().addControl( pagedSearchControl );
return ( SearchResultDone ) req.getResultResponse();
}
示例9: getOid
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getOid()
{
return PagedResults.OID;
}
示例10: newCodecControl
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public CodecControl<PagedResults> newCodecControl()
{
return new PagedResultsDecorator( codec );
}
示例11: doSimpleSearch
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Conducts a simple search across the result set returning each entry
* back except for the search response done. This is calculated but not
* returned so the persistent search mechanism can leverage this method
* along with standard search.<br>
* <br>
* @param session the LDAP session object for this request
* @param req the search request
* @return the result done
* @throws Exception if there are failures while processing the request
*/
private SearchResultDone doSimpleSearch( LdapSession session, SearchRequest req ) throws Exception
{
LdapResult ldapResult = req.getResultResponse().getLdapResult();
// Check if we are using the Paged Search Control
Object control = req.getControls().get( PagedResults.OID );
if ( control != null )
{
// Let's deal with the pagedControl
return doPagedSearch( session, req, ( PagedResultsDecorator ) control );
}
// A normal search
// Check that we have a cursor or not.
// No cursor : do a search.
EntryFilteringCursor cursor = session.getCoreSession().search( req );
// register the request in the session
session.registerSearchRequest( req, cursor );
// Position the cursor at the beginning
cursor.beforeFirst();
/*
* Iterate through all search results building and sending back responses
* for each search result returned.
*/
try
{
// Get the size limits
// Don't bother setting size limits for administrators that don't ask for it
long serverLimit = getServerSizeLimit( session, req );
long requestLimit = req.getSizeLimit() == 0L ? Long.MAX_VALUE : req.getSizeLimit();
req.addAbandonListener( new SearchAbandonListener( ldapServer, cursor ) );
setTimeLimitsOnCursor( req, session, cursor );
if ( IS_DEBUG )
{
LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit );
}
long sizeLimit = min( requestLimit, serverLimit );
writeResults( session, req, ldapResult, cursor, sizeLimit );
}
finally
{
if ( ( cursor != null ) && !cursor.isClosed() )
{
try
{
cursor.close();
}
catch ( Exception e )
{
LOG.error( I18n.err( I18n.ERR_168 ), e );
}
}
}
return req.getResultResponse();
}
示例12: toShortString
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
public static void toShortString(StringBuilder sb, Control control) {
if (control == null) {
return;
}
if (control instanceof PagedResults) {
sb.append("PagedResults(size=");
sb.append(((PagedResults)control).getSize());
sb.append(", cookie=");
byte[] cookie = ((PagedResults)control).getCookie();
if (cookie == null) {
sb.append("null");
} else {
sb.append(Base64.encode(cookie));
}
sb.append("),");
} else if (control instanceof VirtualListViewRequest) {
sb.append("VLV(beforeCount=");
sb.append(((VirtualListViewRequest)control).getBeforeCount());
sb.append(", afterCount=");
sb.append(((VirtualListViewRequest)control).getAfterCount());
sb.append(", offset=");
sb.append(((VirtualListViewRequest)control).getOffset());
sb.append(", contentCount=");
sb.append(((VirtualListViewRequest)control).getContentCount());
sb.append(", contextID=");
byte[] contextId = ((VirtualListViewRequest)control).getContextId();
if (contextId == null) {
sb.append("null");
} else {
sb.append(Base64.encode(contextId));
}
sb.append("),");
} else if (control instanceof SortRequest) {
sb.append("Sort(");
for (SortKey sortKey: ((SortRequest)control).getSortKeys()) {
sb.append(sortKey.getAttributeTypeDesc());
sb.append(":");
sb.append(sortKey.getMatchingRuleId());
sb.append(":");
if (sortKey.isReverseOrder()) {
sb.append("D");
} else {
sb.append("A");
}
sb.append("),");
}
} else {
String controlDesc = null;
Class<? extends Control> controlClass = control.getClass();
Class<?>[] interfaces = controlClass.getInterfaces();
if (interfaces != null) {
for (Class<?> iface: interfaces) {
if (iface.getPackage().getName().startsWith("org.apache.directory.api")) {
controlDesc = iface.getSimpleName();
break;
}
}
}
if (controlDesc == null) {
controlDesc = controlClass.getName();
}
sb.append(controlDesc);
}
}
示例13: chooseSearchStrategy
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
protected SearchStrategy<C> chooseSearchStrategy(ObjectClass objectClass,
org.apache.directory.api.ldap.model.schema.ObjectClass ldapObjectClass,
ResultsHandler handler, OperationOptions options) {
AbstractSchemaTranslator<C> schemaTranslator = getSchemaTranslator();
String pagingStrategy = configuration.getPagingStrategy();
if (pagingStrategy == null) {
pagingStrategy = LdapConfiguration.PAGING_STRATEGY_AUTO;
}
if (options != null && options.getAllowPartialResults() != null && options.getAllowPartialResults() &&
options.getPagedResultsOffset() == null && options.getPagedResultsCookie() == null &&
options.getPageSize() == null) {
// Search that allow partial results, no need for paging. Regardless of the configured strategy.
return getDefaultSearchStrategy(objectClass, ldapObjectClass, handler, options);
}
if (LdapConfiguration.PAGING_STRATEGY_NONE.equals(pagingStrategy)) {
// This may fail on a sizeLimit. But this is what has been configured so we are going to do it anyway.
LOG.ok("Selecting default search strategy because strategy setting is set to {0}", pagingStrategy);
return getDefaultSearchStrategy(objectClass, ldapObjectClass, handler, options);
} else if (LdapConfiguration.PAGING_STRATEGY_SPR.equals(pagingStrategy)) {
if (supportsControl(PagedResults.OID)) {
LOG.ok("Selecting SimplePaged search strategy because strategy setting is set to {0}", pagingStrategy);
return new SimplePagedResultsSearchStrategy<>(connectionManager, configuration, schemaTranslator, objectClass, ldapObjectClass, handler, options);
} else {
throw new ConfigurationException("Configured paging strategy "+pagingStrategy+", but the server does not support PagedResultsControl.");
}
} else if (LdapConfiguration.PAGING_STRATEGY_VLV.equals(pagingStrategy)) {
if (supportsControl(VirtualListViewRequest.OID)) {
LOG.ok("Selecting VLV search strategy because strategy setting is set to {0}", pagingStrategy);
return new VlvSearchStrategy<>(connectionManager, configuration, getSchemaTranslator(), objectClass, ldapObjectClass, handler, options);
} else {
throw new ConfigurationException("Configured paging strategy "+pagingStrategy+", but the server does not support VLV.");
}
} else if (LdapConfiguration.PAGING_STRATEGY_AUTO.equals(pagingStrategy)) {
if (options.getPagedResultsOffset() != null) {
// Always prefer VLV even if the offset is 1. We expect that the client will use paging and subsequent
// queries will come with offset other than 1. The server may use a slightly different sorting for VLV and other
// paging mechanisms. Bu we want consisten results. Therefore in this case prefer VLV even if it might be less efficient.
if (supportsControl(VirtualListViewRequest.OID)) {
LOG.ok("Selecting VLV search strategy because strategy setting is set to {0} and the request specifies an offset", pagingStrategy);
return new VlvSearchStrategy<>(connectionManager, configuration, getSchemaTranslator(), objectClass, ldapObjectClass, handler, options);
} else {
throw new UnsupportedOperationException("Requested search from offset ("+options.getPagedResultsOffset()+"), but the server does not support VLV. Unable to execute the search.");
}
} else {
if (supportsControl(PagedResults.OID)) {
// SPR is usually a better choice if no offset is specified. Less overhead on the server.
LOG.ok("Selecting SimplePaged search strategy because strategy setting is set to {0} and the request does not specify an offset", pagingStrategy);
return new SimplePagedResultsSearchStrategy<>(connectionManager, configuration, schemaTranslator, objectClass, ldapObjectClass, handler, options);
} else if (supportsControl(VirtualListViewRequest.OID)) {
return new VlvSearchStrategy<>(connectionManager, configuration, getSchemaTranslator(), objectClass, ldapObjectClass, handler, options);
} else {
throw new UnsupportedOperationException("Requested paged search, but the server does not support VLV or PagedResultsControl. Unable to execute the search.");
}
}
}
return getDefaultSearchStrategy(objectClass, ldapObjectClass, handler, options);
}
示例14: PagedResultsContainer
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Creates a new PagedSearchControl container object to contain a PagedResults
* Control, which is optionally decorated if is not a decorator already. If it
* is a decorator then it is used as the decorator for this container.
*
* @param codec The encoder decoder for this container
* @param control A PagedResults Control to optionally be wrapped.
*/
public PagedResultsContainer( LdapApiService codec, PagedResults control )
{
this( codec );
decorate( control );
}
示例15: PagedResultsDecorator
import org.apache.directory.api.ldap.model.message.controls.PagedResults; //导入依赖的package包/类
/**
* Creates a new instance of PagedResultsDecorator using the supplied PagedResults
* Control to be decorated.
*
* @param codec The LDAP service instance
* @param pagedResults The PagedResults Control to be decorated.
*/
public PagedResultsDecorator( LdapApiService codec, PagedResults pagedResults )
{
super( codec, pagedResults );
}