ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-15867. VDF with newlines preventing valid repo files (ncole)
Date Wed, 13 Apr 2016 19:45:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 085b1c0a7 -> c7ba19a33


AMBARI-15867. VDF with newlines preventing valid repo files (ncole)


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

Branch: refs/heads/trunk
Commit: c7ba19a33431b46890688d5bb9cd6387146bf36c
Parents: 085b1c0
Author: Nate Cole <ncole@hortonworks.com>
Authored: Wed Apr 13 14:47:18 2016 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Wed Apr 13 15:45:30 2016 -0400

----------------------------------------------------------------------
 .../ambari/server/state/repository/Release.java |  2 -
 .../state/repository/VersionDefinitionXml.java  |  7 ++--
 .../server/state/repository/package-info.java   | 23 ++++++++++++
 .../server/state/stack/TrimmingAdapter.java     | 39 ++++++++++++++++++++
 .../ambari/server/state/stack/package-info.java | 21 +++++++++++
 .../AmbariManagementControllerTest.java         |  1 +
 .../state/repository/VersionDefinitionTest.java | 35 +++++++++++++++++-
 7 files changed, 122 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
index f855b05..39b30e7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
@@ -20,7 +20,6 @@ package org.apache.ambari.server.state.repository;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.ambari.server.state.RepositoryType;
 import org.apache.commons.lang.StringUtils;
@@ -28,7 +27,6 @@ import org.apache.commons.lang.StringUtils;
 /**
  * Release information for a repository.
  */
-@XmlRootElement(name="release")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class Release {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
index 4488f58..685a07c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
@@ -106,7 +106,7 @@ public class VersionDefinitionXml {
   /**
    * @param stack the stack info needed to lookup service and component display names
    * @return a collection of AvailableServices used for web service consumption.  This
-   * collection is either the subset of the manifest, or the manifest if no services
+   * collection is either the subset of the manifest, or the manifest itself if no services
    * are specified as "available".
    */
   public Collection<AvailableService> getAvailableServices(StackInfo stack) {
@@ -158,7 +158,8 @@ public class VersionDefinitionXml {
 
     for (ServiceInfo si : stack.getServices()) {
       Set<String> versions = manifestVersions.containsKey(si.getName()) ?
-          manifestVersions.get(si.getName()) : Collections.singleton("");
+          manifestVersions.get(si.getName()) : Collections.singleton(
+              null == si.getVersion() ? "" : si.getVersion());
 
       m_manifest.add(new ManifestServiceInfo(si.getName(), si.getDisplayName(),
           si.getComment(), versions));
@@ -365,4 +366,4 @@ public class VersionDefinitionXml {
 
   }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/main/java/org/apache/ambari/server/state/repository/package-info.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/package-info.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/package-info.java
new file mode 100644
index 0000000..dcc2d75
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * 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.
+ */
+@XmlJavaTypeAdapter(value=TrimmingAdapter.class,type=String.class)
+package org.apache.ambari.server.state.repository;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.ambari.server.state.stack.TrimmingAdapter;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/main/java/org/apache/ambari/server/state/stack/TrimmingAdapter.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/TrimmingAdapter.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/TrimmingAdapter.java
new file mode 100644
index 0000000..d3c3f66
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/TrimmingAdapter.java
@@ -0,0 +1,39 @@
+/**
+ * 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.ambari.server.state.stack;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Adapter that trims strings
+ */
+public class TrimmingAdapter extends XmlAdapter<String, String> {
+
+  @Override
+  public String marshal(String v) throws Exception {
+    return StringUtils.trim(v);
+  }
+
+  @Override
+  public String unmarshal(String v) throws Exception {
+    return StringUtils.trim(v);
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/main/java/org/apache/ambari/server/state/stack/package-info.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/package-info.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/package-info.java
new file mode 100644
index 0000000..f441670
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/package-info.java
@@ -0,0 +1,21 @@
+/**
+ * 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.
+ */
+@XmlJavaTypeAdapter(value=TrimmingAdapter.class,type=String.class)
+package org.apache.ambari.server.state.stack;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 186ebe7..5e38920 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -8519,6 +8519,7 @@ public class AmbariManagementControllerTest {
     requests.clear();
     request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE, REPO_ID);
     request.setBaseUrl("https://hortonworks.com");
+    request.setVerifyBaseUrl(false);
     requests.add(request);
     // test https url
     controller.updateRepositories(requests);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c7ba19a3/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
index d262df3..237eed2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
@@ -155,7 +155,7 @@ public class VersionDefinitionTest {
       } else if ("YARN".equals(msi.m_name)) {
         foundYarn = true;
         assertEquals(1, msi.m_versions.size());
-        assertEquals("", msi.m_versions.iterator().next());
+        assertEquals("1.1.1", msi.m_versions.iterator().next());
       } else if ("HIVE".equals(msi.m_name)) {
         foundHive = true;
         assertEquals(2, msi.m_versions.size());
@@ -208,6 +208,39 @@ public class VersionDefinitionTest {
     assertEquals(xml3.release.version, "2.3.4.1");
   }
 
+  @Test
+  public void testLoadingBadNewLine() throws Exception {
+    List<?> lines = FileUtils.readLines(file);
+
+    // crude
+    StringBuilder builder = new StringBuilder();
+    for (Object line : lines) {
+      String lineString = line.toString().trim();
+      if (lineString.startsWith("<baseurl>")) {
+        lineString = lineString.replace("<baseurl>", "");
+        lineString = lineString.replace("</baseurl>", "");
+
+        builder.append("<baseurl>\n");
+        builder.append(lineString).append('\n');
+        builder.append("</baseurl>\n");
+      } else if (lineString.startsWith("<version>")) {
+        lineString = lineString.replace("<version>", "");
+        lineString = lineString.replace("</version>", "");
+
+        builder.append("<version>\n");
+        builder.append(lineString).append('\n');
+        builder.append("</version>\n");
+      } else {
+        builder.append(line.toString().trim()).append('\n');
+      }
+    }
+
+    VersionDefinitionXml xml = VersionDefinitionXml.load(builder.toString());
+
+    validateXml(xml);
+  }
+
+
   private static ServiceInfo makeService(final String name) {
     return new ServiceInfo() {
       @Override


Mime
View raw message