Skip to content

Commit 3914598

Browse files
author
Angie Zhang
authored
Fixed xContent dependencies due to OSCore changes (#392)
Signed-off-by: Angie Zhang <[email protected]>
1 parent 76375a7 commit 3914598

File tree

87 files changed

+348
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+348
-301
lines changed

Diff for: src/main/java/org/opensearch/commons/authuser/User.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import org.opensearch.common.io.stream.StreamInput;
2323
import org.opensearch.common.io.stream.StreamOutput;
2424
import org.opensearch.common.io.stream.Writeable;
25-
import org.opensearch.common.xcontent.ToXContent;
26-
import org.opensearch.common.xcontent.XContentBuilder;
2725
import org.opensearch.common.xcontent.XContentHelper;
28-
import org.opensearch.common.xcontent.XContentParser;
2926
import org.opensearch.common.xcontent.json.JsonXContent;
27+
import org.opensearch.core.xcontent.ToXContent;
28+
import org.opensearch.core.xcontent.XContentBuilder;
29+
import org.opensearch.core.xcontent.XContentParser;
3030

3131
/**
3232
* Gets current Authenticated User - name, odfe roles.

Diff for: src/main/kotlin/org/opensearch/commons/alerting/action/AcknowledgeAlertResponse.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ package org.opensearch.commons.alerting.action
66

77
import org.opensearch.common.io.stream.StreamInput
88
import org.opensearch.common.io.stream.StreamOutput
9-
import org.opensearch.common.xcontent.ToXContent
10-
import org.opensearch.common.xcontent.XContentBuilder
119
import org.opensearch.commons.alerting.model.Alert
1210
import org.opensearch.commons.notifications.action.BaseResponse
11+
import org.opensearch.core.xcontent.ToXContent
12+
import org.opensearch.core.xcontent.XContentBuilder
1313
import java.io.IOException
1414
import java.util.Collections
1515

@@ -45,7 +45,6 @@ class AcknowledgeAlertResponse : BaseResponse {
4545

4646
@Throws(IOException::class)
4747
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
48-
4948
builder.startObject().startArray("success")
5049
acknowledged.forEach { builder.value(it.id) }
5150
builder.endArray().startArray("failed")

Diff for: src/main/kotlin/org/opensearch/commons/alerting/action/AlertingActions.kt

+4
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ object AlertingActions {
1616
@JvmField
1717
val INDEX_MONITOR_ACTION_TYPE =
1818
ActionType(INDEX_MONITOR_ACTION_NAME, ::IndexMonitorResponse)
19+
1920
@JvmField
2021
val GET_ALERTS_ACTION_TYPE =
2122
ActionType(GET_ALERTS_ACTION_NAME, ::GetAlertsResponse)
23+
2224
@JvmField
2325
val DELETE_MONITOR_ACTION_TYPE =
2426
ActionType(DELETE_MONITOR_ACTION_NAME, ::DeleteMonitorResponse)
27+
2528
@JvmField
2629
val GET_FINDINGS_ACTION_TYPE =
2730
ActionType(GET_FINDINGS_ACTION_NAME, ::GetFindingsResponse)
31+
2832
@JvmField
2933
val ACKNOWLEDGE_ALERTS_ACTION_TYPE =
3034
ActionType(ACKNOWLEDGE_ALERTS_ACTION_NAME, ::AcknowledgeAlertResponse)

Diff for: src/main/kotlin/org/opensearch/commons/alerting/action/DeleteMonitorResponse.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package org.opensearch.commons.alerting.action
22

33
import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
5-
import org.opensearch.common.xcontent.ToXContent
6-
import org.opensearch.common.xcontent.XContentBuilder
75
import org.opensearch.commons.alerting.util.IndexUtils
86
import org.opensearch.commons.notifications.action.BaseResponse
7+
import org.opensearch.core.xcontent.ToXContent
8+
import org.opensearch.core.xcontent.XContentBuilder
99

1010
class DeleteMonitorResponse : BaseResponse {
1111
var id: String

Diff for: src/main/kotlin/org/opensearch/commons/alerting/action/GetAlertsResponse.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package org.opensearch.commons.alerting.action
22

33
import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
5-
import org.opensearch.common.xcontent.ToXContent
6-
import org.opensearch.common.xcontent.XContentBuilder
75
import org.opensearch.commons.alerting.model.Alert
86
import org.opensearch.commons.notifications.action.BaseResponse
7+
import org.opensearch.core.xcontent.ToXContent
8+
import org.opensearch.core.xcontent.XContentBuilder
99
import java.io.IOException
1010
import java.util.Collections
1111

Diff for: src/main/kotlin/org/opensearch/commons/alerting/action/GetFindingsResponse.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package org.opensearch.commons.alerting.action
22

33
import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
5-
import org.opensearch.common.xcontent.ToXContent
6-
import org.opensearch.common.xcontent.XContentBuilder
75
import org.opensearch.commons.alerting.model.FindingWithDocs
86
import org.opensearch.commons.notifications.action.BaseResponse
7+
import org.opensearch.core.xcontent.ToXContent
8+
import org.opensearch.core.xcontent.XContentBuilder
99
import org.opensearch.rest.RestStatus
1010
import java.io.IOException
1111

Diff for: src/main/kotlin/org/opensearch/commons/alerting/action/IndexMonitorResponse.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package org.opensearch.commons.alerting.action
22

33
import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
5-
import org.opensearch.common.xcontent.ToXContent
6-
import org.opensearch.common.xcontent.XContentBuilder
75
import org.opensearch.commons.alerting.model.Monitor
86
import org.opensearch.commons.alerting.util.IndexUtils.Companion._ID
97
import org.opensearch.commons.alerting.util.IndexUtils.Companion._PRIMARY_TERM
108
import org.opensearch.commons.alerting.util.IndexUtils.Companion._SEQ_NO
119
import org.opensearch.commons.alerting.util.IndexUtils.Companion._VERSION
1210
import org.opensearch.commons.notifications.action.BaseResponse
11+
import org.opensearch.core.xcontent.ToXContent
12+
import org.opensearch.core.xcontent.XContentBuilder
1313
import java.io.IOException
1414

1515
class IndexMonitorResponse : BaseResponse {

Diff for: src/main/kotlin/org/opensearch/commons/alerting/aggregation/bucketselectorext/BucketSelectorExtAggregationBuilder.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package org.opensearch.commons.alerting.aggregation.bucketselectorext
22

3-
import org.opensearch.common.ParseField
43
import org.opensearch.common.ParsingException
54
import org.opensearch.common.io.stream.StreamInput
65
import org.opensearch.common.io.stream.StreamOutput
7-
import org.opensearch.common.xcontent.ToXContent
8-
import org.opensearch.common.xcontent.XContentBuilder
9-
import org.opensearch.common.xcontent.XContentParser
106
import org.opensearch.commons.alerting.aggregation.bucketselectorext.BucketSelectorExtFilter.Companion.BUCKET_SELECTOR_COMPOSITE_AGG_FILTER
117
import org.opensearch.commons.alerting.aggregation.bucketselectorext.BucketSelectorExtFilter.Companion.BUCKET_SELECTOR_FILTER
8+
import org.opensearch.core.ParseField
9+
import org.opensearch.core.xcontent.ToXContent
10+
import org.opensearch.core.xcontent.XContentBuilder
11+
import org.opensearch.core.xcontent.XContentParser
1212
import org.opensearch.script.Script
1313
import org.opensearch.search.aggregations.pipeline.AbstractPipelineAggregationBuilder
1414
import org.opensearch.search.aggregations.pipeline.BucketHelpers

Diff for: src/main/kotlin/org/opensearch/commons/alerting/aggregation/bucketselectorext/BucketSelectorExtAggregator.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class BucketSelectorExtAggregator : SiblingPipelineAggregator {
129129
}
130130

131131
return BucketSelectorIndices(
132-
name(), parentBucketPath, selectedBucketsIndex, originalAgg.metadata
132+
name(),
133+
parentBucketPath,
134+
selectedBucketsIndex,
135+
originalAgg.metadata
133136
)
134137
}
135138

Diff for: src/main/kotlin/org/opensearch/commons/alerting/aggregation/bucketselectorext/BucketSelectorExtFilter.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package org.opensearch.commons.alerting.aggregation.bucketselectorext
22

3-
import org.opensearch.common.ParseField
43
import org.opensearch.common.ParsingException
54
import org.opensearch.common.io.stream.StreamInput
65
import org.opensearch.common.io.stream.StreamOutput
7-
import org.opensearch.common.xcontent.ToXContent
8-
import org.opensearch.common.xcontent.XContentBuilder
9-
import org.opensearch.common.xcontent.XContentParser
106
import org.opensearch.commons.notifications.model.BaseModel
7+
import org.opensearch.core.ParseField
8+
import org.opensearch.core.xcontent.ToXContent
9+
import org.opensearch.core.xcontent.XContentBuilder
10+
import org.opensearch.core.xcontent.XContentParser
1111
import org.opensearch.search.aggregations.bucket.terms.IncludeExclude
1212
import java.io.IOException
1313

1414
class BucketSelectorExtFilter : BaseModel {
1515
// used for composite aggregations
1616
val filtersMap: HashMap<String, IncludeExclude>?
17+
1718
// used for filtering string term aggregation
1819
val filters: IncludeExclude?
1920

Diff for: src/main/kotlin/org/opensearch/commons/alerting/aggregation/bucketselectorext/BucketSelectorIndices.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.opensearch.commons.alerting.aggregation.bucketselectorext
22

33
import org.opensearch.common.io.stream.StreamOutput
4-
import org.opensearch.common.xcontent.ToXContent
5-
import org.opensearch.common.xcontent.XContentBuilder
4+
import org.opensearch.core.xcontent.ToXContent
5+
import org.opensearch.core.xcontent.XContentBuilder
66
import org.opensearch.search.aggregations.InternalAggregation
77
import java.io.IOException
88
import java.util.Objects

Diff for: src/main/kotlin/org/opensearch/commons/alerting/alerts/AlertError.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package org.opensearch.commons.alerting.alerts
33
import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
55
import org.opensearch.common.io.stream.Writeable
6-
import org.opensearch.common.xcontent.ToXContent
7-
import org.opensearch.common.xcontent.XContentBuilder
8-
import org.opensearch.common.xcontent.XContentParser
96
import org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken
107
import org.opensearch.commons.alerting.util.instant
118
import org.opensearch.commons.alerting.util.optionalTimeField
9+
import org.opensearch.core.xcontent.ToXContent
10+
import org.opensearch.core.xcontent.XContentBuilder
11+
import org.opensearch.core.xcontent.XContentParser
1212
import java.io.IOException
1313
import java.time.Instant
1414

@@ -33,7 +33,6 @@ data class AlertError(val timestamp: Instant, val message: String) : Writeable,
3333
@JvmStatic
3434
@Throws(IOException::class)
3535
fun parse(xcp: XContentParser): AlertError {
36-
3736
lateinit var timestamp: Instant
3837
lateinit var message: String
3938

Diff for: src/main/kotlin/org/opensearch/commons/alerting/model/ActionExecutionResult.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package org.opensearch.commons.alerting.model
33
import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
55
import org.opensearch.common.io.stream.Writeable
6-
import org.opensearch.common.xcontent.ToXContent
7-
import org.opensearch.common.xcontent.ToXContentObject
8-
import org.opensearch.common.xcontent.XContentBuilder
9-
import org.opensearch.common.xcontent.XContentParser
106
import org.opensearch.common.xcontent.XContentParserUtils
117
import org.opensearch.commons.alerting.util.instant
128
import org.opensearch.commons.alerting.util.optionalTimeField
9+
import org.opensearch.core.xcontent.ToXContent
10+
import org.opensearch.core.xcontent.ToXContentObject
11+
import org.opensearch.core.xcontent.XContentBuilder
12+
import org.opensearch.core.xcontent.XContentParser
1313
import java.io.IOException
1414
import java.time.Instant
1515

Diff for: src/main/kotlin/org/opensearch/commons/alerting/model/AggregationResultBucket.kt

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import org.opensearch.common.ParsingException
44
import org.opensearch.common.io.stream.StreamInput
55
import org.opensearch.common.io.stream.StreamOutput
66
import org.opensearch.common.io.stream.Writeable
7-
import org.opensearch.common.xcontent.ToXContent
8-
import org.opensearch.common.xcontent.ToXContentObject
9-
import org.opensearch.common.xcontent.XContentBuilder
10-
import org.opensearch.common.xcontent.XContentParser
11-
import org.opensearch.common.xcontent.XContentParser.Token
127
import org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken
8+
import org.opensearch.core.xcontent.ToXContent
9+
import org.opensearch.core.xcontent.ToXContentObject
10+
import org.opensearch.core.xcontent.XContentBuilder
11+
import org.opensearch.core.xcontent.XContentParser
12+
import org.opensearch.core.xcontent.XContentParser.Token
1313
import java.io.IOException
1414
import java.util.Locale
1515

@@ -59,8 +59,10 @@ data class AggregationResultBucket(
5959
throw ParsingException(
6060
xcp.tokenLocation,
6161
String.format(
62-
Locale.ROOT, "Failed to parse object: expecting token with name [%s] but found [%s]",
63-
CONFIG_NAME, xcp.currentName()
62+
Locale.ROOT,
63+
"Failed to parse object: expecting token with name [%s] but found [%s]",
64+
CONFIG_NAME,
65+
xcp.currentName()
6466
)
6567
)
6668
}

Diff for: src/main/kotlin/org/opensearch/commons/alerting/model/Alert.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import org.opensearch.common.io.stream.StreamInput
44
import org.opensearch.common.io.stream.StreamOutput
55
import org.opensearch.common.io.stream.Writeable
66
import org.opensearch.common.lucene.uid.Versions
7-
import org.opensearch.common.xcontent.ToXContent
8-
import org.opensearch.common.xcontent.XContentBuilder
9-
import org.opensearch.common.xcontent.XContentParser
107
import org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken
118
import org.opensearch.commons.alerting.alerts.AlertError
129
import org.opensearch.commons.alerting.util.IndexUtils.Companion.NO_SCHEMA_VERSION
1310
import org.opensearch.commons.alerting.util.instant
1411
import org.opensearch.commons.alerting.util.optionalTimeField
1512
import org.opensearch.commons.alerting.util.optionalUserField
1613
import org.opensearch.commons.authuser.User
14+
import org.opensearch.core.xcontent.ToXContent
15+
import org.opensearch.core.xcontent.XContentBuilder
16+
import org.opensearch.core.xcontent.XContentParser
1717
import java.io.IOException
1818
import java.time.Instant
1919

@@ -216,10 +216,10 @@ data class Alert(
216216
const val NO_ID = ""
217217
const val NO_VERSION = Versions.NOT_FOUND
218218

219-
@JvmStatic @JvmOverloads
219+
@JvmStatic
220+
@JvmOverloads
220221
@Throws(IOException::class)
221222
fun parse(xcp: XContentParser, id: String = NO_ID, version: Long = NO_VERSION): Alert {
222-
223223
lateinit var monitorId: String
224224
var schemaVersion = NO_SCHEMA_VERSION
225225
lateinit var monitorName: String

Diff for: src/main/kotlin/org/opensearch/commons/alerting/model/BucketLevelTrigger.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package org.opensearch.commons.alerting.model
22

33
import org.opensearch.common.CheckedFunction
4-
import org.opensearch.common.ParseField
54
import org.opensearch.common.UUIDs
65
import org.opensearch.common.io.stream.StreamInput
76
import org.opensearch.common.io.stream.StreamOutput
8-
import org.opensearch.common.xcontent.NamedXContentRegistry
9-
import org.opensearch.common.xcontent.ToXContent
10-
import org.opensearch.common.xcontent.XContentBuilder
11-
import org.opensearch.common.xcontent.XContentParser
127
import org.opensearch.common.xcontent.XContentParserUtils
138
import org.opensearch.commons.alerting.aggregation.bucketselectorext.BucketSelectorExtAggregationBuilder
149
import org.opensearch.commons.alerting.model.Trigger.Companion.ACTIONS_FIELD
1510
import org.opensearch.commons.alerting.model.Trigger.Companion.ID_FIELD
1611
import org.opensearch.commons.alerting.model.Trigger.Companion.NAME_FIELD
1712
import org.opensearch.commons.alerting.model.Trigger.Companion.SEVERITY_FIELD
1813
import org.opensearch.commons.alerting.model.action.Action
14+
import org.opensearch.core.ParseField
15+
import org.opensearch.core.xcontent.NamedXContentRegistry
16+
import org.opensearch.core.xcontent.ToXContent
17+
import org.opensearch.core.xcontent.XContentBuilder
18+
import org.opensearch.core.xcontent.XContentParser
1919
import java.io.IOException
2020

2121
data class BucketLevelTrigger(
@@ -83,7 +83,8 @@ data class BucketLevelTrigger(
8383
const val PARENT_BUCKET_PATH = "parentBucketPath"
8484

8585
val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(
86-
Trigger::class.java, ParseField(BUCKET_LEVEL_TRIGGER_FIELD),
86+
Trigger::class.java,
87+
ParseField(BUCKET_LEVEL_TRIGGER_FIELD),
8788
CheckedFunction { parseInner(it) }
8889
)
8990

0 commit comments

Comments
 (0)