17
17
* under the License.
18
18
*/
19
19
20
- package org .elasticsearch .protocol . xpack .license ;
20
+ package org .elasticsearch .client .license ;
21
21
22
- import org .elasticsearch .action .support .master .AcknowledgedResponse ;
23
22
import org .elasticsearch .common .ParseField ;
24
- import org .elasticsearch .common .Strings ;
25
23
import org .elasticsearch .common .collect .Tuple ;
26
- import org .elasticsearch .common .io .stream .StreamInput ;
27
- import org .elasticsearch .common .io .stream .StreamOutput ;
28
24
import org .elasticsearch .common .xcontent .ConstructingObjectParser ;
29
- import org .elasticsearch .common .xcontent .XContentBuilder ;
30
25
import org .elasticsearch .common .xcontent .XContentParseException ;
31
26
import org .elasticsearch .common .xcontent .XContentParser ;
32
- import org .elasticsearch .protocol . xpack .common .ProtocolUtils ;
27
+ import org .elasticsearch .client .common .ProtocolUtils ;
33
28
34
29
import java .io .IOException ;
35
30
import java .util .ArrayList ;
42
37
import static org .elasticsearch .common .xcontent .ConstructingObjectParser .constructorArg ;
43
38
import static org .elasticsearch .common .xcontent .ConstructingObjectParser .optionalConstructorArg ;
44
39
45
- public class PutLicenseResponse extends AcknowledgedResponse {
40
+ public final class PutLicenseResponse {
46
41
47
42
private static final ConstructingObjectParser <PutLicenseResponse , Void > PARSER = new ConstructingObjectParser <>(
48
43
"put_license_response" , true , (a , v ) -> {
@@ -97,6 +92,7 @@ public class PutLicenseResponse extends AcknowledgedResponse {
97
92
new ParseField ("acknowledge" ));
98
93
}
99
94
95
+ private boolean acknowledged ;
100
96
private LicensesStatus status ;
101
97
private Map <String , String []> acknowledgeMessages ;
102
98
private String acknowledgeHeader ;
@@ -110,12 +106,16 @@ public PutLicenseResponse(boolean acknowledged, LicensesStatus status) {
110
106
111
107
public PutLicenseResponse (boolean acknowledged , LicensesStatus status , String acknowledgeHeader ,
112
108
Map <String , String []> acknowledgeMessages ) {
113
- super ( acknowledged ) ;
109
+ this . acknowledged = acknowledged ;
114
110
this .status = status ;
115
111
this .acknowledgeHeader = acknowledgeHeader ;
116
112
this .acknowledgeMessages = acknowledgeMessages ;
117
113
}
118
114
115
+ public boolean isAcknowledged () {
116
+ return acknowledged ;
117
+ }
118
+
119
119
public LicensesStatus status () {
120
120
return status ;
121
121
}
@@ -128,62 +128,6 @@ public String acknowledgeHeader() {
128
128
return acknowledgeHeader ;
129
129
}
130
130
131
- @ Override
132
- public void readFrom (StreamInput in ) throws IOException {
133
- super .readFrom (in );
134
- status = LicensesStatus .fromId (in .readVInt ());
135
- acknowledgeHeader = in .readOptionalString ();
136
- int size = in .readVInt ();
137
- Map <String , String []> acknowledgeMessages = new HashMap <>(size );
138
- for (int i = 0 ; i < size ; i ++) {
139
- String feature = in .readString ();
140
- int nMessages = in .readVInt ();
141
- String [] messages = new String [nMessages ];
142
- for (int j = 0 ; j < nMessages ; j ++) {
143
- messages [j ] = in .readString ();
144
- }
145
- acknowledgeMessages .put (feature , messages );
146
- }
147
- this .acknowledgeMessages = acknowledgeMessages ;
148
- }
149
-
150
- @ Override
151
- public void writeTo (StreamOutput out ) throws IOException {
152
- super .writeTo (out );
153
- out .writeVInt (status .id ());
154
- out .writeOptionalString (acknowledgeHeader );
155
- out .writeVInt (acknowledgeMessages .size ());
156
- for (Map .Entry <String , String []> entry : acknowledgeMessages .entrySet ()) {
157
- out .writeString (entry .getKey ());
158
- out .writeVInt (entry .getValue ().length );
159
- for (String message : entry .getValue ()) {
160
- out .writeString (message );
161
- }
162
- }
163
- }
164
-
165
- @ Override
166
- protected void addCustomFields (XContentBuilder builder , Params params ) throws IOException {
167
- builder .field ("license_status" , status .toString ());
168
- if (!acknowledgeMessages .isEmpty ()) {
169
- builder .startObject ("acknowledge" );
170
- builder .field ("message" , acknowledgeHeader );
171
- for (Map .Entry <String , String []> entry : acknowledgeMessages .entrySet ()) {
172
- builder .startArray (entry .getKey ());
173
- for (String message : entry .getValue ()) {
174
- builder .value (message );
175
- }
176
- builder .endArray ();
177
- }
178
- builder .endObject ();
179
- }
180
- }
181
-
182
- @ Override
183
- public String toString () {
184
- return Strings .toString (this , true , true );
185
- }
186
-
187
131
public static PutLicenseResponse fromXContent (XContentParser parser ) throws IOException {
188
132
return PARSER .parse (parser , null );
189
133
}
@@ -205,5 +149,4 @@ public int hashCode() {
205
149
return Objects .hash (super .hashCode (), status , ProtocolUtils .hashCode (acknowledgeMessages ), acknowledgeHeader );
206
150
}
207
151
208
-
209
152
}
0 commit comments