diff --git a/pom.xml b/pom.xml
index 994c12d6..546ae152 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
api
jar
${project.groupId}:${project.artifactId}
- 3.4.1-SNAPSHOT
+ 4.0.0-SNAPSHOT
Hygieia Rest API Layer
https://github.com/Hygieia/api
@@ -44,6 +44,16 @@
CapitalOne
http://www.capitalone.com
+
+ erictice
+ Eric Tice
+ eric.tice@wipro.com
+ https://github.com/erictice
+
+ maintainer
+
+ America/Chicago
+
@@ -54,26 +64,27 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.22.RELEASE
+ 2.5.3
- 3.14.0
- 4.2.18.RELEASE
- 8.5.57
+ 4.0.0
+ 5.5.1
+ 10.1.0-M2
1.9.4
- 1.14
+ 1.15
4.1
2.4
3.10
2.2.0-RC2
- 29.0-jre
- 5.4.2.Final
- 2.10.3
+ 30.1.1-jre
+ 6.1.5.Final
+ 2.11.4
1.18
1.2.3
- 3.6.4
+ 2.14.1
+ 4.0.6
0.6.0
2.4.0
3.9.0
@@ -84,8 +95,8 @@
0.8.3
0.200
300
- 1.8
- 1.8
+ 14
+ 14
3.1
2.12.1
3.0.0
@@ -136,7 +147,39 @@
org.springframework.boot
spring-boot-starter-web
+ 2.5.3
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-websocket
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 4.0.1
+ provided
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j2.version}
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j2.version}
+
+
+
+ org.apache.commons
+ commons-compress
+ 1.21
+
org.springframework.boot
@@ -153,9 +196,16 @@
spring-boot-starter-aop
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
org.springframework.boot
spring-boot-starter-test
+ 2.5.3
test
@@ -232,8 +282,10 @@
${java.compilation.source}
${java.compilation.target}
+
+
org.apache.maven.plugins
maven-checkstyle-plugin
@@ -668,8 +720,8 @@
maven-compiler-plugin
3.5.1
- 1.8
- 1.8
+ ${java.compilation.source}
+ ${java.compilation.target}
@@ -732,4 +784,4 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/com/capitalone/dashboard/Application.java b/src/main/java/com/capitalone/dashboard/Application.java
index 2aad11ba..c72577c7 100644
--- a/src/main/java/com/capitalone/dashboard/Application.java
+++ b/src/main/java/com/capitalone/dashboard/Application.java
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import com.capitalone.dashboard.config.MongoConfig;
diff --git a/src/main/java/com/capitalone/dashboard/auth/access/MethodLevelSecurityHandler.java b/src/main/java/com/capitalone/dashboard/auth/access/MethodLevelSecurityHandler.java
index 0f22b385..dc86c1c9 100644
--- a/src/main/java/com/capitalone/dashboard/auth/access/MethodLevelSecurityHandler.java
+++ b/src/main/java/com/capitalone/dashboard/auth/access/MethodLevelSecurityHandler.java
@@ -1,5 +1,7 @@
package com.capitalone.dashboard.auth.access;
+import java.util.Optional;
+
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -21,10 +23,11 @@ public MethodLevelSecurityHandler(DashboardRepository dashboardRepository) {
}
public boolean isOwnerOfDashboard(ObjectId dashboardId) {
- Dashboard dashboard = dashboardRepository.findOne(dashboardId);
- if (dashboard == null) {
+ Optional optDash = dashboardRepository.findById(dashboardId);
+ if (optDash == null) {
return false;
}
+ Dashboard dashboard = optDash.get();
String username = AuthenticationUtil.getUsernameFromContext();
AuthType authType = AuthenticationUtil.getAuthTypeFromContext();
diff --git a/src/main/java/com/capitalone/dashboard/auth/ldap/CustomUserDetailsContextMapper.java b/src/main/java/com/capitalone/dashboard/auth/ldap/CustomUserDetailsContextMapper.java
index 6f022cdb..c0aff8c8 100644
--- a/src/main/java/com/capitalone/dashboard/auth/ldap/CustomUserDetailsContextMapper.java
+++ b/src/main/java/com/capitalone/dashboard/auth/ldap/CustomUserDetailsContextMapper.java
@@ -1,6 +1,7 @@
package com.capitalone.dashboard.auth.ldap;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DirContextOperations;
@@ -14,7 +15,7 @@
@Configuration
public class CustomUserDetailsContextMapper extends LdapUserDetailsMapper {
- private static final Logger LOGGER = Logger.getLogger(CustomUserDetailsContextMapper.class);
+ private static final Logger LOGGER = LogManager.getLogger(CustomUserDetailsContextMapper.class);
@Override
public CustomUserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection authorities) {
diff --git a/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationFilter.java b/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationFilter.java
index 7c703ecc..c2d1bdbd 100644
--- a/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationFilter.java
+++ b/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationFilter.java
@@ -7,7 +7,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
@@ -19,7 +20,7 @@
@Component
public class SsoAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
- private static final Logger LOGGER = Logger.getLogger(SsoAuthenticationFilter.class);
+ private static final Logger LOGGER = LogManager.getLogger(SsoAuthenticationFilter.class);
@Autowired
private SsoAuthenticationService ssoAuthenticationService;
diff --git a/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationServiceImpl.java b/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationServiceImpl.java
index 640bf780..334a2ccf 100644
--- a/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationServiceImpl.java
@@ -5,7 +5,8 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
@@ -17,7 +18,7 @@
@Component
public class SsoAuthenticationServiceImpl implements SsoAuthenticationService {
- private static final Logger LOGGER = Logger.getLogger(SsoAuthenticationServiceImpl.class);
+ private static final Logger LOGGER = LogManager.getLogger(SsoAuthenticationServiceImpl.class);
@Autowired
private SsoAuthenticationUtil ssoAuthenticationUtil;
diff --git a/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationUtil.java b/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationUtil.java
index 8803e071..1ef873fc 100644
--- a/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationUtil.java
+++ b/src/main/java/com/capitalone/dashboard/auth/sso/SsoAuthenticationUtil.java
@@ -3,7 +3,8 @@
import java.util.ArrayList;
import java.util.Map;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
@@ -16,7 +17,7 @@
@Component
public class SsoAuthenticationUtil {
- private static final Logger LOGGER = Logger.getLogger(SsoAuthenticationUtil.class);
+ private static final Logger LOGGER = LogManager.getLogger(SsoAuthenticationUtil.class);
@Autowired
private AuthProperties authProperties;
diff --git a/src/main/java/com/capitalone/dashboard/auth/token/JwtAuthenticationFilter.java b/src/main/java/com/capitalone/dashboard/auth/token/JwtAuthenticationFilter.java
index b1297440..f2310814 100644
--- a/src/main/java/com/capitalone/dashboard/auth/token/JwtAuthenticationFilter.java
+++ b/src/main/java/com/capitalone/dashboard/auth/token/JwtAuthenticationFilter.java
@@ -11,7 +11,8 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.security.core.Authentication;
@@ -24,7 +25,7 @@
@Order(2)
public class JwtAuthenticationFilter extends OncePerRequestFilter {
- private static final Logger LOGGER = Logger.getLogger(JwtAuthenticationFilter.class);
+ private static final Logger LOGGER = LogManager.getLogger(JwtAuthenticationFilter.class);
private TokenAuthenticationService tokenAuthenticationService;
@Autowired
diff --git a/src/main/java/com/capitalone/dashboard/config/WebSecurityConfig.java b/src/main/java/com/capitalone/dashboard/config/WebSecurityConfig.java
index afdc9c08..03fdf550 100644
--- a/src/main/java/com/capitalone/dashboard/config/WebSecurityConfig.java
+++ b/src/main/java/com/capitalone/dashboard/config/WebSecurityConfig.java
@@ -15,12 +15,13 @@
import com.capitalone.dashboard.settings.ApiSettings;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint;
+import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.ldap.LdapAuthenticationProviderConfigurer;
@@ -100,7 +101,7 @@ protected void configure(HttpSecurity http) throws Exception {
.addFilterBefore(apiTokenRequestFilter(), UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(githubWebhookRequestFilter(), UsernamePasswordAuthenticationFilter.class)
- .exceptionHandling().authenticationEntryPoint(new Http401AuthenticationEntryPoint("Authorization"));
+ .exceptionHandling().authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.ACCEPTED));
}
@Override
diff --git a/src/main/java/com/capitalone/dashboard/logging/LoggingFilter.java b/src/main/java/com/capitalone/dashboard/logging/LoggingFilter.java
index 358e1a37..7071f1eb 100644
--- a/src/main/java/com/capitalone/dashboard/logging/LoggingFilter.java
+++ b/src/main/java/com/capitalone/dashboard/logging/LoggingFilter.java
@@ -1,37 +1,8 @@
package com.capitalone.dashboard.logging;
-import com.capitalone.dashboard.misc.HygieiaException;
-import com.capitalone.dashboard.model.RequestLog;
-import com.capitalone.dashboard.repository.RequestLogRepository;
-import com.capitalone.dashboard.settings.ApiSettings;
-import com.mongodb.util.JSON;
-import org.apache.commons.io.output.TeeOutputStream;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.annotation.Order;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Component;
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ReadListener;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.WriteListener;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -49,13 +20,45 @@
import java.util.Locale;
import java.util.Map;
-import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.WriteListener;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.output.TeeOutputStream;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.Order;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+
+import com.capitalone.dashboard.misc.HygieiaException;
+import com.capitalone.dashboard.model.RequestLog;
+import com.capitalone.dashboard.repository.RequestLogRepository;
+import com.capitalone.dashboard.settings.ApiSettings;
+import com.mongodb.BasicDBObject;
@Component
@Order(1)
public class LoggingFilter implements Filter {
- private static final Logger LOGGER = Logger.getLogger("LoggingFilter");
+ private static final Logger LOGGER = LogManager.getLogger("LoggingFilter");
private static final String API_USER_KEY = "apiUser";
@@ -107,10 +110,10 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
boolean skipBody = settings.checkIgnoreBodyEndPoint(endPointURI);
if ((httpServletRequest.getContentType() != null) && (new MimeType(httpServletRequest.getContentType()).match(new MimeType(APPLICATION_JSON_VALUE)))) {
- requestLog.setRequestBody(JSON.parse(bufferedRequest.getRequestBody()));
+ requestLog.setRequestBody(BasicDBObject.parse(bufferedRequest.getRequestBody()));
}
if ((bufferedResponse.getContentType() != null) && (new MimeType(bufferedResponse.getContentType()).match(new MimeType(APPLICATION_JSON_VALUE)))) {
- requestLog.setResponseBody( skipBody ? StringUtils.EMPTY : JSON.parse(bufferedResponse.getContent()));
+ requestLog.setResponseBody( skipBody ? StringUtils.EMPTY : BasicDBObject.parse(bufferedResponse.getContent()));
}
}
catch (MimeTypeParseException e) {
diff --git a/src/main/java/com/capitalone/dashboard/request/DashboardRemoteRequest.java b/src/main/java/com/capitalone/dashboard/request/DashboardRemoteRequest.java
index e1e98469..6e908df9 100644
--- a/src/main/java/com/capitalone/dashboard/request/DashboardRemoteRequest.java
+++ b/src/main/java/com/capitalone/dashboard/request/DashboardRemoteRequest.java
@@ -7,7 +7,7 @@
import com.capitalone.dashboard.model.CollectorType;
import com.capitalone.dashboard.model.Owner;
import com.capitalone.dashboard.util.GitHubParsedUrl;
-import org.hibernate.validator.constraints.NotEmpty;
+import javax.validation.constraints.NotEmpty;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
diff --git a/src/main/java/com/capitalone/dashboard/request/PipelineSearchRequest.java b/src/main/java/com/capitalone/dashboard/request/PipelineSearchRequest.java
index d06a0c98..c560d214 100644
--- a/src/main/java/com/capitalone/dashboard/request/PipelineSearchRequest.java
+++ b/src/main/java/com/capitalone/dashboard/request/PipelineSearchRequest.java
@@ -2,7 +2,7 @@
import com.capitalone.dashboard.model.CollectorItem;
import org.bson.types.ObjectId;
-import org.hibernate.validator.constraints.NotEmpty;
+import javax.validation.constraints.NotEmpty;
import java.util.List;
diff --git a/src/main/java/com/capitalone/dashboard/request/TestResultRequest.java b/src/main/java/com/capitalone/dashboard/request/TestResultRequest.java
index ad71aa75..97f1717f 100644
--- a/src/main/java/com/capitalone/dashboard/request/TestResultRequest.java
+++ b/src/main/java/com/capitalone/dashboard/request/TestResultRequest.java
@@ -1,12 +1,14 @@
package com.capitalone.dashboard.request;
-import com.capitalone.dashboard.model.TestSuiteType;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.validation.constraints.NotNull;
+
import org.bson.types.ObjectId;
import org.hibernate.validator.constraints.Range;
-import javax.validation.constraints.NotNull;
-import java.util.ArrayList;
-import java.util.List;
+import com.capitalone.dashboard.model.TestSuiteType;
public class TestResultRequest {
@NotNull
diff --git a/src/main/java/com/capitalone/dashboard/rest/PingController.java b/src/main/java/com/capitalone/dashboard/rest/PingController.java
index 1e256fa2..be4ea66d 100644
--- a/src/main/java/com/capitalone/dashboard/rest/PingController.java
+++ b/src/main/java/com/capitalone/dashboard/rest/PingController.java
@@ -1,6 +1,7 @@
package com.capitalone.dashboard.rest;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
@@ -15,7 +16,7 @@
@RestController
public class PingController {
- private static final Logger LOGGER = Logger.getLogger(PingController.class);
+ private static final Logger LOGGER = LogManager.getLogger(PingController.class);
@Value("${version.number}")
private String versionNumber;
diff --git a/src/main/java/com/capitalone/dashboard/rest/ScoreController.java b/src/main/java/com/capitalone/dashboard/rest/ScoreController.java
index 477207f9..2cbc2a17 100644
--- a/src/main/java/com/capitalone/dashboard/rest/ScoreController.java
+++ b/src/main/java/com/capitalone/dashboard/rest/ScoreController.java
@@ -1,6 +1,7 @@
package com.capitalone.dashboard.rest;
import com.capitalone.dashboard.model.DataResponse;
+import com.capitalone.dashboard.model.score.QScoreMetric;
import com.capitalone.dashboard.model.score.ScoreMetric;
import com.capitalone.dashboard.service.ScoreService;
import org.bson.types.ObjectId;
diff --git a/src/main/java/com/capitalone/dashboard/service/ApiTokenServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/ApiTokenServiceImpl.java
index f3ee5394..a164c3b2 100644
--- a/src/main/java/com/capitalone/dashboard/service/ApiTokenServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/ApiTokenServiceImpl.java
@@ -1,9 +1,27 @@
package com.capitalone.dashboard.service;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.bson.types.ObjectId;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.stereotype.Component;
+
import com.capitalone.dashboard.misc.HygieiaException;
import com.capitalone.dashboard.model.ApiToken;
-import com.capitalone.dashboard.model.AuthType;
-import com.capitalone.dashboard.model.Authentication;
import com.capitalone.dashboard.model.UserInfo;
import com.capitalone.dashboard.model.UserRole;
import com.capitalone.dashboard.repository.ApiTokenRepository;
@@ -12,30 +30,11 @@
import com.capitalone.dashboard.util.EncryptionException;
import com.capitalone.dashboard.util.UnsafeDeleteException;
import com.google.common.collect.Sets;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.log4j.Logger;
-import org.bson.types.ObjectId;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.stereotype.Component;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.List;
@Component
public class ApiTokenServiceImpl implements ApiTokenService {
- private static final Logger LOGGER = Logger.getLogger(ApiTokenServiceImpl.class);
+ private static final Logger LOGGER = LogManager.getLogger(ApiTokenServiceImpl.class);
private ApiTokenRepository apiTokenRepository;
@@ -101,26 +100,28 @@ private boolean isUserAdmin(UserInfo user) {
@Override
public void deleteToken(ObjectId id) {
- ApiToken apiToken = apiTokenRepository.findOne(id);
+ Optional apiToken = apiTokenRepository.findById(id);
if(apiToken == null) {
throw new UnsafeDeleteException("Cannot delete token ");
}else{
- apiTokenRepository .delete(apiToken);
+ ApiToken token = apiToken.get();
+ apiTokenRepository.delete(token);
}
}
@Override
public String updateToken(Long expirationDt, ObjectId id) throws HygieiaException{
- ApiToken apiToken = apiTokenRepository.findOne(id);
+ Optional apiToken = apiTokenRepository.findById(id);
+ ApiToken token = null;
if(apiToken == null) {
throw new HygieiaException("Cannot find token ", HygieiaException.BAD_DATA);
}else{
-
- apiToken.setExpirationDt(expirationDt);
- apiTokenRepository.save(apiToken);
+ token = apiToken.get();
+ token.setExpirationDt(expirationDt);
+ apiTokenRepository.save(token);
}
- return apiToken.getId().toString();
+ return token.getId().toString();
}
private Collection extends GrantedAuthority> createAuthorities(Collection authorities) {
Collection grantedAuthorities = new HashSet<>();
diff --git a/src/main/java/com/capitalone/dashboard/service/AutoDiscoveryServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/AutoDiscoveryServiceImpl.java
index 7f89a3c5..7147f770 100644
--- a/src/main/java/com/capitalone/dashboard/service/AutoDiscoveryServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/AutoDiscoveryServiceImpl.java
@@ -1,5 +1,21 @@
package com.capitalone.dashboard.service;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import javax.validation.constraints.NotNull;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.types.ObjectId;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
import com.capitalone.dashboard.misc.HygieiaException;
import com.capitalone.dashboard.model.AutoDiscoveredEntry;
import com.capitalone.dashboard.model.AutoDiscovery;
@@ -13,19 +29,6 @@
import com.capitalone.dashboard.util.FeatureFlagsEnum;
import com.capitalone.dashboard.util.HygieiaUtils;
import com.google.common.collect.Iterables;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.bson.types.ObjectId;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.validation.constraints.NotNull;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
@Service
public class AutoDiscoveryServiceImpl implements AutoDiscoveryService {
@@ -41,7 +44,7 @@ public AutoDiscoveryServiceImpl(AutoDiscoveryRepository autoDiscoveryRepository,
this.featureFlagRepository = featureFlagRepository;
}
- @Override
+
public AutoDiscovery save(AutoDiscoveryRemoteRequest request) throws HygieiaException {
String autoDiscoveryId = request.getAutoDiscoveryId();
if (autoDiscoveryId==null || !ObjectId.isValid(autoDiscoveryId)) {
@@ -49,24 +52,28 @@ public AutoDiscovery save(AutoDiscoveryRemoteRequest request) throws HygieiaExce
}
ObjectId id = new ObjectId(autoDiscoveryId);
- AutoDiscovery autoDiscovery;
+ Optional autoDiscovery;
FeatureFlag featureFlag = featureFlagRepository.findByName(FeatureFlagsEnum.auto_discover.toString());
-
- if (autoDiscoveryRepository.exists(id)) {
+ AutoDiscovery ad = null;
+ if (autoDiscoveryRepository.existsById(id)) {
// update existing AutoDiscovery record with the status from request
- autoDiscovery = autoDiscoveryRepository.findOne(id);
- updateAutoDiscovery(autoDiscovery, request, featureFlag);
- autoDiscovery.setModifiedTimestamp(System.currentTimeMillis());
+ autoDiscovery = autoDiscoveryRepository.findById(id);
+ if(autoDiscovery != null) {
+ throw new HygieiaException("Cannot find autoDiscovery ", HygieiaException.BAD_DATA);
+ }
+ ad = autoDiscovery.get();
+ updateAutoDiscovery(ad, request, featureFlag);
+ ad.setModifiedTimestamp(System.currentTimeMillis());
} else {
// create new AutoDiscovery record
- autoDiscovery = requestToAutoiscovery(request, featureFlag);
+ ad = requestToAutoiscovery(request, featureFlag);
long currTime = System.currentTimeMillis();
- autoDiscovery.setCreatedTimestamp(currTime);
- autoDiscovery.setModifiedTimestamp(currTime);
+ ad.setCreatedTimestamp(currTime);
+ ad.setModifiedTimestamp(currTime);
}
- autoDiscoveryRepository.save(autoDiscovery);
- return autoDiscovery;
+ autoDiscoveryRepository.save(ad);
+ return ad;
}
/**
diff --git a/src/main/java/com/capitalone/dashboard/service/BinaryArtifactServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/BinaryArtifactServiceImpl.java
index 7f907185..dd3991fd 100644
--- a/src/main/java/com/capitalone/dashboard/service/BinaryArtifactServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/BinaryArtifactServiceImpl.java
@@ -1,5 +1,15 @@
package com.capitalone.dashboard.service;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.bson.types.ObjectId;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
import com.capitalone.dashboard.model.BinaryArtifact;
import com.capitalone.dashboard.model.Build;
import com.capitalone.dashboard.model.DataResponse;
@@ -10,15 +20,6 @@
import com.capitalone.dashboard.request.BinaryArtifactCreateRequest;
import com.capitalone.dashboard.request.BinaryArtifactSearchRequest;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.ObjectUtils;
-import org.bson.types.ObjectId;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
@Service
public class BinaryArtifactServiceImpl implements BinaryArtifactService {
@@ -73,10 +74,9 @@ public DataResponse> search(BinaryArtifactSearchRequest
}
private Build getBuildById(ObjectId buildId){
- return buildRepository.findOne(buildId);
+ return buildRepository.findById(buildId).get();
}
- @Override
public String create(BinaryArtifactCreateRequest request) {
BinaryArtifact ba = new BinaryArtifact();
ba.setArtifactName(request.getArtifactName());
@@ -126,7 +126,7 @@ private void setBuildInformation(BinaryArtifact ba, ObjectId buildId) {
ba.setBuildNumber(build.getNumber());
}
- JobCollectorItem ci = jobRepository.findOne(build.getCollectorItemId());
+ JobCollectorItem ci = jobRepository.findById(build.getCollectorItemId()).get();
if (ci != null) {
if (ba.getInstanceUrl() == null) {
ba.setInstanceUrl(ci.getInstanceUrl());
diff --git a/src/main/java/com/capitalone/dashboard/service/BuildServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/BuildServiceImpl.java
index 27a364a5..a5e53f6a 100644
--- a/src/main/java/com/capitalone/dashboard/service/BuildServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/BuildServiceImpl.java
@@ -27,7 +27,8 @@
import com.querydsl.core.BooleanBuilder;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
import org.bson.types.ObjectId;
import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
@@ -60,7 +61,7 @@ public class BuildServiceImpl implements BuildService {
@Autowired
private ApiSettings settings;
- private static final Logger LOGGER = Logger.getLogger(BuildService.class);
+ private static final Logger LOGGER = LogManager.getLogger(BuildService.class);
@Autowired
public BuildServiceImpl(BuildRepository buildRepository,
@@ -84,7 +85,7 @@ public BuildServiceImpl(BuildRepository buildRepository,
@Override
public DataResponse> search(BuildSearchRequest request) {
CollectorItem item = null;
- Component component = componentRepository.findOne(request.getComponentId());
+ Component component = componentRepository.findById(request.getComponentId()).get();
if ( (component == null)
|| ((item = component.getLastUpdatedCollectorItemForType(CollectorType.Build)) == null) ) {
Iterable results = new ArrayList<>();
@@ -115,13 +116,13 @@ public DataResponse> search(BuildSearchRequest request) {
builder.and(build.buildStatus.in(request.getBuildStatuses()));
}
- Collector collector = collectorRepository.findOne(item.getCollectorId());
+ Collector collector = collectorRepository.findById(item.getCollectorId()).get();
Iterable result;
if (request.getMax() == null) {
result = buildRepository.findAll(builder.getValue());
} else {
- PageRequest pageRequest = new PageRequest(0, request.getMax(), Sort.Direction.DESC, "timestamp");
+ PageRequest pageRequest = PageRequest.of(0, request.getMax(), Sort.Direction.DESC, "timestamp");
result = buildRepository.findAll(builder.getValue(), pageRequest).getContent();
}
@@ -184,7 +185,7 @@ public BuildDataCreateResponse createV3(BuildDataCreateRequest request) throws H
}
}
// Will be refactored soon
- CollectorItem buildCollectorItem = collectorItemRepository.findOne(build.getCollectorItemId());
+ CollectorItem buildCollectorItem = collectorItemRepository.findById(build.getCollectorItemId()).get();
if(buildCollectorItem != null) {
LOGGER.info("buildUrl=" + build.getBuildUrl()
+ ", buildDuration=" + build.getDuration()
@@ -202,7 +203,7 @@ public BuildDataCreateResponse createV3(BuildDataCreateRequest request) throws H
private void populateDashboardId(BuildDataCreateResponse response) {
if (response == null) return;
- CollectorItem collectorItem = collectorItemRepository.findOne(response.getCollectorItemId());
+ CollectorItem collectorItem = collectorItemRepository.findById(response.getCollectorItemId()).get();
if (collectorItem == null) return;
List dashboards = dashboardService.getDashboardsByCollectorItems
diff --git a/src/main/java/com/capitalone/dashboard/service/CloudInstanceServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CloudInstanceServiceImpl.java
index 3fdb0edb..9ea7e6c1 100644
--- a/src/main/java/com/capitalone/dashboard/service/CloudInstanceServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CloudInstanceServiceImpl.java
@@ -51,7 +51,7 @@ public Collection getInstanceDetails(CollectorItem item) {
}
private CollectorItem getCollectorItem(ObjectId componentId) {
- Component component = componentRepository.findOne(componentId);
+ Component component = componentRepository.findById(componentId).get();
if (CollectionUtils.isEmpty(component.getCollectorItems())) return null;
return component.getCollectorItems().get(CollectorType.Cloud).get(0);
}
@@ -106,7 +106,7 @@ public Collection refreshInstances(CloudInstanceListRefreshRequest reque
}
}
if (CollectionUtils.isEmpty(toDelete)) {
- cloudInstanceRepository.delete(toDelete);
+ cloudInstanceRepository.deleteAll(toDelete);
}
return deletedIds;
}
diff --git a/src/main/java/com/capitalone/dashboard/service/CloudSubnetServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CloudSubnetServiceImpl.java
index 1f6c8a85..b7f1b5cc 100644
--- a/src/main/java/com/capitalone/dashboard/service/CloudSubnetServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CloudSubnetServiceImpl.java
@@ -37,7 +37,7 @@ public CloudSubnetServiceImpl(CloudSubNetworkRepository cloudSubNetworkRepositor
private CollectorItem getCollectorItem(ObjectId componentId) {
- Component component = componentRepository.findOne(componentId);
+ Component component = componentRepository.findById(componentId).get();
if (CollectionUtils.isEmpty(component.getCollectorItems())) return null;
return component.getCollectorItems().get(CollectorType.Cloud).get(0);
}
@@ -67,7 +67,7 @@ public Collection refreshSubnets(CloudInstanceListRefreshRequest request
}
}
if (CollectionUtils.isEmpty(toDelete)) {
- cloudSubNetworkRepository.delete(toDelete);
+ cloudSubNetworkRepository.deleteAll(toDelete);
}
return deletedIds;
}
diff --git a/src/main/java/com/capitalone/dashboard/service/CloudVirtualNetworkServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CloudVirtualNetworkServiceImpl.java
index bc325a85..872a82ef 100644
--- a/src/main/java/com/capitalone/dashboard/service/CloudVirtualNetworkServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CloudVirtualNetworkServiceImpl.java
@@ -39,7 +39,7 @@ public CloudVirtualNetworkServiceImpl(CloudVirtualNetworkRepository cloudVirtual
}
private CollectorItem getCollectorItem(ObjectId componentId) {
- Component component = componentRepository.findOne(componentId);
+ Component component = componentRepository.findById(componentId).get();
if (CollectionUtils.isEmpty(component.getCollectorItems())) return null;
return component.getCollectorItems().get(CollectorType.Cloud).get(0);
}
diff --git a/src/main/java/com/capitalone/dashboard/service/CloudVolumeServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CloudVolumeServiceImpl.java
index 5f99eaa1..43ca509c 100644
--- a/src/main/java/com/capitalone/dashboard/service/CloudVolumeServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CloudVolumeServiceImpl.java
@@ -51,7 +51,7 @@ public Collection getVolumeDetails(CollectorItem item) {
}
private CollectorItem getCollectorItem(ObjectId componentId) {
- Component component = componentRepository.findOne(componentId);
+ Component component = componentRepository.findById(componentId).get();
if (CollectionUtils.isEmpty(component.getCollectorItems())) return null;
return component.getCollectorItems().get(CollectorType.Cloud).get(0);
}
@@ -112,7 +112,7 @@ public Collection refreshVolumes(CloudVolumeListRefreshRequest request)
}
}
if (CollectionUtils.isEmpty(toDelete)) {
- cloudVolumeRepository.delete(toDelete);
+ cloudVolumeRepository.deleteAll(toDelete);
}
return deletedIds;
}
diff --git a/src/main/java/com/capitalone/dashboard/service/CmdbServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CmdbServiceImpl.java
index 6eabbe23..768c59ef 100644
--- a/src/main/java/com/capitalone/dashboard/service/CmdbServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CmdbServiceImpl.java
@@ -52,7 +52,7 @@ public String configurationItemNameByObjectId(ObjectId objectId){
}
@Override
public Cmdb configurationItemsByObjectId(ObjectId objectId){
- Cmdb cmdb = cmdbRepository.findOne(objectId);
+ Cmdb cmdb = cmdbRepository.findById(objectId).get();
return cmdb;
}
@Override
diff --git a/src/main/java/com/capitalone/dashboard/service/CodeQualityServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CodeQualityServiceImpl.java
index 1e6e91c5..b71fc46e 100644
--- a/src/main/java/com/capitalone/dashboard/service/CodeQualityServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CodeQualityServiceImpl.java
@@ -95,20 +95,20 @@ private DataResponse> searchType(CodeQualityRequest reques
result = codeQualityRepository.findAll(builder.getValue(), quality.timestamp.desc());
} else {
PageRequest pageRequest =
- new PageRequest(0, request.getMax(), Sort.Direction.DESC, "timestamp");
+ PageRequest.of(0, request.getMax(), Sort.Direction.DESC, "timestamp");
result = codeQualityRepository.findAll(builder.getValue(), pageRequest).getContent();
}
String instanceUrl = (String)item.getOptions().get("instanceUrl");
String projectId = (String) item.getOptions().get("projectId");
String reportUrl = getReportURL(instanceUrl,"dashboard/index/",projectId);
- Collector collector = collectorRepository.findOne(item.getCollectorId());
+ Collector collector = collectorRepository.findById(item.getCollectorId()).get();
long lastExecuted = (collector == null) ? 0 : collector.getLastExecuted();
return new DataResponse<>(result, lastExecuted,reportUrl);
}
protected CollectorItem getCollectorItem(CodeQualityRequest request) {
- Component component = componentRepository.findOne(request.getComponentId());
+ Component component = componentRepository.findById(request.getComponentId()).get();
if (component == null) {
return null;
}
diff --git a/src/main/java/com/capitalone/dashboard/service/CollectorServiceAspect.java b/src/main/java/com/capitalone/dashboard/service/CollectorServiceAspect.java
index 4282238e..4ec0191f 100644
--- a/src/main/java/com/capitalone/dashboard/service/CollectorServiceAspect.java
+++ b/src/main/java/com/capitalone/dashboard/service/CollectorServiceAspect.java
@@ -45,7 +45,7 @@ private boolean isGit(Collector collector) {
}
private void normalizeOptions(CollectorItem item, Map uniqueOptions) {
- Collector collector = collectorRepository.findOne(item.getCollectorId());
+ Collector collector = collectorRepository.findById(item.getCollectorId()).get();
if (collector.getCollectorType() == CollectorType.SCM && isGit(collector)) {
String repoUrl = (String)uniqueOptions.get("url");
GitHubParsedUrl gitHubParsed = new GitHubParsedUrl(repoUrl);
diff --git a/src/main/java/com/capitalone/dashboard/service/CollectorServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CollectorServiceImpl.java
index bd59f0ce..65d3b99c 100644
--- a/src/main/java/com/capitalone/dashboard/service/CollectorServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CollectorServiceImpl.java
@@ -71,7 +71,9 @@ public List collectorsByType(CollectorType collectorType) {
@Override
public List collectorsById(ObjectId id) {
- return collectorRepository.findById(id);
+ List ids = new ArrayList();
+ ids.add(collectorRepository.findById(id).get());
+ return ids;
}
@Override
@@ -151,11 +153,11 @@ public void initProductCollectorOnStartup() {
@Override
public CollectorItem getCollectorItem(ObjectId id) throws HygieiaException {
- CollectorItem item = collectorItemRepository.findOne(id);
+ CollectorItem item = collectorItemRepository.findById(id).get();
if(item == null){
throw new HygieiaException("Failed to find collectorItem by Id.", HygieiaException.BAD_DATA);
}
- item.setCollector(collectorRepository.findOne(item.getCollectorId()));
+ item.setCollector(collectorRepository.findById(item.getCollectorId()).get());
return item;
}
@@ -179,7 +181,7 @@ private List lookUpCollectorItem(CollectorItem collectorItem){
if (collectorItem==null){
return Collections.emptyList();
}
- Collector collector = collectorRepository.findOne(collectorItem.getCollectorId());
+ Collector collector = collectorRepository.findById(collectorItem.getCollectorId()).get();
if (collector == null){
return Collections.emptyList();
}
@@ -199,7 +201,7 @@ private List lookUpCollectorItem(CollectorItem collectorItem){
// just update the new credentials.
@Override
public CollectorItem createCollectorItemSelectOptions(CollectorItem item, Map allOptions, Map uniqueOptions) {
- Collector collector = collectorRepository.findOne(item.getCollectorId());
+ Collector collector = collectorRepository.findById(item.getCollectorId()).get();
Map uniqueFieldsFromCollector = collector.getUniqueFields();
List existing = customRepositoryQuery.findCollectorItemsBySubsetOptions(
item.getCollectorId(), allOptions, uniqueOptions,uniqueFieldsFromCollector);
@@ -282,7 +284,7 @@ public Collector createCollector(Collector collector) {
public List getCollectorItemForComponent(String id, String type) {
ObjectId oid = new ObjectId(id);
CollectorType ctype = CollectorType.fromString(type);
- Component component = componentRepository.findOne(oid);
+ Component component = componentRepository.findById(oid).get();
List items = component.getCollectorItems(ctype);
@@ -292,13 +294,13 @@ public List getCollectorItemForComponent(String id, String type)
for (CollectorItem item : items) {
ids.add(item.getId());
}
- return (List) collectorItemRepository.findAll(ids);
+ return (List) collectorItemRepository.findAllById(ids);
}
@Override
public void deletePropertiesInCollectorById(String id) {
ObjectId objectId = new ObjectId(id);
- Collector collectorById = collectorRepository.findOne(objectId);
+ Collector collectorById = collectorRepository.findById(objectId).get();
Map blankMap = new HashMap<>();
if(collectorById.getProperties().size() > 0) {
@@ -335,7 +337,7 @@ public void deleteCollectorItem(String id, boolean deleteFromComponent) throws H
}
//delete the collector item.
- collectorItemRepository.delete(objectId);
+ collectorItemRepository.deleteById(objectId);
}
private Collector collectorById(ObjectId collectorId, List collectors) {
diff --git a/src/main/java/com/capitalone/dashboard/service/CommitServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/CommitServiceImpl.java
index a41b2925..324aed5c 100644
--- a/src/main/java/com/capitalone/dashboard/service/CommitServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/CommitServiceImpl.java
@@ -55,7 +55,7 @@ public DataResponse> search(CommitRequest request) {
BooleanBuilder builder = new BooleanBuilder();
CollectorItem item = null;
- Component component = componentRepository.findOne(request.getComponentId());
+ Component component = componentRepository.findById(request.getComponentId()).get();
if ( (component == null)
|| ((item = component.getLastUpdatedCollectorItemForType(CollectorType.SCM)) == null) ) {
@@ -88,7 +88,7 @@ public DataResponse> search(CommitRequest request) {
builder.and(commit.scmCommitLog.contains(request.getMessageContains()));
}
- Collector collector = collectorRepository.findOne(item.getCollectorId());
+ Collector collector = collectorRepository.findById(item.getCollectorId()).get();
return new DataResponse<>(commitRepository.findAll(builder.getValue()), collector.getLastExecuted());
}
diff --git a/src/main/java/com/capitalone/dashboard/service/ConfigurationServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/ConfigurationServiceImpl.java
index d506d2cf..831ceebf 100644
--- a/src/main/java/com/capitalone/dashboard/service/ConfigurationServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/ConfigurationServiceImpl.java
@@ -32,7 +32,7 @@ public List insertConfigurationData(List configLis
for (Configuration config : configList) {
config.decryptOrEncrptInfo();
}
- return (List) configurationRepository.save(configList);
+ return (List) configurationRepository.saveAll(configList);
}
@Override
diff --git a/src/main/java/com/capitalone/dashboard/service/DashboardRemoteServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/DashboardRemoteServiceImpl.java
index 5b8dcd22..6ce54eb7 100644
--- a/src/main/java/com/capitalone/dashboard/service/DashboardRemoteServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/DashboardRemoteServiceImpl.java
@@ -145,7 +145,7 @@ public Dashboard remoteCreate(DashboardRemoteRequest request, boolean isUpdate)
Set incomingTypes = new HashSet<>();
List entries = request.getAllEntries();
Map allWidgetRequests = generateRequestWidgetList( entries, dashboard, incomingTypes);
- Component component = componentRepository.findOne(dashboard.getApplication().getComponents().get(0).getId());
+ Component component = componentRepository.findById(dashboard.getApplication().getComponents().get(0).getId()).get();
Set existingTypes = new HashSet<>(component.getCollectorItems().keySet());
//adds widgets
diff --git a/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java b/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java
index 25c973c6..3e9539a3 100644
--- a/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java
+++ b/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java
@@ -111,7 +111,7 @@ public DashboardServiceImpl(DashboardRepository dashboardRepository,
@Override
public Iterable all() {
- Iterable dashboards = dashboardRepository.findAll(new Sort(Sort.Direction.ASC, "title"));
+ Iterable dashboards = dashboardRepository.findAll(Sort.by(Sort.Direction.ASC, "title"));
for(Dashboard dashboard: dashboards){
String appName = dashboard.getConfigurationItemBusServName();
String compName = dashboard.getConfigurationItemBusAppName();
@@ -136,7 +136,7 @@ public Iterable allTemplate(String template){
@Override
public Dashboard get(ObjectId id) {
- Dashboard dashboard = dashboardRepository.findOne(id);
+ Dashboard dashboard = dashboardRepository.findById(id).get();
String appName = dashboard.getConfigurationItemBusServName();
String compName = dashboard.getConfigurationItemBusAppName();
@@ -182,7 +182,7 @@ private Dashboard create(Dashboard dashboard, boolean isUpdate) throws HygieiaEx
if(!isUpdate) {
dashboard.setCreatedAt(System.currentTimeMillis());
- components = componentRepository.save(dashboard.getApplication().getComponents());
+ components = componentRepository.saveAll(dashboard.getApplication().getComponents());
}
dashboard.setUpdatedAt(System.currentTimeMillis());
@@ -199,7 +199,7 @@ private Dashboard create(Dashboard dashboard, boolean isUpdate) throws HygieiaEx
} catch (Exception e) {
//Exclude deleting of components if this is an update request
if(!isUpdate) {
- componentRepository.delete(components);
+ componentRepository.deleteAll(components);
}
if(e instanceof HygieiaException){
@@ -221,7 +221,7 @@ public Dashboard update(Dashboard dashboard) throws HygieiaException {
@Override
public void delete(ObjectId id) {
- Dashboard dashboard = dashboardRepository.findOne(id);
+ Dashboard dashboard = dashboardRepository.findById(id).get();
if (!isSafeDelete(dashboard)) {
throw new UnsafeDeleteException("Cannot delete team dashboard " + dashboard.getTitle() + " as it is referenced by program dashboards.");
@@ -229,7 +229,7 @@ public void delete(ObjectId id) {
// Remove this Dashboard's services and service dependencies
- serviceRepository.delete(serviceRepository.findByDashboardId(id));
+ serviceRepository.deleteAll(serviceRepository.findByDashboardId(id));
for (com.capitalone.dashboard.model.Service service : serviceRepository.findByDependedBy(id)) { //NOPMD - using fully qualified or we pickup an incorrect spring class
service.getDependedBy().remove(id);
serviceRepository.save(service);
@@ -239,7 +239,7 @@ public void delete(ObjectId id) {
* Delete Dashboard. Then delete component. Then disable collector items if needed
*/
dashboardRepository.delete(dashboard);
- componentRepository.delete(dashboard.getApplication().getComponents());
+ componentRepository.deleteAll(dashboard.getApplication().getComponents());
handleCollectorItems(dashboard.getApplication().getComponents());
if (dashboard.isScoreEnabled()) {
this.scoreDashboardService.disableScoreForDashboard(dashboard);
@@ -300,7 +300,7 @@ public Component associateCollectorToComponent(ObjectId componentId, List