This is an automated email from the ASF dual-hosted git repository.

swagle pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new 89dfc60  Revert "AMBARI-22934. [API] Updating current stack repo 
without GPL repos in the body does not throw any error. (mpapirkovkyy)" (#457)
89dfc60 is described below

commit 89dfc60ea77877dc0213596930f9c83ae7c3317e
Author: Siddharth <swa...@apache.org>
AuthorDate: Fri Feb 23 09:02:01 2018 -0800

    Revert "AMBARI-22934. [API] Updating current stack repo without GPL repos 
in the body does not throw any error. (mpapirkovkyy)" (#457)
    
    This reverts commit cad4b63ec782e34b2b9a77b0ee56f20602a198ab.
---
 .../controller/AmbariManagementControllerImpl.java |  3 +-
 .../RepositoryVersionResourceProvider.java         | 30 -------------
 .../stack/upgrade/RepositoryVersionHelper.java     | 36 +---------------
 .../RepositoryVersionResourceProviderTest.java     | 49 ----------------------
 .../stack/upgrade/RepositoryVersionHelperTest.java | 43 -------------------
 5 files changed, 3 insertions(+), 158 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index f7d4d7a..2f49bf3 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -190,6 +190,7 @@ import 
org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfile;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
 import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
 import org.apache.ambari.server.state.stack.OsFamily;
+import org.apache.ambari.server.state.stack.RepoTag;
 import org.apache.ambari.server.state.stack.RepositoryXml;
 import org.apache.ambari.server.state.stack.WidgetLayout;
 import org.apache.ambari.server.state.stack.WidgetLayoutInfo;
@@ -4505,7 +4506,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
         for (RepositoryXml.Repo repo : os.getRepos()) {
           RepositoryResponse resp = new RepositoryResponse(repo.getBaseUrl(), 
os.getFamily(),
               repo.getRepoId(), repo.getRepoName(), repo.getDistribution(), 
repo.getComponents(), repo.getMirrorsList(),
-              repo.getBaseUrl(), repo.getLatestUri(), 
Collections.<String>emptyList(), repo.getTags());
+              repo.getBaseUrl(), repo.getLatestUri(), 
Collections.<String>emptyList(), Collections.<RepoTag>emptySet());
 
           resp.setVersionDefinitionId(versionDefinitionId);
           resp.setStackName(stackId.getStackName());
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
index a3fe56e..73336ae 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
@@ -63,7 +63,6 @@ import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.repository.ManifestServiceInfo;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
-import org.apache.ambari.server.state.stack.RepoTag;
 import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.ObjectUtils;
@@ -497,10 +496,6 @@ public class RepositoryVersionResourceProvider extends 
AbstractAuthorizedResourc
       }
     }
 
-    if 
(RepositoryVersionHelper.shouldContainGPLRepo(repositoryVersion.getStackId(), 
repositoryVersion.getVersion())) {
-      validateGPLRepoPresence(repositoryVersion);
-    }
-
     if 
(!RepositoryVersionEntity.isVersionInStack(repositoryVersion.getStackId(), 
repositoryVersion.getVersion())) {
       throw new AmbariException(MessageFormat.format("Version {0} needs to 
belong to stack {1}",
           repositoryVersion.getVersion(), repositoryVersion.getStackName() + 
"-" + repositoryVersion.getStackVersion()));
@@ -508,31 +503,6 @@ public class RepositoryVersionResourceProvider extends 
AbstractAuthorizedResourc
   }
 
   /**
-   * Checks HDP repository version contains GPL repo for each os.
-   * @param repositoryVersion repository version to check.
-   * @throws AmbariException in case repository version id HDP and should 
contain GPL repo, bug shouldn't.
-   */
-  private static void validateGPLRepoPresence(RepositoryVersionEntity 
repositoryVersion) throws AmbariException {
-    if (!repositoryVersion.getStackName().equals("HDP")) {
-      return;
-    }
-    for (OperatingSystemEntity os : repositoryVersion.getOperatingSystems()) {
-      boolean hasGPLRepo = false;
-      for (RepositoryEntity repositoryEntity : os.getRepositories()) {
-        if (repositoryEntity.getTags().contains(RepoTag.GPL)) {
-          hasGPLRepo = true;
-        }
-      }
-      if (!hasGPLRepo) {
-        throw new AmbariException("Operating system type " + os.getOsType()
-            + " for repository with id " + repositoryVersion.getId()
-            + " should contain GPL repo for HDP repository version greater 
than "
-            + RepositoryVersionHelper.GPL_MINIMAL_VERSION);
-      }
-    }
-  }
-
-  /**
    * Transforms map of json properties to repository version entity.
    *
    * @param properties json map
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
index 3f7ccaf..5c12922 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
@@ -100,9 +100,6 @@ public class RepositoryVersionHelper {
 
   @Inject Provider<Clusters> clusters;
 
-  public static final String GPL_MINIMAL_VERSION = "2.6.4.0";
-  private static final String ZERO_VERSION = "0.0.0.0";
-  private static final String VERSION_SPLITTER = "\\.";
 
   /**
    * Checks repo URLs against the current version for the cluster and make
@@ -719,36 +716,5 @@ public class RepositoryVersionHelper {
     });
   }
 
-  /**
-   * Checks repository version is HDP and should contain repo with GPL tag.
-   * @param stackId stack id
-   * @param version repository version as x.x.x.x, x.x.x.x-x, x.x-x, x.x
-   * @return true if stack is HDP and version is younger than {@value 
#GPL_MINIMAL_VERSION}
-   */
-  public static boolean shouldContainGPLRepo(StackId stackId, String version) {
-    if (!stackId.getStackName().equals("HDP")) {
-      return false;
-    }
-    if (version.contains("-")) {
-      version = version.split("-")[0];
-    }
-    String[] versionItems = ZERO_VERSION.split(VERSION_SPLITTER);
-    int versionIndex = 0;
-    for (String versionItem : version.split(VERSION_SPLITTER)) {
-      versionItems[versionIndex++] = versionItem;
-    }
-    String[] gplMinimalItems = GPL_MINIMAL_VERSION.split(VERSION_SPLITTER);
-
-    for (versionIndex = 0; versionIndex < versionItems.length; versionIndex++) 
{
-      Integer versionItem = Integer.parseInt(versionItems[versionIndex]);
-      Integer gplMinimalItem = Integer.parseInt(gplMinimalItems[versionIndex]);
-      if (versionItem < gplMinimalItem) {
-        return false;
-      } else if (versionItem > gplMinimalItem) {
-        return true;
-      }
-    }
-    return true;
-  }
 
-}
+}
\ No newline at end of file
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
index 11b8d8b..243b060 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
@@ -18,8 +18,6 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -565,53 +563,6 @@ public class RepositoryVersionResourceProviderTest {
     Assert.assertEquals(false, RepositoryVersionEntity.isVersionInStack(sid3, 
"HDF-2.1"));
   }
 
-  private void testGPLRepoCheck(RepositoryVersionEntity 
repositoryVersionEntity) throws NoSuchMethodException,
-      InvocationTargetException, IllegalAccessException {
-    final ResourceProvider provider = 
injector.getInstance(ResourceProviderFactory.class)
-        .getRepositoryVersionResourceProvider();
-
-    Method validateGPLRepoMethod = 
RepositoryVersionResourceProvider.class.getDeclaredMethod("validateGPLRepoPresence",
-        RepositoryVersionEntity.class);
-    validateGPLRepoMethod.setAccessible(true);
-    validateGPLRepoMethod.invoke(provider, repositoryVersionEntity);
-  }
-
-  @Test
-  public void testGPLRepoCheckWithUnsatisfiedGPLRepoRequirement() throws 
NoSuchMethodException, InvocationTargetException, IllegalAccessException {
-    RepositoryVersionEntity repositoryVersionEntity = new 
RepositoryVersionEntity();
-    
repositoryVersionEntity.setOperatingSystems("[{\"repositories\":[],\"OperatingSystems/os_type\":\"debian7\"}]");
-
-    // check should not be failed for no-HDP stack
-    StackEntity hdpStackEntity = new StackEntity();
-    hdpStackEntity.setStackName("NOTHDP");
-    repositoryVersionEntity.setStack(hdpStackEntity);
-    testGPLRepoCheck(repositoryVersionEntity);
-
-    // should be failed for HDP only
-    hdpStackEntity.setStackName("HDP");
-    try {
-      testGPLRepoCheck(repositoryVersionEntity);
-    } catch (InvocationTargetException e) {
-      Assert.assertTrue(e.getTargetException() instanceof AmbariException);
-    }
-  }
-
-  @Test
-  public void testGPLRepoCheckWithSatisfiedGPLRepoRequirement() throws 
NoSuchMethodException, InvocationTargetException, IllegalAccessException {
-    RepositoryVersionEntity newRepositoryVersion = new 
RepositoryVersionEntity();
-    StackEntity hdpStackEntity = new StackEntity();
-    hdpStackEntity.setStackName("HDP");
-    newRepositoryVersion.setStack(hdpStackEntity);
-    
newRepositoryVersion.setOperatingSystems("[{\"repositories\":[{\"Repositories/repo_id\":\"\""
 +
-        
",\"Repositories/tags\":[\"GPL\"],\"Repositories/base_url\":\"\",\"Repositories/repo_name\":\"\"}"
 +
-        
",{\"Repositories/repo_id\":\"\",\"Repositories/tags\":[],\"Repositories/base_url\":\"\""
 +
-        
",\"Repositories/repo_name\":\"\"}],\"OperatingSystems/os_type\":\"debian7\"}]");
-
-    testGPLRepoCheck(newRepositoryVersion);
-
-    hdpStackEntity.setStackName("NOTHDP");
-    testGPLRepoCheck(newRepositoryVersion);
-  }
 
   @After
   public void after() throws AmbariException, SQLException {
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelperTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelperTest.java
index 909cecb..171eb88 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelperTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelperTest.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.StackId;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -56,46 +55,4 @@ public class RepositoryVersionHelperTest {
     final String serialized = helper.serializeOperatingSystems(repositories);
     
Assert.assertEquals("[{\"OperatingSystems/ambari_managed_repositories\":true,\"repositories\":[{\"Repositories/base_url\":\"baseurl\",\"Repositories/repo_id\":\"repoId\",\"Repositories/unique\":true,\"Repositories/tags\":[],\"Repositories/applicable_services\":[]}],\"OperatingSystems/os_type\":\"os\"}]",
 serialized);
   }
-
-  @Test
-  public void testGPLRepoIsRequired(){
-    String versionGreater1 = "2.7.0.3-75";
-    String versionGreater2 = "2.7.0.3";
-    String versionGreater3 = "2.7";
-    String versionEquals1 = "2.6.4.0-75";
-    String versionEquals2 = "2.6.4.0";
-    String versionEquals3 = "2.6.4";
-    String versionLower1 = "2.1.0.3-75";
-    String versionLower2 = "2.1.0.3";
-    String versionLower3 = "2.1";
-    StackId hdpStackId = new StackId();
-    hdpStackId.setStackId("HDP-x.x");
-
-    Assert.assertEquals(true, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionGreater1));
-    Assert.assertEquals(true, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionGreater2));
-    Assert.assertEquals(true, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionGreater3));
-
-    Assert.assertEquals(true, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionEquals1));
-    Assert.assertEquals(true, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionEquals2));
-    Assert.assertEquals(true, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionEquals3));
-
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionLower1));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionLower2));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(hdpStackId, versionLower3));
-
-    StackId nonHDPStackId = new StackId();
-    hdpStackId.setStackId("NOTHDP-x.x");
-
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionGreater1));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionGreater2));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionGreater3));
-
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionEquals1));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionEquals2));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionEquals3));
-
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionLower1));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionLower2));
-    Assert.assertEquals(false, 
RepositoryVersionHelper.shouldContainGPLRepo(nonHDPStackId, versionLower3));
-  }
 }

-- 
To stop receiving notification emails like this one, please contact
swa...@apache.org.

Reply via email to