| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | import org.opends.server.protocols.asn1.ASN1Sequence; |
| | | import org.opends.server.types.DereferencePolicy; |
| | | import org.opends.server.types.SearchScope; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | |
| | | public class SearchRequestProtocolOp |
| | | extends ProtocolOp |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class to use for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.protocols.ldap.SearchRequestProtocolOp"; |
| | | |
| | | |
| | | |
| | |
| | | boolean typesOnly, LDAPFilter filter, |
| | | LinkedHashSet<String> attributes) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, |
| | | String.valueOf(baseDN), |
| | | String.valueOf(scope), |
| | | String.valueOf(dereferencePolicy), |
| | | String.valueOf(sizeLimit), |
| | | String.valueOf(timeLimit), |
| | | String.valueOf(typesOnly), |
| | | String.valueOf(filter), |
| | | String.valueOf(attributes) |
| | | ); |
| | | |
| | | |
| | | this.baseDN = baseDN; |
| | |
| | | */ |
| | | public ASN1OctetString getBaseDN() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getBaseDN"); |
| | | |
| | | return baseDN; |
| | | } |
| | |
| | | */ |
| | | public void setBaseDN(ASN1OctetString baseDN) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setBaseDN", String.valueOf(baseDN)); |
| | | |
| | | this.baseDN = baseDN; |
| | | } |
| | |
| | | */ |
| | | public SearchScope getScope() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getScope"); |
| | | |
| | | return scope; |
| | | } |
| | |
| | | */ |
| | | public void setScope(SearchScope scope) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setScope", String.valueOf(scope)); |
| | | |
| | | this.scope = scope; |
| | | } |
| | |
| | | */ |
| | | public DereferencePolicy getDereferencePolicy() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getDereferencePolicy"); |
| | | |
| | | return dereferencePolicy; |
| | | } |
| | |
| | | */ |
| | | public void setDereferencePolicy(DereferencePolicy dereferencePolicy) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setDereferencePolicy", |
| | | String.valueOf(dereferencePolicy)); |
| | | |
| | | this.dereferencePolicy = dereferencePolicy; |
| | | } |
| | |
| | | */ |
| | | public int getSizeLimit() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSizeLimit"); |
| | | |
| | | return sizeLimit; |
| | | } |
| | |
| | | */ |
| | | public void setSizeLimit(int sizeLimit) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setSizeLimit", String.valueOf(sizeLimit)); |
| | | |
| | | this.sizeLimit = sizeLimit; |
| | | } |
| | |
| | | */ |
| | | public int getTimeLimit() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getTimeLimit"); |
| | | |
| | | return timeLimit; |
| | | } |
| | |
| | | */ |
| | | public void setTimeLimit(int timeLimit) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setTimeLimit", String.valueOf(timeLimit)); |
| | | |
| | | this.timeLimit = timeLimit; |
| | | } |
| | |
| | | */ |
| | | public boolean getTypesOnly() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getTypesOnly"); |
| | | |
| | | return typesOnly; |
| | | } |
| | |
| | | */ |
| | | public void setTypesOnly(boolean typesOnly) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setTypesOnly", String.valueOf(typesOnly)); |
| | | |
| | | this.typesOnly = typesOnly; |
| | | } |
| | |
| | | */ |
| | | public LDAPFilter getFilter() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getFilter"); |
| | | |
| | | return filter; |
| | | } |
| | |
| | | */ |
| | | public void setFilter(LDAPFilter filter) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setFilter", String.valueOf(filter)); |
| | | |
| | | this.filter = filter; |
| | | } |
| | |
| | | */ |
| | | public LinkedHashSet<String> getAttributes() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getAttributes"); |
| | | |
| | | return attributes; |
| | | } |
| | |
| | | */ |
| | | public void setAttributes(LinkedHashSet<String> attributes) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setAttributes", String.valueOf(attributes)); |
| | | |
| | | if (attributes == null) |
| | | { |
| | |
| | | */ |
| | | public byte getType() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getType"); |
| | | |
| | | return OP_TYPE_SEARCH_REQUEST; |
| | | } |
| | |
| | | */ |
| | | public String getProtocolOpName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getProtocolOpName"); |
| | | |
| | | return "Search Request"; |
| | | } |
| | |
| | | */ |
| | | public ASN1Element encode() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encode"); |
| | | |
| | | ArrayList<ASN1Element> elements = new ArrayList<ASN1Element>(8); |
| | | elements.add(baseDN); |
| | |
| | | public static SearchRequestProtocolOp decodeSearchRequest(ASN1Element element) |
| | | throws LDAPException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "decodeSearchRequest", |
| | | String.valueOf(element)); |
| | | |
| | | ArrayList<ASN1Element> elements; |
| | | try |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_SEQUENCE; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_SEQUENCE; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_BASE; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_BASE; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_SCOPE; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_SCOPE; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_DEREF; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_DEREF; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_SIZE_LIMIT; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_SIZE_LIMIT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_TIME_LIMIT; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_TIME_LIMIT; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_TYPES_ONLY; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_TYPES_ONLY; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_FILTER; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_FILTER; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeSearchRequest", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_ATTRIBUTES; |
| | | int msgID = MSGID_LDAP_SEARCH_REQUEST_DECODE_ATTRIBUTES; |
| | | String message = getMessage(msgID, String.valueOf(e)); |
| | | throw new LDAPException(PROTOCOL_ERROR, msgID, message, e); |
| | | } |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString", "java.lang.StringBuilder"); |
| | | |
| | | buffer.append("SearchRequest(baseDN="); |
| | | baseDN.toString(buffer); |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString", "java.lang.StringBuilder", |
| | | String.valueOf(indent)); |
| | | |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | | for (int i=0 ; i < indent; i++) |