diff options
3 files changed, 13 insertions, 6 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java b/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java index e4cfd74d3..4a3a4da66 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/converters/CDataConditioner.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2021 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. @@ -20,6 +21,7 @@ package org.onap.policy.models.dao.converters; +import com.google.re2j.Pattern; import javax.persistence.AttributeConverter; import javax.persistence.Converter; import javax.xml.bind.annotation.adapters.XmlAdapter; @@ -31,6 +33,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter; @Converter public class CDataConditioner extends XmlAdapter<String, String> implements AttributeConverter<String, String> { + private static final Pattern TRAILING_SPACE_PAT = Pattern.compile("\\s+$"); private static final String NL = "\n"; @Override @@ -63,7 +66,7 @@ public class CDataConditioner extends XmlAdapter<String, String> implements Attr if (in == null) { return null; } else { - return in.replaceAll("\\s+$", "").replaceAll("\\r?\\n", NL); + return TRAILING_SPACE_PAT.matcher(in).replaceAll("").replaceAll("\\r?\\n", NL); } } } diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java index 42a06acc4..d1e32935c 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java @@ -626,8 +626,12 @@ public class DefaultPfDao implements PfDao { final var mg = getEntityManager(); long size = 0; try { + /* + * The invoking code only passes well-known classes into this method, thus + * disabling the sonar about SQL injection. + */ size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class) - .getSingleResult(); + .getSingleResult(); // NOSONAR } finally { mg.close(); } diff --git a/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java b/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java index 7354fff5d..0e66217f4 100644 --- a/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java +++ b/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 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. @@ -33,9 +33,9 @@ import javax.persistence.Table; import lombok.Data; @Entity -@Table(name = "operationshistory", - indexes = {@Index(name = "operationshistory_clreqid_index", columnList = "closedLoopName,requestId"), - @Index(name = "operationshistory_target_index", columnList = "target,operation,actor")}) +@Table(name = "operationshistory", indexes = { + @Index(name = "operationshistory_clreqid_index", columnList = "requestId,closedLoopName"), + @Index(name = "operationshistory_target_index", columnList = "target,operation,actor,endtime")}) @Data public class OperationsHistory implements Serializable { |