aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
authorAdam Krysiak <adam.krysiak@nokia.com>2019-03-13 08:10:33 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-13 08:10:33 +0000
commitd7df3862dd3af9b1b0062bd68bb183dd5a3416ed (patch)
tree42bef4799f9fcfbcf323992424fdc196b0fda7f6 /src/main/java/org/onap
parentf451ca668c1de480211b380b58e1010c47f28008 (diff)
parent89695a32a794bd1a12464878a7ce834b2e2e07d3 (diff)
Merge "Add updateGlobalPropertiesJson controller"
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java10
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java38
2 files changed, 38 insertions, 10 deletions
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index 7e4517492..2bcce1e37 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -24,6 +24,8 @@
package org.onap.clamp.loop;
import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
@@ -60,13 +62,17 @@ public class LoopController {
public Loop updateOperationalPolicies(String loopName, JsonArray operationalPoliciesJson) {
List<OperationalPolicy> operationalPolicies = JsonUtils.GSON
.fromJson(operationalPoliciesJson, OPERATIONAL_POLICY_TYPE);
- return loopService.updateOperationalPolicies(loopName, operationalPolicies);
+ return loopService.updateAndSaveOperationalPolicies(loopName, operationalPolicies);
}
public Loop updateMicroservicePolicies(String loopName, JsonArray microServicePoliciesJson) {
List<MicroServicePolicy> microservicePolicies = JsonUtils.GSON
.fromJson(microServicePoliciesJson, MICROSERVICE_POLICY_TYPE);
- return loopService.updateMicroservicePolicies(loopName, microservicePolicies);
+ return loopService.updateAndSaveMicroservicePolicies(loopName, microservicePolicies);
+ }
+
+ public Loop updateGlobalPropertiesJson(String loopName, JsonObject globalProperties){
+ return loopService.updateAndSaveGlobalPropertiesJson(loopName, globalProperties);
}
public String getSVGRepresentation(String loopName) {
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index 91b4bdf89..cf2f4c669 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -26,6 +26,8 @@ package org.onap.clamp.loop;
import java.util.List;
import java.util.Set;
import javax.persistence.EntityNotFoundException;
+
+import com.google.gson.JsonObject;
import org.onap.clamp.policy.microservice.MicroservicePolicyService;
import org.onap.clamp.policy.operational.OperationalPolicyService;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
@@ -66,22 +68,42 @@ public class LoopService {
return closedLoopByName.getSvgRepresentation();
}
- Loop updateOperationalPolicies(String loopName, List<OperationalPolicy> newOperationalPolicies) {
+ Loop updateAndSaveOperationalPolicies(String loopName, List<OperationalPolicy> newOperationalPolicies) {
Loop loop = findClosedLoopByName(loopName);
- Set<OperationalPolicy> newPolicies = operationalPolicyService
- .updatePolicies(loop, newOperationalPolicies);
+ updateOperationalPolicies(loop, newOperationalPolicies);
+ return loopsRepository.save(loop);
+ }
- loop.setOperationalPolicies(newPolicies);
+ Loop updateAndSaveMicroservicePolicies(String loopName, List<MicroServicePolicy> newMicroservicePolicies) {
+ Loop loop = findClosedLoopByName(loopName);
+ updateMicroservicePolicies(loop, newMicroservicePolicies);
return loopsRepository.save(loop);
}
- Loop updateMicroservicePolicies(String loopName, List<MicroServicePolicy> newMicroservicePolicies) {
+ Loop updateAndSaveGlobalPropertiesJson(String loopName, JsonObject newGlobalPropertiesJson) {
Loop loop = findClosedLoopByName(loopName);
- Set<MicroServicePolicy> newPolicies = microservicePolicyService
- .updatePolicies(loop, newMicroservicePolicies);
+ updateGlobalPropertiesJson(loop, newGlobalPropertiesJson);
+ return loopsRepository.save(loop);
+ }
+ private Loop updateOperationalPolicies(Loop loop, List<OperationalPolicy> newOperationalPolicies) {
+ Set<OperationalPolicy> newPolicies = operationalPolicyService
+ .updatePolicies(loop, newOperationalPolicies);
+
+ loop.setOperationalPolicies(newPolicies);
+ return loop;
+ }
+
+ private Loop updateMicroservicePolicies(Loop loop, List<MicroServicePolicy> newMicroservicePolicies) {
+ Set<MicroServicePolicy> newPolicies = microservicePolicyService
+ .updatePolicies(loop, newMicroservicePolicies);
loop.setMicroServicePolicies(newPolicies);
- return loopsRepository.save(loop);
+ return loop;
+ }
+
+ private Loop updateGlobalPropertiesJson(Loop loop, JsonObject newGlobalPropertiesJson) {
+ loop.setGlobalPropertiesJson(newGlobalPropertiesJson);
+ return loop;
}
private Loop findClosedLoopByName(String loopName) {
/* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
<?xml version="1.0" encoding="UTF-8"?>
<!--* ============LICENSE_START==================================================== 
	* =========================================================================== 
	* org.onap.aaf 
	* Copyright (c) 2017 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. 
	* You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 
	* 
	* Unless required by applicable law or agreed to in writing, software 
	* distributed under the License is distributed on an "AS IS" BASIS, 
	* 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==================================================== 
	* -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<parent>
		<groupId>org.onap.aaf.cadi</groupId>
		<artifactId>parent</artifactId>
		<version>2.1.17-SNAPSHOT</version>
		<relativePath>..</relativePath>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.onap.aaf.cadi.sidecar</groupId>
	<artifactId>sidecar</artifactId>
	<name>Sidecar Parent</name>
	<packaging>pom</packaging>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<sonar.skip>false</sonar.skip>
		<jacoco.version>0.7.7.201606060606</jacoco.version>
		<sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
		<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
		<!-- Default Sonar configuration -->
		<sonar.jacoco.reportPaths>target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPaths>
		<sonar.jacoco.itReportPaths>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPaths>
		<!-- Note: This list should match jacoco-maven-plugin's exclusion list 
			below -->
		<sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions>
		<nexusproxy>https://nexus.onap.org</nexusproxy>
		<snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
		<releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
		<stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
		<sitePath>/content/sites/site/org/onap/aaf/authz/${project.artifactId}/${project.version}</sitePath>

		<java.version>1.8</java.version>
		<!-- Spring boot version 
		  Must match oParent
		-->
		<spring.boot.version>2.1.1.RELEASE</spring.boot.version>
		<spring.web.version>5.1.3.RELEASE</spring.web.version>

		<docker.location>${basedir}/target/build</docker.location>
		<!-- <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo> -->

	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.onap.aaf.cadi.sidecar</groupId>
				<artifactId>fproxy</artifactId>
				<version>2.1.13</version>
			</dependency>
			<dependency>
				<groupId>org.onap.aaf.cadi.sidecar</groupId>
				<artifactId>rproxy</artifactId>
				<version>2.1.13</version>
			</dependency>
			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>javax.servlet-api</artifactId>
				<version>3.1.0</version>
			</dependency>
			<dependency>
				<groupId>org.aspectj</groupId>
				<artifactId>aspectjrt</artifactId>
				<version>1.9.2</version>
			</dependency>
			<dependency>
				<groupId>com.google.code.gson</groupId>
				<artifactId>gson</artifactId>
				<version>2.8.5</version>
			</dependency>
			<dependency>
				<groupId>org.apache.commons</groupId>
				<artifactId>commons-lang3</artifactId>
				<version>3.8.1</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-jetty</artifactId>
				<version>${spring.boot.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-aop</artifactId>
				<version>${spring.boot.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-web</artifactId>
				<version>${spring.boot.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-test</artifactId>
				<version>${spring.boot.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-core</artifactId>
				<version>${spring.web.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-expression</artifactId>
				<version>${spring.web.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
				<version>${spring.web.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-webmvc</artifactId>
				<version>${spring.web.version}</version>
			</dependency>
			<dependency>
				<groupId>ch.qos.logback</groupId>
				<artifactId>logback-classic</artifactId>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<!-- ============================================================== -->
	<!-- Define sub-projects (modules) -->
	<!-- ============================================================== -->
	<modules>
		<module>fproxy</module>
		<module>rproxy</module>
		<module>tproxy-config</module>
	</modules>

	<build>
		<pluginManagement>
			<plugins>

				<plugin>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>2.17</version>
					<configuration>
						<!-- Suppresses parent pom config of Surefire plugin. Has the affect of 
						     setting Surefire file includes back to default and re-enables sidecar
						     unit tests -->
						<includes combine.self="override"></includes>
					</configuration>
				</plugin>

				<plugin>
					<groupId>com.mycila</groupId>
					<artifactId>license-maven-plugin</artifactId>
					<version>3.0</version>
					<configuration>
						<header>License.txt</header>
						<includes>
							<include>src/main/java/**</include>
							<include>src/test/java/**</include>
							<include>pom.xml</include>
						</includes>
						<skipExistingHeaders>true</skipExistingHeaders>
					</configuration>
					<executions>
						<execution>
							<goals>
								<!-- Set goal from "check" to "format" to auto update license headers -->
								<goal>check</goal>
							</goals>
							<phase>validate</phase>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
</project>