diff options
author | 2018-10-10 18:10:43 -0400 | |
---|---|---|
committer | 2018-10-11 12:17:40 -0400 | |
commit | 846c78de8dff13cd5780b4501bbb5e261a62ae38 (patch) | |
tree | ba5a68cd5ee64b5ffa51b5d085ef6e0b3a237759 /cmso-service/src | |
parent | d84cee50fa9901a0d2c2f8385c5b287a47f4d50c (diff) |
Update CMSO dev project to pass all Robot ETE test
Issue-ID: OPTFRA-373
Change-Id: I05cffb239909bf6ed68c9c79f17b203357d8b057
Signed-off-by: Jerry Flood <jf9860@att.com>
Signed-off-by: Jerry Flood <jflood@att.com>
Diffstat (limited to 'cmso-service/src')
21 files changed, 288 insertions, 299 deletions
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java index 7327124..f0580bd 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java @@ -97,6 +97,7 @@ public class Application extends SpringBootServletInitializer { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
int port = Integer.parseInt(dispatchPort);
tomcat.addAdditionalTomcatConnectors(createStandardConnector(port));
+ org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter ss = null;
return tomcat;
}
diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/service/H2Test.java b/cmso-service/src/main/java/org/onap/optf/cmso/ApplicationPropertiesFiles.java index 8a586a9..912a6e1 100644 --- a/cmso-service/src/test/java/org/onap/optf/cmso/service/H2Test.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ApplicationPropertiesFiles.java @@ -1,47 +1,46 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.service;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:testConfig.xml"})
-public class H2Test {
-
- @Test
- public void h2Test() {
-
- }
-}
+/* + * Copyright © 2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; + + +@Configuration +@PropertySources({ + @PropertySource("file:etc/config/cmso.properties"), + @PropertySource("file:etc/config/optimizer.properties"), + @PropertySource("file:etc/config/ticketmgt.properties"), +}) +public class ApplicationPropertiesFiles +{ +}
\ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java new file mode 100644 index 0000000..e002b7d --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso; + +import java.util.ArrayList; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.stereotype.Component; + +@Component +public class AuthProvider + implements AuthenticationProvider { + + @Autowired + Environment env; + + @Override + public Authentication authenticate(Authentication authentication) + throws AuthenticationException { + org.springframework.security.web.authentication.www.BasicAuthenticationFilter f = null; + String name = authentication.getName(); + String password = authentication.getCredentials().toString(); + //TODO check credentials until we enable AAF + return new UsernamePasswordAuthenticationToken( + name, password, new ArrayList<>()); + } + + @Override + public boolean supports(Class<?> authentication) { + return authentication.equals( + UsernamePasswordAuthenticationToken.class); + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java index d1ccb7e..e5aca31 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,8 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources;
public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor {
-
+ // TODO tested in ONAP springboot and this is called before all of the properties files have been loaded...
+ // perhaps there is a post post processor? Until this works. DB password will be in the clear in the proeprties files.
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
String pwd = environment.getProperty("cmso.database.password");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java new file mode 100644 index 0000000..a4802d2 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +@EnableWebSecurity +@ComponentScan("org.onap.optf") +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private AuthProvider authProvider; + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + + auth.authenticationProvider(authProvider); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic(); + + } +}
\ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java index d4ab593..121774b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@@ -50,11 +51,11 @@ public class ApprovalType implements Serializable { private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
@Column(name = "approval_count")
- private int approvalCount;
+ private Integer approvalCount;
@Column(name = "approval_type")
private String approvalType;
@@ -65,19 +66,19 @@ public class ApprovalType implements Serializable { public ApprovalType() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
- public int getApprovalCount() {
+ public Integer getApprovalCount() {
return this.approvalCount;
}
- public void setApprovalCount(int approvalCount) {
+ public void setApprovalCount(Integer approvalCount) {
this.approvalCount = approvalCount;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java index ceece9a..7224508 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@@ -58,8 +59,8 @@ public class ChangeManagementChangeWindow implements Serializable { @JsonIgnore
@Id
- @GeneratedValue
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
@JsonIgnore
@Column(name = "finish_time")
@@ -81,15 +82,15 @@ public class ChangeManagementChangeWindow implements Serializable { @JsonIgnore
@Column(name = "change_management_groups_id")
- private int changeManagementGroupsId;
+ private Integer changeManagementGroupsId;
public ChangeManagementChangeWindow() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
@@ -109,11 +110,11 @@ public class ChangeManagementChangeWindow implements Serializable { public void setStartTime(String startTime) {}
- public int getChangeManagementGroupsId() {
+ public Integer getChangeManagementGroupsId() {
return changeManagementGroupsId;
}
- public void setChangeManagementGroupsId(int changeManagementGroupsId) {
+ public void setChangeManagementGroupsId(Integer changeManagementGroupsId) {
this.changeManagementGroupsId = changeManagementGroupsId;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java index 3b82c62..31c4a2b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ package org.onap.optf.cmso.model; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Transient;
@@ -58,8 +59,8 @@ import io.swagger.annotations.ApiModelProperty; public class ChangeManagementDetail {
@Id
@JsonIgnore
- @GeneratedValue
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
@ApiModelProperty(value = "Name of the VNF.")
@Column(name = "vnf_name")
@@ -167,7 +168,7 @@ public class ChangeManagementDetail { private String msoTime;
@JsonIgnore
- private int schedules_id;
+ private Integer schedules_id;
public String getVnfName() {
return vnfName;
@@ -241,11 +242,11 @@ public class ChangeManagementDetail { this.policyId = policyId;
}
- public int getSchedulesId() {
+ public Integer getSchedulesId() {
return schedules_id;
}
- public void setSchedulesId(int schedules_id) {
+ public void setSchedulesId(Integer schedules_id) {
this.schedules_id = schedules_id;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java index 0664851..6aeb325 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import java.util.List; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@@ -59,8 +60,8 @@ public class ChangeManagementGroup implements Serializable { @JsonIgnore
@Id
- @GeneratedValue
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
@JsonIgnore
@Column(name = "finish_time")
@@ -95,19 +96,19 @@ public class ChangeManagementGroup implements Serializable { @JsonIgnore
@Column(name = "schedules_id")
- private int schedulesId;
+ private Integer schedulesId;
@Column(name = "additional_duration_in_secs")
@ApiModelProperty(value = "Time added to the workflow interval to allow for rollback in case of failure.")
- private int additionalDurationInSecs;
+ private Integer additionalDurationInSecs;
@ApiModelProperty(value = "The maximum number of workflows that should be started simultaneiously.")
@Column(name = "concurrency_limit")
- private int concurrencyLimit;
+ private Integer concurrencyLimit;
@ApiModelProperty(value = "Expected duration of a successful workflow execution.")
@Column(name = "normal_duration_in_secs")
- private int normalDurationInSecs;
+ private Integer normalDurationInSecs;
@ApiModelProperty(
value = "The name of the schedule optimization policy used by the change management schedule optimizer.")
@@ -121,11 +122,11 @@ public class ChangeManagementGroup implements Serializable { public ChangeManagementGroup() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
@@ -161,35 +162,35 @@ public class ChangeManagementGroup implements Serializable { public void setStartTime(String startTime) {}
- public int getSchedulesId() {
+ public Integer getSchedulesId() {
return schedulesId;
}
- public void setSchedulesId(int schedulesId) {
+ public void setSchedulesId(Integer schedulesId) {
this.schedulesId = schedulesId;
}
- public int getAdditionalDurationInSecs() {
+ public Integer getAdditionalDurationInSecs() {
return additionalDurationInSecs;
}
- public void setAdditionalDurationInSecs(int additionalDurationInSecs) {
+ public void setAdditionalDurationInSecs(Integer additionalDurationInSecs) {
this.additionalDurationInSecs = additionalDurationInSecs;
}
- public int getConcurrencyLimit() {
+ public Integer getConcurrencyLimit() {
return concurrencyLimit;
}
- public void setConcurrencyLimit(int concurrencyLimit) {
+ public void setConcurrencyLimit(Integer concurrencyLimit) {
this.concurrencyLimit = concurrencyLimit;
}
- public int getNormalDurationInSecs() {
+ public Integer getNormalDurationInSecs() {
return normalDurationInSecs;
}
- public void setNormalDurationInSecs(int normalDurationInSecs) {
+ public void setNormalDurationInSecs(Integer normalDurationInSecs) {
this.normalDurationInSecs = normalDurationInSecs;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java index 779e8ca..9690290 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQuery;
@@ -60,7 +61,7 @@ public class ChangeManagementSchedule implements Serializable { @JsonIgnore
@Id
- @GeneratedValue
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
@ApiModelProperty(value = "TM Change Id")
@@ -108,7 +109,7 @@ public class ChangeManagementSchedule implements Serializable { @Column(name = "change_management_groups_id")
@JsonIgnore
- private int changeManagementGroupsId;
+ private Integer changeManagementGroupsId;
@JsonIgnore
@Column(name = "dispatch_time")
@@ -161,11 +162,11 @@ public class ChangeManagementSchedule implements Serializable { public ChangeManagementSchedule() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
@@ -217,11 +218,11 @@ public class ChangeManagementSchedule implements Serializable { this.tmChangeId = tmChangeId;
}
- public int getChangeManagementGroupsId() {
+ public Integer getChangeManagementGroupsId() {
return changeManagementGroupsId;
}
- public void setChangeManagementGroupsId(int changeManagementGroupsId) {
+ public void setChangeManagementGroupsId(Integer changeManagementGroupsId) {
this.changeManagementGroupsId = changeManagementGroupsId;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java index f32ff98..fc86964 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ package org.onap.optf.cmso.model; import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@@ -55,8 +56,8 @@ public class DomainData implements Serializable { @JsonIgnore
@Id
- @GeneratedValue
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
private String name;
@@ -69,11 +70,11 @@ public class DomainData implements Serializable { public DomainData() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java index 3a13563..d6fe4f9 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import javax.persistence.CascadeType; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQuery;
@@ -63,8 +64,8 @@ public class Schedule implements Serializable { @JsonIgnore
@Id
- @GeneratedValue
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
@JsonIgnore
@Column(name = "create_date_time")
@@ -93,7 +94,7 @@ public class Schedule implements Serializable { @JsonIgnore
@Column(name = "optimizer_attempts_to_schedule")
- private int optimizerAttemptsToSchedule;
+ private Integer optimizerAttemptsToSchedule;
@JsonIgnore
@Column(name = "optimizer_return_date_time")
@@ -159,11 +160,11 @@ public class Schedule implements Serializable { public Schedule() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
@@ -307,11 +308,11 @@ public class Schedule implements Serializable { return sa;
}
- public int getOptimizerAttemptsToSchedule() {
+ public Integer getOptimizerAttemptsToSchedule() {
return optimizerAttemptsToSchedule;
}
- public void setOptimizerAttemptsToSchedule(int optimizerAttemptsToSchedule) {
+ public void setOptimizerAttemptsToSchedule(Integer optimizerAttemptsToSchedule) {
this.optimizerAttemptsToSchedule = optimizerAttemptsToSchedule;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java index adfafd1..dee3c42 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@@ -59,9 +60,9 @@ public class ScheduleApproval implements Serializable { private static final long serialVersionUID = 1L;
@Id
- @GeneratedValue
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
@JsonIgnore
- private int id;
+ private Integer id;
@JsonIgnore
@Column(name = "approval_date_time")
@@ -91,11 +92,11 @@ public class ScheduleApproval implements Serializable { public ScheduleApproval() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java index 97a96f0..46cb46e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,8 @@ package org.onap.optf.cmso.model; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQuery;
@@ -54,7 +56,8 @@ public class ScheduleEvent implements Serializable { private static final long serialVersionUID = 1L;
@Id
- private int id;
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Integer id;
private String domain;
@@ -79,17 +82,17 @@ public class ScheduleEvent implements Serializable { private String reminderTime;
@Column(name = "schedules_id")
- private int schedulesId;
+ private Integer schedulesId;
private String status;
public ScheduleEvent() {}
- public int getId() {
+ public Integer getId() {
return this.id;
}
- public void setId(int id) {
+ public void setId(Integer id) {
this.id = id;
}
@@ -109,11 +112,11 @@ public class ScheduleEvent implements Serializable { this.eventText = eventText;
}
- public int getSchedulesId() {
+ public Integer getSchedulesId() {
return this.schedulesId;
}
- public void setSchedulesId(int schedulesId) {
+ public void setSchedulesId(Integer schedulesId) {
this.schedulesId = schedulesId;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java index 8dbafbc..2e0cfeb 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -91,6 +91,7 @@ public class BaseSchedulerServiceImpl { // are 1<=>1 at this
// point.
s.setScheduleName(scheduleMessage.getScheduleName());
+ s.setOptimizerAttemptsToSchedule(0);
s.setScheduleInfo(scheduleMessage.getSchedulingInfo().toString());
s.setStatus(CMSStatusEnum.PendingSchedule.toString());
scheduleDAO.save(s);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java index f994dc8..a3a4ae8 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,8 +80,8 @@ public class HealthCheckImpl implements HealthCheck { if (checkInterfaces) {
addToHealthCheckMessage(hc, tmClient.healthCheck());
- addToHealthCheckMessage(hc, sniroClient.healthCheck());
addToHealthCheckMessage(hc, msoStatusClient.healthCheck());
+ addToHealthCheckMessage(hc, sniroClient.healthCheck());
}
addToHealthCheckMessage(hc, this.healthCheck());
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java index 42f282a..8cbe459 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -247,8 +247,8 @@ public class MsoStatusClient { public HealthCheckComponent healthCheck() {
Map<String, String> mdcSave = Mdc.save();
String requestId = "healthCheck";
- String url = env.getProperty("so.url");
- String user = env.getProperty("so.user");
+ String url = env.getProperty("so.url", "");
+ String user = env.getProperty("so.user", "");
String pass = pm.getProperty("so.pass", "");
if (!url.endsWith("/"))
url = url + "/";
diff --git a/cmso-service/src/main/resources/META-INF/spring.factories b/cmso-service/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..5047be8 --- /dev/null +++ b/cmso-service/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.CMSEnvironmentPostProcessor
\ No newline at end of file diff --git a/cmso-service/src/main/resources/application.properties b/cmso-service/src/main/resources/application.properties index b6239c9..25c5b10 100644 --- a/cmso-service/src/main/resources/application.properties +++ b/cmso-service/src/main/resources/application.properties @@ -36,7 +36,7 @@ info.build.version=@project.version@ spring.jersey.type=filter
spring.mvc.urls=swagger,docs,prometheus
-server.contextPath=/cmso
+server.servlet.context-path=/cmso
#This property is used to set the Tomcat connector attributes.developers can define multiple attributes separated by comma
#tomcat.connector.attributes=allowTrace-true
@@ -53,3 +53,9 @@ server.port=8080 server.dispatchPort=8089
kubernetes.namespace=org.onap.optf.cmso
+
+
+com.att.eelf.logging.file=logback.xml
+com.att.eelf.logging.path=
+
+logging.config=
diff --git a/cmso-service/src/main/resources/swagger-ui/dist/swagger.json b/cmso-service/src/main/resources/swagger-ui/dist/swagger.json index b8f5def..635d6a9 100644 --- a/cmso-service/src/main/resources/swagger-ui/dist/swagger.json +++ b/cmso-service/src/main/resources/swagger-ui/dist/swagger.json @@ -2,7 +2,7 @@ "swagger" : "2.0", "info" : { "version" : "0.1.0-SNAPSHOT", - "title" : "cmso" + "title" : "cmso-service" }, "basePath" : "/cmso", "paths" : { diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java b/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java deleted file mode 100644 index b989a73..0000000 --- a/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/*
- * Copyright © 2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
-*/
-
-package org.onap.optf.cmso.service.rs;
-
-import static org.junit.Assert.assertEquals;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.optf.cmso.JpaInit;
-import org.onap.optf.cmso.JtestHelper;
-import org.onap.optf.cmso.common.CMSRequestError;
-import org.onap.optf.cmso.service.rs.models.CMSMessage;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
-import org.springframework.test.context.junit4.SpringRunner;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import scala.collection.mutable.StringBuilder;
-
-@RunWith(SpringRunner.class)
-@DataJpaTest
-public class CMSOServiceImplTest {
-
- @Autowired
- CMSOService cMSOServiceImpl;
-
- @Autowired
- private TestEntityManager entityManager;
-
- @Before
- public void setUp() throws Exception {
- JpaInit.init(entityManager);
- }
-
- @Test
- public void test_createScheduleRequest() {
- String[] templates = {"changemanagement/MultipleVnfImmediate.json.template",};
- String[] domains = {"ChangeManagement",};
- String[] userIds = {"jf9860",};
- String[] callbackUrls = {"http://localhost:8089/",};
- String[] callbackDatum = {"sdafafadfdasfdsafdsa",};
- String[] workflows = {"Replace", "Update", "NewOne",};
- Integer[] normalDurationInSeeconds = {10,};
- Integer[] additionalDurationInSeeconds = {10,};
- String[] results = {"500:", // {additionalDurationInSeconds=10, workflow=Replace,
- // domain=ChangeManagement,
- // callbackData=sdafafadfdasfdsafdsa, testid=79e1,
- // callbackUrl=http://localhost:8089/,
- // uuid=a36b45b9-dff4-45b4-ac6b-2a4f35e179e1, userId=jf9860,
- // normalDurationInSeconds=10}
- "500:", // {additionalDurationInSeconds=10, workflow=Update,
- // domain=ChangeManagement,
- // callbackData=sdafafadfdasfdsafdsa, testid=c525,
- // callbackUrl=http://localhost:8089/,
- // uuid=26b189f7-b075-4013-b487-d938b895c525, userId=jf9860,
- // normalDurationInSeconds=10}
- "500:", // {additionalDurationInSeconds=10, workflow=NewOne,
- // domain=ChangeManagement,
- // callbackData=sdafafadfdasfdsafdsa, testid=8e87,
- // callbackUrl=http://localhost:8089/,
- // uuid=4f59b14a-8040-4257-8981-defcb8f38e87, userId=jf9860,
- // normalDurationInSeconds=10}
- };
-
- int i = 0;
- for (String template : templates) {
- for (String domain : domains) {
- for (String userId : userIds) {
- for (String callbackUrl : callbackUrls) {
- for (String callbackData : callbackDatum) {
- for (String workflow : workflows) {
- for (Integer normalDuration : normalDurationInSeeconds) {
- for (Integer additionalDuration : additionalDurationInSeeconds) {
- Map<String, String> values = new HashMap<String, String>();
- String scheduleId = UUID.randomUUID().toString();
- values.put("uuid", scheduleId);
- values.put("testid", scheduleId.substring(scheduleId.length() - 4));
- values.put("domain", domain);
- values.put("userId", userId);
- values.put("callbackUrl", callbackUrl);
- values.put("callbackData", callbackData);
- values.put("workflow", workflow);
- values.put("normalDurationInSeconds", normalDuration.toString());
- values.put("additionalDurationInSeconds", additionalDuration.toString());
- String json = JtestHelper.template(template, values);
- ObjectMapper om = new ObjectMapper();
- CMSMessage scheduleMessage;
- try {
- scheduleMessage = om.readValue(json, CMSMessage.class);
- MockHttpServletRequest mrequest = new MockHttpServletRequest();
- mrequest.url.append(scheduleId);
-
- Response response = cMSOServiceImpl.createScheduleRequest("v2", scheduleId,
- scheduleMessage, mrequest.request);
-
- Object result = response.getEntity();
- StringBuilder sb = new StringBuilder();
- sb.append(response.getStatus()).append(":");
- if (result instanceof CMSRequestError) {
- String r = result.toString().replaceAll(" : Reason :.*$", "");
- sb.append(r.replaceAll(scheduleId, "<uuid>"));
- }
- // Generate results[] entry
- System.out.println("\"" + sb.toString() + "\", //" + values.toString());
-
- // Debug an assertion
- System.out.println(results[i] + ":" + sb.toString());
- assertEquals(results[i].equals(sb.toString()), true);
- i++;
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
- }
- }
-
- }
- }
- }
- }
- }
- }
-}
|