Fix call pianificate
This commit is contained in:
@@ -3,6 +3,7 @@ package it.integry.ems.schedule.new_cron_job.dto.operations.runners;
|
||||
import it.integry.ems.schedule.new_cron_job.dto.operations.CheckB2BAutomatedOperationDTO;
|
||||
import it.integry.ems.service.HttpRestWrapper;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
public class CheckB2BScheduledOperationRunner extends BaseScheduledOperationRunner<CheckB2BAutomatedOperationDTO> {
|
||||
@@ -12,9 +13,10 @@ public class CheckB2BScheduledOperationRunner extends BaseScheduledOperationRunn
|
||||
public void run() throws Exception {
|
||||
final HttpRestWrapper httpRestWrapper = ContextLoader.getCurrentWebApplicationContext().getBean(HttpRestWrapper.class);
|
||||
|
||||
final Object internalGetResponse = httpRestWrapper.callInternalGet(getDtoInstance().getProfileDb(),
|
||||
final Object internalGetResponse = httpRestWrapper.callInternalMethod(getDtoInstance().getProfileDb(),
|
||||
EmsRestConstants.PATH_READ_FPX_INBOX,
|
||||
getDtoInstance().getUsername());
|
||||
getDtoInstance().getUsername(),
|
||||
RequestMethod.POST);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -57,24 +57,39 @@ public class HttpRestWrapper {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Object callInternalGet(String profileDb, String service, String username) throws Exception {
|
||||
public Object callInternalMethod(String profileDb, String service, String username, RequestMethod requestMethod) throws Exception {
|
||||
final String endPoint = String.format("http://localhost:%s/ems-api/", UtilityServer.getLocalServerPort());
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
final WebTarget resource = client.target(endPoint)
|
||||
.path(service);
|
||||
|
||||
Response response = resource
|
||||
final Invocation.Builder requestBuilder = resource
|
||||
.queryParam(CommonConstants.PROFILE_DB, profileDb)
|
||||
.request()
|
||||
//.header("Authorization", "Basic " + auth)
|
||||
.header("username", username)
|
||||
.get();
|
||||
.header("username", username);
|
||||
|
||||
Response response = null;
|
||||
|
||||
switch (requestMethod) {
|
||||
default:
|
||||
case GET:
|
||||
response = requestBuilder.get();
|
||||
break;
|
||||
|
||||
case POST:
|
||||
response = requestBuilder.post(null);
|
||||
break;
|
||||
|
||||
case PUT:
|
||||
response = requestBuilder.put(null);
|
||||
break;
|
||||
}
|
||||
|
||||
int status = response.getStatus();
|
||||
|
||||
if(status != 200)
|
||||
if (status != 200)
|
||||
throw new InternalRestCallException(status);
|
||||
|
||||
String stringResponse = response.readEntity(String.class);
|
||||
|
||||
@@ -409,15 +409,9 @@ public class DocumentController {
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_READ_FPX_INBOX, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse readMail(@RequestParam(CommonConstants.PROFILE_DB) String configuration) {
|
||||
ServiceRestResponse serviceRestResponse = ServiceRestResponse.createPositiveResponse();
|
||||
try {
|
||||
ServiceRestResponse readMail(@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
digitalInvoiceMailService.readMailInbox();
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
serviceRestResponse = ServiceRestResponse.createNegativeResponse(ex);
|
||||
}
|
||||
return serviceRestResponse;
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_FPX_TO_PDF, method = RequestMethod.POST)
|
||||
@@ -512,6 +506,7 @@ public class DocumentController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_CAMBIO_TIPO_DOC, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
List<ServiceRestResponse> cambioTipoDoc(HttpServletRequest request,
|
||||
@@ -540,7 +535,7 @@ public class DocumentController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse cambioTipoDocPlan(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration ) throws Exception {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
|
||||
try {
|
||||
cambioTipoDocPlanService.cambioTipoDoc();
|
||||
|
||||
Reference in New Issue
Block a user