From 4cb6cc72ab1be5789a3a6cdd756c6be36c62dc70 Mon Sep 17 00:00:00 2001 From: arpit-at Date: Wed, 24 Jul 2024 16:20:23 +0530 Subject: [PATCH] DG-1697: PR comments resolved --- .../repository/store/graph/v2/AtlasEntityStoreV2.java | 6 ++---- .../store/graph/v2/BusinessPolicyNotifierImpl.java | 2 +- .../org/apache/atlas/web/rest/BusinessPolicyREST.java | 10 ++-------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java index 73f2f7c526..9839e2e369 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java @@ -2738,7 +2738,7 @@ public void linkBusinessPolicy(String policyGuid, Set linkGuids) throws handleBusinessPolicyMutation(vertices); } catch (Exception e) { LOG.error("Error during linkBusinessPolicy for policyGuid: {}", policyGuid, e); - throw new AtlasBaseException("Failed to link business policy", e); + throw e; } finally { RequestContext.get().endMetricRecord(metric); } @@ -2748,10 +2748,8 @@ public void linkBusinessPolicy(String policyGuid, Set linkGuids) throws @GraphTransaction public void unlinkBusinessPolicy(String policyGuid, Set unlinkGuids) throws AtlasBaseException { AtlasPerfMetrics.MetricRecorder metric = RequestContext.get().startMetricRecord("unlinkBusinessPolicy.GraphTransaction"); - try { List vertices = this.entityGraphMapper.unlinkBusinessPolicy(policyGuid, unlinkGuids); - if (CollectionUtils.isEmpty(vertices)) { return; } @@ -2759,7 +2757,7 @@ public void unlinkBusinessPolicy(String policyGuid, Set unlinkGuids) thr handleBusinessPolicyMutation(vertices); } catch (Exception e) { LOG.error("Error during unlinkBusinessPolicy for policyGuid: {}", policyGuid, e); - throw new AtlasBaseException("Failed to unlink business policy", e); + throw e; } finally { RequestContext.get().endMetricRecord(metric); } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/BusinessPolicyNotifierImpl.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/BusinessPolicyNotifierImpl.java index a35cfa2fd2..84ee770d2c 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/BusinessPolicyNotifierImpl.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/BusinessPolicyNotifierImpl.java @@ -47,13 +47,13 @@ private AtlasEntity createAtlasEntity(AtlasVertex vertex, Map at atlasEntity.setAttributes(attributes); atlasEntity.setGuid(vertex.getProperty(GUID_PROPERTY_KEY, String.class)); atlasEntity.setTypeName(vertex.getProperty(TYPE_NAME_PROPERTY_KEY, String.class)); - atlasEntity.setStatus(vertex.getProperty(ATTR_CERTIFICATE_STATUS, AtlasEntity.Status.class)); atlasEntity.setCreatedBy(vertex.getProperty(CREATED_BY_KEY, String.class)); atlasEntity.setUpdatedBy(vertex.getProperty(MODIFIED_BY_KEY, String.class)); atlasEntity.setCreateTime(new Date(vertex.getProperty(TIMESTAMP_PROPERTY_KEY, Long.class))); atlasEntity.setUpdateTime(new Date(vertex.getProperty(MODIFICATION_TIMESTAMP_PROPERTY_KEY, Long.class))); atlasEntity.setIsProxy(vertex.getProperty(IS_PROXY_KEY, Boolean.class)); atlasEntity.setIsIncomplete(vertex.getProperty(IS_INCOMPLETE_PROPERTY_KEY, Boolean.class)); + atlasEntity.setStatus(getStatus(vertex)); atlasEntity.setProvenanceType(getProvenanceType(vertex)); atlasEntity.setCustomAttributes(getCustomAttributes(vertex)); atlasEntity.setHomeId(getHomeId(vertex)); diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/BusinessPolicyREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/BusinessPolicyREST.java index 82e830be94..9c7a94f687 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/BusinessPolicyREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/BusinessPolicyREST.java @@ -40,7 +40,7 @@ public BusinessPolicyREST(AtlasEntityStore entitiesStore) { * Links a business policy to entities. * * @param policyGuid the ID of the policy to be linked - * @param request the request containing the GUIDs of the assets to link the policy to + * @param request the request containing the GUIDs of the assets to link the policy to * @throws AtlasBaseException if there is an error during the linking process */ @POST @@ -65,9 +65,6 @@ public void linkBusinessPolicy(@PathParam("policyId") final String policyGuid, f // Link the business policy to the specified entities entitiesStore.linkBusinessPolicy(policyGuid, request.getLinkGuids()); - } catch (AtlasBaseException abe) { - LOG.error("Error in policy linking: ", abe); - throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "During Policy linking"); } finally { // Log performance metrics AtlasPerfTracer.log(perf); @@ -78,7 +75,7 @@ public void linkBusinessPolicy(@PathParam("policyId") final String policyGuid, f * Unlinks a business policy from entities. * * @param policyGuid the ID of the policy to be unlinked - * @param request the request containing the GUIDs of the assets to unlink the policy from + * @param request the request containing the GUIDs of the assets to unlink the policy from * @throws AtlasBaseException if there is an error during the unlinking process */ @POST @@ -103,9 +100,6 @@ public void unlinkBusinessPolicy(@PathParam("policyId") final String policyGuid, // Unlink the business policy from the specified entities entitiesStore.unlinkBusinessPolicy(policyGuid, request.getUnlinkGuids()); - } catch (AtlasBaseException abe) { - LOG.error("Error in policy unlinking: ", abe); - throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "During Policy unlinking"); } finally { // Log performance metrics AtlasPerfTracer.log(perf);