X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fmain%2Fservice%2FPdpGroupService.java;h=09c9640f66433402907834e3a629a3ea59ed8069;hb=42c18ef1c6506e63151b55a96d90362da9fbda63;hp=5f0520ff76bc49f315a56738839e10296fb5e046;hpb=eb4cf2ad5d004cbfda90a752d10fbc6e91ef8fb4;p=policy%2Fpap.git diff --git a/main/src/main/java/org/onap/policy/pap/main/service/PdpGroupService.java b/main/src/main/java/org/onap/policy/pap/main/service/PdpGroupService.java index 5f0520ff..09c9640f 100644 --- a/main/src/main/java/org/onap/policy/pap/main/service/PdpGroupService.java +++ b/main/src/main/java/org/onap/policy/pap/main/service/PdpGroupService.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,9 +21,9 @@ package org.onap.policy.pap.main.service; +import jakarta.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; -import javax.ws.rs.core.Response; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.onap.policy.common.parameters.BeanValidationResult; @@ -151,11 +152,12 @@ public class PdpGroupService { * @param pdpGroup the name of the pdpGroup to delete */ public void deletePdpGroup(String pdpGroup) { - try { - pdpGroupRepository.deleteById(new PfConceptKey(pdpGroup, "0.0.0")); - } catch (Exception exc) { + PfConceptKey groupKey = new PfConceptKey(pdpGroup, "0.0.0"); + if (pdpGroupRepository.existsById(groupKey)) { + pdpGroupRepository.deleteById(groupKey); + } else { String errorMessage = "delete of PDP group \"" + pdpGroup + "\" failed, PDP group does not exist"; - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage, exc); + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); } }