Repository: incubator-atlas
Updated Branches:
  refs/heads/master b2ec89d59 -> 2a93a6aa4


Move classification endpoint from Entities API to Entity API and remove 
Entities API


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/2a93a6aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/2a93a6aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/2a93a6aa

Branch: refs/heads/master
Commit: 2a93a6aa4090612c5c013037b40dfd687fc7f399
Parents: b2ec89d
Author: Vimal Sharma <[email protected]>
Authored: Tue Feb 14 14:49:15 2017 +0530
Committer: Vimal Sharma <[email protected]>
Committed: Tue Feb 14 14:49:15 2017 +0530

----------------------------------------------------------------------
 dashboardv2/public/js/utils/UrlLinks.js         |   2 +-
 release-log.txt                                 |   1 +
 .../org/apache/atlas/web/rest/EntitiesREST.java | 111 -------------------
 .../org/apache/atlas/web/rest/EntityREST.java   |  32 ++++++
 .../atlas/web/adapters/TestEntitiesREST.java    |   6 +-
 5 files changed, 35 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2a93a6aa/dashboardv2/public/js/utils/UrlLinks.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/UrlLinks.js 
b/dashboardv2/public/js/utils/UrlLinks.js
index 911650b..bdeda8d 100644
--- a/dashboardv2/public/js/utils/UrlLinks.js
+++ b/dashboardv2/public/js/utils/UrlLinks.js
@@ -57,7 +57,7 @@ define(['require', 'utils/Enums'], function(require, Enums) {
                 return this.baseUrlV2 + '/entity/guid/' + token + 
'/classifications';
             } else {
                 // For Multiple Assignment
-                return this.baseUrlV2 + '/entities/classification';
+                return this.baseUrlV2 + '/entity/bulk/classification';
             }
 
         },

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2a93a6aa/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index e2155f4..33dc8ce 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance 
improvements for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of 
Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1555 Move classification endpoint from Entities API to Entity API and 
remove Entities API (svimal2106)
 ATLAS-1548 Create entity : Change PUT and POST object structure based on new 
API Changes (kevalbhatt)
 ATLAS-1522 entity type attributes (like hive_table.sd, hive_table.columns) 
should use AtlasObjectId as value instead of entire entity contents (mneethiraj)
 ATLAS-1546 Hive hook should choose appropriate JAAS config when host uses 
kerberos ticket-cache (nixonrodrigues,gss2002 via mneethiraj)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2a93a6aa/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java 
b/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
deleted file mode 100644
index 5acad55..0000000
--- a/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.atlas.web.rest;
-
-import org.apache.atlas.AtlasClient;
-import org.apache.atlas.AtlasErrorCode;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.exception.AtlasBaseException;
-import org.apache.atlas.model.instance.AtlasClassification;
-import org.apache.atlas.model.instance.AtlasEntity;
-import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
-import org.apache.atlas.model.instance.ClassificationAssociateRequest;
-import org.apache.atlas.model.instance.EntityMutationResponse;
-import org.apache.atlas.repository.store.graph.AtlasEntityStore;
-import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream;
-import org.apache.atlas.repository.store.graph.v1.EntityStream;
-import org.apache.atlas.services.MetadataService;
-import org.apache.atlas.typesystem.ITypedStruct;
-import org.apache.atlas.web.adapters.AtlasInstanceRestAdapters;
-import org.apache.atlas.web.util.Servlets;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import java.util.List;
-
-import static 
org.apache.atlas.web.adapters.AtlasInstanceRestAdapters.toAtlasBaseException;
-
-
-@Path("v2/entities")
-@Singleton
-public class EntitiesREST {
-    private static final Logger LOG = 
LoggerFactory.getLogger(EntitiesREST.class);
-
-    private AtlasEntityStore entitiesStore;
-
-    @Context
-    private HttpServletRequest httpServletRequest;
-
-    private final MetadataService metadataService;
-
-    private final AtlasInstanceRestAdapters restAdapters;
-
-    @Inject
-    public EntitiesREST(AtlasEntityStore entitiesStore, MetadataService 
metadataService, AtlasInstanceRestAdapters restAdapters) {
-        LOG.info("EntitiesRest Init");
-        this.entitiesStore = entitiesStore;
-        this.metadataService = metadataService;
-        this.restAdapters = restAdapters;
-    }
-
-    /**
-     * Bulk API to associate a tag to multiple entities
-     *
-     */
-    @POST
-    @Path("/classification")
-    @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
-    @Produces(Servlets.JSON_MEDIA_TYPE)
-    public void addClassification(ClassificationAssociateRequest request) 
throws AtlasBaseException {
-        AtlasClassification classification = request == null ? null : 
request.getClassification();
-        List<String>        entityGuids    = request == null ? null : 
request.getEntityGuids();
-
-        if (classification == null || 
StringUtils.isEmpty(classification.getTypeName())) {
-            throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, 
"no classification");
-        }
-
-        if (CollectionUtils.isEmpty(entityGuids)) {
-            throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, 
"empty entity list");
-        }
-
-        final ITypedStruct trait = restAdapters.getTrait(classification);
-
-        try {
-            metadataService.addTrait(entityGuids, trait);
-        } catch (IllegalArgumentException e) {
-            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, 
e);
-        } catch (AtlasException e) {
-            throw toAtlasBaseException(e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2a93a6aa/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java 
b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
index 8ba9011..852b124 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
@@ -27,6 +27,7 @@ import org.apache.atlas.model.instance.AtlasClassification;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
+import org.apache.atlas.model.instance.ClassificationAssociateRequest;
 import org.apache.atlas.model.instance.EntityMutationResponse;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
 import org.apache.atlas.repository.store.graph.AtlasEntityStore;
@@ -390,6 +391,37 @@ public class EntityREST {
         }
     }
 
+    /**
+     * Bulk API to associate a tag to multiple entities
+     *
+     */
+    @POST
+    @Path("/bulk/classification")
+    @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
+    @Produces(Servlets.JSON_MEDIA_TYPE)
+    public void addClassification(ClassificationAssociateRequest request) 
throws AtlasBaseException {
+        AtlasClassification classification = request == null ? null : 
request.getClassification();
+        List<String>        entityGuids    = request == null ? null : 
request.getEntityGuids();
+
+        if (classification == null || 
org.apache.commons.lang.StringUtils.isEmpty(classification.getTypeName())) {
+            throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, 
"no classification");
+        }
+
+        if (CollectionUtils.isEmpty(entityGuids)) {
+            throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, 
"empty entity list");
+        }
+
+        final ITypedStruct trait = restAdapters.getTrait(classification);
+
+        try {
+            metadataService.addTrait(entityGuids, trait);
+        } catch (IllegalArgumentException e) {
+            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, 
e);
+        } catch (AtlasException e) {
+            throw toAtlasBaseException(e);
+        }
+    }
+
 
     private AtlasEntityType ensureEntityType(String typeName) throws 
AtlasBaseException {
         AtlasEntityType ret = typeRegistry.getEntityTypeByName(typeName);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/2a93a6aa/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
----------------------------------------------------------------------
diff --git 
a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java 
b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
index c667dc2..1df9d2f 100644
--- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
+++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
@@ -37,7 +37,6 @@ import org.apache.atlas.repository.graph.AtlasGraphProvider;
 import 
org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
 import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.web.rest.EntitiesREST;
 
 import org.apache.atlas.web.rest.EntityREST;
 import org.slf4j.Logger;
@@ -70,9 +69,6 @@ public class TestEntitiesREST {
     private AtlasTypeDefStore typeStore;
 
     @Inject
-    private EntitiesREST entitiesREST;
-
-    @Inject
     private EntityREST entityREST;
 
     private List<String> createdGuids = new ArrayList<>();
@@ -138,7 +134,7 @@ public class TestEntitiesREST {
     public void testTagToMultipleEntities() throws Exception{
         AtlasClassification tag = new 
AtlasClassification(TestUtilsV2.CLASSIFICATION, new HashMap<String, Object>() 
{{ put("tag", "tagName"); }});
         ClassificationAssociateRequest classificationAssociateRequest = new 
ClassificationAssociateRequest(createdGuids, tag);
-        entitiesREST.addClassification(classificationAssociateRequest);
+        entityREST.addClassification(classificationAssociateRequest);
         for (String guid : createdGuids) {
             final AtlasClassification result_tag = 
entityREST.getClassification(guid, TestUtilsV2.CLASSIFICATION);
             Assert.assertNotNull(result_tag);

Reply via email to