1
/** BEGIN COPYRIGHT BLOCK
2
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3
* Copyright (C) 2005 Red Hat, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
* END COPYRIGHT BLOCK **/
20
package com.netscape.admin.dirserv.panel.replication;
27
import netscape.ldap.*;
28
import netscape.ldap.controls.*;
29
import netscape.ldap.util.*;
30
import com.netscape.management.client.util.*;
31
import com.netscape.management.client.console.*;
32
import com.netscape.admin.dirserv.*;
33
import com.netscape.admin.dirserv.panel.*;
34
import com.netscape.admin.dirserv.task.ReadOnly;
35
import com.netscape.admin.dirserv.task.LDAPExport;
38
* Replication Agreement
44
* @see com.netscape.admin.dirserv.panel.replication
46
public class ReplicationAgreement implements IReplicationAgreement {
48
/*==========================================================
50
*==========================================================*/
51
public ReplicationAgreement(int aType) {
52
agreementType = aType;
53
selattrType = SELATTR_ALL; /* just a guess */
54
agreementIsNew = true;
55
updateSchedule = new Vector();
59
/*==========================================================
61
*==========================================================*/
64
* Set the current server information
66
public void setServerInfo(ConsoleInfo info) {
73
public ConsoleInfo getServerInfo() {
78
* Set the nickname for this agreement.
80
public void setNickname(String s) {
85
* Get the nickname for this agreement.
87
public String getNickname() {
92
* Set the original DN of the entry corresponding to this agreement.
94
public void setOrigEntryDN(String dn) {
95
Debug.println( "ReplicationAgreement.setOrigEntryDN: " + dn );
100
* Get the original DN of the entry corresponding to this agreement.
102
public String getOrigEntryDN() {
107
* Set the DN of the entry corresponding to this agreement.
109
protected void setEntryDN(String dn) {
110
Debug.println( "ReplicationAgreement.setEntryDN: " + dn );
115
* Get the DN of the entry corresponding to this agreement.
117
public String getEntryDN() {
122
* Set the root of the replicated subtree. This routine
123
* removes any extra spaces between DN components.
125
public void setReplicatedSubtree(String r) {
127
r.equals(_resource.getString("replication","misc-rootName"))) {
128
replicatedSubtree = "";
130
if (r == null || r.length() == 0) {
131
replicatedSubtree = null;
133
DN tmpDN = new DN(r);
134
replicatedSubtree = tmpDN.toString();
140
* Get the root of the replicated subtree.
142
public String getReplicatedSubtree() {
143
return replicatedSubtree;
147
* Set the host name of the consumer.
149
public void setConsumerHost(String h) {
154
* Get the host name of the consumer.
156
public String getConsumerHost() {
161
* Set the port number for the consumer server.
163
public void setConsumerPort(int p) {
168
* Get the port number for the consumer server.
170
public int getConsumerPort() {
174
* Set the host name of the supplier.
176
public void setSupplierHost(String h) {
181
* Get the host name of the supplier.
183
public String getSupplierHost() {
188
* Set the port number for the supplier server.
190
public void setSupplierPort(int p) {
195
* Get the port number for the supplier server.
197
public int getSupplierPort() {
202
* Set the remote host name of the server
204
public void setRemoteHost(String h) {
209
* Get the remote host name
211
public String getRemoteHost() {
216
* Set the remote port of the server
218
public void setRemotePort(int p) {
223
* Get the remote port
225
public int getRemotePort() {
230
* Set the DN used when binding to the consumer.
232
public void setBindDN(String dn) {
237
* Get the DN used when binding to the consumer.
239
public String getBindDN() {
244
* Set the credentials used when binding to the consumer.
246
public void setBindCredentials(String cred) {
247
bindCredentials = cred;
251
* Get the credentials used when binding to the consumer.
253
public String getBindCredentials() {
254
return bindCredentials;
258
* Set the schedule used to update the consumer.
260
public void setUpdateSchedule(Vector sched) {
261
updateSchedule = sched;
265
* Set the schedule used to update the consumer.
267
public void setUpdateSchedule(String s) {
268
updateSchedule.removeAllElements();
269
updateSchedule.addElement(s);
273
* Add to the update schedule
275
public void addUpdateSchedule(String schedItem) {
276
if (schedItem != null) {
277
updateSchedule.addElement(schedItem);
283
* Get the schedule used to update the consumer.
285
public Vector getUpdateSchedule() {
286
return updateSchedule;
290
* Get the replication schedule, as an array of Strings
292
public String[] getUpdateScheduleStrings() {
295
if (updateSchedule == null || updateSchedule.isEmpty()) {
298
ret = new String[updateSchedule.size()];
300
Enumeration schedEnum = updateSchedule.elements();
302
while (schedEnum.hasMoreElements()) {
303
ret[i] = ((String)schedEnum.nextElement());
310
* Set the useSSL flag
312
public void setUseSSL(String val) {
313
Debug.println(8,"ReplicationAgreement.useSSL() val = " + val);
314
if (val.equalsIgnoreCase("true")) {
316
} else if (val.equals("1")) {
318
} else if (val.equals(ReplicationTool.REPLICA_TRANSPORT_SSL)) {
323
Debug.println(8,"ReplicationAgreement.useSSL() = " + useSSL );
327
* Set the useSSL flag
329
public void setUseSSL(boolean val) {
334
* Get the useSSL flag
336
public boolean getUseSSL() {
341
* Set the useStartTLS flag
343
public void setUseStartTLS(String val) {
344
Debug.println(8,"ReplicationAgreement.useStartTLS() val = " + val);
345
if ((val != null) && val.equals(ReplicationTool.REPLICA_TRANSPORT_TLS)) {
351
Debug.println(8,"ReplicationAgreement.useStartTLS() = " + useStartTLS );
355
* Set the useSSL flag
357
public void setUseStartTLS(boolean val) {
362
* Get the useSSL flag
364
public boolean getUseStartTLS() {
369
* Set the setUseSSLAuth flag
371
public void setUseSSLAuth(String val) {
372
if (val.equalsIgnoreCase("true")) {
374
} else if (val.equals(ReplicationTool.REPLICA_BINDMETHOD_SSLCLIENTAUTH)) {
382
* Set the setUseSSLAuth flag
384
public void setUseSSLAuth(boolean val) {
389
* Get the useSSLAuth flag
391
public boolean getUseSSLAuth() {
396
* Set the setUseGSSAPIAuth flag
398
public void setUseGSSAPIAuth(String val) {
399
if (val.equalsIgnoreCase("true")) {
400
useGSSAPIAuth = true;
401
} else if (val.equals(ReplicationTool.REPLICA_BINDMETHOD_SASL_GSSAPI)) {
402
useGSSAPIAuth = true;
404
useGSSAPIAuth = false;
409
* Set the setUseGSSAPIAuth flag
411
public void setUseGSSAPIAuth(boolean val) {
416
* Get the setUseGSSAPIAuth flag
418
public boolean getUseGSSAPIAuth() {
419
return useGSSAPIAuth;
423
* Set the setUseDigestAuth flag
425
public void setUseDigestAuth(String val) {
426
if (val.equalsIgnoreCase("true")) {
427
useDigestAuth = true;
428
} else if (val.equals(ReplicationTool.REPLICA_BINDMETHOD_SASL_DIGEST_MD5)) {
429
useDigestAuth = true;
431
useDigestAuth = false;
436
* Set the setUseDigestAuth flag
438
public void setUseDigestAuth(boolean val) {
443
* Get the setUseDigestAuth flag
445
public boolean getUseDigestAuth() {
446
return useDigestAuth;
450
* Set the type of agreement.
452
public void setAgreementType(int type) {
453
agreementType = type;
457
* Get the agreement type
459
public int getAgreementType() {
460
return agreementType;
464
* Get the CN (common name) of this entry
466
public String getEntryCN() {
471
* Explicitly set the CN (common name) of this entry
473
public void setEntryCN(String cn) {
478
* Set the replica entry filter (for filtered replication)
480
public void setEntryFilter(String f) {
485
* Get the replica entry filter (for filtered replication)
487
public String getEntryFilter() {
492
* Get the type of attribute selection
494
public int getSelattrType() {
499
* Set the type of attribute selection
501
public void setSelattrType(int t) {
506
* Get the list of selected attributes
508
public Vector getSelectedAttributes() {
509
return selectedAttrs;
512
public String getSelectedAttributesString() {
514
if (selectedAttrs == null) {
517
Enumeration en = selectedAttrs.elements();
518
while (en.hasMoreElements()) {
519
retStr += (String)en.nextElement() + "\n";
525
* Set the list of selected attributes in Sorted Vector format
527
public void setSelectedAttributes(Vector s) {
532
* Set the list of selected attributes, sorting it on the
535
public void setSelectedAttributes(String s) {
536
// Parse the list into a set of attributes. Tokens are
537
// whitespace, newlines, tabs, colon, or comma.
538
// The sorting algorithm is lame, but who cares? There
539
// aren't more than a few hundred elements, tops.
542
StringTokenizer st = new StringTokenizer(s, " \n\t:,", false);
543
Vector tmp = new Vector();
544
while (st.hasMoreTokens()) {
545
tmp.addElement(st.nextToken());
548
// Convert to an array of objects
549
String[] arr = new String[tmp.size()];
552
// Sort "arr" with a cheesy bubble sort
553
for (i = arr.length; --i >= 0; ) {
554
boolean swapped = false;
555
for (j = 0; j < i; j++) {
556
if (arr[j].toLowerCase().compareTo(arr[j + 1].toLowerCase()) > 0) {
568
// Copy back into selectedAttrs
569
selectedAttrs = new Vector(arr.length);
570
for (i = 0; i < arr.length; i++) {
571
if (i < arr.length - 1) {
572
// Remove any duplicates
573
if (arr[i].equalsIgnoreCase(arr[i +1])) {
577
selectedAttrs.addElement(arr[i]);
582
* Return a long, descriptive string for this agreement
584
// public String getDescription() {
589
// host = consumerHost;
590
// port = consumerPort;
593
// if (r != null && port != 0) {
594
// r = r + " : " + port;
596
// if (nickname != null) {
597
// r = r + " (" + nickname + ")";
604
* Set agreement description
606
public void setDescription(String s){
610
public String getDescription(){
614
* Set a reference to the other replciation agreements
616
public void setAgreementTable(AgreementTable r) {
621
* Set the ORC value (one of "start", ???, or null)
623
public void setORCValue(String s) {
629
* Get the state of ORC at the time the entry was last read
631
public String getORCValue() {
637
* Return true if the agreement's DN has changed, false otherwise
639
public boolean agreementDNHasChanged() {
640
computeNewEntryCNandDN();
641
boolean changed = !DSUtil.equalDNs(origEntryDN, entryDN);
642
Debug.println( "ReplicationAgreement.agreementDNHasChanged: " +
643
origEntryDN + (changed ? " <> " : " = ") +
649
* Construct a new entry CN and DNbased on the replica root, host,
652
protected void computeNewEntryCNandDN() {
654
String xdn[] = LDAPDN.explodeDN(origEntryDN, false);
655
entryDN = "cn" + "=" + entryCN;
657
if (xdn == null || xdn.length == 0) {
660
for (int i = 1; i < xdn.length; i++) {
661
entryDN = entryDN + ", " + xdn[i];
667
* Return true if the agreement is new (that is, it does not yet
668
* exist as an entry in the server's database.
670
public boolean getAgreementIsNew() {
671
return agreementIsNew;
674
public int writeAgreementToServer() {
677
if (checkForReORC()) {
678
Debug.println("ReplicationAgreement.writeAgreementToServer: " +
679
"Consumer needs to be reinitialized");
682
// First check for some common fixups we need to do:
683
// 1) If the agreement's subtree, host, or port number has changed,
684
// its DN will change.
685
switch (agreementType) {
686
case AGREEMENT_TYPE_MMR:
687
setConsumerHost(ReplicationTool.fullyQualifyHostName(
690
rc = ((MMRAgreement)this).writeToServer();
691
} catch (IOException e) {
692
Debug.println("ReplicationAgreement.writeAgreementToServer: " +
693
"Cannot save entry <" + entryDN +
694
"> to server: " + e );
697
case AGREEMENT_TYPE_LEGACYR:
698
setConsumerHost(ReplicationTool.fullyQualifyHostName(
701
rc = ((SIRAgreement)this).writeToServer();
702
} catch (IOException e) {
703
Debug.println("ReplicationAgreement.writeAgreementToServer: " +
704
"Cannot save entry <" + entryDN +
705
"> to server: " + e );
708
case AGREEMENT_TYPE_AD:
709
// case AGREEMENT_TYPE_NT:
710
setConsumerHost(ReplicationTool.fullyQualifyHostName(
713
rc = ((ActiveDirectoryAgreement)this).writeToServer();
714
} catch (IOException e) {
715
Debug.println("ReplicationAgreement.writeAgreementToServer: " +
716
"Cannot save entry <" + entryDN +
717
"> to server: " + e );
724
public void deleteAgreementFromServer() throws LDAPException {
725
LDAPConnection ld = _serverInfo.getLDAPConnection();
726
ld.delete(origEntryDN);
730
* Verify that the agreement is valid, and doesn't conflict with any
731
* other agreements we know about. "conflict" means has the same
732
* server, port, and subtree. Returns a vector of integers describing
733
* the errors, which will be empty if there were no errors.
735
public Vector checkForErrors() {
736
Vector errors = new Vector();
737
Enumeration replicasEnum = repList.elements();
740
ReplicationTool.fullyQualifyHostName(getRemoteHost())) != null) {
741
setRemoteHost(tmpHost);
743
while (replicasEnum.hasMoreElements()) {
744
ReplicationAgreement ra =
745
(ReplicationAgreement) replicasEnum.nextElement();
746
if (!ra.getRemoteHost().equalsIgnoreCase(getRemoteHost())) {
749
if (ra.getRemotePort() != getRemotePort()) {
752
if (!DSUtil.equalDNs(ra.getReplicatedSubtree(),
753
getReplicatedSubtree())) {
755
} else if (ra == this) {
756
// If it's this agreement, then it's ok.
760
errors.addElement(new Integer(AGREEMENT_EXISTS));
768
* Cause the replica to be updated immediately
770
public void updateNow() {
772
Debug.println("ReplicationAgreement.updateNow: begin");
773
if (agreementType == AGREEMENT_TYPE_LEGACYR) {
774
attrname = "replicaUpdateSchedule";
775
} else if (agreementType == AGREEMENT_TYPE_MMR || agreementType == AGREEMENT_TYPE_AD) {
776
attrname = ReplicationTool.REPLICA_SCHEDULE_ATTR;
781
LDAPModificationSet mods;
784
mods = new LDAPModificationSet();
785
attr = new LDAPAttribute(attrname, "*");
786
mods.add(LDAPModification.ADD, attr);
788
} catch (LDAPException me) {
789
Debug.println("Unable to add value \"*\" to attribute " + attrname + ": " + me.toString());
792
if (agreementType == AGREEMENT_TYPE_LEGACYR) {
794
mods = new LDAPModificationSet();
795
attr = new LDAPAttribute("replicaUpdateReplayed", (String)null);
796
mods.add(LDAPModification.REPLACE, attr);
797
attr = new LDAPAttribute("replicaUpdateFailedAt", (String)null);
798
mods.add(LDAPModification.REPLACE, attr);
800
} catch (LDAPException me2) {
801
Debug.println("Unable to remove \"replicaUpdateReplayed\" and \"replicaUpdateFailedAt\" attributes: " + me2.toString());
806
mods = new LDAPModificationSet();
807
attr = new LDAPAttribute(attrname, "*");
808
mods.add(LDAPModification.DELETE, attr);
810
} catch (LDAPException me3) {
811
Debug.println("Unable to remove value \"*\" from attribute " + attrname + ": " + me3.toString());
817
* Cause online replica creation to begin for this agreement
818
* @return Status ot ORCTask
820
public int initializeConsumer() {
824
if (this.agreementType == AGREEMENT_TYPE_AD) {
825
title = _resource.getString("sync-node-orc", "title");
826
msg = _resource.getString("sync-node-orc",
829
title = _resource.getString("replication-node-orc", "title");
830
msg = _resource.getString("replication-node-orc",
833
SimpleProgressDialog dlgORC;
836
taskORC = new ORCTask(this);
838
IDSModel model = (IDSModel)_serverInfo.get( "dsresmodel" );
839
dlgORC = new SimpleProgressDialog (model.getFrame(), taskORC,
841
taskORC.setProgressDialog (dlgORC);
842
dlgORC.setModal(true);
843
dlgORC.setLocationRelativeTo(model.getFrame());
844
dlgORC.setVisible(true);
846
if (taskORC.getStatus() == 0) {
847
/* No problem launching initialization => we only display a message if it was not cancelled */
848
if (!dlgORC.isCancelled()) {
849
/* If we had no problems launching the initialization, we check what happened
850
with the first update */
851
if (taskORC.getFirstUpdateStatus() == 0) {
852
if (getStatusByKeyword(ReplicationTool.REPLICA_REFRESH_ATTR).equals(ReplicationTool.REPLICA_CONSUMER_INIT_IN_PROGRESS)) {
853
/* The initialization has been started, we have the first successful
854
result, but it has not finished ...*/
855
DSUtil.showInformationDialog(model.getFrame(),
856
"initconsumer-not-finished",
858
"replication-agreement",
861
/* The initialization has been started, we have the first successful
862
result, and it is finished ...*/
863
DSUtil.showInformationDialog(model.getFrame(),
864
"initconsumer-finished",
866
"replication-agreement",
870
/* We get the error message from the first update */
871
String[] args = {taskORC.getFirstUpdateMessage()};
872
if (getStatusByKeyword(ReplicationTool.REPLICA_REFRESH_ATTR).equals(ReplicationTool.REPLICA_CONSUMER_INIT_IN_PROGRESS)) {
873
/* The initialization has been started, the first result is no good
874
but the initialization has not finished ...*/
875
DSUtil.showErrorDialog(model.getFrame(),
876
"initconsumer-error-not-finished",
878
"replication-agreement",
881
/* The initialization has been started, the first result is no good
882
and the initialization is finished ...*/
883
DSUtil.showErrorDialog(model.getFrame(),
884
"initconsumer-error-finished",
886
"replication-agreement",
892
if (!dlgORC.isCancelled()) {
893
/* An exception was thrown inside the taskORC. We have the ldap error code in the status of the task
894
and the error sent by the server in the firstupdatemessage */
895
String ldapError = LDAPException.errorCodeToString(taskORC.getStatus());
896
String ldapMessage = taskORC.getFirstUpdateMessage();
898
if ((ldapMessage != null) &&
899
(ldapMessage.length() > 0)) {
900
ldapError = ldapError + ". "+ldapMessage;
902
String[] args = {ldapError};
903
DSUtil.showErrorDialog(model.getFrame(),
904
"initconsumer-local-error",
906
"replication-agreement",
909
/* An exception was thrown inside the taskORC and we tried to cancel the task.
910
We have the ldap error code in the status of the task and the error sent by the server in the firstupdatemessage */
911
String ldapError = LDAPException.errorCodeToString(taskORC.getStatus());
912
String ldapMessage = taskORC.getFirstUpdateMessage();
914
if ((ldapMessage != null) &&
915
(ldapMessage.length() > 0)) {
916
ldapError = ldapError + ". "+ldapMessage;
918
String[] args = {ldapError};
919
DSUtil.showErrorDialog(model.getFrame(),
920
"initconsumer-stop-local-error",
922
"replication-agreement",
926
return taskORC.getStatus();
930
* Create an LDIF file with data to initialize the consumer
932
* @param fileName Name of file for consumer data
933
* @return true if the file creation succeeded
935
public boolean populateLDIFFile (String fileName) {
936
/* Check if the file exists and show a warning message */
937
File file = new File(fileName);
938
if (DSUtil.fileExists(file)) {
939
JFrame frame = UtilConsoleGlobals.getActivatedFrame();
940
int response = DSUtil.showConfirmationDialog(frame,
941
"confirm-delete-export-file",
942
DSUtil.inverseAbreviateString(fileName, 30),
944
if ( response != JOptionPane.YES_OPTION ) {
948
String str = getDataVersion();
949
LDAPConnection ld = _serverInfo.getLDAPConnection();
950
boolean status = false;
951
boolean wasReadOnly = false;
952
// RM : TBD : We must add the database dn
953
String backendName = MappingUtils.getBackendForSuffix(_serverInfo.getLDAPConnection(), replicatedSubtree);
954
if (backendName == null) {
957
String dnDB = "cn="+backendName+"," + DSUtil.LDBM_BASE_DN;
958
/* Get read-only state of database */
961
wasReadOnly = ReadOnly.isReadOnly( _serverInfo, dnDB );
963
} catch ( LDAPException e ) {
964
Debug.println("ReplicationAgreement.populateLDIFFile() (1) "+e);
966
if ( status && !wasReadOnly ) {
967
/* Make server read-only */
968
status = ReadOnly.setReadOnly( _serverInfo, true, dnDB );
971
Hashtable attributes = new Hashtable();
973
attributes.put(LDAPExport.FILENAME, new LDAPAttribute(LDAPExport.FILENAME, fileName));
974
attributes.put(LDAPExport.USE_ONE_FILE, new LDAPAttribute(LDAPExport.USE_ONE_FILE, "TRUE"));
975
attributes.put(LDAPExport.INSTANCE, new LDAPAttribute(LDAPExport.INSTANCE, backendName));
976
attributes.put(LDAPExport.EXPORT_REPLICA, new LDAPAttribute(LDAPExport.EXPORT_REPLICA, "TRUE"));
978
IDSModel model = (IDSModel)_serverInfo.get( "dsresmodel" );
980
LDAPExport task = new LDAPExport(model, attributes);
982
if ( !wasReadOnly ) {
983
ReadOnly.setReadOnly( _serverInfo, false, dnDB );
990
* Create an LDIF file with data to initialize the consumer
992
* @param fileName Name of file for consumer data
993
* @return true if the file creation succeeded
995
public boolean populateLDIFFile (IDSModel model) {
996
String str = getDataVersion();
997
LDAPConnection ld = model.getServerInfo().getLDAPConnection();
998
boolean status = false;
999
boolean wasReadOnly = false;
1000
// RM : TBD : We must add the database dn
1001
String backendName = MappingUtils.getBackendForSuffix(ld, replicatedSubtree);
1002
if (backendName == null) {
1005
String dnDB = "cn="+backendName+"," + DSUtil.LDBM_BASE_DN;
1006
/* Get read-only state of database */
1008
wasReadOnly = ReadOnly.isReadOnly( model.getServerInfo(), dnDB );
1010
} catch ( LDAPException e ) {
1011
Debug.println("ReplicationAgreement.populateLDIFFile() (1) "+e);
1013
if ( status && !wasReadOnly ) {
1014
/* Make server read-only */
1015
status = ReadOnly.setReadOnly( model.getServerInfo(), true, dnDB );
1018
DatabaseExportPanel child = new DatabaseExportPanel( model, backendName, true);
1019
String[] args = {backendName};
1020
String title = _resource.getString("replication-export", "title", args);
1021
SimpleDialog dlg = new SimpleDialog( model.getFrame(),
1024
SimpleDialog.CANCEL |
1027
dlg.setComponent( child );
1028
dlg.setOKButtonEnabled( false );
1029
dlg.setDefaultButton( SimpleDialog.OK );
1032
if ( !wasReadOnly ) {
1033
ReadOnly.setReadOnly( model.getServerInfo(), false, dnDB );
1038
void waitForORCCompletion (String attrname) throws LDAPException {
1040
LDAPSearchResults results = null;
1041
String filter="objectclass=*";
1042
LDAPConnection ldc = _serverInfo.getLDAPConnection ();
1043
LDAPConnection ldc_clone = (LDAPConnection)ldc.clone ();
1044
LDAPSearchConstraints cons=ldc_clone.getSearchConstraints();
1048
LDAPSearchResults result;
1049
LDAPPersistSearchControl control;
1051
attrs = new String [1];
1052
attrs[0] = attrname;
1054
/* return intermidiate results */
1055
cons.setBatchSize(1);
1057
/* setup persistent search control to be notified when
1058
start ORC is deleted */
1059
control = new LDAPPersistSearchControl(
1060
LDAPPersistSearchControl.MODIFY, false, false, false);
1061
cons.setServerControls(control);
1063
result = ldc_clone.search(entryDN, ldc_clone.SCOPE_BASE,
1064
filter, attrs, false, cons);
1066
while (!done && result.hasMoreElements ()) {
1067
entry = (LDAPEntry)result.nextElement ();
1069
value = DSUtil.getAttrValue (entry, attrname);
1071
if (!value.equalsIgnoreCase (ReplicationTool.REPLICA_CONSUMER_INIT_IN_PROGRESS))
1075
/* stop persistent serach */
1076
ldc_clone.abandon (result);
1077
ldc_clone.disconnect ();
1081
* Get the copiedFrom attribute for a particular subtree
1083
* @param subtree Directory subtree
1084
* @return The copiedFrom attribute
1086
public static String getCopiedFrom(LDAPConnection ld, String subtree) {
1087
String cfattr[] = { "copiedFrom" };
1090
LDAPEntry entry = ld.read(subtree, cfattr);
1091
if (entry != null) {
1092
LDAPAttribute attr = entry.getAttribute( "copiedFrom");
1093
if ( attr != null ) {
1094
Enumeration vals = attr.getStringValues();
1095
cf = (String)vals.nextElement();
1098
} catch (LDAPException le) {
1104
* Check to see if the consumer needs to be reinitialized based on
1107
* @return true if the consumer needs to be reinitialized
1109
public boolean checkForReORC() {
1110
Debug.print("ReplicationAgreement.checkforReOrc: ");
1111
if (agreementIsNew) {
1113
Debug.println("agreement is new");
1116
// This method could return true after the first needsReOrc,
1117
// but it seems to continue for debugging purposes
1119
// Check if replicatedSubtree has changed
1120
Debug.println(replicatedSubtree + " " + origReplicatedSubtree);
1121
if (!stringsEqualIgnoreCase(replicatedSubtree,
1122
origReplicatedSubtree)) {
1123
Debug.println("replicatedSubtree changed");
1126
// Check if consumerPort has changed
1127
if (consumerPort != origConsumerPort) {
1128
Debug.println("consumerPort changed");
1131
// Check if consumerHost has changed
1132
if (!stringsEqualIgnoreCase(consumerHost, origConsumerHost)) {
1133
Debug.println("consumerHost changed");
1136
// Check if entryFilter has changed
1137
if (!stringsEqualIgnoreCase(entryFilter, origEntryFilter)) {
1138
Debug.println("entryFilter changed");
1141
// Check if selattrType has changed
1142
if (selattrType != origSelattrType) {
1143
Debug.println("selattrType: (" + selattrType +
1144
") != (" + origSelattrType + ")");
1147
// Check if selectedAttrs has changed
1148
// Note: depends on the Vectors being sorted!
1149
if (selectedAttrs == null) {
1150
if (origSelectedAttrs != null) {
1151
Debug.println("selectedAttrs changed");
1155
if (origSelectedAttrs == null) {
1156
Debug.println("selectedAttrs changed");
1159
// Both Vectors non-null. Are they the same length?
1160
if (selectedAttrs.size() != origSelectedAttrs.size()) {
1161
Debug.println("selectedAttrs changed");
1164
// Same length. Compare all elements
1165
int max = selectedAttrs.size();
1167
while (i < max && !needsReORC) {
1168
String s1 = (String)selectedAttrs.elementAt(i);
1169
String s2 = (String)origSelectedAttrs.elementAt(i);
1170
if (!s1.equalsIgnoreCase(s2)) {
1171
Debug.println("selectedAttrs changed");
1179
if ( !needsReORC ) {
1180
Debug.println("no changes");
1186
* Get replication status from Directory
1188
public void updateAgreementFromServer() {
1189
LDAPConnection ldc = _serverInfo.getLDAPConnection();
1193
LDAPEntry entry = null;
1195
entry = ldc.read(getEntryDN());
1196
} catch (LDAPException e) {
1197
Debug.println("ReplicationAgreement.updateAgreementFromServer() "+e);
1199
if (entry == null) {
1206
DSUtil.getAttrValue(entry,
1207
ReplicationTool.REPLICA_LAST_UPDATE_STATUS_ATTR);
1208
if (val != null && val.length() > 0) {
1209
_status.put(ReplicationTool.REPLICA_LAST_UPDATE_STATUS_ATTR,
1212
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1213
"unable to read the replica status from " +
1214
DSUtil.format(ldc));
1217
val = DSUtil.getAttrValue(entry,
1218
ReplicationTool.REPLICA_N_CHANGES_SENT_ATTR);
1219
if (val != null && val.length() > 0) {
1220
_status.put(ReplicationTool.REPLICA_N_CHANGES_SENT_ATTR,
1223
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1224
"unable to read the replica number of changes from " +
1225
DSUtil.format(ldc));
1228
val = DSUtil.getAttrValue(entry,
1229
ReplicationTool.REPLICA_LAST_UPDATE_START_ATTR);
1230
if (val != null && val.length() > 0) {
1231
_status.put(ReplicationTool.REPLICA_LAST_UPDATE_START_ATTR,
1234
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1235
"unable to read the replica last update start from " +
1236
DSUtil.format(ldc));
1239
val = DSUtil.getAttrValue(entry,
1240
ReplicationTool.REPLICA_LAST_UPDATE_END_ATTR);
1241
if (val != null && val.length() > 0) {
1242
_status.put(ReplicationTool.REPLICA_LAST_UPDATE_END_ATTR,
1245
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1246
"unable to read the replica last update end from " +
1247
DSUtil.format(ldc));
1250
val = DSUtil.getAttrValue(entry,
1251
ReplicationTool.REPLICA_UPDATE_IN_PROGRESS_ATTR);
1252
if (val != null && val.length() > 0) {
1253
_status.put(ReplicationTool.REPLICA_UPDATE_IN_PROGRESS_ATTR,
1256
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1257
"unable to read the replica in progress from " +
1258
DSUtil.format(ldc));
1261
val = DSUtil.getAttrValue(entry,
1262
ReplicationTool.REPLICA_REFRESH_ATTR);
1263
if (val != null && val.length() > 0) {
1264
_status.put(ReplicationTool.REPLICA_REFRESH_ATTR,
1267
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1268
"unable to read the replica refresh attribute " +
1269
DSUtil.format(ldc));
1272
val = DSUtil.getAttrValue(entry,
1273
ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR);
1274
if (val != null && val.length() > 0) {
1275
_status.put(ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR,
1278
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1279
"unable to read the consumer initialization begin attribute (" +
1280
ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR + ") "+
1281
DSUtil.format(ldc));
1284
val = DSUtil.getAttrValue(entry,
1285
ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR);
1286
if (val != null && val.length() > 0) {
1287
_status.put(ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR,
1290
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1291
"unable to read the consumer initialization end attribute (" +
1292
ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR + ") "+
1293
DSUtil.format(ldc));
1296
val = DSUtil.getAttrValue(entry,
1297
ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR);
1298
if (val != null && val.length() > 0) {
1299
_status.put(ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR,
1302
Debug.println("ReplicationAgreement.updateAgreementFromServer: " +
1303
"unable to read the consumer initialization status attribute (" +
1304
ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR + ") "+
1305
DSUtil.format(ldc));
1310
nickname = DSUtil.getAttrValue(entry,
1311
ReplicationTool.MMR_NICKNAME_ATTR);
1313
_description = nickname;
1315
entryCN = DSUtil.getAttrValue(entry,
1316
ReplicationTool.MMR_NAME_ATTR);
1318
replicatedSubtree = DSUtil.getAttrValue(entry,
1319
ReplicationTool.REPLICA_ROOT_ATTR);
1320
origReplicatedSubtree = replicatedSubtree;
1322
String sConsumerPort = DSUtil.getAttrValue(entry,
1323
ReplicationTool.REPLICA_PORT_ATTR);
1325
int value = Integer.parseInt(sConsumerPort);
1326
consumerPort = value;
1327
origConsumerPort = consumerPort;
1328
} catch (Exception e) {
1331
consumerHost = DSUtil.getAttrValue(entry,
1332
ReplicationTool.REPLICA_HOST_ATTR);
1336
supplierHost = ldc.getHost();
1337
origSupplierHost = origSupplierHost;
1339
supplierPort = ldc.getPort();
1340
origSupplierPort = supplierPort;
1342
bindDN = DSUtil.getAttrValue(entry,
1343
ReplicationTool.REPLICA_BINDDN_ATTR);
1345
bindCredentials = DSUtil.getAttrValue(entry,
1346
ReplicationTool.REPLICA_CRED_ATTR);
1348
setUseSSL(DSUtil.getAttrValue(entry,
1349
ReplicationTool.REPLICA_TRANSPORT_ATTR));
1350
setUseStartTLS(DSUtil.getAttrValue(entry,
1351
ReplicationTool.REPLICA_TRANSPORT_ATTR));
1353
setUseSSLAuth(DSUtil.getAttrValue(entry,
1354
ReplicationTool.REPLICA_BINDMETHOD_ATTR));
1355
setUseGSSAPIAuth(DSUtil.getAttrValue(entry,
1356
ReplicationTool.REPLICA_BINDMETHOD_ATTR));
1357
setUseDigestAuth(DSUtil.getAttrValue(entry,
1358
ReplicationTool.REPLICA_BINDMETHOD_ATTR));
1360
String[] schedule = DSUtil.getAttrValues(entry,
1361
ReplicationTool.REPLICA_SCHEDULE_ATTR);
1363
Vector v = new Vector();
1364
if ((schedule != null) &&
1365
(schedule.length > 0)) {
1366
for (int i=0; i<schedule.length; i++) {
1367
v.addElement(schedule[i]);
1370
v.addElement(new String(""));
1372
setUpdateSchedule(v);
1377
* Get replication status from Directory
1379
public void updateReplicaStatus() {
1384
LDAPConnection ld = _serverInfo.getLDAPConnection();
1389
LDAPEntry entry = null;
1391
// Get the root DSE status attributes
1393
entry = ld.read(getEntryDN(), ReplicationTool.REPLICA_STATUS_ATTRS);
1394
} catch (LDAPException le2) {
1395
Debug.println("ReplicationAgreement.updateReplicaStatus: "+
1397
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1398
"unable to read the replication status from DN " +
1399
getEntryDN() + ": " + DSUtil.format(ld));
1403
Debug.println(9, "ReplicationAgreement.updateReplicaStatus: status " +
1404
"entry is " + entry.toString());
1406
DSUtil.getAttrValue(entry,
1407
ReplicationTool.REPLICA_LAST_UPDATE_STATUS_ATTR);
1408
if (val != null && val.length() > 0) {
1409
_status.put(ReplicationTool.REPLICA_LAST_UPDATE_STATUS_ATTR,
1412
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1413
"unable to read the replica status from " +
1417
val = DSUtil.getAttrValue(entry,
1418
ReplicationTool.REPLICA_N_CHANGES_SENT_ATTR);
1419
if (val != null && val.length() > 0) {
1420
_status.put(ReplicationTool.REPLICA_N_CHANGES_SENT_ATTR,
1423
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1424
"unable to read the replica number of changes from " +
1428
val = DSUtil.getAttrValue(entry,
1429
ReplicationTool.REPLICA_LAST_UPDATE_START_ATTR);
1430
if (val != null && val.length() > 0) {
1431
_status.put(ReplicationTool.REPLICA_LAST_UPDATE_START_ATTR,
1434
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1435
"unable to read the replica last update start from " +
1439
val = DSUtil.getAttrValue(entry,
1440
ReplicationTool.REPLICA_LAST_UPDATE_END_ATTR);
1441
if (val != null && val.length() > 0) {
1442
_status.put(ReplicationTool.REPLICA_LAST_UPDATE_END_ATTR,
1445
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1446
"unable to read the replica last update end from " +
1450
val = DSUtil.getAttrValue(entry,
1451
ReplicationTool.REPLICA_UPDATE_IN_PROGRESS_ATTR);
1452
if (val != null && val.length() > 0) {
1453
_status.put(ReplicationTool.REPLICA_UPDATE_IN_PROGRESS_ATTR,
1456
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1457
"unable to read the replica in progress from " +
1461
val = DSUtil.getAttrValue(entry,
1462
ReplicationTool.REPLICA_REFRESH_ATTR);
1463
if (val != null && val.length() > 0) {
1464
_status.put(ReplicationTool.REPLICA_REFRESH_ATTR,
1467
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1468
"unable to read the replica refresh attribute " +
1472
val = DSUtil.getAttrValue(entry,
1473
ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR);
1474
if (val != null && val.length() > 0) {
1475
_status.put(ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR,
1478
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1479
"unable to read the consumer initialization begin attribute (" +
1480
ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR + ") "+
1484
val = DSUtil.getAttrValue(entry,
1485
ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR);
1486
if (val != null && val.length() > 0) {
1487
_status.put(ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR,
1490
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1491
"unable to read the consumer initialization end attribute (" +
1492
ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR + ") "+
1496
val = DSUtil.getAttrValue(entry,
1497
ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR);
1498
if (val != null && val.length() > 0) {
1499
_status.put(ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR,
1502
Debug.println("ReplicationAgreement.updateReplicaStatus: " +
1503
"unable to read the consumer initialization status attribute (" +
1504
ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR + ") "+
1510
private String getStatusByKeyword(String keyword) {
1511
if (_status != null && _status.containsKey(keyword)) {
1512
return _status.get(keyword).toString();
1514
return _resource.getString("replication-info-status-code",
1518
public String getLastUpdateStatus() {
1519
return getStatusByKeyword(ReplicationTool.REPLICA_LAST_UPDATE_STATUS_ATTR);
1522
public String getInProgress() {
1523
return getStatusByKeyword(ReplicationTool.REPLICA_UPDATE_IN_PROGRESS_ATTR);
1526
public String getNChangesLast() {
1527
return getStatusByKeyword(ReplicationTool.REPLICA_N_CHANGES_SENT_ATTR);
1530
public String getLastUpdateBegin() {
1531
String sdt = getStatusByKeyword(ReplicationTool.REPLICA_LAST_UPDATE_START_ATTR);
1533
/* In this particular case, the date is not available */
1534
if (sdt.equals("0")) {
1535
return _resource.getString("replication-agreement", "lastupdatebegin-unknown-value");
1538
Date dt = DSUtil.getDateTime(sdt);
1540
return "null"; //XXX
1541
return dt.toString();
1544
public String getLastUpdateEnd() {
1545
String sdt = getStatusByKeyword(ReplicationTool.REPLICA_LAST_UPDATE_END_ATTR);
1547
/* In this particular case, the date is not available */
1548
if (sdt.equals("0")) {
1549
return _resource.getString("replication-agreement", "lastupdateend-unknown-value");
1552
Date dt = DSUtil.getDateTime(sdt);
1554
return "null"; //XXX
1555
return dt.toString();
1558
public String getConsumerInitializationBegin() {
1559
String sdt = getStatusByKeyword(ReplicationTool.REPLICA_CONSUMER_INIT_BEGIN_ATTR);
1561
/* In this particular case, the date is not available */
1562
if ((sdt.equals(_resource.getString("replication-info-status-code",
1564
(sdt.equals("0"))) {
1565
return _resource.getString("replication-agreement", "initconsumer-begin-unknown-value");
1568
Date dt = DSUtil.getDateTime(sdt);
1570
return "null"; //XXX
1571
return dt.toString();
1574
public String getConsumerInitializationEnd() {
1575
String sdt = getStatusByKeyword(ReplicationTool.REPLICA_CONSUMER_INIT_END_ATTR);
1577
/* In this particular case, the date is not available */
1578
if ((sdt.equals(_resource.getString("replication-info-status-code",
1580
(sdt.equals("0"))) {
1581
return _resource.getString("replication-agreement", "initconsumer-end-unknown-value");
1584
Date dt = DSUtil.getDateTime(sdt);
1586
return "null"; //XXX
1587
return dt.toString();
1590
public String getConsumerInitializationStatus() {
1591
String sdt = getStatusByKeyword(ReplicationTool.REPLICA_CONSUMER_INIT_STATUS_ATTR);
1595
public String getConsumerInitializationInProgress() {
1596
String sdt = getStatusByKeyword(ReplicationTool.REPLICA_REFRESH_ATTR);
1597
if ((sdt == null) ||
1598
!sdt.equals(ReplicationTool.REPLICA_CONSUMER_INIT_IN_PROGRESS)) {
1599
return _resource.getString("replication-agreement", "initconsumer-inprogress-false-value");
1601
return _resource.getString("replication-agreement", "initconsumer-inprogress-true-value");
1606
/*==========================================================
1608
*==========================================================*/
1610
protected void parseReplAttrList(LDAPAttribute attr) {
1611
// Note: we only support a single replicatedAttributeList attribute,
1612
// and that attribute must give a filter of "(objectclass=*)".
1614
// multiple attributes, or a different filter, then warn the user.
1615
boolean attrParsed = false;
1617
if (attr.size() == 0) {
1618
selattrType = SELATTR_ALL;
1622
if (attr.size() > 2) {
1623
selattrNotRepresentable = true;
1624
selattrType = SELATTR_ALL;
1628
String selAttrFilter = (String)attr.getStringValues().nextElement();
1629
if (selAttrFilter == null || selAttrFilter.length() == 0) {
1630
// no value in entry
1631
selectedAttrs = null;
1632
selattrType = SELATTR_ALL;
1634
StringTokenizer st =
1635
new StringTokenizer(selAttrFilter, "$", false);
1636
if (st.hasMoreTokens()) {
1637
String s = st.nextToken().trim();
1638
if (!"(objectclass=*)".equalsIgnoreCase(s)) {
1639
selattrNotRepresentable = true;
1643
selattrNotRepresentable = true;
1646
if (st.hasMoreTokens()) {
1647
String s = st.nextToken();
1649
st = new StringTokenizer(s, " ", false);
1650
if (st.hasMoreTokens()) {
1651
String incOrExc = st.nextToken();
1652
if ("include".equalsIgnoreCase(incOrExc)) {
1653
selattrType = SELATTR_INCLUDE;
1654
} else if ("exclude".equalsIgnoreCase(incOrExc)) {
1655
selattrType = SELATTR_EXCLUDE;
1659
String attrString = "";
1660
while (st.hasMoreTokens()) {
1661
attrString += st.nextToken() + " ";
1663
setSelectedAttributes(attrString);
1668
selattrNotRepresentable = true;
1673
protected String createReplicatedAttributesList() {
1674
if (selectedAttrs == null || selectedAttrs.size() == 0) {
1678
String attrList = "(objectclass=*) $ ";
1680
if (selattrType == SELATTR_INCLUDE) {
1681
attrList += "INCLUDE";
1682
} else if (selattrType == SELATTR_EXCLUDE) {
1683
attrList += "EXCLUDE";
1688
Enumeration selAttrsEnum = selectedAttrs.elements();
1689
while (selAttrsEnum.hasMoreElements()) {
1690
attrList += " " + (String)selAttrsEnum.nextElement();
1695
void updateEntry(LDAPModificationSet mods) throws LDAPException {
1700
LDAPConnection ld = _serverInfo.getLDAPConnection();
1701
Debug.println( "Replication.updateEntry: " + entryDN );
1702
ld.modify(entryDN, mods);
1707
protected void createNewEntry(LDAPEntry e) throws LDAPException {
1711
LDAPConnection ld = _serverInfo.getLDAPConnection();
1712
Debug.println( "Replication.createNewEntry: " + e.getDN() );
1718
protected void deleteOldEntry() throws LDAPException {
1719
LDAPConnection ld = _serverInfo.getLDAPConnection();
1720
Debug.println( "Replication.deleteOldEntry: " + getOrigEntryDN() );
1721
ld.delete(getOrigEntryDN());
1725
protected void disconnect(LDAPConnection ld) {
1729
} catch ( LDAPException e ) {
1734
/*==========================================================
1736
*==========================================================*/
1738
private boolean isSpecialNamingContext(String nc) {
1742
// Compare 2 strings. One or both can be null
1743
private boolean stringsEqualIgnoreCase(String s1, String s2) {
1744
boolean ret = false;
1756
if (s1.length() != s2.length()) {
1759
ret = s1.equalsIgnoreCase(s2);
1766
//convert General Time String to Date String
1767
static private String timeToString(String gt) {
1768
Calendar cal = Calendar.getInstance();
1770
cal.set(Integer.parseInt(gt.substring(0,4)),
1771
Integer.parseInt(gt.substring(4,6)) - 1,
1772
Integer.parseInt(gt.substring(6,8)),
1773
Integer.parseInt(gt.substring(8,10)),
1774
Integer.parseInt(gt.substring(10,12)),
1775
Integer.parseInt(gt.substring(12,14)));
1776
} catch (NumberFormatException e) {
1779
Date date = cal.getTime();
1780
DateFormat formatter =
1781
DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM);
1782
return formatter.format(date);
1786
/*==========================================================
1788
*==========================================================*/
1790
public String toString() {
1793
if (agreementType == AGREEMENT_TYPE_MMR) {
1794
ret += "Multi Master";
1795
} else if (agreementType == AGREEMENT_TYPE_LEGACYR) {
1797
} else if (agreementType == AGREEMENT_TYPE_AD) {
1803
ret += "Host: " + getRemoteHost() + "\n";
1804
ret += "Port: " + getRemotePort() + "\n";
1805
ret += "Subtree: " + replicatedSubtree + "\n";
1806
ret += "SSL: " + useSSL + "\n";
1807
ret += "TLS: " + useStartTLS + "\n";
1808
ret += "SSL Client Auth: " + useSSLAuth + "\n";
1809
ret += "SASL/GSSAPI Auth: " + useGSSAPIAuth + "\n";
1810
ret += "SASL/Digest-MD5 Auth: " + useDigestAuth + "\n";
1818
* Dump out a mods set for debugging
1820
private void modsDump(LDAPModificationSet mods) {
1821
Debug.println("ReplicationAgreement.modsDump:");
1823
Debug.println(" null");
1825
LDAPModification lm;
1828
Enumeration valuesEnum;
1829
for (int i = 0; i < mods.size(); i++) {
1830
lm = mods.elementAt(i);
1833
case LDAPModification.ADD:
1836
case LDAPModification.DELETE:
1837
Debug.print("delete");
1839
case LDAPModification.REPLACE:
1840
Debug.print("replace");
1843
Debug.print("unknown op (" + op + "): ");
1846
attr = lm.getAttribute();
1847
Debug.println(attr.getName());
1848
valuesEnum = attr.getStringValues();
1849
while ( (valuesEnum != null) &&
1850
valuesEnum.hasMoreElements()) {
1851
Debug.println(attr.getName() + ": " +
1852
(String)valuesEnum.nextElement());
1859
private String getDataVersion() {
1860
String baseDN = "cn=monitor";
1861
String filter = "objectclass=*";
1862
String[] attrs = {"dataversion"};
1864
LDAPConnection ld = _serverInfo.getLDAPConnection();
1866
LDAPSearchResults res = ld.search(baseDN, ld.SCOPE_BASE,
1867
filter, attrs, false);
1868
LDAPEntry entry = res.next();
1869
if (entry != null) {
1870
LDAPAttribute attr = entry.getAttribute(attrs[0]);
1872
Enumeration enums = attr.getStringValues();
1873
result = (String)enums.nextElement();
1874
Debug.println ("ReplicationAgreement.getDataversion: " + result);
1878
} catch (LDAPException e) {
1879
Debug.println("ReplicationAgreement.getDataversion: " + e );
1885
* Getter for property domain.
1886
* @return Value of windows domain (if applicable)
1888
public String getDomain() {
1893
* Setter for property domain.
1894
* @param domain New value of property domain.
1896
public void setDomain(String domain) {
1897
this.domain = domain;
1900
//==========================================================
1901
// UPDATED FUNCTIONALITY MOVED TO ReplicationTool.java
1903
// private String canonicalHost(String host)
1904
// protected String fullyQualifyHostName(String host)
1905
//==========================================================
1907
/*==========================================================
1909
*==========================================================*/
1910
public static final int AGREEMENT_TYPE_LEGACYR = 1;
1911
public static final int AGREEMENT_TYPE_MMR = 2;
1912
public static final int AGREEMENT_TYPE_CIR = 3;
1913
public static final int AGREEMENT_TYPE_SIR = 4;
1915
public static final int AGREEMENT_TYPE_AD = 5; //Active Directory
1916
public static final int AGREEMENT_TYPE_NT = 6; //legacy nt replication (not used)
1918
protected static final int CLOSE_AGREEMENT = 1;
1919
protected static final int KEEP_AGREEMENT = 2;
1921
protected String nickname; // A short, human-readable nickname for this agreement.
1922
protected String entryDN; // The DN of the entry containing this agreement.
1923
protected String origEntryDN; // DN of entry at time it was read from directory
1924
protected String entryCN; // CN of the entry containing this agreement.
1925
protected String replicatedSubtree; // The DN of the top of the replicated subtree.
1926
protected String supplierHost; // The host name for the supplier server.
1927
protected int supplierPort; // The port number of the supplier server process.
1928
protected String consumerHost; // The host name of the consumer server
1929
protected int consumerPort; // The post number of the consumer server process.
1930
protected String bindDN; // The DN to bind as when connecting to the consumer. XXX LDAPDN?
1931
protected String bindCredentials; // The credentials (password) used when connectin to the consumer.
1932
protected Vector updateSchedule; // Schedule(s) for updates
1933
//protected ReplicationAgreementEditor editor; // Reference to repl agrmt editor window. If null, no window is open
1934
protected boolean useSSL; // true if SSL should be used when connecting to remote server
1935
protected boolean useStartTLS; // true if startTLS should be used when connecting to remote server
1936
protected boolean useSSLAuth; // true if useSSL and strong auth by SSL required
1937
protected boolean useGSSAPIAuth; // true if using SASL/GSSAPI for auth
1938
protected boolean useDigestAuth; // true if using SASL/Digest-MD5 for auth
1939
protected int agreementType; // mmr or legacyr
1940
//protected Vector namingContexts; // Naming contexts supported by the server
1941
protected String orcValue; // non-null if replica is being reinitialized
1942
protected Vector selectedAttrs; // Attribute names for selective attribute replication
1943
protected int selattrType; // Either SELATTR_INCLUDE or SELATTR_EXCLUDE
1944
protected boolean selattrNotRepresentable; // true if the selective attribute repl info found in
1945
// config entry cannot be represented by this UI.
1946
protected String entryFilter; // LDAPFilter describing entries to replicate
1947
protected boolean filterNotRepresentable; // true if fitlered repl info found in config entry
1948
// cannot be represented by this UI.
1949
protected boolean agreementIsNew; // true if this is a new agreement, e.g. not read from srvr
1950
protected AgreementTable repList; // The other replication agreements (for validation)
1952
protected String origSupplierHost; // Original host name
1953
protected int origSupplierPort; // Original supplier port number
1954
protected int origConsumerPort; // Original consumer port number.
1955
protected String origConsumerHost; // Original consumer host name
1956
protected int origSelattrType; // Original type of selattr selection
1957
protected Vector origSelectedAttrs; // Originally-selected attributes
1958
protected String origEntryFilter; // Original entry filter
1959
protected String origReplicatedSubtree; // Original replicated subtree.
1960
protected String machineDataDN; // Machine Data DN of the Directory Server
1961
protected String _description;
1962
private boolean needsReORC; // If true, a change has been made which requires re-initting the consumer
1963
private ConsoleInfo _serverInfo;
1966
private Hashtable _status = new Hashtable();
1968
//get resource bundle
1969
private static ResourceSet _resource =
1970
new ResourceSet("com.netscape.admin.dirserv.panel.replication.replication");
1973
* Holds value of property domain.
1975
private String domain;