39
39
40
40
41
41
/**
42
- * This resource is intended to be used as top level resousce , instead of a sub resource.
42
+ * This resource is intended to be used as top level resource , instead of a sub resource.
43
43
* For sub-resource please use {@link BaseVersionedAspectResource}
44
44
*
45
45
* @param <URN> must be a valid {@link Urn} type
@@ -78,6 +78,13 @@ protected BaseRestliAuditor getAuditor() {
78
78
@ Nonnull
79
79
protected abstract BaseLocalDAO <ASPECT_UNION , URN > getLocalDAO ();
80
80
81
+ /**
82
+ * Returns {@link BaseLocalDAO} for shadowing the aspect.
83
+ */
84
+ protected BaseLocalDAO <ASPECT_UNION , URN > getLocalShadowDAO () {
85
+ return null ;
86
+ }
87
+
81
88
/**
82
89
* Get the ASPECT associated with URN.
83
90
*/
@@ -112,6 +119,10 @@ public Task<CreateResponse> create(@Nonnull URN urn, @Nonnull ASPECT aspect) {
112
119
return RestliUtils .toTask (() -> {
113
120
final AuditStamp auditStamp = getAuditor ().requestAuditStamp (getContext ().getRawRequestContext ());
114
121
getLocalDAO ().add (urn , aspect , auditStamp );
122
+ BaseLocalDAO <ASPECT_UNION , URN > shadowLocalDao = getLocalShadowDAO ();
123
+ if (shadowLocalDao != null ) {
124
+ shadowLocalDao .add (urn , aspect , auditStamp );
125
+ }
115
126
return new CreateResponse (HttpStatus .S_201_CREATED );
116
127
});
117
128
}
@@ -123,6 +134,10 @@ public Task<CreateResponse> createWithTracking(@Nonnull URN urn, @Nonnull ASPECT
123
134
return RestliUtils .toTask (() -> {
124
135
final AuditStamp auditStamp = getAuditor ().requestAuditStamp (getContext ().getRawRequestContext ());
125
136
getLocalDAO ().add (urn , aspect , auditStamp , trackingContext , ingestionParams );
137
+ BaseLocalDAO <ASPECT_UNION , URN > shadowLocalDao = getLocalShadowDAO ();
138
+ if (shadowLocalDao != null ) {
139
+ shadowLocalDao .add (urn , aspect , auditStamp , trackingContext , ingestionParams );
140
+ }
126
141
return new CreateResponse (HttpStatus .S_201_CREATED );
127
142
});
128
143
}
@@ -138,6 +153,10 @@ public Task<CreateKVResponse<URN, ASPECT>> createAndGet(@Nonnull URN urn,
138
153
return RestliUtils .toTask (() -> {
139
154
final AuditStamp auditStamp = getAuditor ().requestAuditStamp (getContext ().getRawRequestContext ());
140
155
final ASPECT newValue = getLocalDAO ().add (urn , _aspectClass , createLambda , auditStamp );
156
+ BaseLocalDAO <ASPECT_UNION , URN > shadowLocalDao = getLocalShadowDAO ();
157
+ if (shadowLocalDao != null ) {
158
+ shadowLocalDao .add (urn , _aspectClass , createLambda , auditStamp );
159
+ }
141
160
return new CreateKVResponse <>(urn , newValue );
142
161
});
143
162
}
@@ -153,6 +172,10 @@ public Task<UpdateResponse> delete(@Nonnull URN urn) {
153
172
return RestliUtils .toTask (() -> {
154
173
final AuditStamp auditStamp = getAuditor ().requestAuditStamp (getContext ().getRawRequestContext ());
155
174
getLocalDAO ().delete (urn , this ._aspectClass , auditStamp );
175
+ BaseLocalDAO <ASPECT_UNION , URN > shadowLocalDao = getLocalShadowDAO ();
176
+ if (shadowLocalDao != null ) {
177
+ shadowLocalDao .delete (urn , this ._aspectClass , auditStamp );
178
+ }
156
179
return new UpdateResponse (HttpStatus .S_200_OK );
157
180
});
158
181
}
0 commit comments