001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 * Portions Copyright 2015-2016 ForgeRock AS. 016 */ 017package org.opends.admin.ads; 018 019import java.util.HashSet; 020import java.util.Set; 021 022/** 023 * Class used to filter what we look for in the topology cache. 024 * This is done in particular to avoid problems of performance when we 025 * know what we are looking for. It is particularly useful to avoid 026 * searching for monitoring information. 027 */ 028public class TopologyCacheFilter 029{ 030 private final Set<String> baseDNs = new HashSet<>(); 031 private boolean searchMonitoringInformation = true; 032 private boolean searchBaseDNInformation = true; 033 034 /** 035 * Returns whether we must search for base DN information or not. 036 * @return <CODE>true</CODE> if we must search base DN information and 037 * <CODE>false</CODE> otherwise. 038 */ 039 boolean searchBaseDNInformation() 040 { 041 return searchBaseDNInformation; 042 } 043 044 /** 045 * Sets whether we must search for base DN information or not. 046 * @param searchBaseDNInformation whether we must search for base DN 047 * information or not. 048 */ 049 public void setSearchBaseDNInformation( 050 boolean searchBaseDNInformation) 051 { 052 this.searchBaseDNInformation = searchBaseDNInformation; 053 } 054 055 056 /** 057 * Returns whether we must search for monitoring information or not. 058 * @return <CODE>true</CODE> if we must search monitoring information and 059 * <CODE>false</CODE> otherwise. 060 */ 061 boolean searchMonitoringInformation() 062 { 063 return searchMonitoringInformation; 064 } 065 066 /** 067 * Sets whether we must search for monitoring information or not. 068 * @param searchMonitoringInformation whether we must search for monitoring 069 * information or not. 070 */ 071 public void setSearchMonitoringInformation( 072 boolean searchMonitoringInformation) 073 { 074 this.searchMonitoringInformation = searchMonitoringInformation; 075 } 076 077 /** 078 * Adds one of the base DNs we must search for. If at least one baseDN 079 * is added using this method, only the added baseDNs are searched. If no 080 * base DN is added, all the base DNs will be retrieved. 081 * @param dn the DN of the base DN to look for. 082 */ 083 public void addBaseDNToSearch(String dn) 084 { 085 baseDNs.add(dn); 086 } 087 088 /** 089 * Returns the list of base DNs that will be searched for. If the list is 090 * empty we will search for all the base DNs. 091 * @return the list of base DNs we will search for. 092 */ 093 public Set<String> getBaseDNsToSearch() 094 { 095 return new HashSet<>(baseDNs); 096 } 097 098 /** 099 * Tells whether this filter specifies to search for all the base DNs or not. 100 * @return <CODE>true</CODE> if the filter specifies to search for all the 101 * base DNs and <CODE>false</CODE> otherwise. 102 */ 103 boolean searchAllBaseDNs() 104 { 105 return baseDNs.isEmpty(); 106 } 107}