Skip to content

Commit

Permalink
change RPARequestHandler interface name and update javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
elmiomar committed Mar 7, 2024
1 parent 2df7be4 commit 383cc7c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import gov.nist.oar.distrib.service.RPACachingService;
import gov.nist.oar.distrib.service.rpa.exceptions.InvalidRecaptchaException;
import gov.nist.oar.distrib.service.rpa.exceptions.InvalidRequestException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecaptchaClientException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecaptchaServerException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecaptchaVerificationFailedException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecordNotFoundException;
import gov.nist.oar.distrib.service.rpa.exceptions.RequestProcessingException;
import gov.nist.oar.distrib.service.rpa.model.JWTToken;
import gov.nist.oar.distrib.service.rpa.model.RecaptchaResponse;
import gov.nist.oar.distrib.service.rpa.model.Record;
import gov.nist.oar.distrib.service.rpa.model.RecordStatus;
import gov.nist.oar.distrib.service.rpa.model.RecordWrapper;
Expand Down Expand Up @@ -45,10 +40,14 @@


/**
* An implementation of the RPARequestHandlerService that uses HttpURLConnection to send HTTP requests and
* receives responses from the Salesforce service.
* An implementation of the {@link RPARequestHandler} interface that uses HttpURLConnection
* to send HTTP requests and receive responses from the Salesforce service. This class serves
* as a bridge between the application and Salesforce, acting as the data source for managing
* records. Through this service, records can be created, retrieved, and updated directly in
* Salesforce, using the platform's API for record management.
*
*/
public class HttpURLConnectionRPARequestHandlerService implements IRPARequestHandler {
public class HttpURLConnectionRPARequestHandlerService implements RPARequestHandler {

private final static Logger LOGGER = LoggerFactory.getLogger(HttpURLConnectionRPARequestHandlerService.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import gov.nist.oar.distrib.service.rpa.model.UserInfoWrapper;

/**
* An interface for handling requests to manage records.
* An interface for handling requests to manage records. This includes operations
* such as creating, retrieving, and updating records. Implementations of this interface
* are responsible for the interaction with a data source to perform these operations.
*/
public interface IRPARequestHandler {
public interface RPARequestHandler {

/**
* Updates the status of a record by ID.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gov.nist.oar.distrib.web;

import gov.nist.oar.distrib.service.RPACachingService;
import gov.nist.oar.distrib.service.rpa.IRPARequestHandler;
import gov.nist.oar.distrib.service.rpa.RPARequestHandler;
import gov.nist.oar.distrib.service.rpa.exceptions.InvalidRequestException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecaptchaClientException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecaptchaServerException;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class RPARequestHandlerController {
/**
* The primary service for handling RPA requests.
*/
IRPARequestHandler service = null;
RPARequestHandler service = null;

/**
* The sanitizer for incoming requests.
Expand Down Expand Up @@ -114,7 +114,7 @@ public RPARequestHandlerController(RPAServiceProvider rpaServiceProvider,
RPACachingService cachingService)
{
if (cachingService != null && rpaServiceProvider != null)
this.service = rpaServiceProvider.getIRPARequestHandler(cachingService);
this.service = rpaServiceProvider.getRPARequestHandler(cachingService);
this.requestSanitizer = new RequestSanitizer();
this.configuration = rpaServiceProvider.getRpaConfiguration();
this.jwtTokenValidator = new JwtTokenValidator(this.configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gov.nist.oar.distrib.service.RPACachingService;
import gov.nist.oar.distrib.service.rpa.HttpURLConnectionRPARequestHandlerService;
import gov.nist.oar.distrib.service.rpa.IRPARequestHandler;
import gov.nist.oar.distrib.service.rpa.RPARequestHandler;

public class RPAServiceProvider {
RPAConfiguration rpaConfiguration;
Expand All @@ -11,11 +11,11 @@ public RPAServiceProvider(RPAConfiguration rpaConfiguration) {
this.rpaConfiguration = rpaConfiguration;
}

public IRPARequestHandler getIRPARequestHandler(RPACachingService rpaCachingService) {
public RPARequestHandler getRPARequestHandler(RPACachingService rpaCachingService) {
return this.getHttpURLConnectionRPARequestHandler(rpaCachingService);
}

private IRPARequestHandler getHttpURLConnectionRPARequestHandler(RPACachingService rpaCachingService) {
private RPARequestHandler getHttpURLConnectionRPARequestHandler(RPACachingService rpaCachingService) {
return new HttpURLConnectionRPARequestHandlerService(this.rpaConfiguration, rpaCachingService);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import gov.nist.oar.distrib.service.RPACachingService;
import gov.nist.oar.distrib.service.rpa.IRPARequestHandler;
import gov.nist.oar.distrib.service.rpa.RPARequestHandler;
import gov.nist.oar.distrib.service.rpa.RecaptchaHelper;
import gov.nist.oar.distrib.service.rpa.exceptions.InvalidRequestException;
import gov.nist.oar.distrib.service.rpa.exceptions.RecaptchaVerificationFailedException;
Expand Down Expand Up @@ -51,7 +51,7 @@
@RunWith(MockitoJUnitRunner.class)
public class RPARequestHandlerControllerTest {
@Mock
private IRPARequestHandler service;
private RPARequestHandler service;

@Mock
RPAServiceProvider mockRPAServiceProvider;
Expand Down Expand Up @@ -79,7 +79,7 @@ public class RPARequestHandlerControllerTest {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(mockRPAServiceProvider.getIRPARequestHandler(mockRPACachingService)).thenReturn(service);
when(mockRPAServiceProvider.getRPARequestHandler(mockRPACachingService)).thenReturn(service);
// create a test instance of the RPARequestHandlerController class
controller = new RPARequestHandlerController(mockRPAServiceProvider, mockRPACachingService);
controller.setRequestSanitizer(mockRequestSanitizer);
Expand Down

0 comments on commit 383cc7c

Please sign in to comment.