1   package com.atlassian.user.impl.ldap.search;
2   
3   import net.sf.ldaptemplate.support.filter.Filter;
4   
5   import javax.naming.NamingEnumeration;
6   import javax.naming.directory.SearchResult;
7   
8   /**
9    * A util class which holds a {@link javax.naming.NamingEnumeration} and a {@link String}
10   * representing the initial ldap search query.
11   *
12   * We use this because the {@link com.atlassian.user.impl.ldap.search.page.LDAPEntityPager}
13   * needs to be able to repeat the original search to preload the next {@link com.atlassian.user.search.page.Pager@PRELOAD_LIMIT}
14   * entries, either on a call to {@link com.atlassian.user.search.page.Pager#skipTo(int)} or
15   * {@link com.atlassian.user.search.page.Pager#nextPage()}.
16   *
17   */
18  
19  public class LDAPPagerInfo
20  {
21      private NamingEnumeration<SearchResult> enume;
22      private Filter relatingSearchQuery;
23      private String originalBaseSearchContext;
24      private boolean searchAllDepths;
25      private String[] returningAttributes;
26      private final int timeToLive;
27  
28      public LDAPPagerInfo(NamingEnumeration<SearchResult> enume, Filter originalSearchQuery,
29                              String originalBaseSearchContext, boolean searchAllDepths,
30                              String[] returningAttributes, int timeToLive)
31      {
32          this.enume = enume;
33          this.relatingSearchQuery = originalSearchQuery;
34          this.originalBaseSearchContext = originalBaseSearchContext;
35          this.searchAllDepths = searchAllDepths;
36          this.returningAttributes = returningAttributes;
37          this.timeToLive = timeToLive;
38      }
39  
40      public NamingEnumeration<SearchResult> getNamingEnumeration()
41      {
42          return enume;
43      }
44  
45      /**
46       * @return a query which relates to the search result. The query itself may not be identical to the original
47       * search query used to generate the associated naming enumeration but its evaluation will produce results which
48       * relate to the enumeration.
49       */
50      public Filter getLDAPQuery()
51      {
52          return relatingSearchQuery;
53      }
54  
55      public String getBaseSearchContext()
56      {
57          return originalBaseSearchContext;
58      }
59  
60      public void setLDAPQuery(Filter relatingQuery)
61      {
62          this.relatingSearchQuery = relatingQuery;
63      }
64  
65      public boolean isSearchAllDepths()
66      {
67          return searchAllDepths;
68      }
69  
70      public String[] getReturningAttributes()
71      {
72          return returningAttributes;
73      }
74  
75      public int getTimeToLive()
76      {
77          return timeToLive;
78      }
79  }