Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-33318] #14

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,19 @@ jobs:
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

sonar_analysis:
needs: build-maven-image-compressor
if: "${{ github.event_name != 'pull_request' }}"
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21
with:
SERVICE_LOCATION: image-compressor
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
ORG_KEY: ${{ secrets.ORG_KEY }}
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}


41 changes: 32 additions & 9 deletions image-compressor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<maven.assembly.plugin.version>3.1.1</maven.assembly.plugin.version>
<nexus.staging.maven.plugin.version>1.6.7</nexus.staging.maven.plugin.version>
<spring.boot.maven.plugin.version>3.2.5</spring.boot.maven.plugin.version>
<maven.sonar.plugin.version>3.7.0.1746</maven.sonar.plugin.version>

<!-- git -->
<git.commit.id.plugin.version>3.0.1</git.commit.id.plugin.version>
Expand Down Expand Up @@ -191,13 +192,6 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<!-- <manifest>
<addClasspath>true</addClasspath>
<mainClass>registrationtest.runapplication.RegistrationMain</mainClass>
</manifest>
-->
</archive>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -271,7 +265,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven.gpg.plugin.version}</version>
<!--<configuration> <skip>true</skip> </configuration>-->
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down Expand Up @@ -346,10 +339,40 @@
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<!-- <format>json</format> -->
</configuration>
</plugin>

</plugins>
</build>
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.sources>.</sonar.sources>
<sonar.inclusions>src/main/java/**,src/main/resources/**</sonar.inclusions>
<sonar.exclusions>${sonar.coverage.exclusions}</sonar.exclusions>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${maven.sonar.plugin.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public enum ResponseStatus {
UNKNOWN_ERROR(500, "UNKNOWN_ERROR");

ResponseStatus(int statusCode, String statusMessage) {
this.setStatusCode(statusCode);
this.setStatusMessage(statusMessage);
this.statusCode = statusCode;
this.statusMessage = statusMessage;
}

private int statusCode;
Expand All @@ -21,18 +21,11 @@ public enum ResponseStatus {
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}

public String getStatusMessage() {
return statusMessage;
}

public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}

public static ResponseStatus fromStatusCode(int code) {
for (ResponseStatus paramCode : ResponseStatus.values()) {
if (paramCode.getStatusCode() == code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
*
*/
public class SdkConstant {
private SdkConstant() {
throw new IllegalStateException("SdkConstant class");
}

/**
* 0 to Double.Max_value
*/
public static String IMAGE_COMPRESSOR_RESIZE_FACTOR_FX = "mosip.bio.image.compressor.resize.factor.fx";
public static final String IMAGE_COMPRESSOR_RESIZE_FACTOR_FX = "mosip.bio.image.compressor.resize.factor.fx";
/**
* 0 to Double.Max_value
*/
public static String IMAGE_COMPRESSOR_RESIZE_FACTOR_FY = "mosip.bio.image.compressor.resize.factor.fy";
public static final String IMAGE_COMPRESSOR_RESIZE_FACTOR_FY = "mosip.bio.image.compressor.resize.factor.fy";
/**
* 1 to 1000
*/
public static String IMAGE_COMPRESSOR_COMPRESSION_RATIO = "mosip.bio.image.compressor.compression.ratio";
public static final String IMAGE_COMPRESSOR_COMPRESSION_RATIO = "mosip.bio.image.compressor.compression.ratio";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import io.mosip.image.compressor.sdk.constant.ResponseStatus;
import io.mosip.image.compressor.sdk.service.ImageCompressionService;
import io.mosip.image.compressor.sdk.service.SDKInfoService;
import io.mosip.kernel.biometrics.constant.BiometricType;
import io.mosip.kernel.biometrics.entities.BiometricRecord;
import io.mosip.kernel.biometrics.model.MatchDecision;
import io.mosip.kernel.biometrics.model.QualityCheck;
import io.mosip.kernel.biometrics.model.Response;
import io.mosip.kernel.biometrics.model.SDKInfo;
import io.mosip.kernel.biometrics.spi.IBioApi;
import io.mosip.image.compressor.sdk.constant.ResponseStatus;
import io.mosip.image.compressor.sdk.service.ImageCompressionService;
import io.mosip.image.compressor.sdk.service.SDKInfoService;

/**
* The Class ImageCompressorSDK.
Expand All @@ -30,20 +27,20 @@
*/
@Component
@EnableAutoConfiguration
@Deprecated
public class ImageCompressorSDK implements IBioApi {
private Logger LOGGER = LoggerFactory.getLogger(ImageCompressorSDK.class);

@Deprecated(since="1.2.0.1", forRemoval=true)
public class ImageCompressorSDK implements IBioApi // NOSONAR
{
/** The environment. */
@Autowired
private Environment env;
@Autowired // NOSONAR
private Environment env;

private static final String API_VERSION = "0.9";

private static final String ERROR_NOT_IMPLEMENTED = "Sorry! Method functionality not implemented...";

@Override
public SDKInfo init(Map<String, String> initParams) {
// TODO validate for mandatory initParams
SDKInfoService service = new SDKInfoService(env, API_VERSION, "sample", "sample", "sample");
SDKInfoService service = new SDKInfoService(env, API_VERSION, "sample", "sample", "sample");// NOSONAR
return service.getSDKInfo();
}

Expand All @@ -52,7 +49,8 @@ public Response<QualityCheck> checkQuality(BiometricRecord sample, List<Biometri
Map<String, String> flags) {
Response<QualityCheck> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(),
ERROR_NOT_IMPLEMENTED));// NOSONAR
response.setResponse(null);
return response;
}
Expand All @@ -62,7 +60,8 @@ public Response<MatchDecision[]> match(BiometricRecord sample, BiometricRecord[]
List<BiometricType> modalitiesToMatch, Map<String, String> flags) {
Response<MatchDecision[]> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(),
ERROR_NOT_IMPLEMENTED));
response.setResponse(null);
return response;
}
Expand All @@ -79,7 +78,8 @@ public Response<BiometricRecord> segment(BiometricRecord sample, List<BiometricT
Map<String, String> flags) {
Response<BiometricRecord> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(),
ERROR_NOT_IMPLEMENTED));
response.setResponse(null);
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import io.mosip.image.compressor.sdk.constant.ResponseStatus;
import io.mosip.image.compressor.sdk.service.ImageCompressionService;
import io.mosip.image.compressor.sdk.service.SDKInfoService;
import io.mosip.kernel.biometrics.constant.BiometricType;
import io.mosip.kernel.biometrics.entities.BiometricRecord;
import io.mosip.kernel.biometrics.model.MatchDecision;
import io.mosip.kernel.biometrics.model.QualityCheck;
import io.mosip.kernel.biometrics.model.Response;
import io.mosip.kernel.biometrics.model.SDKInfo;
import io.mosip.kernel.biometrics.spi.IBioApiV2;
import io.mosip.image.compressor.sdk.constant.ResponseStatus;
import io.mosip.image.compressor.sdk.service.ImageCompressionService;
import io.mosip.image.compressor.sdk.service.SDKInfoService;

/**
* The Class ImageCompressorSDKV2.
Expand All @@ -31,18 +28,16 @@
@Component
@EnableAutoConfiguration
public class ImageCompressorSDKV2 implements IBioApiV2 {
private Logger LOGGER = LoggerFactory.getLogger(ImageCompressorSDKV2.class);

/** The environment. */
@Autowired
@Autowired // NOSONAR
private Environment env;

private static final String API_VERSION = "0.9";
private static final String ERROR_NOT_IMPLEMENTED = "Sorry! Method functionality not implemented...";

@Override
public SDKInfo init(Map<String, String> initParams) {
// TODO validate for mandatory initParams
SDKInfoService service = new SDKInfoService(env, API_VERSION, "sample", "sample", "sample");
SDKInfoService service = new SDKInfoService(env, API_VERSION, "sample", "sample1", "sample2");
return service.getSDKInfo();
}

Expand All @@ -51,7 +46,8 @@ public Response<QualityCheck> checkQuality(BiometricRecord sample, List<Biometri
Map<String, String> flags) {
Response<QualityCheck> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(
String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(), ERROR_NOT_IMPLEMENTED));
response.setResponse(null);
return response;
}
Expand All @@ -61,7 +57,8 @@ public Response<MatchDecision[]> match(BiometricRecord sample, BiometricRecord[]
List<BiometricType> modalitiesToMatch, Map<String, String> flags) {
Response<MatchDecision[]> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(
String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(), ERROR_NOT_IMPLEMENTED));
response.setResponse(null);
return response;
}
Expand All @@ -78,26 +75,31 @@ public Response<BiometricRecord> segment(BiometricRecord sample, List<BiometricT
Map<String, String> flags) {
Response<BiometricRecord> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(
String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(), ERROR_NOT_IMPLEMENTED));
response.setResponse(null);
return response;
}

/**
* @deprecated (use convertFormatV2)
*/
@Override
@Deprecated
@Deprecated(since = "1.2.0.1", forRemoval = true)
public BiometricRecord convertFormat(BiometricRecord sample, String sourceFormat, String targetFormat,
Map<String, String> sourceParams, Map<String, String> targetParams,
List<BiometricType> modalitiesToConvert) {
return null;
}

@Override
public Response<BiometricRecord> convertFormatV2(BiometricRecord record, String sourceFormat, String targetFormat,
Map<String, String> sourceParams, Map<String, String> targetParams,
public Response<BiometricRecord> convertFormatV2(BiometricRecord bioRecord, String sourceFormat,
String targetFormat, Map<String, String> sourceParams, Map<String, String> targetParams,
List<BiometricType> modalitiesToConvert) {
Response<BiometricRecord> response = new Response<>();
response.setStatusCode(ResponseStatus.UNKNOWN_ERROR.getStatusCode());
response.setStatusMessage(String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage() + " Sorry! Method functionality not implemented..."));
response.setStatusMessage(
String.format(ResponseStatus.UNKNOWN_ERROR.getStatusMessage(), ERROR_NOT_IMPLEMENTED));
response.setResponse(null);
return response;
}
Expand Down
Loading
Loading