Skip to content

Commit

Permalink
RANGER-4724: updated importServiceTags API to handle missing service …
Browse files Browse the repository at this point in the history
…name in resources

Signed-off-by: Madhan Neethiraj <[email protected]>
  • Loading branch information
anandN872 authored and mneethiraj committed Feb 26, 2024
1 parent 84ef6e5 commit ca8d7fc
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ private void addOrUpdate(ServiceTags serviceTags) throws Exception {
for (int i = 0; i < resources.size(); i++) {
resource = resources.get(i);

if (StringUtils.isBlank(resource.getServiceName())) {
resource.setServiceName(serviceTags.getServiceName());
}

RangerServiceResource existing = null;
String resourceSignature = null;
Long resourceId = resource.getId();
Expand Down Expand Up @@ -178,9 +182,6 @@ private void addOrUpdate(ServiceTags serviceTags) throws Exception {
perf = RangerPerfTracer.getPerfTracer(PERF_LOG_ADD_OR_UPDATE, "tags.createOrUpdate_service_resource(" + resourceId + ")");
}
if (existing == null) {
if (StringUtils.isBlank(resource.getServiceName())) {
resource.setServiceName(serviceTags.getServiceName());
}
resourceInStore = tagStore.createServiceResource(resource);

} else if (StringUtils.isEmpty(resource.getServiceName()) || MapUtils.isEmpty(resource.getResourceElements())) {
Expand Down Expand Up @@ -515,11 +516,13 @@ private void delete(ServiceTags serviceTags) throws Exception {
if (CollectionUtils.isNotEmpty(serviceResources)) {

for (RangerServiceResource serviceResource : serviceResources) {
if (StringUtils.isBlank(serviceResource.getServiceName())) {
serviceResource.setServiceName(serviceTags.getServiceName());
}

RangerServiceResource objToDelete = null;

try {

if (StringUtils.isNotBlank(serviceResource.getGuid())) {
objToDelete = tagStore.getServiceResourceByGuid(serviceResource.getGuid());
}
Expand Down

0 comments on commit ca8d7fc

Please sign in to comment.