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 2006-2010 Sun Microsystems, Inc. 015 * Portions Copyright 2015 ForgeRock AS. 016 */ 017package org.opends.quicksetup.installer; 018 019import java.util.HashMap; 020import java.util.LinkedHashSet; 021import java.util.Map; 022import java.util.Set; 023 024import org.opends.admin.ads.SuffixDescriptor; 025import org.opends.server.tools.BackendTypeHelper.BackendTypeUIAdapter; 026 027/** 028 * This class is used to provide a data model for the Suffix to Replicate 029 * Options panel of the installer. 030 */ 031public class SuffixesToReplicateOptions 032{ 033 /** 034 * This enumeration is used to know what the user wants to do for the data 035 * (import data or not, what use as source of the data...). 036 */ 037 public enum Type 038 { 039 /** Do not replicate suffix. */ 040 NO_SUFFIX_TO_REPLICATE, 041 042 /** This is a new suffix in topology.. */ 043 NEW_SUFFIX_IN_TOPOLOGY, 044 045 /** Replicate Contents of the new Suffix with existings server. */ 046 REPLICATE_WITH_EXISTING_SUFFIXES 047 } 048 049 private Type type; 050 private Set<SuffixDescriptor> availableSuffixes; 051 private Set<SuffixDescriptor> suffixesToReplicate; 052 private Map<String, BackendTypeUIAdapter> backendsToReplicate; 053 054 /** 055 * Constructor for the SuffixesToReplicateOptions object. 056 * 057 * @param type 058 * the Type of DataReplicationOptions. 059 * @param availableSuffixes 060 * The set of suffixes which are available for replication. 061 * @param suffixesToReplicate 062 * The set of suffixes which user wants to replicate. 063 */ 064 public SuffixesToReplicateOptions(Type type, Set<SuffixDescriptor> availableSuffixes, 065 Set<SuffixDescriptor> suffixesToReplicate) 066 { 067 this(type, availableSuffixes, suffixesToReplicate, new HashMap<String, BackendTypeUIAdapter>()); 068 } 069 070 /** 071 * Constructor for the SuffixesToReplicateOptions object. 072 * 073 * @param type 074 * the Type of DataReplicationOptions. 075 * @param availableSuffixes 076 * The set of suffixes which are available for replication. 077 * @param suffixesToReplicate 078 * The set of suffixes which user wants to replicate. 079 * @param backendsToReplicate 080 * The map with backend name as keys and their associated backend type 081 * as value. 082 */ 083 public SuffixesToReplicateOptions(Type type, Set<SuffixDescriptor> availableSuffixes, 084 Set<SuffixDescriptor> suffixesToReplicate, Map<String, BackendTypeUIAdapter> backendsToReplicate) 085 { 086 this.type = type; 087 this.availableSuffixes = new LinkedHashSet<>(availableSuffixes); 088 this.suffixesToReplicate = new LinkedHashSet<>(suffixesToReplicate); 089 this.backendsToReplicate = new HashMap<>(backendsToReplicate); 090 } 091 092 /** 093 * Returns the type of SuffixesToReplicateOptions represented by this object 094 * (replicate or not). 095 * 096 * @return the type of SuffixesToReplicateOptions. 097 */ 098 public Type getType() 099 { 100 return type; 101 } 102 103 /** 104 * Returns the set of suffixes available for replication. 105 * 106 * @return the set of suffixes available for replication. 107 */ 108 public Set<SuffixDescriptor> getAvailableSuffixes() 109 { 110 return availableSuffixes; 111 } 112 113 /** 114 * The set of suffixes that we must replicate with. 115 * 116 * @return the set of suffixes that we must replicate with. 117 */ 118 public Set<SuffixDescriptor> getSuffixes() 119 { 120 return suffixesToReplicate; 121 } 122 123 /** 124 * Returns a map which associate backend names and backend types. 125 * 126 * @return A map which associate backend names and backend types. 127 */ 128 public Map<String, BackendTypeUIAdapter> getSuffixBackendTypes() 129 { 130 return backendsToReplicate; 131 } 132}