Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3924D192AF for ; Wed, 13 Apr 2016 19:45:37 +0000 (UTC) Received: (qmail 53284 invoked by uid 500); 13 Apr 2016 19:45:37 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 53252 invoked by uid 500); 13 Apr 2016 19:45:37 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 53243 invoked by uid 99); 13 Apr 2016 19:45:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Apr 2016 19:45:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C8B44DFC13; Wed, 13 Apr 2016 19:45:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ncole@apache.org To: commits@ambari.apache.org Message-Id: <31da31fd67d34c3cb34b941fdf83d44c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-15867. VDF with newlines preventing valid repo files (ncole) Date: Wed, 13 Apr 2016 19:45:36 +0000 (UTC) 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 Authored: Wed Apr 13 14:47:18 2016 -0400 Committer: Nate Cole 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 getAvailableServices(StackInfo stack) { @@ -158,7 +158,8 @@ public class VersionDefinitionXml { for (ServiceInfo si : stack.getServices()) { Set 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 { + + @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("")) { + lineString = lineString.replace("", ""); + lineString = lineString.replace("", ""); + + builder.append("\n"); + builder.append(lineString).append('\n'); + builder.append("\n"); + } else if (lineString.startsWith("")) { + lineString = lineString.replace("", ""); + lineString = lineString.replace("", ""); + + builder.append("\n"); + builder.append(lineString).append('\n'); + builder.append("\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