Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.accounting.thirdparty.worldpay.
Thanks Kyra Pritzel-Hentley for reporting and providing the patch.
@@ -48,6 +48,7 @@ import org.apache.ofbiz.product.store.ProductStoreWorker;
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ModelService;
+import org.apache.ofbiz.service.ServiceUtil;
/**
* WorldPay Select Junior Integration Events/Services
@@ -249,7 +250,7 @@ public class WorldPayEvents {
}
}
// create the redirect string
- Map<String, Object> parameters = new HashMap<String, Object>();
+ Map<String, Object> parameters = new HashMap<>();
parameters.put("instId", instId);
parameters.put("cartId", orderId);
parameters.put("currency", defCur);
@@ -424,11 +425,11 @@ public class WorldPayEvents {
Locale locale = UtilHttp.getLocale(request);
String paymentStatus = request.getParameter("transStatus");
String paymentAmount = request.getParameter("authAmount");
- Long paymentDate = new Long(request.getParameter("transTime"));
+ Long paymentDate = Long.valueOf(request.getParameter("transTime"));
String transactionId = request.getParameter("transId");
String gatewayFlag = request.getParameter("rawAuthCode");
String avs = request.getParameter("AVS");
- List<GenericValue> toStore = new LinkedList<GenericValue>();
+ List<GenericValue> toStore = new LinkedList<>();
java.sql.Timestamp authDate = null;
try {
authDate = new java.sql.Timestamp(paymentDate.longValue());
@@ -481,7 +482,8 @@ public class WorldPayEvents {
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resourceErr, "worldPayEvents.failedToExecuteServiceCreatePaymentFromPreference", locale));
return false;
}
- if ((results == null) || (results.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR))) {
+
+ if (ServiceUtil.isError(results)) {
Debug.logError((String) results.get(ModelService.ERROR_MESSAGE), module);
request.setAttribute("_ERROR_MESSAGE_", (String) results.get(ModelService.ERROR_MESSAGE));
return false;
