Skip to content

Commit

Permalink
PHEE-307 Resolve checkstyle errors manually and update gradle command…
Browse files Browse the repository at this point in the history
… in CI (openMF#107)

* PHEE-307 Resolve checkstyle errors manually and update gradle command in CI

* updated the gradle command for checkstyle in CI

* Rebased and resolved conflicts

* Resolved the checkstyle error manually and updated the api package name

* Applied the spotless check

---------

Co-authored-by: Dhruv Sonagara <[email protected]>
  • Loading branch information
dhruvsonagara and Dhruv Sonagara authored Nov 3, 2023
1 parent 96e3d7d commit 398050e
Show file tree
Hide file tree
Showing 57 changed files with 326 additions and 359 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
- run:
name: Build Docker image
command: |
./gradlew checkstyleMain
./gradlew bootJar
docker build -t openmf/ph-ee-bulk-processor:latest .
Expand Down
32 changes: 1 addition & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ plugins {
id 'checkstyle'
id 'org.springframework.boot' version '2.6.2'
id 'com.diffplug.spotless' version '6.19.0'
id 'com.github.hierynomus.license' version '0.16.1'
id 'com.github.jk1.dependency-license-report' version '2.1'
}

repositories {
Expand Down Expand Up @@ -44,32 +42,6 @@ spotless {
}
lineEndings 'UNIX'
}
// Configuration for Gradle license plug-in
// https://github.com/hierynomus/license-gradle-plugin
license {
header rootProject.file("$rootDir/LICENSE.md")
excludes([
"**/gradlew*",
"**/git.properties",
"**/*.html",
"**/templates/**",
"**/features/**",
"**/results/**",
"**/package-info.java",
"**/keystore.jks",
"**/legacy-docs/**",
"**/banner.txt",
"**/build.gradle.mustache",
"**/pom.mustache",
"**/avro/**/*.java",
"**/org/apache/fineract/client/**/*.java"
])
strictCheck true
}

licenseReport {
outputDir = "$projectDir/licenses"
}

ext {
camelVersion = '3.4.0'
Expand Down Expand Up @@ -145,9 +117,7 @@ configure(this) {
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'project-report'
apply plugin: 'com.github.jk1.dependency-license-report'

configurations {
implementation.setCanBeResolved(true)
api.setCanBeResolved(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import org.mifos.processor.bulk.api.ApiOriginFilter;
import org.mifos.processor.bulk.camel.config.HttpClientConfigurerTrustAllCACerts;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

Expand Down Expand Up @@ -56,7 +54,7 @@ public FilterRegistrationBean<ApiOriginFilter> apiOriginFilter() {
registration.setFilter(new ApiOriginFilter());
registration.addUrlPatterns("/**");
registration.setName("apiOriginFilter");
registration.setOrder(Integer.MIN_VALUE+1);
registration.setOrder(Integer.MIN_VALUE + 1);
return registration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void validateFormattingStandard() {
logger.info("Configured formatting standard as >> {}", standardEnum.name());
return;
} catch (Exception e) {
e.printStackTrace();
logger.debug(e.getMessage());
}
List<String> possibleStandards = new ArrayList<>();
for (Field f : Standard.class.getFields()) {
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/mifos/processor/bulk/api/ApiOriginFilter.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
package org.mifos.processor.bulk.api;

import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.GenericFilterBean;

import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;

public class ApiOriginFilter extends GenericFilterBean {

private Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
String tenant = req.getHeader("" +
HEADER_PLATFORM_TENANT_ID);
String tenant = req.getHeader("" + HEADER_PLATFORM_TENANT_ID);
logger.debug("Tenant Name is : {}", tenant);
logger.info("Client IP Address: {}", req.getRemoteHost());
}
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/org/mifos/processor/bulk/api/CallbackController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package org.mifos.processor.bulk.api;

import static org.mifos.processor.bulk.zeebe.ZeebeVariables.APPROVED_AMOUNT;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.AUTHORIZATION_FAIL_REASON;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.AUTHORIZATION_RESPONSE;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.AUTHORIZATION_STATUS;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.AUTHORIZATION_SUCCESSFUL;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.CLIENT_CORRELATION_ID;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.zeebe.client.ZeebeClient;
Expand All @@ -15,8 +22,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import static org.mifos.processor.bulk.zeebe.ZeebeVariables.*;

@RestController
public class CallbackController {

Expand All @@ -30,9 +35,9 @@ public class CallbackController {

private static final String EXPECTED_AUTH_STATUS = "Y";


@PostMapping("/authorization/callback")
public ResponseEntity<Object> handleAuthorizationCallback(@RequestBody AuthorizationResponse authResponse) throws JsonProcessingException {
public ResponseEntity<Object> handleAuthorizationCallback(@RequestBody AuthorizationResponse authResponse)
throws JsonProcessingException {
logger.info("Callback received");
logger.debug("Auth response: {}", objectMapper.writeValueAsString(authResponse));
Map<String, Object> variables = new HashMap<>();
Expand All @@ -50,12 +55,11 @@ public ResponseEntity<Object> handleAuthorizationCallback(@RequestBody Authoriza
logger.info("Is auth successful: {}", isAuthorizationSuccessful);

if (zeebeClient != null) {
zeebeClient.newPublishMessageCommand()
.messageName(AUTHORIZATION_RESPONSE)
.correlationKey(authResponse.getClientCorrelationId())
.timeToLive(Duration.ofMillis(500000))
.variables(variables).send();
zeebeClient.newPublishMessageCommand().messageName(AUTHORIZATION_RESPONSE).correlationKey(authResponse.getClientCorrelationId())
.timeToLive(Duration.ofMillis(500000)).variables(variables).send();
logger.debug("Published zeebe message event {}", AUTHORIZATION_RESPONSE);
zeebeClient.newPublishMessageCommand().messageName(AUTHORIZATION_RESPONSE).correlationKey(authResponse.getClientCorrelationId())
.timeToLive(Duration.ofMillis(500000)).variables(variables).send();
}
return ResponseEntity.ok().build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
package org.mifos.processor.bulk.api.definition;

import com.amazonaws.services.dynamodbv2.xspec.S;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.camel.util.json.JsonObject;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_CLIENT_CORRELATION_ID;
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PROGRAM_ID;
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_REGISTERING_INSTITUTE_ID;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.FILE_NAME;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.HEADER_TYPE;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PURPOSE;

import javax.mail.Multipart;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

import static org.mifos.processor.bulk.camel.config.CamelProperties.*;
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_CLIENT_CORRELATION_ID;
import static org.mifos.processor.bulk.camel.config.CamelProperties.HEADER_PLATFORM_TENANT_ID;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;

public interface BatchTransactions {

@PostMapping(value = "/batchtransactions", produces = "application/json")
String batchTransactions(
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
String batchTransactions(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
@RequestHeader(value = HEADER_CLIENT_CORRELATION_ID) String requestId,
@RequestHeader(value = FILE_NAME, required = false) String fileName,
@RequestHeader(value = PURPOSE) String purpose,
@RequestHeader(value = HEADER_TYPE) String type,
@RequestHeader(value = HEADER_PLATFORM_TENANT_ID) String tenant,
@RequestHeader(value = FILE_NAME, required = false) String fileName, @RequestHeader(value = PURPOSE) String purpose,
@RequestHeader(value = HEADER_TYPE) String type, @RequestHeader(value = HEADER_PLATFORM_TENANT_ID) String tenant,
@RequestHeader(value = HEADER_REGISTERING_INSTITUTE_ID, required = false) String registeringInstitutionId,
@RequestHeader(value = HEADER_PROGRAM_ID, required = false) String programId) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.mifos.processor.bulk.api.definition;

import static org.mifos.processor.bulk.zeebe.ZeebeVariables.FILE_NAME;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PURPOSE;

import java.io.IOException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

import static org.mifos.processor.bulk.zeebe.ZeebeVariables.FILE_NAME;
import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PURPOSE;

public interface BulkTransfer {

@Deprecated

@PostMapping(value = "/bulk/transfer/{requestId}/{fileName}", produces = "application/json")
String bulkTransfer(@RequestHeader(value = "X-CorrelationID", required = false) String requestId,
@RequestParam("data") MultipartFile file, @RequestHeader(value = FILE_NAME, required = false) String fileName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.mifos.processor.bulk.api.definition;

import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;

// from("rest:post:/simulate").log("Reached Simulation");
public interface Simulate {

@PostMapping(value = "/simulate", produces="application/json")
@PostMapping(value = "/simulate", produces = "application/json")
void simulate(HttpServletResponse httpServletResponse) throws IOException;

}
Loading

0 comments on commit 398050e

Please sign in to comment.