You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@atlas.apache.org by "Apoorv Naik (JIRA)" <ji...@apache.org> on 2016/08/29 23:39:20 UTC
[jira] [Issue Comment Deleted] (ATLAS-1144) After updating/creating
a set of entities, response contains the first entity definition only
[ https://issues.apache.org/jira/browse/ATLAS-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Apoorv Naik updated ATLAS-1144:
-------------------------------
Comment: was deleted
(was: Index: webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java (revision f408e93eebfd870f7eef547438c41260f729fdd9)
+++ webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java (revision )
@@ -20,6 +20,8 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasConstants;
import org.apache.atlas.AtlasException;
@@ -35,6 +37,7 @@
import org.apache.atlas.utils.ParamChecker;
import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.atlas.web.util.Servlets;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
@@ -81,6 +84,7 @@
private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.EntityResource");
private static final String TRAIT_NAME = "traitName";
+ private static final String RESPONSE_TYPE = "responseType";
private final MetadataService metadataService;
@@ -181,7 +185,28 @@
String entityDefinition = metadataService.getEntityDefinition(sampleEntityId);
response.put(AtlasClient.DEFINITION, new JSONObject(entityDefinition));
}
+ // After adding a sample entity definition, add other definitions if needed
+ addAllEntityDefinitions(entityResult, response);
+
return response;
+ }
+
+ private void addAllEntityDefinitions(AtlasClient.EntityResult entityResult, JSONObject response)
+ throws JSONException, AtlasException {
+ // Check if responseType parameter is provided as a query parameter
+ String responseTypeParam = uriInfo.getQueryParameters().getFirst(RESPONSE_TYPE);
+ boolean provideFullResponse = StringUtils.isNotBlank(responseTypeParam)
+ && "full".equalsIgnoreCase(responseTypeParam);
+ // Provide full response only if the it's explicitly requested
+ if (provideFullResponse && CollectionUtils.isNotEmpty(entityResult.getCreatedEntities())){
+ List<JSONObject> entityDefinitions = Lists.newLinkedList();
+ for (String entityId : entityResult.getCreatedEntities()) {
+ entityDefinitions.add(new JSONObject(metadataService.getEntityDefinition(entityId)));
+ }
+ if (CollectionUtils.isNotEmpty(entityDefinitions)){
+ response.put("definitionList", new JSONArray(entityDefinitions));
+ }
+ }
}
/**
)
> After updating/creating a set of entities, response contains the first entity definition only
> ---------------------------------------------------------------------------------------------
>
> Key: ATLAS-1144
> URL: https://issues.apache.org/jira/browse/ATLAS-1144
> Project: Atlas
> Issue Type: Bug
> Affects Versions: 0.7-incubating
> Reporter: Apoorv Naik
> Fix For: 0.7-incubating
>
> Attachments: ATLAS_1144.patch
>
>
> Version: Atlas 0.7
> Steps to recreate:
> Create two entities (POST /entities) and note guid1 and guid2 that get generated.
> Update these entities in the same PUT /entities and response contains (truncated for convenience):
> {
> "requestId": "...",
> "GUID": [
> "guid1",
> "guid2"
> ],
> "definition": "{......*\"id\":\"guid1\"*,....}
> }
> {color:red}Issue: definition does not contain the data for second entity.{color}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)