diff options
author | Ram Krishna Verma <ram_krishna.verma@bell.ca> | 2020-03-03 12:37:27 -0500 |
---|---|---|
committer | Ram Krishna Verma <ram_krishna.verma@bell.ca> | 2020-03-03 16:43:00 -0500 |
commit | 5949dbc9b1a3648a9d9f4046e565d0ca8be9149a (patch) | |
tree | d7b32d3ba5816d5efb4ae9ff7e9b951d75a53c36 /main/src | |
parent | 26df4c98fb4f1467a405608f761100575bbc34f8 (diff) |
Removing deployed from policy/api
The deployed API has already been created in PAP as part of Policy Update Notifications work.
Removing the corresponding one from policy/api to make sure that all run time administration
of PdpGroup and deployed policies are done only via PAP.
Leaving the deployed API's in legacy controller as they will be removed together.
Issue-ID: POLICY-1941
Change-Id: Ibe131f1aab3ec6a0eec05a2c91b5a140efc61b72
Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
Diffstat (limited to 'main/src')
4 files changed, 0 insertions, 127 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java index f9eff4c2..60ccba0f 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java @@ -36,11 +36,7 @@ import io.swagger.annotations.Info; import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SecurityDefinition;
import io.swagger.annotations.SwaggerDefinition;
-
-import java.util.List;
-import java.util.Map;
import java.util.UUID;
-
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -50,8 +46,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
-
-import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.api.main.rest.provider.HealthCheckProvider;
import org.onap.policy.api.main.rest.provider.PolicyProvider;
import org.onap.policy.api.main.rest.provider.PolicyTypeProvider;
@@ -62,7 +56,6 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil; import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -696,62 +689,6 @@ public class ApiRestController extends CommonRestController { }
/**
- * Retrieves deployed versions of a particular policy in PDP groups.
- *
- * @param policyTypeId the ID of specified policy type
- * @param policyTypeVersion the version of specified policy type
- * @param policyId the ID of specified policy
- *
- * @return the Response object containing the results of the API operation
- */
- @GET
- @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/deployed")
- @ApiOperation(value = "Retrieve deployed versions of a particular policy in pdp groups",
- notes = "Returns deployed versions of specified policy in pdp groups", response = ToscaPolicy.class,
- responseContainer = "List",
- responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
- response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by"
- + " the client on request",
- response = String.class),
- @ResponseHeader(name = "X-LatestVersion",
- description = "Used only to communicate an API's latest version", response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy",},
- extensions = {@Extension(name = "interface info",
- properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- public Response getDeployedVersionsOfPolicy(
- @PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
- @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
-
- try (PolicyProvider policyProvider = new PolicyProvider()) {
- Map<Pair<String, String>, List<ToscaPolicy>> deployedPolicies =
- policyProvider.fetchDeployedPolicies(policyTypeId, policyTypeVersion, policyId);
- updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
- return makeOkResponse(requestId, deployedPolicies);
- } catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/deployed", policyTypeId,
- policyTypeVersion, policyId, pfme);
- updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
- return makeErrorResponse(requestId, pfme);
- }
- }
-
- /**
* Creates a new policy for a particular policy type and version.
*
* @param policyTypeId the ID of specified policy type
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java index afed3165..35d0e805 100644 --- a/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java +++ b/main/src/main/java/org/onap/policy/api/main/rest/provider/PolicyProvider.java @@ -23,14 +23,7 @@ package org.onap.policy.api.main.rest.provider;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -84,24 +77,6 @@ public class PolicyProvider extends CommonModelProvider { }
/**
- * Retrieves a list of deployed policies in each pdp group.
- *
- * @param policyTypeId the ID of policy type
- * @param policyTypeVersion the version of policy type
- * @param policyId the ID of the policy
- *
- * @return a list of deployed policies in each pdp group
- *
- * @throws PfModelException the PfModel parsing exception
- */
- public Map<Pair<String, String>, List<ToscaPolicy>> fetchDeployedPolicies(String policyTypeId,
- String policyTypeVersion, String policyId) throws PfModelException {
-
- return collectDeployedPolicies(policyId, new PfConceptKey(policyTypeId, policyTypeVersion),
- modelsProvider::getPolicyList, List::addAll, new ArrayList<>(5));
- }
-
- /**
* Creates one or more new policies for the same policy type ID and version.
*
* @param policyTypeId the ID of policy type
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java index 7780ea7d..95a20692 100644 --- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java +++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java @@ -38,7 +38,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; - import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.ws.rs.client.Client; @@ -47,7 +46,6 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; - import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.junit.AfterClass; @@ -882,26 +880,6 @@ public class TestApiRestServer { } @Test - public void testGetDeployedVersionsOfPolicyJson() throws Exception { - testGetDeployedVersionsOfPolicy(APP_JSON); - } - - @Test - public void testGetDeployedVersionsOfPolicyYaml() throws Exception { - testGetDeployedVersionsOfPolicy(APP_YAML); - } - - private void testGetDeployedVersionsOfPolicy(String mediaType) throws Exception { - Response rawResponse = readResource(POLICYTYPES_TCA_POLICIES_VCPE_DEPLOYED, mediaType); - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus()); - ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class); - assertEquals( - "could not find policy with ID onap.restart.tca and type " - + "onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 deployed in any pdp group", - errorResponse.getErrorMessage()); - } - - @Test public void testGetLatestVersionOfOperationalPolicyJson() throws Exception { testGetLatestVersionOfOperationalPolicy(APP_JSON); } diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java index be9b5838..f458013d 100644 --- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java +++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.Base64; import java.util.Collections; import java.util.List; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -158,11 +157,6 @@ public class TestPolicyProvider { String policyTypeVersion = "1.0.0"; String policyTypeId = "onap.policies.monitoring.cdap.tca.hi.lo.app"; - // Basic Exception Throw - assertThatThrownBy(() -> { - policyProvider.fetchDeployedPolicies("dummy", "1.0.0", "dummy"); - }).hasMessage("could not find policy with ID dummy and type dummy:1.0.0 deployed in any pdp group"); - try (PolicyModelsProvider databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(providerParams)) { assertEquals(0, databaseProvider.getPdpGroups("name").size()); @@ -216,23 +210,12 @@ public class TestPolicyProvider { assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty()); }).doesNotThrowAnyException(); - // Test fetchDeployedPolicies (deployedPolicyMap.isEmpty())==true - assertThatThrownBy(() -> { - policyProvider.fetchDeployedPolicies(policyTypeId, policyTypeVersion, policyId); - }).hasMessage("could not find policy with ID " + policyId + " and type " + policyTypeId + ":" - + policyTypeVersion + " deployed in any pdp group"); - // Update pdpSubGroup pdpSubGroup.setPolicies(new ArrayList<>()); pdpSubGroup.getPolicies().add(new ToscaPolicyIdentifier(policyId, policyVersion)); assertEquals(1, databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getPolicies().size()); - // Test fetchDeployedPolicies - assertThatCode(() -> { - policyProvider.fetchDeployedPolicies(policyTypeId, policyTypeVersion, policyId); - }).doesNotThrowAnyException(); - // Test validateDeleteEligibility exception path(!pdpGroups.isEmpty()) assertThatThrownBy(() -> { policyProvider.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", |