1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.extras.extended.gracefulDisconnect;
21
22
23 import org.apache.directory.api.i18n.I18n;
24 import org.apache.directory.api.ldap.model.message.ExtendedResponseImpl;
25 import org.apache.directory.api.ldap.model.message.Referral;
26 import org.apache.directory.api.ldap.model.message.ReferralImpl;
27 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
28
29
30
31
32
33
34
35
36
37
38
39 public class GracefulDisconnectResponseImpl extends ExtendedResponseImpl implements GracefulDisconnectResponse
40 {
41
42 private int timeOffline;
43
44
45 private int delay;
46
47
48 private Referral replicatedContexts = new ReferralImpl();
49
50
51
52
53
54 public GracefulDisconnectResponseImpl()
55 {
56 super( 0, EXTENSION_OID );
57 }
58
59
60
61
62
63
64
65
66 public GracefulDisconnectResponseImpl( int timeOffline, int delay )
67 {
68 super( 0, EXTENSION_OID );
69 responseName = EXTENSION_OID;
70 this.timeOffline = timeOffline;
71 this.delay = delay;
72
73 StringBuffer buf = new StringBuffer();
74 buf.append( "The server will disconnect and will be unavailable for " ).append( timeOffline );
75 buf.append( " minutes in " ).append( delay ).append( " seconds." );
76
77 ldapResult.setDiagnosticMessage( buf.toString() );
78 ldapResult.setMatchedDn( null );
79 ldapResult.setResultCode( ResultCodeEnum.UNAVAILABLE );
80 }
81
82
83
84
85
86
87
88
89 public String getResponseName()
90 {
91 return EXTENSION_OID;
92 }
93
94
95
96
97
98
99
100
101 public void setResponseName( String oid )
102 {
103 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) );
104 }
105
106
107
108
109
110
111
112
113 public int getDelay()
114 {
115 return delay;
116 }
117
118
119
120
121
122 public void setDelay( int delay )
123 {
124 this.delay = delay;
125 }
126
127
128
129
130
131 public int getTimeOffline()
132 {
133 return timeOffline;
134 }
135
136
137
138
139
140 public void setTimeOffline( int timeOffline )
141 {
142 this.timeOffline = timeOffline;
143 }
144
145
146 public Referral getReplicatedContexts()
147 {
148 return replicatedContexts;
149 }
150
151
152
153
154
155
156 public void addReplicatedContexts( String replicatedContext )
157 {
158 replicatedContexts.addLdapUrl( replicatedContext );
159 }
160 }