diff options
author | ojasdubey <ojas.dubey@amdocs.com> | 2018-08-21 17:55:30 +0530 |
---|---|---|
committer | ojasdubey <ojas.dubey@amdocs.com> | 2018-08-22 12:31:35 +0530 |
commit | b111bbed40e9fe02d980fe0af360f60ca47f5ac6 (patch) | |
tree | 71c5913289347dca52a2f01f93dc222ed52d0c55 /openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java | |
parent | 34db62e9a6b338219980c21ba9f39029f481f866 (diff) |
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 <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java')
2 files changed, 77 insertions, 89 deletions
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<String> vendorList; + private Set<String> vendorList; @Column(name = "category_list") - private List<String> categoryList; + private Set<String> categoryList; @Column(name = "timestamp") private Date timestamp; @Column(name = "user") private String user; @Column(name = "supportedModels") - private List<String> supportedModels; + private Set<String> supportedModels; @Column(name = "supportedComponents") - private List<String> supportedComponents; + private Set<String> supportedComponents; @Column(name = "data") private String data; @@ -119,7 +115,7 @@ public class ActionEntity { this.name = name; } - public List<String> getVendorList() { + public Set<String> getVendorList() { return vendorList; } @@ -128,18 +124,12 @@ public class ActionEntity { * * @param vendorList the vendor list */ - public void setVendorList(List<String> vendorList) { - if (vendorList != null && !vendorList.isEmpty()) { - List<String> lowerCaseVendorList = new ArrayList<>(); - lowerCaseVendorList - .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList())); - this.vendorList = lowerCaseVendorList; - } else { - this.vendorList = vendorList; - } - } - - public List<String> getCategoryList() { + public void setVendorList(Set<String> vendorList) { + this.vendorList = vendorList != null && !vendorList.isEmpty() ? + vendorList.stream().map(String::toLowerCase).collect(Collectors.toSet()) : vendorList; + } + + public Set<String> getCategoryList() { return categoryList; } @@ -148,15 +138,10 @@ public class ActionEntity { * * @param categoryList the category list */ - public void setCategoryList(List<String> categoryList) { - if (categoryList != null && !categoryList.isEmpty()) { - List<String> lowerCaseCategoryList = new ArrayList<>(); - lowerCaseCategoryList - .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList())); - this.categoryList = lowerCaseCategoryList; - } else { - this.categoryList = categoryList; - } + public void setCategoryList(Set<String> 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<String> getSupportedModels() { + public Set<String> getSupportedModels() { return supportedModels; } - public void setSupportedModels(List<String> supportedModels) { + public void setSupportedModels(Set<String> supportedModels) { this.supportedModels = supportedModels; } - public List<String> getSupportedComponents() { + public Set<String> getSupportedComponents() { return supportedComponents; } - public void setSupportedComponents(List<String> supportedComponents) { + public void setSupportedComponents(Set<String> 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<String> categoryList; private Date timestamp; private String user; - private List<HashMap<String, String>> supportedModels; - private List<HashMap<String, String>> supportedComponents; + private List<Map<String, String>> supportedModels; + private List<Map<String, String>> supportedComponents; //private List<HashMap<String,String>> artifacts; private List<ActionArtifact> artifacts; private String data; @@ -151,19 +150,19 @@ public class Action implements Comparable { this.user = user; } - public List<HashMap<String, String>> getSupportedModels() { + public List<Map<String, String>> getSupportedModels() { return supportedModels; } - public void setSupportedModels(List<HashMap<String, String>> supportedModels) { + public void setSupportedModels(List<Map<String, String>> supportedModels) { this.supportedModels = supportedModels; } - public List<HashMap<String, String>> getSupportedComponents() { + public List<Map<String, String>> getSupportedComponents() { return supportedComponents; } - public void setSupportedComponents(List<HashMap<String, String>> supportedComponents) { + public void setSupportedComponents(List<Map<String, String>> 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<String> getIdFromMap(List<HashMap<String, String>> map, String idName) { - List<String> list = new ArrayList<>(); + private Set<String> getIdFromMap(List<Map<String, String>> map, String idName) { + Set<String> list = new HashSet<>(); if (map != null && !map.isEmpty()) { - for (HashMap<String, String> entry : map) { + for (Map<String, String> entry : map) { if (entry.containsKey(idName)) { list.add(entry.get(idName) != null ? entry.get(idName).toLowerCase() : null); } |