| | |
| | | * The set of attributes that will be requested when performing internal |
| | | * search operations. This indicates that no attributes should be returned. |
| | | */ |
| | | private static final Set<String> SEARCH_ATTRS = new LinkedHashSet<String>(1); |
| | | private static final LinkedHashSet<String> SEARCH_ATTRS = new LinkedHashSet<String>(1); |
| | | static |
| | | { |
| | | SEARCH_ATTRS.add(SchemaConstants.NO_ATTRIBUTES); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, String filterString, |
| | | Set<String> attributes) |
| | | LinkedHashSet<String> attributes) |
| | | throws DirectoryException |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, String filterString, |
| | | Set<String> attributes, |
| | | LinkedHashSet<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | throws DirectoryException |
| | | { |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, String filterString, |
| | | Set<String> attributes, |
| | | LinkedHashSet<String> attributes, |
| | | List<Control> controls, |
| | | InternalSearchListener searchListener) |
| | | throws DirectoryException |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, RawFilter filter, |
| | | Set<String> attributes) |
| | | LinkedHashSet<String> attributes) |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filter, attributes, |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, RawFilter filter, |
| | | Set<String> attributes, |
| | | LinkedHashSet<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, RawFilter filter, |
| | | Set<String> attributes, |
| | | LinkedHashSet<String> attributes, |
| | | List<Control> controls, |
| | | InternalSearchListener searchListener) |
| | | { |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, SearchFilter filter, |
| | | Set<String> attributes) |
| | | LinkedHashSet<String> attributes) |
| | | { |
| | | return processSearch(baseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filter, attributes, |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, SearchFilter filter, |
| | | Set<String> attributes, |
| | | LinkedHashSet<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | return processSearch(baseDN, scope, derefPolicy, sizeLimit, |
| | |
| | | DereferencePolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, SearchFilter filter, |
| | | Set<String> attributes, |
| | | LinkedHashSet<String> attributes, |
| | | List<Control> controls, |
| | | InternalSearchListener searchListener) |
| | | { |
| | |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.service.ReplicationMonitor.*; |
| | | import static org.opends.server.types.ResultCode.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | * Set of attributes that will return all the user attributes and the |
| | | * replication related operational attributes when used in a search operation. |
| | | */ |
| | | private static final Set<String> USER_AND_REPL_OPERATIONAL_ATTRS = |
| | | new HashSet<String>(Arrays.asList( |
| | | private static final LinkedHashSet<String> USER_AND_REPL_OPERATIONAL_ATTRS = |
| | | new LinkedHashSet<String>(Arrays.asList( |
| | | HISTORICAL_ATTRIBUTE_NAME, ENTRYUUID_ATTRIBUTE_NAME, "*")); |
| | | |
| | | /** |
| | |
| | | |
| | | // Search the domain root entry that is used to save the generation id |
| | | final ByteString asn1BaseDn = ByteString.valueOf(getBaseDNString()); |
| | | final Set<String> attributes = newSet( |
| | | final LinkedHashSet<String> attributes = newLinkedHashSet( |
| | | REPLICATION_GENERATION_ID, |
| | | REPLICATION_FRACTIONAL_EXCLUDE, |
| | | REPLICATION_FRACTIONAL_INCLUDE); |
| | |
| | | { |
| | | // Construct and store new attribute list |
| | | newRdnAttrLists.add( |
| | | newList(Attributes.create(attributeType, sameAttrValue))); |
| | | newArrayList(Attributes.create(attributeType, sameAttrValue))); |
| | | /* |
| | | Store matching attribute type |
| | | The mapping will be done using object from rdnAttrTypes as key |
| | |
| | | return hasSomeAttributesToFilter; |
| | | } |
| | | |
| | | private static <T> ArrayList<T> newList(T elem) |
| | | { |
| | | final ArrayList<T> list = new ArrayList<T>(1); |
| | | list.add(elem); |
| | | return list; |
| | | } |
| | | |
| | | private static <T> Set<T> newSet(T... elems) |
| | | { |
| | | final Set<T> list = new LinkedHashSet<T>(elems.length); |
| | | for (T elem : elems) |
| | | { |
| | | list.add(elem); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses, |
| | | AttributeType attributeType) |
| | | { |
| | |
| | | } |
| | | try |
| | | { |
| | | final Set<String> attrs = newSet(ENTRYUUID_ATTRIBUTE_NAME); |
| | | final LinkedHashSet<String> attrs = newLinkedHashSet(ENTRYUUID_ATTRIBUTE_NAME); |
| | | |
| | | final InternalSearchOperation search = getRootConnection().processSearch( |
| | | dn, SearchScope.BASE_OBJECT, DereferencePolicy.NEVER_DEREF_ALIASES, |
| | |
| | | // Find an rename child entries. |
| | | try |
| | | { |
| | | final Set<String> attrs = |
| | | newSet(ENTRYUUID_ATTRIBUTE_NAME, HISTORICAL_ATTRIBUTE_NAME); |
| | | final LinkedHashSet<String> attrs = newLinkedHashSet(ENTRYUUID_ATTRIBUTE_NAME, HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | | InternalSearchOperation op = |
| | | conn.processSearch(entryDN, SearchScope.SINGLE_LEVEL, |
| | |
| | | true); |
| | | Attribute attr = Attributes.create(attrType, AttributeValues.create( |
| | | attrType, conflictDN.toNormalizedString())); |
| | | List<Modification> mods = |
| | | newList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyOperation newOp = new ModifyOperationBasis( |
| | | conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0), |
| | |
| | | // The generationId is stored in the root entry of the domain. |
| | | final ByteString asn1BaseDn = ByteString.valueOf(entryDN.toString()); |
| | | final ArrayList<ByteString> values = |
| | | newList(ByteString.valueOf(Long.toString(generationId))); |
| | | newArrayList(ByteString.valueOf(Long.toString(generationId))); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute(REPLICATION_GENERATION_ID, values); |
| | | List<RawModification> mods = new ArrayList<RawModification>(1); |
| | |
| | | * Search the database entry that is used to periodically |
| | | * save the generation id |
| | | */ |
| | | final Set<String> attributes = newSet(REPLICATION_GENERATION_ID); |
| | | final LinkedHashSet<String> attributes = newLinkedHashSet(REPLICATION_GENERATION_ID); |
| | | final String filter = "(objectclass=*)"; |
| | | InternalSearchOperation search = conn.processSearch(getBaseDNString(), |
| | | SearchScope.BASE_OBJECT, |
| | |
| | | |
| | | // baseDN branch is the only one included in the export |
| | | LDIFExportConfig exportConfig = new LDIFExportConfig(os); |
| | | exportConfig.setIncludeBranches(newList(getBaseDN())); |
| | | exportConfig.setIncludeBranches(newArrayList(getBaseDN())); |
| | | |
| | | // For the checksum computing mode, only consider the 'stable' attributes |
| | | if (checksumOutput) |
| | |
| | | } |
| | | |
| | | importConfig = new LDIFImportConfig(input); |
| | | importConfig.setIncludeBranches(newList(getBaseDN())); |
| | | importConfig.setIncludeBranches(newArrayList(getBaseDN())); |
| | | importConfig.setAppendToExistingData(false); |
| | | importConfig.setSkipDNValidation(true); |
| | | // We should not validate schema for replication |
| | |
| | | entryHist.setPurgeDelay(getHistoricalPurgeDelay()); |
| | | Attribute attr = entryHist.encodeAndPurge(); |
| | | count += entryHist.getLastPurgedValuesCount(); |
| | | List<Modification> mods = |
| | | newList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyOperation newOp = new ModifyOperationBasis( |
| | | conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0), |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | |
| | | * The attribute name used to store the state in the backend. |
| | | */ |
| | | private static final String REPLICATION_STATE = "ds-sync-state"; |
| | | private static final LinkedHashSet<String> REPLICATION_STATE_ATTRS = |
| | | new LinkedHashSet<String>(Collections.singleton(REPLICATION_STATE)); |
| | | |
| | | /** |
| | | * Create a new PersistentServerState based on an already existing |
| | |
| | | */ |
| | | final InternalSearchOperation search = getRootConnection().processSearch( |
| | | baseDN, SearchScope.BASE_OBJECT, DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 0, 0, false, filter, Collections.singleton(REPLICATION_STATE)); |
| | | 0, 0, false, filter, REPLICATION_STATE_ATTRS); |
| | | final ResultCode resultCode = search.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS |
| | | && resultCode != ResultCode.NO_SUCH_OBJECT) |
| | |
| | | DN.decode("cn=config"), |
| | | SearchScope.SUBORDINATE_SUBTREE, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, |
| | | 1, 0, false, filter, Collections.singleton(REPLICATION_STATE)); |
| | | 1, 0, false, filter, REPLICATION_STATE_ATTRS); |
| | | return getFirstResult(op); |
| | | } |
| | | catch (DirectoryException e) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates a new {@link List} with the provided elements. |
| | | * |
| | | * @param <E> |
| | | * the elements' type |
| | | * @param elements |
| | | * the elements to add to the new List |
| | | * @return a new ArrayList with the provided elements |
| | | */ |
| | | public static <E> List<E> newList(E... elements) |
| | | { |
| | | return newArrayList(elements); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new {@link HashSet} with the provided elements. |
| | | * |
| | | * @param <E> |
| | |
| | | { |
| | | return new TreeSet<E>(Arrays.asList(elements)); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new {@link SortedSet} with the provided elements. |
| | | * |
| | | * @param <E> |
| | | * the elements' type |
| | | * @param elements |
| | | * the elements to add to the new SortedSet |
| | | * @return a new TreeSet with the provided elements |
| | | */ |
| | | public static <E> SortedSet<E> newSortedSet(E... elements) |
| | | { |
| | | return newTreeSet(elements); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new {@link Set} with the provided elements. |
| | | * |
| | | * @param <E> |
| | | * the elements' type |
| | | * @param elements |
| | | * the elements to add to the new Set |
| | | * @return a new TreeSet with the provided elements |
| | | */ |
| | | public static <E> Set<E> newSet(E... elements) |
| | | { |
| | | return newHashSet(elements); |
| | | } |
| | | } |
| | |
| | | "--set", "enabled:" + enabled); |
| | | } |
| | | |
| | | public static <T> Set<T> newSet(T... elems) |
| | | { |
| | | return new HashSet<T>(Arrays.asList(elems)); |
| | | } |
| | | |
| | | public static <T> SortedSet<T> newSortedSet(T... elems) |
| | | { |
| | | return new TreeSet<T>(Arrays.asList(elems)); |
| | | } |
| | | |
| | | public static <T> List<T> newList(T... elems) |
| | | { |
| | | return new ArrayList<T>(Arrays.asList(elems)); |
| | | } |
| | | |
| | | /** Saves a thread dump in a file with the provided id used in file prefix. */ |
| | | public static void generateThreadDump(String id) |
| | | { |
| | |
| | | * When used in a search operation, it includes all attributes (user and |
| | | * operational) |
| | | */ |
| | | private static final Set<String> ALL_ATTRIBUTES = newSet("*", "+"); |
| | | private static final LinkedHashSet<String> ALL_ATTRIBUTES = newLinkedHashSet("*", "+"); |
| | | private static final List<Control> NO_CONTROL = null; |
| | | |
| | | @BeforeClass |
| | |
| | | String testName = "attributesVisibleOutsideRootDSE"; |
| | | debugInfo(testName, "Starting test \n\n"); |
| | | |
| | | Set<String> attributes = |
| | | newSet("firstchangenumber", "lastchangenumber", "changelog", "lastExternalChangelogCookie"); |
| | | LinkedHashSet<String> attributes = |
| | | newLinkedHashSet("firstchangenumber", "lastchangenumber", "changelog", "lastExternalChangelogCookie"); |
| | | |
| | | InternalSearchOperation searchOp = searchDNWithBaseScope(TEST_ROOT_DN_STRING, attributes); |
| | | waitForSearchOpResult(searchOp, ResultCode.SUCCESS); |
| | |
| | | { |
| | | try |
| | | { |
| | | final Set<String> attributes = new LinkedHashSet<String>(); |
| | | final LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | if (expectedFirstChangeNumber > 0) |
| | | { |
| | | attributes.add("firstchangenumber"); |
| | |
| | | String cookie = ""; |
| | | LDIFWriter ldifWriter = getLDIFWriter(); |
| | | |
| | | InternalSearchOperation searchOp = searchDNWithBaseScope("", newSet("lastExternalChangelogCookie")); |
| | | InternalSearchOperation searchOp = searchDNWithBaseScope("", newLinkedHashSet("lastExternalChangelogCookie")); |
| | | List<SearchResultEntry> entries = searchOp.getSearchEntries(); |
| | | if (entries != null) |
| | | { |
| | |
| | | return searchChangelog(filterString, ALL_ATTRIBUTES, NO_CONTROL, expectedNbEntries, expectedResultCode, testName); |
| | | } |
| | | |
| | | private InternalSearchOperation searchChangelog(String filterString, Set<String> attributes, |
| | | private InternalSearchOperation searchChangelog(String filterString, LinkedHashSet<String> attributes, |
| | | List<Control> controls, int expectedNbEntries, ResultCode expectedResultCode, String testName) throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = null; |
| | |
| | | return searchOperation; |
| | | } |
| | | |
| | | private InternalSearchOperation searchDNWithBaseScope(String dn, Set<String> attributes) throws Exception |
| | | private InternalSearchOperation searchDNWithBaseScope(String dn, LinkedHashSet<String> attributes) throws Exception |
| | | { |
| | | final InternalSearchOperation searchOp = connection.processSearch( |
| | | dn, |
| | |
| | | public void testSearchIndex() throws Exception { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | Set<String> attribs = new LinkedHashSet<String>(); |
| | | LinkedHashSet<String> attribs = new LinkedHashSet<String>(); |
| | | |
| | | String debugString; |
| | | int finalStartPos; |
| | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | Set<String> attribs = new LinkedHashSet<String>(); |
| | | LinkedHashSet<String> attribs = new LinkedHashSet<String>(); |
| | | attribs.add(ATTR_DEBUG_SEARCH_INDEX); |
| | | |
| | | InternalSearchOperation search = |
| | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | Set<String> attribs = new LinkedHashSet<String>(); |
| | | LinkedHashSet<String> attribs = new LinkedHashSet<String>(); |
| | | attribs.add(ATTR_DEBUG_SEARCH_INDEX); |
| | | |
| | | InternalSearchOperation search = |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | //Create a persistent search request. |
| | | Set<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("cn"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("cn"); |
| | | List<Control> controls = new LinkedList<Control>(); |
| | | // Creates psearch control |
| | | Set<PersistentSearchChangeType> changeTypes = |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.schema.DirectoryStringSyntax.*; |
| | | import static org.opends.server.types.ResultCode.*; |
| | | import static org.opends.server.types.SearchScope.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | private TestBroker(List<ReplicationMsg> list) |
| | | { |
| | | super(new DummyReplicationDomain(0), null, |
| | | new DomainFakeCfg(null, 0, TestCaseUtils.<String> newSortedSet()), null); |
| | | new DomainFakeCfg(null, 0, CollectionUtils.<String> newSortedSet()), null); |
| | | this.list = list; |
| | | } |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | import static org.assertj.core.data.MapEntry.*; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.replication.service.ReplicationBroker.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | import static java.util.Collections.*; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |