From b111bbed40e9fe02d980fe0af360f60ca47f5ac6 Mon Sep 17 00:00:00 2001 From: ojasdubey Date: Tue, 21 Aug 2018 17:55:30 +0530 Subject: Bugfix - Broken Action Library APIs 1. Fix for Sev-1 bug related to broken action library APIs due to cassandra driver upgrade to 3.x 2. Updated code based on review comments Change-Id: I4e62a7f2bf30a78d1f72f3c78ad8270985bcd56e Issue-ID: SDC-1669 Signed-off-by: ojasdubey --- .../sdc/action/dao/types/ActionEntity.java | 93 +++++++++------------- .../org/openecomp/sdc/action/types/Action.java | 73 +++++++++-------- 2 files changed, 77 insertions(+), 89 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api') diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java index 9d0f3d830d..17f6deaa72 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java @@ -1,22 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ +/* +* Copyright © 2016-2018 European Support Limited +* +* Licensed 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.openecomp.sdc.action.dao.types; @@ -24,15 +20,15 @@ import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.Frozen; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; -import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.action.types.Action; -import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.ArrayList; import java.util.Date; -import java.util.List; +import java.util.Set; import java.util.stream.Collectors; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.action.types.Action; +import org.openecomp.sdc.versioning.dao.types.Version; + @Table(keyspace = "dox", name = "Action") public class ActionEntity { @@ -51,17 +47,17 @@ public class ActionEntity { @Column(name = "name") private String name; @Column(name = "vendor_list") - private List vendorList; + private Set vendorList; @Column(name = "category_list") - private List categoryList; + private Set categoryList; @Column(name = "timestamp") private Date timestamp; @Column(name = "user") private String user; @Column(name = "supportedModels") - private List supportedModels; + private Set supportedModels; @Column(name = "supportedComponents") - private List supportedComponents; + private Set supportedComponents; @Column(name = "data") private String data; @@ -119,7 +115,7 @@ public class ActionEntity { this.name = name; } - public List getVendorList() { + public Set getVendorList() { return vendorList; } @@ -128,18 +124,12 @@ public class ActionEntity { * * @param vendorList the vendor list */ - public void setVendorList(List vendorList) { - if (vendorList != null && !vendorList.isEmpty()) { - List lowerCaseVendorList = new ArrayList<>(); - lowerCaseVendorList - .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList())); - this.vendorList = lowerCaseVendorList; - } else { - this.vendorList = vendorList; - } - } - - public List getCategoryList() { + public void setVendorList(Set vendorList) { + this.vendorList = vendorList != null && !vendorList.isEmpty() ? + vendorList.stream().map(String::toLowerCase).collect(Collectors.toSet()) : vendorList; + } + + public Set getCategoryList() { return categoryList; } @@ -148,15 +138,10 @@ public class ActionEntity { * * @param categoryList the category list */ - public void setCategoryList(List categoryList) { - if (categoryList != null && !categoryList.isEmpty()) { - List lowerCaseCategoryList = new ArrayList<>(); - lowerCaseCategoryList - .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList())); - this.categoryList = lowerCaseCategoryList; - } else { - this.categoryList = categoryList; - } + public void setCategoryList(Set categoryList) { + this.categoryList = categoryList != null && !categoryList.isEmpty() ? + categoryList.stream().map(String::toLowerCase).collect(Collectors.toSet()) : + categoryList; } public Date getTimestamp() { @@ -175,19 +160,19 @@ public class ActionEntity { this.user = user; } - public List getSupportedModels() { + public Set getSupportedModels() { return supportedModels; } - public void setSupportedModels(List supportedModels) { + public void setSupportedModels(Set supportedModels) { this.supportedModels = supportedModels; } - public List getSupportedComponents() { + public Set getSupportedComponents() { return supportedComponents; } - public void setSupportedComponents(List supportedComponents) { + public void setSupportedComponents(Set supportedComponents) { this.supportedComponents = supportedComponents; } diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java index cde97bc151..0acd051004 100644 --- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java @@ -1,34 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ +/* +* Copyright © 2016-2018 European Support Limited +* +* Licensed 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.openecomp.sdc.action.types; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + import org.openecomp.sdc.action.ActionConstants; import org.openecomp.sdc.action.dao.types.ActionEntity; import org.openecomp.sdc.versioning.dao.types.Version; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; - public class Action implements Comparable { private String actionUuId; private String actionInvariantUuId; @@ -40,8 +39,8 @@ public class Action implements Comparable { private List categoryList; private Date timestamp; private String user; - private List> supportedModels; - private List> supportedComponents; + private List> supportedModels; + private List> supportedComponents; //private List> artifacts; private List artifacts; private String data; @@ -151,19 +150,19 @@ public class Action implements Comparable { this.user = user; } - public List> getSupportedModels() { + public List> getSupportedModels() { return supportedModels; } - public void setSupportedModels(List> supportedModels) { + public void setSupportedModels(List> supportedModels) { this.supportedModels = supportedModels; } - public List> getSupportedComponents() { + public List> getSupportedComponents() { return supportedComponents; } - public void setSupportedComponents(List> supportedComponents) { + public void setSupportedComponents(List> supportedComponents) { this.supportedComponents = supportedComponents; } @@ -197,8 +196,12 @@ public class Action implements Comparable { destination.setActionInvariantUuId( this.getActionInvariantUuId() != null ? this.getActionInvariantUuId().toUpperCase() : null); destination.setName(this.getName() != null ? this.getName().toLowerCase() : null); - destination.setVendorList(this.getVendorList()); - destination.setCategoryList(this.getCategoryList()); + if (Objects.nonNull(this.getVendorList())) { + destination.setVendorList(new HashSet<>(this.getVendorList())); + } + if (Objects.nonNull(this.getCategoryList())) { + destination.setCategoryList(new HashSet<>(this.getCategoryList())); + } destination.setTimestamp(this.getTimestamp()); destination.setUser(this.getUser()); destination.setVersion(Version.valueOf(this.getVersion())); @@ -213,10 +216,10 @@ public class Action implements Comparable { return destination; } - private List getIdFromMap(List> map, String idName) { - List list = new ArrayList<>(); + private Set getIdFromMap(List> map, String idName) { + Set list = new HashSet<>(); if (map != null && !map.isEmpty()) { - for (HashMap entry : map) { + for (Map entry : map) { if (entry.containsKey(idName)) { list.add(entry.get(idName) != null ? entry.get(idName).toLowerCase() : null); } -- cgit 1.2.3-korg