diff options
author | 2019-07-11 15:00:30 +0200 | |
---|---|---|
committer | 2019-07-12 14:41:30 +0200 | |
commit | 6e5862fe42af10c854425e5405133a448d00ec9e (patch) | |
tree | a1a6ac37907e8cecd8b6ef42b98beefeea4e3766 | |
parent | 95cb37d58586fc2629286d1f0c19dc12caa3cc5b (diff) |
Set Oparent as parent and fix Checkstyle errors in sdc/dcae-d/dt
Additionally fixed all checkstyle warnings.
Change-Id: I99c2ddd024976bff2f9544d6b4f183427fea3273
Issue-ID: SDC-2440
Signed-off-by: michal.banka <michal.banka@nokia.com>
-rw-r--r-- | checkstyle-suppressions.xml | 35 | ||||
-rw-r--r-- | pom.xml | 43 | ||||
-rw-r--r-- | src/main/java/org/onap/sdc/dcae/FeApp.java | 90 | ||||
-rw-r--r-- | src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java | 90 | ||||
-rw-r--r-- | src/main/java/org/onap/sdc/dcae/controller/proxy/DcaeProxyOld.java | 41 |
5 files changed, 212 insertions, 87 deletions
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml new file mode 100644 index 0000000..eefb648 --- /dev/null +++ b/checkstyle-suppressions.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + SDC + ================================================================================ + Copyright (C) 2019 Nokia. 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========================================================= + --> +<!DOCTYPE suppressions PUBLIC + "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN" + "https://checkstyle.org/dtds/suppressions_1_0.dtd"> +<suppressions> + <suppress checks=".*" files="\.java" lines="1-20"/> + <suppress checks=".*" files="\.properties"/> + <suppress checks="javadoc" files="\.java"/> + <suppress checks="LineLength" files="\.java"/> + <suppress checks="HiddenField" files="\.java"/> + <suppress checks="FinalClass" files="\.java"/> + <suppress checks="FinalParameters" files="\.java"/> + <suppress checks="AvoidInlineConditionals" files="\.java"/> + <suppress checks="DesignForExtension" files="\.java"/> + <suppress checks="ImportOrder" files="\.java"/> + <suppress checks="LocalVariableName" files="\.java"/> + <suppress checks="AbbreviationAsWordInName" files="\.java"/> +</suppressions> @@ -9,12 +9,12 @@ <name>dcae-dt</name> <url>DCAE FE</url> - <parent> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-parent</artifactId> - <version>1.5.9.RELEASE</version> - <relativePath /> <!-- lookup parent from repository --> - </parent> + <parent> + <groupId>org.onap.oparent</groupId> + <artifactId>oparent</artifactId> + <version>2.0.0</version> + <relativePath/> + </parent> <properties> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> @@ -24,9 +24,24 @@ <nexus.proxy>https://nexus.onap.org</nexus.proxy> <staging.profile.id>176c31dfe190a</staging.profile.id> <sitePath>/content/sites/site/org/openecomp/sdc/${project.version}</sitePath> + <springboot.version>1.5.9.RELEASE</springboot.version> + <jetty.version>9.4.10.v20180503</jetty.version> <sonar.branch>${project.version}</sonar.branch> <sonar.coverage.exclusions>**</sonar.coverage.exclusions> </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>${springboot.version}</version> + <scope>import</scope> + <type>pom</type> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -219,6 +234,14 @@ <build> <plugins> <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.17</version> + <configuration> + <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation> + <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression> + </configuration> + </plugin> + <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> @@ -305,6 +328,14 @@ <!-- CLEAN --> <plugins> <plugin> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.17</version> + <configuration> + <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation> + <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression> + </configuration> + </plugin> + <plugin> <artifactId>maven-clean-plugin</artifactId> <executions> <execution> diff --git a/src/main/java/org/onap/sdc/dcae/FeApp.java b/src/main/java/org/onap/sdc/dcae/FeApp.java index c2e3bc9..7463c63 100644 --- a/src/main/java/org/onap/sdc/dcae/FeApp.java +++ b/src/main/java/org/onap/sdc/dcae/FeApp.java @@ -1,3 +1,22 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 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========================================================= + */ package org.onap.sdc.dcae; import org.onap.sdc.dcae.controller.proxy.DcaeProxyOld; @@ -8,7 +27,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.support.SpringBootServletInitializer; -import org.springframework.context.annotation.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import javax.servlet.ServletContext; import java.io.IOException; @@ -21,50 +43,50 @@ import java.util.jar.Manifest; @ComponentScan() @EnableAutoConfiguration @PropertySource("file:${jetty.base}/config/dcae-dt/application.properties") -public class FeApp extends SpringBootServletInitializer implements CommandLineRunner{ +public class FeApp extends SpringBootServletInitializer implements CommandLineRunner { - private static final String SPECIFICATION_VERSION = "Specification-Version"; - @Autowired - ServletContext servletContext; + private static final String SPECIFICATION_VERSION = "Specification-Version"; + @Autowired + private ServletContext servletContext; - private static final String MANIFEST_FILE_NAME = "/META-INF/MANIFEST.MF"; - private static String dcaeVersion; + private static final String MANIFEST_FILE_NAME = "/META-INF/MANIFEST.MF"; + private static String dcaeVersion; @Value("${newFeUrl}") - private String newFeUrl; + private String newFeUrl; @Value("${newFeContextPath}") - private String newFeContextPath; + private String newFeContextPath; public static void main(String[] args) { SpringApplication.run(FeApp.class, args); } - public void run(String... arg0) throws Exception { - InputStream inputStream = servletContext.getResourceAsStream(MANIFEST_FILE_NAME); - - System.out.println("Server is starting..reading DCAE version..."); - - String version = null; - try { - Manifest mf = new Manifest(inputStream); - Attributes atts = mf.getMainAttributes(); - version = atts.getValue(SPECIFICATION_VERSION); - if (version == null || version.isEmpty()) { - System.err.println("failed to read DCAE version from MANIFEST."); - } else { - System.out.println("DCAE version from MANIFEST is "+ version); - dcaeVersion = version; - } - - } catch (IOException e) { - System.err.println("failed to read DCAE version from MANIFEST: "+ e.getMessage()); - } - } - - public static String getDcaeVersion() { - return dcaeVersion; - } + public void run(String... arg0) throws Exception { + InputStream inputStream = servletContext.getResourceAsStream(MANIFEST_FILE_NAME); + + System.out.println("Server is starting..reading DCAE version..."); + + String version = null; + try { + Manifest mf = new Manifest(inputStream); + Attributes atts = mf.getMainAttributes(); + version = atts.getValue(SPECIFICATION_VERSION); + if (version == null || version.isEmpty()) { + System.err.println("failed to read DCAE version from MANIFEST."); + } else { + System.out.println("DCAE version from MANIFEST is " + version); + dcaeVersion = version; + } + + } catch (IOException e) { + System.err.println("failed to read DCAE version from MANIFEST: " + e.getMessage()); + } + } + + public static String getDcaeVersion() { + return dcaeVersion; + } @Bean diff --git a/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java b/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java index 9086600..1ef27d0 100644 --- a/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java +++ b/src/main/java/org/onap/sdc/dcae/controller/health/HealthController.java @@ -1,3 +1,22 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 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========================================================= + */ package org.onap.sdc.dcae.controller.health; import java.util.ArrayList; @@ -19,54 +38,51 @@ import com.google.gson.Gson; /** - * * @author lezer * Example: * { - "healthCheckComponent": "DCAE Designer", - "healthCheckStatus": "UP", - "description": "OK", - "componentsInfo": [{ - "healthCheckComponent": "FE", - "healthCheckStatus": "UP", - "description": "OK" - }] -} - * + * "healthCheckComponent": "DCAE Designer", + * "healthCheckStatus": "UP", + * "description": "OK", + * "componentsInfo": [{ + * "healthCheckComponent": "FE", + * "healthCheckStatus": "UP", + * "description": "OK" + * }] + * } */ @RestController @EnableAutoConfiguration @CrossOrigin public class HealthController { - Gson gson = new Gson(); + private Gson gson = new Gson(); - @RequestMapping(value = "/healthCheckOld", method = RequestMethod.GET) - public ResponseEntity<String> healthCheck() { - try{ - HealthResponse healthResponse = new HealthResponse(); - healthResponse.setHealthCheckComponent(DcaeFeConstants.Health.APP_NAME); - healthResponse.setHealthCheckStatus(DcaeFeConstants.Health.UP); - healthResponse.setSdcVersion(FeApp.getDcaeVersion()); - healthResponse.setDescription(DcaeFeConstants.Health.OK); + @RequestMapping(value = "/healthCheckOld", method = RequestMethod.GET) + public ResponseEntity<String> healthCheck() { + try { + HealthResponse healthResponse = new HealthResponse(); + healthResponse.setHealthCheckComponent(DcaeFeConstants.Health.APP_NAME); + healthResponse.setHealthCheckStatus(DcaeFeConstants.Health.UP); + healthResponse.setSdcVersion(FeApp.getDcaeVersion()); + healthResponse.setDescription(DcaeFeConstants.Health.OK); - List<ComponentsInfo> componentsInfoList = new ArrayList<ComponentsInfo>(); - ComponentsInfo componentsInfo = new ComponentsInfo(); - componentsInfo.setHealthCheckComponent(DcaeFeConstants.Health.FE); - componentsInfo.setHealthCheckStatus(DcaeFeConstants.Health.UP); - componentsInfo.setVersion(FeApp.getDcaeVersion()); - componentsInfo.setDescription(DcaeFeConstants.Health.OK); - componentsInfoList.add(componentsInfo); + List<ComponentsInfo> componentsInfoList = new ArrayList<ComponentsInfo>(); + ComponentsInfo componentsInfo = new ComponentsInfo(); + componentsInfo.setHealthCheckComponent(DcaeFeConstants.Health.FE); + componentsInfo.setHealthCheckStatus(DcaeFeConstants.Health.UP); + componentsInfo.setVersion(FeApp.getDcaeVersion()); + componentsInfo.setDescription(DcaeFeConstants.Health.OK); + componentsInfoList.add(componentsInfo); - healthResponse.setComponentsInfo(componentsInfoList); - String json = gson.toJson(healthResponse, HealthResponse.class); - System.out.println("Health Check response: "+json); + healthResponse.setComponentsInfo(componentsInfoList); + String json = gson.toJson(healthResponse, HealthResponse.class); + System.out.println("Health Check response: " + json); - return new ResponseEntity<String>(json, HttpStatus.OK); - } - catch(Exception e){ - System.err.println("Error occured while performing HealthCheck: "+e.getLocalizedMessage()); - return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); - } - } + return new ResponseEntity<String>(json, HttpStatus.OK); + } catch (Exception e) { + System.err.println("Error occured while performing HealthCheck: " + e.getLocalizedMessage()); + return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); + } + } } diff --git a/src/main/java/org/onap/sdc/dcae/controller/proxy/DcaeProxyOld.java b/src/main/java/org/onap/sdc/dcae/controller/proxy/DcaeProxyOld.java index cacb092..dbd475e 100644 --- a/src/main/java/org/onap/sdc/dcae/controller/proxy/DcaeProxyOld.java +++ b/src/main/java/org/onap/sdc/dcae/controller/proxy/DcaeProxyOld.java @@ -1,3 +1,22 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 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========================================================= + */ package org.onap.sdc.dcae.controller.proxy; import com.google.common.cache.Cache; @@ -19,15 +38,16 @@ import java.util.concurrent.TimeUnit; public class DcaeProxyOld extends ProxyServlet { + private static final int EXPIRATION_TIME = 10; + private static final int TIMEOUT = 180000; private static Logger log = LoggerFactory.getLogger(DcaeProxyOld.class); - private static Cache<String, MdcData> mdcDataCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build(); - + private static Cache<String, MdcData> mdcDataCache = CacheBuilder.newBuilder().expireAfterWrite(EXPIRATION_TIME, TimeUnit.SECONDS).build(); //TODO proper configuration class private String newFeUrl; private String newFeContextPath; - public DcaeProxyOld(String newFeUrl, String newFeContextPath){ + public DcaeProxyOld(String newFeUrl, String newFeContextPath) { this.newFeUrl = newFeUrl; this.newFeContextPath = newFeContextPath; } @@ -41,16 +61,16 @@ public class DcaeProxyOld extends ProxyServlet { @Override protected HttpClient createHttpClient() throws ServletException { HttpClient client = super.createHttpClient(); - client.setIdleTimeout(180000); - client.setConnectTimeout(180000); + client.setIdleTimeout(TIMEOUT); + client.setConnectTimeout(TIMEOUT); return client; } @Override protected String rewriteTarget(HttpServletRequest request) { - try{ + try { logRequest(request); - }catch (Exception e){ + } catch (Exception e) { log.error("Unexpected FE request logging error :", e); } String uri = request.getRequestURI(); @@ -59,8 +79,9 @@ public class DcaeProxyOld extends ProxyServlet { String query = request.getQueryString(); StringBuilder url = new StringBuilder(); url.append(newFeUrl).append(uri); - if(null != query) + if (null != query) { url.append("?").append(query); + } String urlString = url.toString(); log.info("Proxy outgoing request={}", urlString); return urlString; @@ -68,9 +89,9 @@ public class DcaeProxyOld extends ProxyServlet { @Override protected void onProxyResponseSuccess(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, Response serverResponse) { - try{ + try { logResponse(clientRequest, serverResponse); - }catch (Exception e){ + } catch (Exception e) { log.error("Unexpected FE response logging error :", e); } super.onProxyResponseSuccess(clientRequest, proxyResponse, serverResponse); |