99import software .amazon .awssdk .http .async .SdkAsyncHttpClient ;
1010import software .amazon .awssdk .http .nio .netty .NettyNioAsyncHttpClient ;
1111import software .amazon .awssdk .regions .Region ;
12- import software .amazon .awssdk .services .entityresolution .EntityResolutionClient ;
1312import software .amazon .awssdk .services .entityresolution .EntityResolutionAsyncClient ;
14-
13+ import org .slf4j .Logger ;
14+ import org .slf4j .LoggerFactory ;
1515import software .amazon .awssdk .services .entityresolution .model .CreateMatchingWorkflowRequest ;
1616import software .amazon .awssdk .services .entityresolution .model .CreateMatchingWorkflowResponse ;
1717import software .amazon .awssdk .services .entityresolution .model .CreateSchemaMappingRequest ;
3535import software .amazon .awssdk .services .s3 .model .PutObjectResponse ;
3636import software .amazon .awssdk .services .s3 .model .S3Exception ;
3737import software .amazon .awssdk .services .entityresolution .model .TagResourceRequest ;
38-
3938import java .time .Duration ;
4039import java .util .HashMap ;
4140import java .util .List ;
4241import java .util .Map ;
4342import java .util .concurrent .CompletableFuture ;
4443
4544public class EntityResActions {
46-
47- private EntityResolutionClient resolutionClient ;
45+ private static final Logger logger = LoggerFactory .getLogger (EntityResActions .class );
4846
4947 private static EntityResolutionAsyncClient entityResolutionAsyncClient ;
5048
@@ -128,7 +126,7 @@ public void ListSchemaMappings() {
128126 // Iterate through the pages of results
129127 CompletableFuture <Void > future = paginator .subscribe (response -> {
130128 response .schemaList ().forEach (schemaMapping ->
131- System . out . println ("Schema Mapping Name: " +schemaMapping .schemaName ())
129+ logger . info ("Schema Mapping Name: " +schemaMapping .schemaName ())
132130 );
133131 });
134132
@@ -182,7 +180,7 @@ public CompletableFuture<CreateSchemaMappingResponse> createSchemaMappingAsync(S
182180 return getResolutionAsyncClient ().createSchemaMapping (request )
183181 .whenComplete ((response , exception ) -> {
184182 if (response != null ) {
185- System . out . println ("Schema Mapping Created Successfully!" );
183+ logger . info ("Schema Mapping Created Successfully!" );
186184 } else {
187185 throw new RuntimeException ("Failed to create schema mapping: " + exception .getMessage (), exception );
188186 }
@@ -207,7 +205,7 @@ public CompletableFuture<GetSchemaMappingResponse> getSchemaMappingAsync(String
207205 .whenComplete ((response , exception ) -> {
208206 if (response != null ) {
209207 response .mappedInputFields ().forEach (attribute ->
210- System . out . println ("Attribute Name: " + attribute .fieldName () +
208+ logger . info ("Attribute Name: " + attribute .fieldName () +
211209 ", Attribute Type: " + attribute .type ().toString ()));
212210 } else {
213211 throw new RuntimeException ("Failed to get schema mapping: " + exception .getMessage (), exception );
@@ -232,8 +230,8 @@ public CompletableFuture<Void> getMatchingJobAsync(String jobId, String workflow
232230
233231 return getResolutionAsyncClient ().getMatchingJob (request )
234232 .thenAccept (response -> {
235- System . out . println ("Job status: " + response .status ());
236- System . out . println ("Job details: " + response .toString ());
233+ logger . info ("Job status: " + response .status ());
234+ logger . info ("Job details: " + response .toString ());
237235 })
238236 .exceptionally (ex -> {
239237 throw new RuntimeException ("Error fetching matching job: " + ex .getMessage (), ex );
@@ -258,7 +256,7 @@ public CompletableFuture<String> startMatchingJobAsync(String workflowName) {
258256 if (response != null ) {
259257 // Get the job ID from the response
260258 String jobId = response .jobId ();
261- System . out . println ("Job ID: " + jobId );
259+ logger . info ("Job ID: " + jobId );
262260 } else {
263261 // Handle the exception if the response is null
264262 throw new RuntimeException ("Failed to start matching job: " + exception .getMessage (), exception );
@@ -284,11 +282,11 @@ public CompletableFuture<Boolean> checkWorkflowStatusCompleteAsync(String jobId,
284282
285283 return getResolutionAsyncClient ().getMatchingJob (request )
286284 .thenApply (response -> {
287- System . out . println ("\n Job status: " + response .status ());
285+ logger . info ("\n Job status: " + response .status ());
288286 return "SUCCEEDED" .equalsIgnoreCase (String .valueOf (response .status ()));
289287 })
290288 .exceptionally (exception -> {
291- System . out . println ("Error checking workflow status: " + exception .getMessage ());
289+ logger . info ("Error checking workflow status: " + exception .getMessage ());
292290 return false ;
293291 });
294292 }
@@ -336,7 +334,7 @@ public CompletableFuture<String> createMatchingWorkflowAsync(String roleARN, Str
336334 return getResolutionAsyncClient ().createMatchingWorkflow (workflowRequest )
337335 .whenComplete ((response , exception ) -> {
338336 if (response != null ) {
339- System . out . println ("Workflow created successfully." );
337+ logger . info ("Workflow created successfully." );
340338 } else {
341339 throw new RuntimeException ("Failed to create workflow: " + exception .getMessage (), exception );
342340 }
@@ -362,7 +360,7 @@ public CompletableFuture<Void> tagEntityResource(String schemaMappingARN) {
362360 .build ();
363361
364362 return getResolutionAsyncClient ().tagResource (request )
365- .thenAccept (response -> System . out . println ("Successfully tagged the resource." ))
363+ .thenAccept (response -> logger . info ("Successfully tagged the resource." ))
366364 .exceptionally (exception -> {
367365 throw new RuntimeException ("Failed to tag the resource: " + exception .getMessage (), exception );
368366 });
@@ -414,6 +412,4 @@ public boolean doesObjectExist(String bucketName) {
414412 return false ;
415413 }
416414 }
417-
418-
419415}
0 commit comments