5
5
*/
6
6
package org .elasticsearch .xpack .watcher .actions .index ;
7
7
8
- import org .apache .logging .log4j .LogManager ;
9
8
import org .elasticsearch .ElasticsearchParseException ;
10
9
import org .elasticsearch .action .support .WriteRequest .RefreshPolicy ;
11
10
import org .elasticsearch .common .Nullable ;
12
11
import org .elasticsearch .common .ParseField ;
13
- import org .elasticsearch .common .logging .DeprecationLogger ;
14
12
import org .elasticsearch .common .time .DateUtils ;
15
13
import org .elasticsearch .common .unit .TimeValue ;
16
14
import org .elasticsearch .common .xcontent .XContentBuilder ;
@@ -29,31 +27,17 @@ public class IndexAction implements Action {
29
27
30
28
public static final String TYPE = "index" ;
31
29
32
- @ Nullable @ Deprecated final String docType ;
33
30
@ Nullable final String index ;
34
31
@ Nullable final String docId ;
35
32
@ Nullable final String executionTimeField ;
36
33
@ Nullable final TimeValue timeout ;
37
34
@ Nullable final ZoneId dynamicNameTimeZone ;
38
35
@ Nullable final RefreshPolicy refreshPolicy ;
39
36
40
- private static final DeprecationLogger deprecationLogger = new DeprecationLogger (LogManager .getLogger (IndexAction .class ));
41
- public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher index action is deprecated." ;
42
-
43
37
public IndexAction (@ Nullable String index , @ Nullable String docId ,
44
38
@ Nullable String executionTimeField ,
45
39
@ Nullable TimeValue timeout , @ Nullable ZoneId dynamicNameTimeZone , @ Nullable RefreshPolicy refreshPolicy ) {
46
- this (index , null , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
47
- }
48
- /**
49
- * Document types are deprecated, use constructor without docType
50
- */
51
- @ Deprecated
52
- public IndexAction (@ Nullable String index , @ Nullable String docType , @ Nullable String docId ,
53
- @ Nullable String executionTimeField ,
54
- @ Nullable TimeValue timeout , @ Nullable ZoneId dynamicNameTimeZone , @ Nullable RefreshPolicy refreshPolicy ) {
55
40
this .index = index ;
56
- this .docType = docType ;
57
41
this .docId = docId ;
58
42
this .executionTimeField = executionTimeField ;
59
43
this .timeout = timeout ;
@@ -70,10 +54,6 @@ public String getIndex() {
70
54
return index ;
71
55
}
72
56
73
- public String getDocType () {
74
- return docType ;
75
- }
76
-
77
57
public String getDocId () {
78
58
return docId ;
79
59
}
@@ -97,7 +77,7 @@ public boolean equals(Object o) {
97
77
98
78
IndexAction that = (IndexAction ) o ;
99
79
100
- return Objects .equals (index , that .index ) && Objects .equals (docType , that . docType ) && Objects . equals ( docId , that .docId )
80
+ return Objects .equals (index , that .index ) && Objects .equals (docId , that .docId )
101
81
&& Objects .equals (executionTimeField , that .executionTimeField )
102
82
&& Objects .equals (timeout , that .timeout )
103
83
&& Objects .equals (dynamicNameTimeZone , that .dynamicNameTimeZone )
@@ -106,7 +86,7 @@ public boolean equals(Object o) {
106
86
107
87
@ Override
108
88
public int hashCode () {
109
- return Objects .hash (index , docType , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
89
+ return Objects .hash (index , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
110
90
}
111
91
112
92
@ Override
@@ -115,9 +95,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
115
95
if (index != null ) {
116
96
builder .field (Field .INDEX .getPreferredName (), index );
117
97
}
118
- if (docType != null ) {
119
- builder .field (Field .DOC_TYPE .getPreferredName (), docType );
120
- }
121
98
if (docId != null ) {
122
99
builder .field (Field .DOC_ID .getPreferredName (), docId );
123
100
}
@@ -138,7 +115,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
138
115
139
116
public static IndexAction parse (String watchId , String actionId , XContentParser parser ) throws IOException {
140
117
String index = null ;
141
- String docType = null ;
142
118
String docId = null ;
143
119
String executionTimeField = null ;
144
120
TimeValue timeout = null ;
@@ -165,10 +141,7 @@ public static IndexAction parse(String watchId, String actionId, XContentParser
165
141
watchId , actionId , currentFieldName );
166
142
}
167
143
} else if (token == XContentParser .Token .VALUE_STRING ) {
168
- if (Field .DOC_TYPE .match (currentFieldName , parser .getDeprecationHandler ())) {
169
- deprecationLogger .deprecatedAndMaybeLog ("watcher_index_action" , TYPES_DEPRECATION_MESSAGE );
170
- docType = parser .text ();
171
- } else if (Field .DOC_ID .match (currentFieldName , parser .getDeprecationHandler ())) {
144
+ if (Field .DOC_ID .match (currentFieldName , parser .getDeprecationHandler ())) {
172
145
docId = parser .text ();
173
146
} else if (Field .EXECUTION_TIME_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
174
147
executionTimeField = parser .text ();
@@ -194,15 +167,7 @@ public static IndexAction parse(String watchId, String actionId, XContentParser
194
167
}
195
168
}
196
169
197
- return new IndexAction (index , docType , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
198
- }
199
-
200
- /**
201
- * Document types are deprecated, use {@link #builder(java.lang.String)}
202
- */
203
- @ Deprecated
204
- public static Builder builder (String index , String docType ) {
205
- return new Builder (index , docType );
170
+ return new IndexAction (index , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
206
171
}
207
172
208
173
public static Builder builder (String index ) {
@@ -233,16 +198,14 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
233
198
static class Simulated extends Action .Result {
234
199
235
200
private final String index ;
236
- private final String docType ;
237
201
@ Nullable private final String docId ;
238
202
@ Nullable private final RefreshPolicy refreshPolicy ;
239
203
private final XContentSource source ;
240
204
241
- protected Simulated (String index , String docType , @ Nullable String docId , @ Nullable RefreshPolicy refreshPolicy ,
205
+ protected Simulated (String index , @ Nullable String docId , @ Nullable RefreshPolicy refreshPolicy ,
242
206
XContentSource source ) {
243
207
super (TYPE , Status .SIMULATED );
244
208
this .index = index ;
245
- this .docType = docType ;
246
209
this .docId = docId ;
247
210
this .source = source ;
248
211
this .refreshPolicy = refreshPolicy ;
@@ -252,10 +215,6 @@ public String index() {
252
215
return index ;
253
216
}
254
217
255
- public String docType () {
256
- return docType ;
257
- }
258
-
259
218
public String docId () {
260
219
return docId ;
261
220
}
@@ -268,8 +227,7 @@ public XContentSource source() {
268
227
public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
269
228
builder .startObject (type )
270
229
.startObject (Field .REQUEST .getPreferredName ())
271
- .field (Field .INDEX .getPreferredName (), index )
272
- .field (Field .DOC_TYPE .getPreferredName (), docType );
230
+ .field (Field .INDEX .getPreferredName (), index );
273
231
274
232
if (docId != null ) {
275
233
builder .field (Field .DOC_ID .getPreferredName (), docId );
@@ -288,25 +246,14 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
288
246
public static class Builder implements Action .Builder <IndexAction > {
289
247
290
248
final String index ;
291
- final String docType ;
292
249
String docId ;
293
250
String executionTimeField ;
294
251
TimeValue timeout ;
295
252
ZoneId dynamicNameTimeZone ;
296
253
RefreshPolicy refreshPolicy ;
297
254
298
- /**
299
- * Document types are deprecated and should not be used. Use: {@link Builder#Builder(java.lang.String)}
300
- */
301
- @ Deprecated
302
- private Builder (String index , String docType ) {
303
- this .index = index ;
304
- this .docType = docType ;
305
- }
306
-
307
255
private Builder (String index ) {
308
256
this .index = index ;
309
- this .docType = null ;
310
257
}
311
258
312
259
public Builder setDocId (String docId ) {
@@ -336,13 +283,12 @@ public Builder setRefreshPolicy(RefreshPolicy refreshPolicy) {
336
283
337
284
@ Override
338
285
public IndexAction build () {
339
- return new IndexAction (index , docType , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
286
+ return new IndexAction (index , docId , executionTimeField , timeout , dynamicNameTimeZone , refreshPolicy );
340
287
}
341
288
}
342
289
343
290
interface Field {
344
291
ParseField INDEX = new ParseField ("index" );
345
- ParseField DOC_TYPE = new ParseField ("doc_type" );
346
292
ParseField DOC_ID = new ParseField ("doc_id" );
347
293
ParseField EXECUTION_TIME_FIELD = new ParseField ("execution_time_field" );
348
294
ParseField SOURCE = new ParseField ("source" );
0 commit comments