ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [1/2] ambari git commit: AMBARI-17334. Registering 2.5 HDP repo URLs throwing 500 error in the backend (dlysnichenko)
Date Tue, 21 Jun 2016 10:59:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 979697bbf -> 04640850b
  refs/heads/trunk 6c2a17519 -> cc0478f2b


AMBARI-17334. Registering 2.5 HDP repo URLs throwing 500 error in the backend (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/04640850
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/04640850
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/04640850

Branch: refs/heads/branch-2.4
Commit: 04640850b3aeaf0bb037340390cf6e0a42898850
Parents: 979697b
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Tue Jun 21 13:58:26 2016 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Tue Jun 21 13:59:20 2016 +0300

----------------------------------------------------------------------
 .../ambari/server/orm/entities/RepositoryVersionEntity.java | 8 ++++++++
 .../CompatibleRepositoryVersionResourceProviderTest.java    | 9 +++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/04640850/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
index db393b9..5e5a0a8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
@@ -56,6 +56,8 @@ import org.slf4j.LoggerFactory;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
+import static java.util.Arrays.asList;
+
 @Entity
 @Table(name = "repo_version", uniqueConstraints = {
     @UniqueConstraint(columnNames = {"display_name"}),
@@ -77,6 +79,7 @@ import com.google.inject.Provider;
 @StaticallyInject
 public class RepositoryVersionEntity {
 
+  private static final List<String> STACK_PREFIXES = asList(StackId.HDP_STACK, StackId.HDPWIN_STACK);
   private static Logger LOG = LoggerFactory.getLogger(RepositoryVersionEntity.class);
 
   @Inject
@@ -387,6 +390,11 @@ public class RepositoryVersionEntity {
    */
   public static boolean isVersionInStack(StackId stackId, String version) {
     if (null != version && !StringUtils.isBlank(version)) {
+      for (String stackPrefix : STACK_PREFIXES) {
+        if (version.startsWith(stackPrefix + "-")) {
+          version = version.substring(stackPrefix.length() + 1);
+        }
+      }
       // HDP Stack
       if (stackId.getStackName().equalsIgnoreCase(StackId.HDP_STACK) ||
           stackId.getStackName().equalsIgnoreCase(StackId.HDPWIN_STACK)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/04640850/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
index 066e0d0..78f0a48 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
@@ -247,6 +247,15 @@ public class CompatibleRepositoryVersionResourceProviderTest {
   }
 
   @Test
+  public void testVersionInStack() {
+    assertTrue(RepositoryVersionEntity.isVersionInStack(new StackId("HDP", "2.3"), "2.3.0.0"));
+    assertTrue(RepositoryVersionEntity.isVersionInStack(new StackId("HDPWIN", "2.3"), "2.3.0.0"));
+
+    assertTrue(RepositoryVersionEntity.isVersionInStack(new StackId("HDP", "2.3"), "HDP-2.3.0.0"));
+    assertTrue(RepositoryVersionEntity.isVersionInStack(new StackId("HDPWIN", "2.3"), "HDPWIN-2.3.0.0"));
+  }
+
+  @Test
   public void testGetResources() throws Exception {
     SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createClusterAdministrator("admin",
2L));
 


Mime
View raw message