From b836d3492984e8c751f00b200d24eb07da792c75 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Tue, 11 Jun 2019 13:41:48 +0200 Subject: BeanUtils upgrade to 1.9.x Transitive dependency to beanutils 1.8.3 removed. Refactor of existing usage of beanutils proposed. Change-Id: I6614a5794979225376338c778b25f71911ae9c50 Issue-ID: SDC-2269 Signed-off-by: Tomasz Golabek --- .../sdc/externalupload/utils/ServiceUtils.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'catalog-be') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/externalupload/utils/ServiceUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/externalupload/utils/ServiceUtils.java index 20501efab8..47e676dd25 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/externalupload/utils/ServiceUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/externalupload/utils/ServiceUtils.java @@ -12,16 +12,19 @@ * 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ package org.openecomp.sdc.externalupload.utils; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableSet; -import org.apache.commons.beanutils.BeanUtils; import java.lang.reflect.Field; import java.util.*; +import org.onap.sdc.tosca.services.CommonUtil; public class ServiceUtils { @@ -38,20 +41,11 @@ public class ServiceUtils { } Map objectAsMap = getObjectAsMap(objectCandidate); - T result = classToCreate.newInstance(); List declaredFields = getAllFields(classToCreate); - for( Field field : declaredFields){ - if(isComplexClass(field)){ - Optional objectUsingSetters = - createObjectUsingSetters(objectAsMap.get(field.getName()), field.getType()); - if( objectUsingSetters.isPresent()){ - objectAsMap.remove(field.getName()); - objectAsMap.put(field.getName(), objectUsingSetters.get()); - } - } - } - BeanUtils.populate(result, objectAsMap); + + CommonUtil.createSubObjectsUsingSetters(objectAsMap, declaredFields.toArray(new Field[0])); + T result = CommonUtil.populateBean(objectAsMap, classToCreate); return Optional.of(result); } -- cgit 1.2.3-korg