Skip to content

Commit

Permalink
[MOSIP-33318] Merge develop from develop-java21
Browse files Browse the repository at this point in the history
Signed-off-by: JanardhanBS-SyncByte <[email protected]>
  • Loading branch information
JanardhanBS-SyncByte committed Jun 18, 2024
1 parent 13caf81 commit 2e5c264
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 97 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
/.metadata/
10 changes: 5 additions & 5 deletions image-compressor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>image-compressor</artifactId>
<groupId>io.mosip.image.compressor</groupId>
<version>0.0.1-java21-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
<name>image-compressor</name>
<description>Image Compressorimplementation of biometrics SDK</description>
<packaging>jar</packaging>
Expand Down Expand Up @@ -73,10 +73,10 @@
<git.commit.id.plugin.version>3.0.1</git.commit.id.plugin.version>

<!-- Mosip kernel -->
<kernel.bom.version>1.2.1-java21-SNAPSHOT</kernel.bom.version>
<kernel.core.version>1.2.1-java21-SNAPSHOT</kernel.core.version>
<kernel.biometrics.api.version>1.2.1-java21-SNAPSHOT</kernel.biometrics.api.version>
<biometrics-util.version>1.2.1-java21-SNAPSHOT</biometrics-util.version>
<kernel.bom.version>1.2.1-SNAPSHOT</kernel.bom.version>
<kernel.core.version>1.2.1-SNAPSHOT</kernel.core.version>
<kernel.biometrics.api.version>1.2.1-SNAPSHOT</kernel.biometrics.api.version>
<biometrics-util.version>1.2.1-SNAPSHOT</biometrics-util.version>

<!-- utilities -->
<jai.imageio.jpeg2000.version>1.3.0</jai.imageio.jpeg2000.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,95 @@
package io.mosip.image.compressor.sdk.constant;

/**
* Enumeration representing various HTTP response statuses used by the BioSDK
* client.
*
* This enum defines commonly used HTTP response statuses and their
* corresponding messages for responses generated by the BioSDK client
* application. It provides a standardized way to communicate success or error
* conditions to external clients.
*
* @author Janardhan B S
* @since 1.0.0
*/
public enum ResponseStatus {
/**
* Indicates a successful operation.
*
* This status code (200) and message ("OK") are used when the BioSDK client
* processes a request successfully and has a valid response to return.
*/
SUCCESS(200, "OK"),
INVALID_INPUT(401, "Invalid Input Parameter"),
MISSING_INPUT(402, "Missing Input Parameter"),

/**
* Indicates an invalid input parameter in the request.
*
* This status code (400) and message format ("Invalid Input Parameter - %s")
* are used when a required input parameter is missing, has an invalid format,
* or violates any defined validation rules. The specific parameter name or
* details can be included in the formatted message using String.format().
*/
INVALID_INPUT(401, "Invalid Input Parameter - %s"),

/**
* Indicates a missing input parameter in the request.
*
* This status code (402) and message format ("Missing Input Parameter - %s")
* are used when a required input parameter is completely absent from the
* request. The specific parameter name can be included in the formatted message
* using String.format().
*/
MISSING_INPUT(402, "Missing Input Parameter - %s"),

/**
* Indicates a failure during quality check of biometric data.
*
* This status code (403) and message ("Quality check of Biometric data failed")
* are used when the BioSDK client performs quality checks on biometric data and
* the data fails to meet the minimum quality requirements.
*/
QUALITY_CHECK_FAILED(403, "Quality check of Biometric data failed"),

/**
* Indicates a failure during biometric data not found.
*
* This status code (404) and message ("Biometric data not found").
*/
BIOMETRIC_NOT_FOUND_IN_CBEFF(404, "Biometrics not found in CBEFF"),

/**
* Indicates a failure during biometric data Mathcing data failed.
*
* This status code (405) and message ("Matching of Biometric data failed").
*/
MATCHING_OF_BIOMETRIC_DATA_FAILED(405, "Matching of Biometric data failed"),

/**
* Indicates poor quality of provided data.
*
* This status code (406) and message ("Data provided is of poor quality") , although
* technically valid, might be of insufficient quality for further processing.
*/
POOR_DATA_QUALITY(406, "Data provided is of poor quality"),

/**
* Indicates an unexpected error occurred on the server.
*
* This status code (500) and message ("UNKNOWN_ERROR") are used as a catch-all
* for any internal server errors that may occur during processing. It's
* important to investigate and resolve the root cause of such errors for proper
* handling in future versions.
*/
UNKNOWN_ERROR(500, "UNKNOWN_ERROR");

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

private int statusCode;
private String statusMessage;

public int getStatusCode() {
return statusCode;
}
Expand All @@ -26,12 +98,12 @@ public String getStatusMessage() {
return statusMessage;
}

public static ResponseStatus fromStatusCode(int code) {
for (ResponseStatus paramCode : ResponseStatus.values()) {
if (paramCode.getStatusCode() == code) {
return paramCode;
}
}
return UNKNOWN_ERROR;
}
public static ResponseStatus fromStatusCode(int code) {
for (ResponseStatus paramCode : ResponseStatus.values()) {
if (paramCode.getStatusCode() == code) {
return paramCode;
}
}
return UNKNOWN_ERROR;
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
package io.mosip.image.compressor.sdk.constant;

/**
* The class contains variable names used from configuration
* Constants used in the Image Compressor SDK configuration.
* <p>
* This class provides constant variable names used in the configuration
* related to image compression and resizing factors.
* </p>
* <p>
* Example usage:
* <pre>{@code
* double resizeFactorFx = env.getProperty(SdkConstant.IMAGE_COMPRESSOR_RESIZE_FACTOR_FX, Double.class, 0.25);
* double resizeFactorFy = env.getProperty(SdkConstant.IMAGE_COMPRESSOR_RESIZE_FACTOR_FY, Double.class, 0.25);
* int compressionRatio = env.getProperty(SdkConstant.IMAGE_COMPRESSOR_COMPRESSION_RATIO, Integer.class, 50);
* }</pre>
* </p>
* <p>
* Note: The constants {@code IMAGE_COMPRESSOR_RESIZE_FACTOR_FX} and {@code IMAGE_COMPRESSOR_RESIZE_FACTOR_FY}
* represent the resize factors for image compression, and {@code IMAGE_COMPRESSOR_COMPRESSION_RATIO} represents
* the compression ratio.
* </p>
* <p>
* All constants are defined as {@code public static final} and are not meant to be instantiated.
* </p>
*
* @author Janardhan B S
*
* @since 1.0
*/
public class SdkConstant {
private SdkConstant() {
throw new IllegalStateException("SdkConstant class");
}

/**
* 0 to Double.Max_value
*/
* Configuration key for the resize factor FX used in image compression.
* <p>
* The value range is from 0 to {@code Double.MAX_VALUE}.
* </p>
*/
public static final String IMAGE_COMPRESSOR_RESIZE_FACTOR_FX = "mosip.bio.image.compressor.resize.factor.fx";
/**
* 0 to Double.Max_value
*/
/**
* Configuration key for the resize factor FY used in image compression.
* <p>
* The value range is from 0 to {@code Double.MAX_VALUE}.
* </p>
*/
public static final String IMAGE_COMPRESSOR_RESIZE_FACTOR_FY = "mosip.bio.image.compressor.resize.factor.fy";
/**
* 1 to 1000
*/
* Configuration key for the compression ratio used in image compression.
* <p>
* The value range is from 1 to 1000.
* </p>
*/
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 @@ -20,14 +20,38 @@
import io.mosip.kernel.biometrics.spi.IBioApi;

/**
* The Class ImageCompressorSDK.
*
* @author Janardhan B S
*
* This class is deprecated and will be removed in future versions.
* Deprecated implementation class for the Image Compressor SDK.
* <p>
* This class provides biometric operations that include initializing the SDK,
* quality checks, matching biometric samples, extracting templates, and segmenting samples.
* </p>
* <p>
* This class is deprecated and will be removed in a future release.
* Please migrate to {@link ImageCompressorSDKV2} for updated functionality.
* </p>
* <p>
* It uses Spring's {@code @Component} for automatic component scanning and {@code @EnableAutoConfiguration}
* for enabling Spring Boot auto-configuration.
* </p>
* <p>
* The methods in this class handle various response scenarios and use {@code Response} objects
* to encapsulate the response status, message, and data.
* </p>
* <p>
* Example usage:
* <pre>{@code
* ImageCompressorSDK sdk = new ImageCompressorSDK();
* SDKInfo sdkInfo = sdk.init(initParams);
* Response<BiometricRecord> response = sdk.extractTemplate(sample, modalitiesToExtract, flags);
* }</pre>
* </p>
*
* @author Janardhan B S
* @since 1.2.0.1
* @deprecated since 1.2.0.1, for removal in a future release
* @deprecated Since 1.2.0.1, for removal in a future release. Use {@link ImageCompressorSDKV2} instead.
* @see IBioApi
* @see ImageCompressionService
* @see SDKInfoService
*/
@Component
@EnableAutoConfiguration
Expand All @@ -43,12 +67,26 @@ public class ImageCompressorSDK implements IBioApi

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

/**
* Initializes the SDK with the provided initialization parameters.
*
* @param initParams The initialization parameters for the SDK.
* @return Information about the initialized SDK.
*/
@Override
public SDKInfo init(Map<String, String> initParams) {
SDKInfoService service = new SDKInfoService(env, API_VERSION, "sample1", "sample2", "sample3");
return service.getSDKInfo();
}

/**
* Performs quality check on the provided biometric sample.
*
* @param sample The biometric record sample to check.
* @param modalitiesToCheck The list of biometric types to check.
* @param flags Additional configuration flags.
* @return Response containing the quality check result.
*/
@Override
public Response<QualityCheck> checkQuality(BiometricRecord sample, List<BiometricType> modalitiesToCheck,
Map<String, String> flags) {
Expand All @@ -60,6 +98,15 @@ public Response<QualityCheck> checkQuality(BiometricRecord sample, List<Biometri
return response;
}

/**
* Matches the provided biometric sample against a gallery of biometric records.
*
* @param sample The biometric record sample to match.
* @param gallery The array of biometric records in the gallery.
* @param modalitiesToMatch The list of biometric types to match.
* @param flags Additional configuration flags.
* @return Response containing the match decision array.
*/
@Override
public Response<MatchDecision[]> match(BiometricRecord sample, BiometricRecord[] gallery,
List<BiometricType> modalitiesToMatch, Map<String, String> flags) {
Expand All @@ -71,13 +118,29 @@ public Response<MatchDecision[]> match(BiometricRecord sample, BiometricRecord[]
return response;
}

/**
* Extracts biometric template from the provided biometric sample.
*
* @param sample The biometric record sample to extract template from.
* @param modalitiesToExtract The list of biometric types to extract.
* @param flags Additional configuration flags.
* @return Response containing the extracted biometric record.
*/
@Override
public Response<BiometricRecord> extractTemplate(BiometricRecord sample, List<BiometricType> modalitiesToExtract,
Map<String, String> flags) {
ImageCompressionService service = new ImageCompressionService(env, sample, modalitiesToExtract, flags);
return service.getExtractTemplateInfo();
}

/**
* Segments the provided biometric sample into segments based on modalities.
*
* @param sample The biometric record sample to segment.
* @param modalitiesToSegment The list of biometric types to segment.
* @param flags Additional configuration flags.
* @return Response containing the segmented biometric record.
*/
@Override
public Response<BiometricRecord> segment(BiometricRecord sample, List<BiometricType> modalitiesToSegment,
Map<String, String> flags) {
Expand All @@ -89,10 +152,14 @@ public Response<BiometricRecord> segment(BiometricRecord sample, List<BiometricT
return response;
}

/**
* @deprecated (since 1.2.0.1, use {@code ImageCompressorSDKV2#convertFormatV2})
*/
@Override
@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;
}
}
}
Loading

0 comments on commit 2e5c264

Please sign in to comment.