* ================================================================================\r
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.\r
+ * Modifications Copyright (C) 2020-2023 Nordix Foundation.\r
* Modifications Copyright (C) 2020-2023 Bell Canada. All rights reserved.\r
* ================================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
\r
package org.onap.policy.api.main.rest;\r
\r
+import jakarta.ws.rs.core.Response.Status;\r
import java.util.List;\r
import java.util.UUID;\r
-import javax.ws.rs.core.Response.Status;\r
import lombok.RequiredArgsConstructor;\r
import org.onap.policy.api.main.exception.PolicyApiRuntimeException;\r
import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;\r
import org.onap.policy.models.base.PfModelRuntimeException;\r
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
import org.springframework.context.annotation.Profile;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
import org.springframework.http.ResponseEntity;\r
import org.springframework.web.bind.annotation.RestController;\r
\r
@Profile("default")\r
public class ApiRestController extends CommonRestController implements PolicyDesignApi {\r
\r
- private enum Target {\r
- POLICY,\r
- POLICY_TYPE,\r
- OTHER\r
- }\r
-\r
private final ToscaServiceTemplateService toscaServiceTemplateService;\r
private final HealthCheckProvider healthCheckProvider;\r
\r
* Retrieves all versions of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(\r
- String policyTypeId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);\r
return makeOkResponse(requestId, serviceTemplate);\r
* Retrieves specified version of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- * @param versionId the version of specified policy type\r
- *\r
+ * @param versionId the version of specified policy type\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(\r
- String policyTypeId,\r
- String versionId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String versionId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);\r
* Retrieves latest version of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(\r
- String policyTypeId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);\r
return makeOkResponse(requestId, serviceTemplate);\r
* Creates a new policy type.\r
*\r
* @param body the body of policy type following TOSCA definition\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> createPolicyType(\r
- ToscaServiceTemplate body,\r
- UUID requestId) {\r
+ ToscaServiceTemplate body,\r
+ UUID requestId) {\r
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));\r
}\r
* Deletes specified version of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- * @param versionId the version of specified policy type\r
- *\r
+ * @param versionId the version of specified policy type\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(\r
- String policyTypeId,\r
- String versionId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String versionId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);\r
/**\r
* Retrieves all versions of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getAllPolicies(\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);\r
/**\r
* Retrieves all versions of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(\r
- String policyId,\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);\r
/**\r
* Retrieves the specified version of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- * @param policyVersion the version of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
+ * @param policyVersion the version of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(\r
- String policyId,\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- String policyVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ String policyVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService\r
.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);\r
/**\r
* Retrieves the latest version of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(\r
- String policyId,\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);\r
/**\r
* Creates a new policy for a particular policy type and version.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param body the body of policy following TOSCA definition\r
- *\r
+ * @param body the body of policy following TOSCA definition\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> createPolicy(\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- ToscaServiceTemplate body,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ ToscaServiceTemplate body,\r
+ UUID requestId) {\r
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,\r
"/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));\r
/**\r
* Deletes the specified version of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- * @param policyVersion the version of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
+ * @param policyVersion the version of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getPolicies(\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);\r
/**\r
* Retrieves the specified version of a particular policy.\r
*\r
- * @param policyId the Name of specified policy\r
+ * @param policyId the Name of specified policy\r
* @param policyVersion the version of specified policy\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(\r
- String policyId,\r
- String policyVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);\r
* Creates one or more new policies in one call.\r
*\r
* @param body the body of policy following TOSCA definition\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
/**\r
* Deletes the specified version of a particular policy.\r
*\r
- * @param policyId the ID of specified policy\r
+ * @param policyId the ID of specified policy\r
* @param policyVersion the version of specified policy\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r