Improved: Corrected checkstyle formatting issues, 'is preceded/not preceded with whitespace' for applications component.

(OFBIZ-11874)
This fixes following checkstyle issues:
'{' is not preceded with whitespace.
'{' is not followed by whitespace.
'}' is not followed by whitespace.
'}' is not preceded with whitespace.
'typecast' is not followed by whitespace.
'try' is not followed by whitespace.
';' is preceded with whitespace.
This commit is contained in:
Suraj Khurana
2020-07-11 14:29:35 +05:30
parent 932e28d444
commit bdc8c73fd8
106 changed files with 517 additions and 597 deletions
@@ -74,8 +74,8 @@ public class AgreementServices {
List<Map<String, Object>> commissions = new LinkedList<>();
try {
BigDecimal amount = ((BigDecimal)context.get("amount"));
BigDecimal quantity = (BigDecimal)context.get("quantity");
BigDecimal amount = ((BigDecimal) context.get("amount"));
BigDecimal quantity = (BigDecimal) context.get("quantity");
quantity = quantity == null ? BigDecimal.ONE : quantity;
boolean negative = amount.signum() < 0;
// Ensure that price and quantity are positive since the terms may not be linear.
@@ -224,7 +224,7 @@ public class InvoiceServices {
GenericValue billingAccount = orderHeader.getRelatedOne("BillingAccount", false);
String billingAccountId = billingAccount != null ? billingAccount.getString("billingAccountId") : null;
Timestamp invoiceDate = (Timestamp)context.get("eventDate");
Timestamp invoiceDate = (Timestamp) context.get("eventDate");
if (UtilValidate.isEmpty(invoiceDate)) {
// TODO: ideally this should be the same time as when a shipment is sent and be passed in as a parameter
invoiceDate = UtilDateTime.nowTimestamp();
@@ -1565,7 +1565,7 @@ public class InvoiceServices {
billAvail = BigDecimal.ZERO;
} else {
// now have been billed
if (issueQty == null){
if (issueQty == null) {
issueQty = BigDecimal.ZERO;
}
billAvail = billAvail.subtract(issueQty).setScale(DECIMALS, ROUNDING);
@@ -2320,7 +2320,7 @@ public class InvoiceServices {
}
String invoiceId = (String) context.get("invoiceId");
GenericValue invoice = null ;
GenericValue invoice = null;
try {
invoice = EntityQuery.use(delegator).from("Invoice").where("invoiceId", invoiceId).queryOne();
} catch (GenericEntityException e) {
@@ -61,7 +61,7 @@ public final class InvoiceWorker {
private static final int taxDecimals = UtilNumber.getBigDecimalScale("salestax.calc.decimals");
private static final RoundingMode taxRounding = UtilNumber.getRoundingMode("salestax.rounding");
private InvoiceWorker () {}
private InvoiceWorker() { }
/**
* Return the total amount of the invoice (including tax) using the the invoiceId as input.
@@ -210,7 +210,7 @@ public final class BillingAccountWorker {
}
@SuppressWarnings("serial")
protected static class BillingAccountComparator implements Comparator<Map<String, Object>>, Serializable{
protected static class BillingAccountComparator implements Comparator<Map<String, Object>>, Serializable {
@Override
public int compare(Map<String, Object> billingAccount1, Map<String, Object> billingAccount2) {
return ((BigDecimal)billingAccount1.get("accountBalance")).compareTo((BigDecimal)billingAccount2.get("accountBalance"));
@@ -1927,7 +1927,7 @@ public class PaymentGatewayServices {
// save the response and respective messages
savePgrAndMsgs(dctx, response, messageEntities);
if (response.getBigDecimal("amount").compareTo((BigDecimal)context.get("processAmount")) != 0) {
if (response.getBigDecimal("amount").compareTo((BigDecimal) context.get("processAmount")) != 0) {
Debug.logWarning("The authorized amount does not match the max amount : Response - " + response + " : result - " + context, MODULE);
}
@@ -307,7 +307,6 @@ public class PaymentMethodServices {
// get the masked card number from the db
String origCardNumber = creditCard.getString("cardNumber");
int cardLength = origCardNumber.length() - 4;
// use builder for better performance
StringBuilder builder = new StringBuilder();
for (int i = 0; i < cardLength; i++) {
@@ -214,7 +214,7 @@ public class AIMPaymentServices {
if (canDoVoid) {
Debug.logWarning("Refund was unsuccessful; will now attempt a VOID transaction.", MODULE);
BigDecimal authAmountObj = authTransaction.getBigDecimal("amount");
BigDecimal refundAmountObj = (BigDecimal)context.get("refundAmount");
BigDecimal refundAmountObj = (BigDecimal) context.get("refundAmount");
BigDecimal authAmount = authAmountObj != null ? authAmountObj : BigDecimal.ZERO;
BigDecimal refundAmount = refundAmountObj != null ? refundAmountObj : BigDecimal.ZERO;
if (authAmount.compareTo(refundAmount) == 0) {
@@ -363,7 +363,7 @@ public class AIMPaymentServices {
}
private static boolean isTestMode() {
return "true".equalsIgnoreCase((String)AIMProperties.get("testReq"));
return "true".equalsIgnoreCase((String) AIMProperties.get("testReq"));
}
private static Properties buildAIMProperties(Map<String, Object> context, Delegator delegator) {
@@ -468,31 +468,28 @@ public class AIMPaymentServices {
if (UtilValidate.isNotEmpty(duplicateWindow)) {
AIMRequest.put("x_duplicate_window", props.getProperty("duplicateWindow"));
}
// CP market type
String cpMarketType = props.getProperty("cpMarketType");
if (UtilValidate.isNotEmpty(cpMarketType)) {
AIMRequest.put("x_market_type", cpMarketType);
// CP test mode
if ("true".equalsIgnoreCase(props.getProperty("testReq"))) {
AIMRequest.put("x_test_request", props.getProperty("testReq"));
AIMRequest.put("x_test_request", props.getProperty("testReq"));
}
}
// CP device typ
String cpDeviceType = props.getProperty("cpDeviceType");
if (UtilValidate.isNotEmpty(cpDeviceType)) {
AIMRequest.put("x_device_type", cpDeviceType);
}
}
}
private static void buildGatewayResponeConfig(Map<String, Object> params, Properties props, Map<String, Object> AIMRequest) {
if (AIMRequest.get("x_market_type") != null) {
// card present transaction
AIMRequest.put("x_response_format", "true".equalsIgnoreCase(props.getProperty("delimited")) ? "1" : "0");
AIMRequest.put("x_response_format", "true".equalsIgnoreCase(props.getProperty("delimited")) ? "1" : "0");
} else {
AIMRequest.put("x_Delim_Data", props.getProperty("delimited"));
AIMRequest.put("x_Delim_Data", props.getProperty("delimited"));
}
AIMRequest.put("x_Delim_Char", props.getProperty("delimiter"));
}
@@ -520,7 +517,7 @@ public class AIMPaymentServices {
AIMRequest.put("x_Zip", UtilFormatOut.checkNull(address.getString("postalCode")));
AIMRequest.put("x_Country", UtilFormatOut.checkNull(address.getString("countryGeoId")));
}
}
}
} else {
Debug.logWarning("Payment preference " + opp + " is not a credit card", MODULE);
}
@@ -573,7 +570,7 @@ public class AIMPaymentServices {
String expDate = UtilFormatOut.checkNull(cc.getString("expireDate"));
String cardSecurityCode = (String) params.get("cardSecurityCode");
AIMRequest.put("x_Amount", amount);
AIMRequest.put("x_Currency_Code", currency);
AIMRequest.put("x_Currency_Code", currency);
AIMRequest.put("x_Method", props.getProperty("method"));
AIMRequest.put("x_Type", props.getProperty("transType"));
AIMRequest.put("x_Card_Num", number);
@@ -793,7 +790,7 @@ public class AIMPaymentServices {
}
private static String getPaymentGatewayConfigValue(Delegator delegator, String paymentGatewayConfigId, String paymentGatewayConfigParameterName,
String RESOURCE, String parameterName) {
String resource, String parameterName) {
String returnValue = "";
if (UtilValidate.isNotEmpty(paymentGatewayConfigId)) {
try {
@@ -808,24 +805,22 @@ public class AIMPaymentServices {
Debug.logError(e, MODULE);
}
} else {
String value = EntityUtilProperties.getPropertyValue(RESOURCE, parameterName, delegator);
String value = EntityUtilProperties.getPropertyValue(resource, parameterName, delegator);
if (value != null) {
returnValue = value.trim();
}
}
return returnValue;
}
private static String getCardType(String cardType) {
if (("CCT_VISA".equalsIgnoreCase(cardType))) return "V";
if (("CCT_MASTERCARD".equalsIgnoreCase(cardType))) return "M";
if ((("CCT_AMERICANEXPRESS".equalsIgnoreCase(cardType)) || ("CCT_AMEX".equalsIgnoreCase(cardType)))) return "A";
if (("CCT_DISCOVER".equalsIgnoreCase(cardType))) return "D";
if (("CCT_JCB".equalsIgnoreCase(cardType))) return "J";
if ((("CCT_DINERSCLUB".equalsIgnoreCase(cardType)))) return "C";
if ((("CCT_DINERSCLUB".equalsIgnoreCase(cardType)))) return "C";
return "";
}
private static BigDecimal getXAmount(Map<String, Object> request) {
BigDecimal amt = BigDecimal.ZERO;
if (request.get("x_Amount") != null) {
@@ -36,12 +36,10 @@ public class AIMRespPositions extends AuthorizeResponse.RespPositions {
positions.put(AuthorizeResponse.TRANSACTION_ID, 7);
positions.put(AuthorizeResponse.AMOUNT, 10);
}
@Override
public int getPosition(String name) {
return positions.getOrDefault(name, -1);
}
@Override
public String getApprovalString() {
return "1";
@@ -29,14 +29,11 @@ public class AuthorizeResponse {
private String[] response;
private RespPositions pos;
private String rawResp;
// response types
public static final int AIM_RESPONSE = 1;
public static final int CP_RESPONSE = 2;
// status constants
public static final String ERROR = "Error";
public static final String ERROR = "Error";
// positions of the result
public static final String RESPONSE_CODE = "RESPONSE_CODE";
public static final String REASON_CODE = "REASON_CODE";
@@ -46,58 +43,47 @@ public class AuthorizeResponse {
public static final String CVV_RESULT_CODE = "CVV_RESULT_CODE";
public static final String TRANSACTION_ID = "TRANSACTION_ID";
public static final String AMOUNT = "AMOUNT";
// singletons
private static final AIMRespPositions aimPos = new AIMRespPositions();
private static final CPRespPositions cpPos = new CPRespPositions();
public AuthorizeResponse(String resp, int responseType) {
this(resp, "\\|", responseType);
}
public AuthorizeResponse(String resp, String delim, int responseType) {
this.rawResp = resp;
this.response = resp.split(delim);
if (responseType == CP_RESPONSE) {
pos = cpPos;
} else {
pos = aimPos;
}
}
public boolean isApproved() {
return pos.getApprovalString().equals(getResponseCode());
}
public String getTransactionId() {
return getResponseField(TRANSACTION_ID);
}
public String getAuthorizationCode() {
return getResponseField(AUTHORIZATION_CODE);
}
public String getResponseCode() {
return getResponseField(RESPONSE_CODE);
}
public String getReasonCode() {
return getResponseField(REASON_CODE);
}
public String getReasonText() {
return getResponseField(REASON_TEXT);
}
public String getAvsResult() {
return getResponseField(AVS_RESULT_CODE);
}
public String getCvResult() {
return getResponseField(CVV_RESULT_CODE);
}
public BigDecimal getAmount() {
BigDecimal amount = BigDecimal.ZERO;
String amtStr = getResponseField(AMOUNT);
@@ -106,11 +92,9 @@ public class AuthorizeResponse {
}
return amount;
}
public String getRawResponse() {
return this.rawResp;
}
private String getResponseField(String field) {
int position = pos.getPosition(field);
if (position == -1) {
@@ -118,7 +102,6 @@ public class AuthorizeResponse {
}
return getResponseField(position);
}
private String getResponseField(int position) {
if (response.length < position) {
return null;
@@ -127,13 +110,11 @@ public class AuthorizeResponse {
return response[position-1];
}
}
@Override
public String toString() {
return Arrays.toString(response);
}
public static abstract class RespPositions {
public static abstract class RespPositions {
public abstract int getPosition(String name);
public abstract String getApprovalString();
}
@@ -36,12 +36,10 @@ public class CPRespPositions extends AuthorizeResponse.RespPositions {
positions.put(AuthorizeResponse.TRANSACTION_ID, 8);
positions.put(AuthorizeResponse.AMOUNT, 25);
}
@Override
public int getPosition(String name) {
return positions.getOrDefault(name, -1);
}
@Override
public String getApprovalString() {
return "1";
@@ -66,22 +66,22 @@ public class EwayServices {
if (cc.get("expireDate") != null) {
String[] exp = cc.getString("expireDate").split("\\/");
req.setCardExpiryMonth(exp[0]);
req.setCardExpiryYear(exp[1]);
req.setCardExpiryYear(exp[1]);
}
// security code
if (UtilValidate.isNotEmpty(cvv2)) {
req.setCVN(cvv2);
req.setCVN(cvv2);
}
// billing address
if (address != null) {
String street = address.getString("address1") + ((UtilValidate.isNotEmpty(address.getString("address2"))) ? " " + address.getString("address2") : "");
req.setCustomerAddress(street);
req.setCustomerPostcode(address.getString("postalCode"));
req.setCustomerBillingCountry(address.getString("countryGeoId"));
req.setCustomerBillingCountry(address.getString("countryGeoId"));
}
// send the request
GatewayConnector con = new GatewayConnector();
GatewayResponse reply;
@@ -90,11 +90,9 @@ public class EwayServices {
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
// process the result
Map<String, Object> result = ServiceUtil.returnSuccess();
Map<String, Object> result = ServiceUtil.returnSuccess();
Boolean authResult = reply.getTrxnStatus();
// auth fields
result.put("authResult", authResult);
result.put("authMessage", reply.getTrxnError());
@@ -102,29 +100,27 @@ public class EwayServices {
result.put("authRefNum", reply.getTrxnNumber());
result.put("scoreCode", Double.valueOf(reply.getBeagleScore()).toString());
result.put("processAmount", reply.getTransactionAmount());
// capture fields
result.put("captureResult", result.get("authResult"));
result.put("captureMessage", result.get("authMessage"));
result.put("captureRefNum", result.get("authRefNum"));
result.put("captureRefNum", result.get("authRefNum"));
return result;
}
// eway refund
public static Map<String, Object> ewayRefund(DispatchContext dctx, Map<String, Object> context) {
public static Map<String, Object> ewayRefund(DispatchContext dctx, Map<String, Object> context) {
Delegator delegator = dctx.getDelegator();
GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
BigDecimal refundAmount = (BigDecimal) context.get("refundAmount");
Locale locale = (Locale) context.get("locale");
// original charge transaction
GenericValue chargeTrans = PaymentGatewayServices.getCaptureTransaction(paymentPref);
if (chargeTrans == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
}
// credit card used for transaction
GenericValue cc = null;
try {
@@ -134,62 +130,59 @@ public class EwayServices {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingPaymentUnableToGetCCInfo", locale));
}
// orig ref number
String refNum = chargeTrans.getString("referenceNum");
String orderId = paymentPref.getString("orderId");
GatewayRequest req = initRequest(dctx, context, true);
req.setCustomerInvoiceRef(orderId);
req.setTotalAmount(refundAmount);
req.setTrxnNumber(refNum);
// set the card expire date
if (cc.get("expireDate") != null) {
String[] exp = cc.getString("expireDate").split("\\/");
req.setCardExpiryMonth(exp[0]);
req.setCardExpiryYear(exp[1]);
req.setCardExpiryYear(exp[1]);
}
// send the request
GatewayConnector con = new GatewayConnector();
GatewayConnector con = new GatewayConnector();
GatewayResponse reply;
try {
reply = con.sendRequest(req);
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
// process the result
Map<String, Object> result = ServiceUtil.returnSuccess();
Boolean refundResult = reply.getTrxnStatus();
Map<String, Object> result = ServiceUtil.returnSuccess();
Boolean refundResult = reply.getTrxnStatus();
result.put("refundResult", refundResult);
result.put("refundMessage", reply.getTrxnError());
result.put("refundCode", reply.getAuthCode());
result.put("refundRefNum", reply.getTrxnNumber());
result.put("refundAmount", reply.getTransactionAmount());
return result;
}
// eway release (does a refund)
public static Map<String, Object> ewayRelease(DispatchContext dctx, Map<String, Object> context) {
public static Map<String, Object> ewayRelease(DispatchContext dctx, Map<String, Object> context) {
Delegator delegator = dctx.getDelegator();
GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
BigDecimal releaseAmount = (BigDecimal) context.get("releaseAmount");
Locale locale = (Locale) context.get("locale");
// original charge transaction
GenericValue chargeTrans = (GenericValue) context.get("authTrans");
if (chargeTrans == null) {
chargeTrans = PaymentGatewayServices.getAuthTransaction(paymentPref);
}
if (chargeTrans == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
// credit card used for transaction
GenericValue cc = null;
try {
@@ -199,23 +192,22 @@ public class EwayServices {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingPaymentUnableToGetCCInfo", locale));
}
// orig ref number
String refNum = chargeTrans.getString("referenceNum");
String orderId = paymentPref.getString("orderId");
GatewayRequest req = initRequest(dctx, context, true);
req.setCustomerInvoiceRef(orderId);
req.setTotalAmount(releaseAmount);
req.setTrxnNumber(refNum);
// set the card expire date
if (cc.get("expireDate") != null) {
String[] exp = cc.getString("expireDate").split("\\/");
req.setCardExpiryMonth(exp[0]);
req.setCardExpiryYear(exp[1]);
req.setCardExpiryYear(exp[1]);
}
// send the request
GatewayConnector con = new GatewayConnector();
GatewayResponse reply;
@@ -224,46 +216,40 @@ public class EwayServices {
} catch (Exception e) {
return ServiceUtil.returnError(e.getMessage());
}
// process the result
Map<String, Object> result = ServiceUtil.returnSuccess();
Boolean refundResult = reply.getTrxnStatus();
Map<String, Object> result = ServiceUtil.returnSuccess();
Boolean refundResult = reply.getTrxnStatus();
result.put("releaseResult", refundResult);
result.put("releaseMessage", reply.getTrxnError());
result.put("releaseCode", reply.getAuthCode());
result.put("releaseRefNum", reply.getTrxnNumber());
result.put("releaseAmount", reply.getTransactionAmount());
result.put("releaseAmount", reply.getTransactionAmount());
return result;
}
private static GatewayRequest initRequest(DispatchContext dctx, Map<String, Object> context, boolean refund) {
String pgcId = (String) context.get("paymentGatewayConfigId");
String cfgStr = (String) context.get("paymentConfig");
Delegator delegator = dctx.getDelegator();
String customerId = getPaymentGatewayConfigValue(delegator, pgcId, "customerId", cfgStr, "payment.eway.customerId");
String refundPwd = getPaymentGatewayConfigValue(delegator, pgcId, "refundPwd", cfgStr, "payment.eway.refundPwd");
Boolean testMode = "Y".equalsIgnoreCase(getPaymentGatewayConfigValue(delegator, pgcId, "testMode", cfgStr, "payment.eway.testMode"));
Boolean beagle = "Y".equalsIgnoreCase(getPaymentGatewayConfigValue(delegator, pgcId, "enableBeagle", cfgStr, "payment.eway.enableBeagle"));
Boolean cvn = "Y".equalsIgnoreCase(getPaymentGatewayConfigValue(delegator, pgcId, "enableCvn", cfgStr, "payment.eway.enableCvn"));
// the request mode
int requestMode = refund ? GatewayRequest.REQUEST_METHOD_REFUND : beagle ?
GatewayRequest.REQUEST_METHOD_BEAGLE : cvn ? GatewayRequest.REQUEST_METHOD_CVN : 0;
int requestMode = refund ? GatewayRequest.REQUEST_METHOD_REFUND : beagle
? GatewayRequest.REQUEST_METHOD_BEAGLE : cvn ? GatewayRequest.REQUEST_METHOD_CVN : 0;
// create the request object
GatewayRequest req = new GatewayRequest(requestMode);
req.setTestMode(testMode);
req.setCustomerID(customerId);
req.setCustomerID(customerId);
if (refund) {
req.setRefundPassword(refundPwd);
}
}
return req;
}
private static String getPaymentGatewayConfigValue(Delegator delegator, String cfgId, String cfgParamName,
String RESOURCE, String resParamName) {
String returnValue = "";
@@ -78,34 +78,28 @@ public class GatewayConnector {
* @throws Exception in case of networking and xml parsing errors
*/
public GatewayResponse sendRequest(GatewayRequest request) throws Exception {
// determine the gateway url to be used, based on the request type
String serverurl = request.getUrl();
GatewayResponse response = null;
InputStream in = null;
HttpURLConnection connection = null;
try {
// connect to the gateway
URL u = new URL(serverurl);
connection = (HttpURLConnection)(u.openConnection());
connection = (HttpURLConnection) (u.openConnection());
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST");
connection.setConnectTimeout(timeout*1000);
connection.setConnectTimeout(timeout * 1000);
try (OutputStream out = connection.getOutputStream();
Writer wout = new OutputStreamWriter(out, "UTF-8")) {
wout.write(request.toXml());
wout.flush();
in = connection.getInputStream();
response = new GatewayResponse(in, request);
return response;
}
}
catch (Exception e) {
} catch (Exception e) {
// re-throws exception so that the caller knows what went wrong
Debug.logError(e, e.getMessage(), MODULE);
throw e;
@@ -143,7 +143,7 @@ public class GatewayResponse {
NodeList list = doc.getElementsByTagName("*");
int length = list.getLength();
for (int i = 0; i < length; i++) {
Node node = list.item(i);
Node node = list.item(i);
String name = node.getNodeName();
if (name == "ewayResponse") {
continue;
@@ -195,12 +195,10 @@ public class GatewayResponse {
throw new Exception("Unknown field in response: " + name);
}
}
if (req.isTestMode()) {
Debug.logInfo("[eWay Reply]\n" + this.toString(), MODULE);
}
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
@@ -84,7 +84,7 @@ public class PayPalServices {
private static final String MODULE = PayPalServices.class.getName();
public final static String RESOURCE = "AccountingErrorUiLabels";
// Used to maintain a weak reference to the ShoppingCart for customers who have gone to PayPal to checkout
// so that we can quickly grab the cart, perform shipment estimates and send the info back to PayPal.
// The weak key is a simple wrapper for the checkout token String and is stored as a cart attribute. The value
@@ -1046,7 +1046,6 @@ public class PayPalServices {
GenericValue geoAssocAndGeoTo = null;
try {
geoAssocAndGeoTo = EntityQuery.use(delegator).from("GeoAssocAndGeoTo").where(cond).cache().queryFirst();
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
}
@@ -81,7 +81,7 @@ public class SagePayPaymentServices {
GenericValue billingAddress = (GenericValue) context.get("billingAddress");
postalCode = billingAddress.getString("postalCode");
String address2 = billingAddress.getString("address2");
if (address2 == null){
if (address2 == null) {
address2 = "";
}
address = billingAddress.getString("address1") + " " + address2;
@@ -91,7 +91,7 @@ public class SagePayPaymentServices {
String firstName = creditCard.getString("firstNameOnCard");
String middleName = creditCard.getString("middleNameOnCard");
String lastName = creditCard.getString("lastNameOnCard");
if (middleName == null){
if (middleName == null) {
middleName = "";
}
nameOnCard = firstName + " " + middleName + " " + lastName;
@@ -130,7 +130,7 @@ public class SagePayPaymentServices {
}
billingInfo.put("orderId", orderId);
if (processAmount != null){
if (processAmount != null) {
billingInfo.put("amount", processAmount.toString());
} else {
billingInfo.put("amount", "");
@@ -158,7 +158,6 @@ public class SagePayPaymentServices {
String orderId = (String) context.get("orderId");
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
if (orderPaymentPreference == null) {
response = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayOrderPaymenPreferenceIsNull", UtilMisc.toMap("orderId", orderId, "orderPaymentPreference", null), locale));
} else {
@@ -168,17 +167,13 @@ public class SagePayPaymentServices {
Debug.logInfo("SagePay - Exiting ccAuth", MODULE);
return response;
}
private static Map<String, Object> processCardAuthorisationPayment(DispatchContext ctx, Map<String, Object> context) {
Map<String, Object> result = ServiceUtil.returnSuccess();
LocalDispatcher dispatcher = ctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
Map<String, String> billingInfo = buildCustomerBillingInfo(context);
String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId");
try {
Map<String, Object> paymentResult = dispatcher.runSync("SagePayPaymentAuthentication",
UtilMisc.toMap(
"paymentGatewayConfigId", paymentGatewayConfigId,
@@ -230,7 +225,7 @@ public class SagePayPaymentServices {
Debug.logInfo("SagePay - Invalid status " + status + " received for order : " + vendorTxCode, MODULE);
result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, BigDecimal.ZERO, "ERROR", vendorTxCode, statusDetail);
}
} catch(GenericServiceException e) {
} catch (GenericServiceException e) {
Debug.logError(e, "Error in calling SagePayPaymentAuthentication", MODULE);
result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayPaymentAuthorisationException", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
@@ -285,7 +280,7 @@ public class SagePayPaymentServices {
Debug.logInfo("SagePay - Invalid status " + status + " received for order : " + vendorTxCode, MODULE);
result = SagePayUtil.buildCardCapturePaymentResponse(Boolean.FALSE, txAuthCode, securityKey, amount, vpsTxId, vendorTxCode, statusDetail);
}
} catch(GenericServiceException e) {
} catch (GenericServiceException e) {
Debug.logError(e, "Error in calling SagePayPaymentAuthorisation", MODULE);
result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayPaymentAuthorisationException", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
@@ -395,7 +390,7 @@ public class SagePayPaymentServices {
result = SagePayUtil.buildCardRefundPaymentResponse(Boolean.FALSE, null, BigDecimal.ZERO, status, orderId, statusDetail);
}
} catch(GenericServiceException e) {
} catch (GenericServiceException e) {
Debug.logError(e, "Error in calling SagePayPaymentRefund", MODULE);
result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayPaymentRefundException", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
@@ -434,15 +429,15 @@ public class SagePayPaymentServices {
} else if (status != null && "MALFORMED".equals(status)) {
Debug.logInfo("SagePay - Malformed void request for order : " + orderId, MODULE);
result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, BigDecimal.ZERO, "MALFORMED", orderId, statusDetail);
} else if (status != null && "INVALID".equals(status)){
} else if (status != null && "INVALID".equals(status)) {
Debug.logInfo("SagePay - Invalid void request for order : " + orderId, MODULE);
result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, BigDecimal.ZERO, "INVALID", orderId, statusDetail);
} else if (status != null && "ERROR".equals(status)){
} else if (status != null && "ERROR".equals(status)) {
Debug.logInfo("SagePay - Error in void request for order : " + orderId, MODULE);
result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, BigDecimal.ZERO, "ERROR", orderId, statusDetail);
}
} catch(GenericServiceException e) {
} catch (GenericServiceException e) {
Debug.logError(e, "Error in calling SagePayPaymentVoid", MODULE);
result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayPaymentVoidException", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
@@ -503,7 +498,7 @@ public class SagePayPaymentServices {
result = SagePayUtil.buildCardReleasePaymentResponse(Boolean.FALSE, null, amount, refNum, orderId, statusDetail);
}
} catch(GenericServiceException e) {
} catch (GenericServiceException e) {
Debug.logError(e, "Error in calling SagePayPaymentRelease", MODULE);
result = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayPaymentReleaseException", UtilMisc.toMap("errorString", e.getMessage()), locale));
}
@@ -58,7 +58,7 @@ public class SagePayServices
GenericValue sagePay = EntityQuery.use(delegator).from("PaymentGatewaySagePay").where("paymentGatewayConfigId", paymentGatewayConfigId).queryOne();
if (sagePay != null) {
for (Entry<String, Object> set : sagePay.entrySet()) {
if (set.getValue() == null){
if (set.getValue() == null) {
sagePayConfig.put(set.getKey(), null);
} else {
sagePayConfig.put(set.getKey(), set.getValue().toString());
@@ -83,7 +83,7 @@ public class SagePayServices
Map<String, String> props = buildSagePayProperties(context, delegator);
String vendorTxCode = (String)context.get("vendorTxCode");
String vendorTxCode = (String) context.get("vendorTxCode");
String cardHolder = (String) context.get("cardHolder");
String cardNumber = (String) context.get("cardNumber");
String expiryDate = (String) context.get("expiryDate");
@@ -129,22 +129,20 @@ public class SagePayServices
String vpsProtocol = props.get("protocolVersion");
String vendor = props.get("vendor");
String txType = props.get("authenticationTransType");
//start - required parameters
StringBuilder errorRequiredParameters = new StringBuilder();
if (vpsProtocol == null){
if (vpsProtocol == null) {
errorRequiredParameters.append("Required transaction parameter 'protocolVersion' is missing. ");
}
if (vendor == null){
if (vendor == null) {
errorRequiredParameters.append("Required transaction parameter 'vendor' is missing. ");
}
if (txType == null){
if (txType == null) {
errorRequiredParameters.append("Required transaction parameter 'authenticationsTransType' is missing. ");
}
if (errorRequiredParameters.length() > 0){
if (errorRequiredParameters.length() > 0) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayPaymentAuthorisationException", UtilMisc.toMap("errorString", errorRequiredParameters), locale));
}
parameters.put("VPSProtocol", vpsProtocol);
parameters.put("TxType", txType);
parameters.put("Vendor", vendor);
@@ -278,15 +276,15 @@ public class SagePayServices
resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage);
} catch(UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException uee) {
//exception in encoding parameters in httpPost
Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale));
} catch(ClientProtocolException cpe) {
} catch (ClientProtocolException cpe) {
//from httpClient execute
Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale));
} catch(IOException ioe) {
} catch (IOException ioe) {
//from httpClient execute or getResponsedata
Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
@@ -303,7 +301,7 @@ public class SagePayServices
Map<String, String> props = buildSagePayProperties(context, delegator);
String vendorTxCode = (String)context.get("vendorTxCode");
String vendorTxCode = (String) context.get("vendorTxCode");
String vpsTxId = (String) context.get("vpsTxId");
String securityKey = (String) context.get("securityKey");
String txAuthNo = (String) context.get("txAuthNo");
@@ -370,15 +368,15 @@ public class SagePayServices
resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage);
} catch(UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException uee) {
//exception in encoding parameters in httpPost
Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale));
} catch(ClientProtocolException cpe) {
} catch (ClientProtocolException cpe) {
//from httpClient execute
Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale));
} catch(IOException ioe) {
} catch (IOException ioe) {
//from httpClient execute or getResponsedata
Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
@@ -395,7 +393,7 @@ public class SagePayServices
Map<String, String> props = buildSagePayProperties(context, delegator);
String vendorTxCode = (String)context.get("vendorTxCode");
String vendorTxCode = (String) context.get("vendorTxCode");
String vpsTxId = (String) context.get("vpsTxId");
String securityKey = (String) context.get("securityKey");
String txAuthNo = (String) context.get("txAuthNo");
@@ -459,15 +457,15 @@ public class SagePayServices
resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage);
} catch(UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException uee) {
//exception in encoding parameters in httpPost
Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale));
} catch(ClientProtocolException cpe) {
} catch (ClientProtocolException cpe) {
//from httpClient execute
Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale));
} catch(IOException ioe) {
} catch (IOException ioe) {
//from httpClient execute or getResponsedata
Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
@@ -484,7 +482,7 @@ public class SagePayServices
Map<String, String> props = buildSagePayProperties(context, delegator);
String vendorTxCode = (String)context.get("vendorTxCode");
String vendorTxCode = (String) context.get("vendorTxCode");
String vpsTxId = (String) context.get("vpsTxId");
String securityKey = (String) context.get("securityKey");
String txAuthNo = (String) context.get("txAuthNo");
@@ -545,16 +543,15 @@ public class SagePayServices
resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage);
} catch(UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException uee) {
//exception in encoding parameters in httpPost
Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale));
} catch(ClientProtocolException cpe) {
} catch (ClientProtocolException cpe) {
//from httpClient execute
Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale));
} catch(IOException ioe) {
} catch (IOException ioe) {
//from httpClient execute or getResponsedata
Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
@@ -571,10 +568,10 @@ public class SagePayServices
Map<String, String> props = buildSagePayProperties(context, delegator);
String vendorTxCode = (String)context.get("vendorTxCode");
String amount = (String)context.get("amount");
String currency = (String)context.get("currency");
String description = (String)context.get("description");
String vendorTxCode = (String) context.get("vendorTxCode");
String amount = (String) context.get("amount");
String currency = (String) context.get("currency");
String description = (String) context.get("description");
String relatedVPSTxId = (String) context.get("relatedVPSTxId");
String relatedVendorTxCode = (String) context.get("relatedVendorTxCode");
@@ -605,7 +602,6 @@ public class SagePayServices
try (CloseableHttpClient httpClient = SagePayUtil.getHttpClient()) {
String successMessage = null;
HttpPost httpPost = SagePayUtil.getHttpPost(props.get("refundUrl"), parameters);
HttpResponse response = httpClient.execute(host, httpPost);
Map<String, String> responseData = SagePayUtil.getResponseData(response);
@@ -653,15 +649,15 @@ public class SagePayServices
resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage);
} catch(UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException uee) {
//exception in encoding parameters in httpPost
Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale));
} catch(ClientProtocolException cpe) {
} catch (ClientProtocolException cpe) {
//from httpClient execute
Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale));
} catch(IOException ioe) {
} catch (IOException ioe) {
//from httpClient execute or getResponsedata
Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", MODULE);
resultMap = ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale));
@@ -46,7 +46,7 @@ import org.apache.ofbiz.base.util.Debug;
public final class SagePayUtil {
private static final String MODULE = SagePayUtil.class.getName();
private SagePayUtil() {}
private SagePayUtil() { }
public static Map<String, Object> buildCardAuthorisationPaymentResponse
(Boolean authResult, String authCode, String authFlag, BigDecimal processAmount, String authRefNum, String authAltRefNum, String authMessage) {
@@ -127,7 +127,7 @@ public final class SagePayUtil {
} else if ("TEST".equals(props.get("sagePayMode"))) {
hostUrl = props.get("testingHost");
}
if (hostUrl == null){
if (hostUrl == null) {
throw new IllegalArgumentException("Could not find host-url via SagePay Properties");
}
String scheme = hostUrl.substring(0, 5);
@@ -112,7 +112,7 @@ public class SecurePayPaymentServices {
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
boolean approved = resp.getApproved();
if (approved == false){
if (approved == false) {
result.put("authResult", Boolean.FALSE);
result.put("authRefNum", "N/A");
result.put("processAmount", BigDecimal.ZERO);
@@ -191,10 +191,10 @@ public class SecurePayPaymentServices {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1){
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
boolean approved = resp.getApproved();
if (approved == false){
if (approved == false) {
result.put("captureResult", false);
result.put("captureRefNum", authTransaction.getString("referenceNum"));
result.put("captureAmount", BigDecimal.ZERO);
@@ -270,10 +270,10 @@ public class SecurePayPaymentServices {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1){
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
boolean approved = resp.getApproved();
if (approved == false){
if (approved == false) {
result.put("releaseResult", false);
result.put("releaseRefNum", authTransaction.getString("referenceNum"));
result.put("releaseAmount", BigDecimal.ZERO);
@@ -357,10 +357,10 @@ public class SecurePayPaymentServices {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
"AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1){
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
boolean approved = resp.getApproved();
if (approved == false){
if (approved == false) {
result.put("refundResult", false);
result.put("refundRefNum", authTransaction.getString("referenceNum"));
result.put("refundAmount", BigDecimal.ZERO);
@@ -439,7 +439,7 @@ public class SecurePayPaymentServices {
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
boolean approved = resp.getApproved();
if (approved == false){
if (approved == false) {
result.put("creditResult", false);
result.put("creditRefNum", "N/A");
result.put("creditAmount", BigDecimal.ZERO);
@@ -33,12 +33,11 @@ import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.ModelService;
import org.apache.ofbiz.service.testtools.OFBizTestCase;
public class SecurePayServiceTest extends OFBizTestCase{
public class SecurePayServiceTest extends OFBizTestCase {
public SecurePayServiceTest(String name) {
super(name);
}
private static final String MODULE = SecurePayServiceTest.class.getName();
// test data
@@ -103,14 +102,13 @@ public class SecurePayServiceTest extends OFBizTestCase{
"paymentMethodTypeId", "CREDIT_CARD",
"maxAmount", new BigDecimal("200.00"),
"statusId", "PAYMENT_AUTHORIZED"));
GenericValue checkOrderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", "testOrder1000_01").queryOne();
if (UtilValidate.isEmpty(checkOrderPaymentPreference)) {
orderPaymentPreference.create();
}
}
public void testAuth() throws Exception{
public void testAuth() throws Exception {
Debug.logInfo("=====[testAuth] starting....", MODULE);
try {
Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
@@ -190,7 +188,6 @@ public class SecurePayServiceTest extends OFBizTestCase{
checkPaymentGatewayResponse.store();
Debug.logInfo("[testdoCapture] Result from SecurePay: " + result, MODULE);
}
} catch (GenericServiceException ex) {
TestCase.fail(ex.getMessage());
}
@@ -224,7 +221,7 @@ public class SecurePayServiceTest extends OFBizTestCase{
}
}
public void testdoCredit() throws Exception{
public void testdoCredit() throws Exception {
Debug.logInfo("=====[testdoCredit] starting....", MODULE);
try {
Map<String, Object> serviceInput = UtilMisc.toMap(
@@ -89,7 +89,7 @@ public class ValueLinkApi {
protected Long mwkIndex = null;
protected boolean debug = false;
protected ValueLinkApi() {}
protected ValueLinkApi() { }
protected ValueLinkApi(Delegator delegator, Properties props) {
String mId = (String) props.get("payment.valuelink.merchantId");
String tId = (String) props.get("payment.valuelink.terminalId");
@@ -39,7 +39,7 @@ public final class UtilAccounting {
private static final String MODULE = UtilAccounting.class.getName();
private UtilAccounting() {}
private UtilAccounting() { }
/**
* Get the GL Account for a product or the default account type based on input. This replaces the simple-method service
@@ -212,15 +212,15 @@ public class ContentManagementEvents {
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
boolean statusIdUpdated = false;
Map<String, Object> result = new HashMap<>();
for (Object [] arr : origPublishedLinkList) {
String contentId = (String)arr[0]; // main (2nd level) site id
for (Object[] arr : origPublishedLinkList) {
String contentId = (String) arr[0]; // main (2nd level) site id
String origSubContentId = null;
List<Object []> origSubList = UtilGenerics.cast(arr[1]);
List<Object[]> origSubList = UtilGenerics.cast(arr[1]);
Timestamp origFromDate = null;
for (Object [] pubArr : origSubList) {
Timestamp fromDate = (Timestamp)pubArr[2];
for (Object[] pubArr : origSubList) {
Timestamp fromDate = (Timestamp) pubArr[2];
if (fromDate != null) {
origSubContentId = (String)pubArr[0];
origSubContentId = (String) pubArr[0];
origFromDate = fromDate;
break;
}
@@ -76,9 +76,9 @@ public class ContentManagementServices {
String subContentId = (String) context.get("subContentId");
String mapKey = (String) context.get("mapKey");
GenericValue userLogin = (GenericValue)context.get("userLogin");
Timestamp fromDate = (Timestamp)context.get("fromDate");
Timestamp fromDate = (Timestamp) context.get("fromDate");
List<String> assocTypes = UtilGenerics.cast(context.get("assocTypes"));
String assocTypesString = (String)context.get("assocTypesString");
String assocTypesString = (String) context.get("assocTypesString");
if (UtilValidate.isNotEmpty(assocTypesString)) {
List<String> lst = StringUtil.split(assocTypesString, "|");
if (assocTypes == null) {
@@ -144,7 +144,7 @@ public class ContentManagementServices {
// Knowing why a request fails permission check is one of the more difficult
// aspects of content management. Setting "displayFailCond" to true will
// put an html table in result.errorMessage that will show what tests were performed
Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond");
Boolean bDisplayFailCond = (Boolean) context.get("displayFailCond");
String mapKey = (String) context.get("mapKey");
// If "deactivateExisting" is set, other Contents that are tied to the same
@@ -190,7 +190,7 @@ public class ContentManagementServices {
dataResource.setNonPKFields(context);
dataResource.setAllFields(context, false, "dr", null);
String isPublic = (String) context.get("isPublic");
if (UtilValidate.isEmpty(isPublic)){
if (UtilValidate.isEmpty(isPublic)) {
dataResource.set("isPublic", "N");
}
context.putAll(dataResource);
@@ -201,11 +201,11 @@ public class ContentManagementServices {
}
GenericValue contentAssoc = delegator.makeValue("ContentAssoc");
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
context.put("caContentAssocTypeId", contentAssocTypeId);
}
contentAssocTypeId = (String)context.get("caContentAssocTypeId");
contentAssocTypeId = (String) context.get("caContentAssocTypeId");
contentAssoc.setAllFields(context, false, "ca", null);
contentAssoc.put("contentId", context.get("caContentId"));
context.putAll(contentAssoc);
@@ -399,8 +399,8 @@ public class ContentManagementServices {
Delegator delegator = dctx.getDelegator();
GenericValue userLogin = (GenericValue)context.get("userLogin");
Map<String, Object> results = new HashMap<>();
String siteContentId = (String)context.get("contentId");
String partyId = (String)context.get("partyId");
String siteContentId = (String) context.get("contentId");
String partyId = (String) context.get("partyId");
if (UtilValidate.isEmpty(siteContentId) || UtilValidate.isEmpty(partyId))
return results;
@@ -423,7 +423,7 @@ public class ContentManagementServices {
if (Debug.infoOn()) {
Debug.logInfo("updateSiteRoles, cappediteRole(1):" + cappedSiteRole, MODULE);
}
String siteRoleVal = (String)context.get(cappedSiteRole);
String siteRoleVal = (String) context.get(cappedSiteRole);
if (Debug.infoOn()) {
Debug.logInfo("updateSiteRoles, siteRoleVal(1):" + siteRoleVal, MODULE);
Debug.logInfo("updateSiteRoles, context(1):" + context, MODULE);
@@ -618,7 +618,7 @@ public class ContentManagementServices {
}
Map<String, Object> fileContext = new HashMap<>();
fileContext.put("userLogin", userLogin);
String forceElectronicText = (String)context.get("forceElectronicText");
String forceElectronicText = (String) context.get("forceElectronicText");
if ("IMAGE_OBJECT".equals(dataResourceTypeId)) {
if (imageDataBytes != null || "true".equalsIgnoreCase(forceElectronicText)) {
fileContext.put("dataResourceId", dataResourceId);
@@ -684,8 +684,8 @@ public class ContentManagementServices {
// with a new siteContentId each time.
// siteContentId could also have been name deptContentId, since this same
// service is used for updating department roles, too.
String siteContentId = (String)context.get("contentId");
String partyId = (String)context.get("partyId");
String siteContentId = (String) context.get("contentId");
String partyId = (String) context.get("partyId");
serviceContext.put("partyId", partyId);
serviceContext.put("contentId", siteContentId);
@@ -699,7 +699,7 @@ public class ContentManagementServices {
String siteRole = (String)roleType.get("roleTypeId"); // BLOG_EDITOR, BLOG_ADMIN, etc.
String cappedSiteRole = ModelUtil.dbNameToVarName(siteRole);
String siteRoleVal = (String)context.get(cappedSiteRole);
String siteRoleVal = (String) context.get(cappedSiteRole);
Object fromDate = context.get(cappedSiteRole + "FromDate");
serviceContext.put("roleTypeId", siteRole);
if (siteRoleVal != null && "Y".equalsIgnoreCase(siteRoleVal)) {
@@ -745,14 +745,14 @@ public class ContentManagementServices {
public static Map<String, Object> updateOrRemove(DispatchContext dctx, Map<String, ? extends Object> context) {
Map<String, Object> results = new HashMap<>();
Delegator delegator = dctx.getDelegator();
String entityName = (String)context.get("entityName");
String action = (String)context.get("action");
String pkFieldCount = (String)context.get("pkFieldCount");
String entityName = (String) context.get("entityName");
String action = (String) context.get("action");
String pkFieldCount = (String) context.get("pkFieldCount");
Map<String, String> pkFields = new HashMap<>();
int fieldCount = Integer.parseInt(pkFieldCount);
for (int i=0; i<fieldCount; i++) {
String fieldName = (String)context.get("fieldName" + i);
String fieldValue = (String)context.get("fieldValue" + i);
for (int i = 0; i < fieldCount; i++) {
String fieldName = (String) context.get("fieldName" + i);
String fieldValue = (String) context.get("fieldValue" + i);
if (UtilValidate.isEmpty(fieldValue)) {
// It may be the case that the last row in a form is "empty" waiting for
// someone to enter a value, in which case we do not want to throw an
@@ -796,10 +796,10 @@ public class ContentManagementServices {
return results;
}
public static Map<String, Object> resequence(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> resequence(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
String contentIdTo = (String)context.get("contentIdTo");
String contentIdTo = (String) context.get("contentIdTo");
Integer seqInc = (Integer)context.get("seqInc");
if (seqInc == null) {
seqInc = 100;
@@ -809,7 +809,7 @@ public class ContentManagementServices {
if (typeList == null) {
typeList = new LinkedList<>();
}
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
typeList.add(contentAssocTypeId);
}
@@ -823,11 +823,11 @@ public class ContentManagementServices {
.where(conditionMain)
.orderBy("sequenceNum", "fromDate", "createdDate")
.filterByDate().queryList();
String contentId = (String)context.get("contentId");
String dir = (String)context.get("dir");
String contentId = (String) context.get("contentId");
String dir = (String) context.get("dir");
int seqNum = seqIncrement;
String thisContentId = null;
for (int i=0; i < listAll.size(); i++) {
for (int i = 0; i < listAll.size(); i++) {
GenericValue contentAssoc = listAll.get(i);
if (UtilValidate.isNotEmpty(contentId) && UtilValidate.isNotEmpty(dir)) {
// move targeted entry up or down
@@ -876,12 +876,12 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> changeLeafToNode(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> changeLeafToNode(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> thisResult = new HashMap<>();
String contentId = (String)context.get("contentId");
String contentId = (String) context.get("contentId");
GenericValue userLogin = (GenericValue)context.get("userLogin");
String userLoginId = userLogin.getString("userLoginId");
Locale locale = (Locale) context.get("locale");
@@ -934,14 +934,14 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> updateLeafCount(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> updateLeafCount(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
List<String> typeList = UtilGenerics.cast(context.get("typeList"));
if (typeList == null) {
typeList = UtilMisc.toList("PUBLISH_LINK", "SUB_CONTENT");
}
String startContentId = (String)context.get("contentId");
String startContentId = (String) context.get("contentId");
try {
int leafCount = ContentManagementWorker.updateStatsTopDown(delegator, startContentId, typeList);
result.put("leafCount", leafCount);
@@ -960,7 +960,7 @@ public class ContentManagementServices {
* if pageMode == "page" then if the contentTypeId of children is not "PAGE_NODE" or "SUBPAGE_NODE"
* (it could be DOCUMENT or OUTLINE_NODE) then it will get changed to SUBPAGE_NODE.`
*/
public static Map<String, Object> updatePageType(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException{
public static Map<String, Object> updatePageType(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException {
Delegator delegator = dctx.getDelegator();
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Map<String, Object> results = new HashMap<>();
@@ -970,8 +970,8 @@ public class ContentManagementServices {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
}
String pageMode = (String)context.get("pageMode");
String contentId = (String)context.get("contentId");
String pageMode = (String) context.get("pageMode");
String contentId = (String) context.get("contentId");
visitedSet.add(contentId);
String contentTypeId = "PAGE_NODE";
if (pageMode != null && pageMode.toLowerCase(Locale.getDefault()).indexOf("outline") >= 0)
@@ -1000,7 +1000,7 @@ public class ContentManagementServices {
return results;
}
public static Map<String, Object> resetToOutlineMode(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException{
public static Map<String, Object> resetToOutlineMode(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException {
Delegator delegator = dctx.getDelegator();
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Map<String, Object> results = new HashMap<>();
@@ -1010,8 +1010,8 @@ public class ContentManagementServices {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
}
String contentId = (String)context.get("contentId");
String pageMode = (String)context.get("pageMode");
String contentId = (String) context.get("contentId");
String pageMode = (String) context.get("pageMode");
String contentTypeId = "OUTLINE_NODE";
if (pageMode != null && pageMode.toLowerCase(Locale.getDefault()).indexOf("page") >= 0) {
contentTypeId = "PAGE_NODE";
@@ -1045,7 +1045,7 @@ public class ContentManagementServices {
return results;
}
public static Map<String, Object> clearContentAssocViewCache(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> clearContentAssocViewCache(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> results = new HashMap<>();
UtilCache<?, ?> utilCache = UtilCache.findCache("entitycache.entity-list.default.ContentAssocViewFrom");
@@ -1061,7 +1061,7 @@ public class ContentManagementServices {
return results;
}
public static Map<String, Object> clearContentAssocDataResourceViewCache(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> clearContentAssocDataResourceViewCache(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> results = new HashMap<>();
UtilCache<?, ?> utilCache = UtilCache.findCache("entitycache.entity-list.default.ContentAssocViewDataResourceFrom");
@@ -1141,10 +1141,10 @@ public class ContentManagementServices {
}
}
public static Map<String, Object> findSubNodes(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> findSubNodes(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> results = new HashMap<>();
Delegator delegator = dctx.getDelegator();
String contentIdTo = (String)context.get("contentId");
String contentIdTo = (String) context.get("contentId");
try {
List<GenericValue> lst = EntityQuery.use(delegator).from("ContentAssocDataResourceViewFrom")
.where("caContentIdTo", contentIdTo,
@@ -1176,7 +1176,7 @@ public class ContentManagementServices {
return retVal;
}
public static Map<String, Object> initContentChildCounts(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> initContentChildCounts(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Locale locale = (Locale) context.get("locale");
GenericValue content = (GenericValue)context.get("content");
@@ -1195,12 +1195,12 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> incrementContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> incrementContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
String contentId = (String)context.get("contentId");
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String contentId = (String) context.get("contentId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
try {
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
@@ -1221,12 +1221,12 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> decrementContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> decrementContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
String contentId = (String)context.get("contentId");
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String contentId = (String) context.get("contentId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
try {
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
@@ -1247,12 +1247,12 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> updateContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> updateContentChildStats(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
String contentId = (String)context.get("contentId");
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String contentId = (String) context.get("contentId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
List<String> typeList = new LinkedList<>();
if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
typeList.add(contentAssocTypeId);
@@ -1268,7 +1268,7 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> updateContentSubscription(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> updateContentSubscription(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
@@ -1351,7 +1351,7 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> updateContentSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException{
public static Map<String, Object> updateContentSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException {
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Map<String, Object> result;
Delegator delegator = dctx.getDelegator();
@@ -1403,7 +1403,7 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> updateContentSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException{
public static Map<String, Object> updateContentSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> rcontext) throws GenericServiceException {
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Map<String, Object> result = new HashMap<>();
Delegator delegator = dctx.getDelegator();
@@ -1458,7 +1458,7 @@ public class ContentManagementServices {
return result;
}
public static Map<String, Object> followNodeChildren(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> followNodeChildren(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = null;
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
@@ -1468,9 +1468,9 @@ public class ContentManagementServices {
if (!security.hasEntityPermission("CONTENTMGR", "_ADMIN", userLogin)) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentPermissionNotGranted", locale));
}
String contentId = (String)context.get("contentId");
String serviceName = (String)context.get("serviceName");
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String contentId = (String) context.get("contentId");
String serviceName = (String) context.get("serviceName");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
List<String> contentAssocTypeIdList = new LinkedList<>();
if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
contentAssocTypeIdList = StringUtil.split(contentAssocTypeId, "|");
@@ -1527,10 +1527,10 @@ public class ContentManagementServices {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericValue dataResource = null;
String masterRevisionContentId = (String)context.get("masterRevisionContentId");
String oldDataResourceId = (String)context.get("drDataResourceId");
String masterRevisionContentId = (String) context.get("masterRevisionContentId");
String oldDataResourceId = (String) context.get("drDataResourceId");
if (UtilValidate.isEmpty(oldDataResourceId)) {
oldDataResourceId = (String)context.get("dataResourceId");
oldDataResourceId = (String) context.get("dataResourceId");
}
if (UtilValidate.isNotEmpty(oldDataResourceId)) {
try {
@@ -64,7 +64,7 @@ public final class ContentManagementWorker {
private static Map<String, GenericValue> cachedWebSitePublishPoints = new HashMap<>();
private static Map<String, Map<String, Object>> cachedStaticValues = new HashMap<>();
private ContentManagementWorker() {}
private ContentManagementWorker() { }
public static void mruAdd(HttpServletRequest request, GenericEntity pk, String suffix) {
HttpSession session = request.getSession();
@@ -41,7 +41,7 @@ import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;
public class ConvertTree{
public class ConvertTree {
private static final String MODULE = ConvertTree.class.getName();
/*
@@ -78,7 +78,7 @@ public class CompDocServices {
LocalDispatcher dispatcher = dctx.getDispatcher();
Locale locale = (Locale)context.get("locale");
GenericValue userLogin = (GenericValue)context.get("userLogin");
String contentId = (String)context.get("contentId");
String contentId = (String) context.get("contentId");
if (UtilValidate.isNotEmpty(contentId)) {
try {
@@ -165,7 +165,7 @@ public class CompDocServices {
if (dataResource != null) {
inputMimeType = dataResource.getString("mimeTypeId");
}
byte [] inputByteArray = null;
byte[] inputByteArray = null;
PdfReader reader = null;
if (inputMimeType != null && "application/pdf".equals(inputMimeType)) {
ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, thisDataResourceId, https, webSiteId, locale, rootDir);
@@ -225,7 +225,7 @@ public class CompDocServices {
}
if (reader != null) {
int n = reader.getNumberOfPages();
for (int i=0; i < n; i++) {
for (int i = 0; i < n; i++) {
PdfImportedPage pg = writer.getImportedPage(reader, i + 1);
writer.addPage(pg);
}
@@ -326,7 +326,7 @@ public class CompDocServices {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ContentSurveyErrorBuildingPDF", locale), null, null, survey2PdfResults);
}
ByteBuffer outByteBuffer = (ByteBuffer)survey2PdfResults.get("outByteBuffer");
ByteBuffer outByteBuffer = (ByteBuffer) survey2PdfResults.get("outByteBuffer");
inputByteArray = outByteBuffer.array();
} else {
// Fill in acroForm
@@ -53,7 +53,7 @@ public class ContentPermissionServices {
private static final String MODULE = ContentPermissionServices.class.getName();
private static final String RESOURCE = "ContentUiLabels";
public ContentPermissionServices() {}
public ContentPermissionServices() { }
/**
* checkContentPermission
@@ -102,13 +102,13 @@ public class ContentPermissionServices {
//TODO this parameters is still not used but this service need to be replaced by genericContentPermission
// String privilegeEnumId = (String) context.get("privilegeEnumId");
GenericValue content = (GenericValue) context.get("currentContent");
Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond");
Boolean bDisplayFailCond = (Boolean) context.get("displayFailCond");
boolean displayFailCond = false;
if (bDisplayFailCond != null && bDisplayFailCond) {
displayFailCond = true;
}
Debug.logInfo("displayFailCond(0):" + displayFailCond, "");
Boolean bDisplayPassCond = (Boolean)context.get("displayPassCond");
Boolean bDisplayPassCond = (Boolean) context.get("displayPassCond");
boolean displayPassCond = false;
if (bDisplayPassCond != null && bDisplayPassCond) {
displayPassCond = true;
@@ -118,7 +118,7 @@ public class ContentPermissionServices {
GenericValue userLogin = (GenericValue) context.get("userLogin");
String partyId = (String) context.get("partyId");
if (UtilValidate.isEmpty(partyId)) {
String passedUserLoginId = (String)context.get("userLoginId");
String passedUserLoginId = (String) context.get("userLoginId");
if (UtilValidate.isNotEmpty(passedUserLoginId)) {
try {
userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", passedUserLoginId).cache().queryOne();
@@ -254,7 +254,7 @@ public class ContentPermissionServices {
// Security security = dctx.getSecurity();
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond");
Boolean bDisplayFailCond = (Boolean) context.get("displayFailCond");
String contentIdFrom = (String) context.get("contentIdFrom");
String contentIdTo = (String) context.get("contentIdTo");
GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -130,9 +130,9 @@ public class ContentServices {
List<Object> parentList = new LinkedList<>();
results.put("parentList", parentList);
LocalDispatcher dispatcher = dctx.getDispatcher();
String contentId = (String)context.get("contentId");
String contentAssocTypeId = (String)context.get("contentAssocTypeId");
String direction = (String)context.get("direction");
String contentId = (String) context.get("contentId");
String contentAssocTypeId = (String) context.get("contentAssocTypeId");
String direction = (String) context.get("direction");
if (UtilValidate.isEmpty(direction)) {
direction="To";
}
@@ -536,7 +536,7 @@ public class ContentServices {
return results;
}
public static Map<String, Object> publishContent(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> publishContent(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
GenericValue content = (GenericValue)context.get("content");
@@ -550,10 +550,10 @@ public class ContentServices {
return result;
}
public static Map<String, Object> getPrefixedMembers(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> getPrefixedMembers(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Map<String, Object> mapIn = UtilGenerics.cast(context.get("mapIn"));
String prefix = (String)context.get("prefix");
String prefix = (String) context.get("prefix");
Map<String, Object> mapOut = new HashMap<>();
result.put("mapOut", mapOut);
if (mapIn != null) {
@@ -569,11 +569,11 @@ public class ContentServices {
return result;
}
public static Map<String, Object> splitString(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> splitString(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
List<String> outputList = new LinkedList<>();
String delimiter = UtilFormatOut.checkEmpty((String)context.get("delimiter"), "|");
String inputString = (String)context.get("inputString");
String delimiter = UtilFormatOut.checkEmpty((String) context.get("delimiter"), "|");
String inputString = (String) context.get("inputString");
if (UtilValidate.isNotEmpty(inputString)) {
outputList = StringUtil.split(inputString, delimiter);
}
@@ -581,10 +581,10 @@ public class ContentServices {
return result;
}
public static Map<String, Object> joinString(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> joinString(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
String outputString = null;
String delimiter = UtilFormatOut.checkEmpty((String)context.get("delimiter"), "|");
String delimiter = UtilFormatOut.checkEmpty((String) context.get("delimiter"), "|");
List<String> inputList = UtilGenerics.cast(context.get("inputList"));
if (inputList != null) {
outputString = StringUtil.join(inputList, delimiter);
@@ -593,7 +593,7 @@ public class ContentServices {
return result;
}
public static Map<String, Object> urlEncodeArgs(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> urlEncodeArgs(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Map<String, Object> result = new HashMap<>();
Map<String, Object> mapFiltered = new HashMap<>();
Map<String, Object> mapIn = UtilGenerics.cast(context.get("mapIn"));
@@ -67,13 +67,13 @@ public class ContentServicesComplex {
Delegator delegator = dctx.getDelegator();
List<String> assocTypes = UtilGenerics.cast(context.get("assocTypes"));
List<String> contentTypes = UtilGenerics.cast(context.get("contentTypes"));
Timestamp fromDate = (Timestamp)context.get("fromDate");
Timestamp thruDate = (Timestamp)context.get("thruDate");
String fromDateStr = (String)context.get("fromDateStr");
String thruDateStr = (String)context.get("thruDateStr");
String contentId = (String)context.get("contentId");
String direction = (String)context.get("direction");
String mapKey = (String)context.get("mapKey");
Timestamp fromDate = (Timestamp) context.get("fromDate");
Timestamp thruDate = (Timestamp) context.get("thruDate");
String fromDateStr = (String) context.get("fromDateStr");
String thruDateStr = (String) context.get("thruDateStr");
String contentId = (String) context.get("contentId");
String direction = (String) context.get("direction");
String mapKey = (String) context.get("mapKey");
Map<String, Object> results = getAssocAndContentAndDataResourceMethod(delegator, contentId, mapKey, direction, fromDate, thruDate, fromDateStr, thruDateStr, assocTypes, contentTypes);
return results;
}
@@ -159,7 +159,7 @@ public class ContentServicesComplex {
public static Map<String, Object> getAssocAndContentAndDataResourceCache(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
List<String> assocTypes = UtilGenerics.cast(context.get("assocTypes"));
String assocTypesString = (String)context.get("assocTypesString");
String assocTypesString = (String) context.get("assocTypesString");
if (UtilValidate.isNotEmpty(assocTypesString)) {
List<String> lst = StringUtil.split(assocTypesString, "|");
if (assocTypes == null) {
@@ -168,7 +168,7 @@ public class ContentServicesComplex {
assocTypes.addAll(lst);
}
List<String> contentTypes = UtilGenerics.cast(context.get("contentTypes"));
String contentTypesString = (String)context.get("contentTypesString");
String contentTypesString = (String) context.get("contentTypesString");
if (UtilValidate.isNotEmpty(contentTypesString)) {
List<String> lst = StringUtil.split(contentTypesString, "|");
if (contentTypes == null) {
@@ -176,13 +176,13 @@ public class ContentServicesComplex {
}
contentTypes.addAll(lst);
}
Timestamp fromDate = (Timestamp)context.get("fromDate");
String fromDateStr = (String)context.get("fromDateStr");
String contentId = (String)context.get("contentId");
String direction = (String)context.get("direction");
String mapKey = (String)context.get("mapKey");
String contentAssocPredicateId = (String)context.get("contentAssocPredicateId");
Boolean nullThruDatesOnly = (Boolean)context.get("nullThruDatesOnly");
Timestamp fromDate = (Timestamp) context.get("fromDate");
String fromDateStr = (String) context.get("fromDateStr");
String contentId = (String) context.get("contentId");
String direction = (String) context.get("direction");
String mapKey = (String) context.get("mapKey");
String contentAssocPredicateId = (String) context.get("contentAssocPredicateId");
Boolean nullThruDatesOnly = (Boolean) context.get("nullThruDatesOnly");
Map<String, Object> results = null;
try {
results = getAssocAndContentAndDataResourceCacheMethod(delegator, contentId, mapKey, direction, fromDate, fromDateStr, assocTypes, contentTypes, nullThruDatesOnly, contentAssocPredicateId, null);
@@ -242,7 +242,7 @@ public class ContentServicesComplex {
GenericValue dataResource = null;
List<GenericValue> contentAssocDataResourceList = new LinkedList<>();
Locale locale = Locale.getDefault(); // TODO: this needs to be passed in
try{
try {
for (GenericValue contentAssocView : contentAssocsTypeFiltered) {
GenericValue contentAssoc = EntityQuery.use(delegator).from("ContentAssoc").where(UtilMisc.toMap("contentId", contentAssocView.getString("contentId"),
"contentIdTo", contentAssocView.getString(contentFieldName), "contentAssocTypeId", contentAssocView.getString("caContentAssocTypeId"),
@@ -184,7 +184,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
return content;
}
public static void renderContentAsText(LocalDispatcher dispatcher, GenericValue content, Appendable out, Map<String, Object>templateContext,
public static void renderContentAsText(LocalDispatcher dispatcher, GenericValue content, Appendable out, Map<String, Object> templateContext,
Locale locale, String mimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
// if the content has a service attached run the service
@@ -310,7 +310,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
StringReader sr = new StringReader(textData);
try {
NodeModel nodeModel = NodeModel.parse(new InputSource(sr));
templateContext.put("doc", nodeModel) ;
templateContext.put("doc", nodeModel);
} catch (SAXException | ParserConfigurationException e) {
throw new GeneralException(e.getMessage());
}
@@ -1281,7 +1281,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
public static List<String> prepTargetOperationList(Map<String, ? extends Object> context, String md) {
List<String> targetOperationList = UtilGenerics.cast(context.get("targetOperationList"));
String targetOperationString = (String)context.get("targetOperationString");
String targetOperationString = (String) context.get("targetOperationString");
if (Debug.infoOn()) {
Debug.logInfo("in prepTargetOperationList, targetOperationString(0):" + targetOperationString, "");
}
@@ -1313,7 +1313,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
*/
public static List<String> prepContentPurposeList(Map<String, Object> context) {
List<String> contentPurposeList = UtilGenerics.cast(context.get("contentPurposeList"));
String contentPurposeString = (String)context.get("contentPurposeString");
String contentPurposeString = (String) context.get("contentPurposeString");
if (Debug.infoOn()) {
Debug.logInfo("in prepContentPurposeList, contentPurposeString(0):" + contentPurposeString, "");
}
@@ -1555,7 +1555,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
public static String logMap(String lbl, Map<String, Object> map, int indentLevel) {
StringBuilder indent = new StringBuilder();
for (int i=0; i<indentLevel; i++) {
for (int i = 0; i<indentLevel; i++) {
indent.append(' ');
}
return logMap(new StringBuilder(), lbl, map, indent).toString();
@@ -1599,7 +1599,7 @@ public class ContentWorker implements org.apache.ofbiz.widget.content.ContentWor
public static String logList(String lbl, List<Object> lst, int indentLevel) {
StringBuilder indent = new StringBuilder();
for (int i=0; i<indentLevel; i++) {
for (int i = 0; i < indentLevel; i++) {
indent.append(' ');
}
return logList(new StringBuilder(), lbl, lst, indent).toString();
@@ -66,7 +66,7 @@ public class UploadContentAndImage {
private static final String MODULE = UploadContentAndImage.class.getName();
public static final String err_resource = "ContentErrorUiLabels";
public UploadContentAndImage() {}
public UploadContentAndImage() { }
public static String uploadContentAndImage(HttpServletRequest request, HttpServletResponse response) {
try {
@@ -398,7 +398,7 @@ public class UploadContentAndImage {
rowCount = 1;
}
TransactionUtil.begin();
for (int i=0; i < rowCount; i++) {
for (int i = 0; i < rowCount; i++) {
String suffix = "_o_" + i;
if (i==0) {
suffix = "";
@@ -434,7 +434,7 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
return prefix;
}
public static File getContentFile(String dataResourceTypeId, String objectInfo, String contextRoot) throws GeneralException, FileNotFoundException{
public static File getContentFile(String dataResourceTypeId, String objectInfo, String contextRoot) throws GeneralException, FileNotFoundException {
File file = null;
if ("LOCAL_FILE".equals(dataResourceTypeId) || "LOCAL_FILE_BIN".equals(dataResourceTypeId)) {
@@ -786,7 +786,7 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data
} catch (TemplateException e) {
throw new GeneralException("Error creating Screen renderer", e);
}
} else if ("FORM_COMBINED".equals(dataTemplateTypeId)){
} else if ("FORM_COMBINED".equals(dataTemplateTypeId)) {
try {
Map<String, Object> context = UtilGenerics.cast(templateContext.get("globalContext"));
context.put("locale", locale);
@@ -581,7 +581,7 @@ public class DataServices {
String dataResourceTypeId = (String) dataResource.get("dataResourceTypeId");
String objectInfo = (String) dataResource.get("objectInfo");
byte [] imageData = (byte []) context.get("imageData");
String rootDir = (String)context.get("rootDir");
String rootDir = (String) context.get("rootDir");
File file = null;
if (Debug.infoOn()) {
Debug.logInfo("in createBinaryFileMethod, dataResourceTypeId:" + dataResourceTypeId, MODULE);
@@ -634,7 +634,7 @@ public class DataServices {
String dataResourceTypeId = (String) dataResource.get("dataResourceTypeId");
String objectInfo = (String) dataResource.get("objectInfo");
byte [] imageData = (byte []) context.get("imageData");
String rootDir = (String)context.get("rootDir");
String rootDir = (String) context.get("rootDir");
File file = null;
if (Debug.infoOn()) {
Debug.logInfo("in updateBinaryFileMethod, dataResourceTypeId:" + dataResourceTypeId, MODULE);
@@ -654,7 +654,7 @@ public class DataServices {
if (imageData != null && imageData.length > 0) {
try (
FileOutputStream out = new FileOutputStream(file);
){
) {
out.write(imageData);
if (Debug.infoOn()) {
Debug.logInfo("in updateBinaryFileMethod, length:" + file.length(), MODULE);
@@ -47,7 +47,7 @@ public final class LayoutWorker {
private static final String MODULE = LayoutWorker.class.getName();
private static final String err_resource = "ContentErrorUiLabels";
private LayoutWorker() {}
private LayoutWorker() { }
/**
* Uploads image data from a form and stores it in ImageDataResource.
@@ -225,9 +225,9 @@ public class PdfSurveyServices {
Locale locale = (Locale) context.get("locale");
try {
Delegator delegator = dctx.getDelegator();
String partyId = (String)context.get("partyId");
String surveyId = (String)context.get("surveyId");
surveyResponseId = (String)context.get("surveyResponseId");
String partyId = (String) context.get("partyId");
String surveyId = (String) context.get("surveyId");
surveyResponseId = (String) context.get("surveyResponseId");
if (UtilValidate.isNotEmpty(surveyResponseId)) {
GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
if (surveyResponse != null) {
@@ -363,8 +363,8 @@ public class PdfSurveyServices {
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Delegator delegator = dctx.getDelegator();
Map<String, Object> results = ServiceUtil.returnSuccess();
String surveyResponseId = (String)context.get("surveyResponseId");
String contentId = (String)context.get("contentId");
String surveyResponseId = (String) context.get("surveyResponseId");
String contentId = (String) context.get("contentId");
String surveyId = null;
Document document = new Document();
@@ -429,7 +429,7 @@ public class PdfSurveyServices {
public static Map<String, Object> buildSurveyQuestionsAndAnswers(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
Map<String, Object> results = ServiceUtil.returnSuccess();
String surveyResponseId = (String)context.get("surveyResponseId");
String surveyResponseId = (String) context.get("surveyResponseId");
List<Object> qAndA = new LinkedList<>();
try {
@@ -456,7 +456,7 @@ public class PdfSurveyServices {
Locale locale = (Locale) context.get("locale");
Map<String, Object> results = ServiceUtil.returnSuccess();
Map<String, Object> acroFieldMap = new HashMap<>();
String surveyResponseId = (String)context.get("surveyResponseId");
String surveyResponseId = (String) context.get("surveyResponseId");
String acroFormContentId = null;
try {
@@ -540,8 +540,8 @@ public class PdfSurveyServices {
ByteBuffer inputByteBuffer = (ByteBuffer)context.get("inputByteBuffer");
if (inputByteBuffer == null) {
String pdfFileNameIn = (String)context.get("pdfFileNameIn");
String contentId = (String)context.get("contentId");
String pdfFileNameIn = (String) context.get("pdfFileNameIn");
String contentId = (String) context.get("contentId");
if (UtilValidate.isNotEmpty(pdfFileNameIn)) {
try (FileInputStream fis = new FileInputStream(pdfFileNameIn)) {
int c;
@@ -556,9 +556,9 @@ public class PdfSurveyServices {
} else if (UtilValidate.isNotEmpty(contentId)) {
try {
Locale locale = (Locale)context.get("locale");
String https = (String)context.get("https");
String webSiteId = (String)context.get("webSiteId");
String rootDir = (String)context.get("rootDir");
String https = (String) context.get("https");
String webSiteId = (String) context.get("webSiteId");
String rootDir = (String) context.get("rootDir");
GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).cache().queryOne();
String dataResourceId = content.getString("dataResourceId");
inputByteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir);
@@ -71,7 +71,7 @@ public class SurveyWrapper {
protected Map<String, Object> defaultValues = null;
protected boolean edit = false;
protected SurveyWrapper() {}
protected SurveyWrapper() { }
public SurveyWrapper(Delegator delegator, String responseId, String partyId, String surveyId, Map<String, Object> passThru, Map<String, Object> defaultValues) {
this.delegator = delegator;
@@ -226,7 +226,7 @@ public class SurveyWrapper {
try (
InputStream templateStream = templateUrl.openStream();
InputStreamReader templateReader = new InputStreamReader(templateStream, StandardCharsets.UTF_8);
){
) {
template = new Template(templateUrl.toExternalForm(), templateReader, config);
} catch (IOException e) {
Debug.logError(e, "Unable to get template from URL :" + templateUrl.toExternalForm(), MODULE);
@@ -151,7 +151,7 @@ public class TraverseSubContentCacheTransform implements TemplateTransformModel
Map<String, Object> node = null;
List<Map<String, ? extends Object>> globalNodeTrail = UtilGenerics.cast(templateRoot.get("globalNodeTrail"));
if (globalNodeTrail.size() > 0) {
int sz = globalNodeTrail.size() ;
int sz = globalNodeTrail.size();
nodeTrail = new LinkedList<>();
node = UtilGenerics.cast(globalNodeTrail.get(sz - 1));
Boolean checkedObj = (Boolean)node.get("checked");
@@ -42,7 +42,7 @@ public class HumanResEvents {
private static final String RES_ERROR = "HumanResErrorUiLabels";
// Please note : the structure of map in this function is according to the JSON data map of the jsTree
public static String getChildHRCategoryTree(HttpServletRequest request, HttpServletResponse response){
public static String getChildHRCategoryTree(HttpServletRequest request, HttpServletResponse response) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
String partyId = request.getParameter("partyId");
String onclickFunction = request.getParameter("onclickFunction");
@@ -83,7 +83,7 @@ public class HumanResEvents {
return "success";
}
private static List<Map<String, Object>> getCurrentEmployeeDetails(Map<String, Object> params) throws GenericEntityException{
private static List<Map<String, Object>> getCurrentEmployeeDetails(Map<String, Object> params) throws GenericEntityException {
Delegator delegator = (Delegator) params.get("delegator");
List<Map<String, Object>> responseList = new ArrayList<>();
long emplPosCount;
@@ -121,7 +121,7 @@ public class HumanResEvents {
dataMap.put("attr", dataAttrMap);
josonMap.put("attr", attrMap);
josonMap.put("data", dataMap);
responseList.add(josonMap) ;
responseList.add(josonMap);
}
}
}
@@ -132,7 +132,7 @@ public class HumanResEvents {
return responseList;
}
private static List<Map<String, Object>> getChildComps(Map<String, Object> params) throws GenericEntityException{
private static List<Map<String, Object>> getChildComps(Map<String, Object> params) throws GenericEntityException {
Delegator delegator = (Delegator) params.get("delegator");
Map<String , Object> partyGroup = UtilGenerics.cast(params.get("partyGroup"));
List<Map<String, Object>> resultList = new ArrayList<>();
@@ -191,7 +191,7 @@ public class HumanResEvents {
return resultList;
}
private static List<Map<String, Object>> getEmployeeInComp(Map<String, Object> params) throws GenericEntityException{
private static List<Map<String, Object>> getEmployeeInComp(Map<String, Object> params) throws GenericEntityException {
List<GenericValue> isEmpls = null;
Delegator delegator = (Delegator) params.get("delegator");
String partyId = (String) params.get("partyId");
@@ -41,7 +41,7 @@ public final class ProductionRunHelper {
private static final String MODULE = ProductionRunHelper.class.getName();
private ProductionRunHelper() {}
private ProductionRunHelper() { }
/**
* Get a Production Run.
@@ -53,7 +53,6 @@ public final class ProductionRunHelper {
*/
public static Map<String, Object> getProductionRun(Delegator delegator, String productionRunId) {
Map<String, Object> result = new HashMap<>();
try {
if (productionRunId != null) {
GenericValue productionRun = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", productionRunId).queryOne();
@@ -187,8 +187,7 @@ public class ProductionRunServices {
LocalDispatcher dispatcher = ctx.getDispatcher();
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
/* TODO: security management and finishing cleaning (ex copy from PartyServices.java)
*/
// TODO: security management and finishing cleaning (ex copy from PartyServices.java)
// Mandatory input fields
String productId = (String) context.get("productId");
Timestamp startDate = (Timestamp) context.get("startDate");
@@ -1045,7 +1044,7 @@ public class ProductionRunServices {
}
}
}
} catch(GenericEntityException | GenericServiceException gse) {
} catch (GenericEntityException | GenericServiceException gse) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingProductionRunUnableToFindOverheadCosts"
, UtilMisc.toMap("errorString", gse.getMessage()), locale));
}
@@ -1065,7 +1064,7 @@ public class ProductionRunServices {
public static Map<String, Object> getWorkEffortCosts(DispatchContext ctx, Map<String, ? extends Object> context) {
Map<String, Object> result = new HashMap<>();
Delegator delegator = ctx.getDelegator();
String workEffortId = (String)context.get("workEffortId");
String workEffortId = (String) context.get("workEffortId");
Locale locale = (Locale) context.get("locale");
try {
GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffortId).queryOne();
@@ -1101,7 +1100,7 @@ public class ProductionRunServices {
Delegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
String workEffortId = (String)context.get("workEffortId");
String workEffortId = (String) context.get("workEffortId");
Locale locale = (Locale) context.get("locale");
try {
List<GenericValue> tasks = EntityQuery.use(delegator).from("WorkEffort")
@@ -1139,7 +1138,7 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
Map<String, Object> serviceResult = new HashMap<>();
// this is the id of the actual (real) production run task
String productionRunTaskId = (String)context.get("productionRunTaskId");
String productionRunTaskId = (String) context.get("productionRunTaskId");
try {
GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", productionRunTaskId).queryOne();
if (UtilValidate.isEmpty(workEffort)) {
@@ -1387,11 +1386,11 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunId = (String)context.get("productionRunId");
String productId = (String)context.get("productId");
String productionRunId = (String) context.get("productionRunId");
String productId = (String) context.get("productId");
BigDecimal quantity = (BigDecimal) context.get("estimatedQuantity");
// Optional input fields
String workEffortId = (String)context.get("workEffortId");
String workEffortId = (String) context.get("workEffortId");
ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher);
List<GenericValue> tasks = productionRun.getProductionRunRoutingTasks();
@@ -1460,10 +1459,10 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunId = (String)context.get("productionRunId");
String productId = (String)context.get("productId");
String productionRunId = (String) context.get("productionRunId");
String productId = (String) context.get("productId");
// Optional input fields
String workEffortId = (String)context.get("workEffortId"); // the production run task
String workEffortId = (String) context.get("workEffortId"); // the production run task
BigDecimal quantity = (BigDecimal) context.get("estimatedQuantity");
ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher);
@@ -1537,23 +1536,23 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunId = (String)context.get("productionRunId");
String routingTaskId = (String)context.get("routingTaskId");
String productionRunId = (String) context.get("productionRunId");
String routingTaskId = (String) context.get("routingTaskId");
Long priority = (Long)context.get("priority");
// Optional input fields
String workEffortName = (String)context.get("workEffortName");
String description = (String)context.get("description");
Timestamp estimatedStartDate = (Timestamp)context.get("estimatedStartDate");
Timestamp estimatedCompletionDate = (Timestamp)context.get("estimatedCompletionDate");
String workEffortName = (String) context.get("workEffortName");
String description = (String) context.get("description");
Timestamp estimatedStartDate = (Timestamp) context.get("estimatedStartDate");
Timestamp estimatedCompletionDate = (Timestamp) context.get("estimatedCompletionDate");
Double estimatedSetupMillis = null;
if (context.get("estimatedSetupMillis") != null)
estimatedSetupMillis = ((BigDecimal)context.get("estimatedSetupMillis")).doubleValue();
estimatedSetupMillis = ((BigDecimal) context.get("estimatedSetupMillis")).doubleValue();
Double estimatedMilliSeconds = null;
if (context.get("estimatedMilliSeconds") != null)
estimatedMilliSeconds = ((BigDecimal)context.get("estimatedMilliSeconds")).doubleValue();
estimatedMilliSeconds = ((BigDecimal) context.get("estimatedMilliSeconds")).doubleValue();
// The production run is loaded
ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher);
@@ -1687,16 +1686,16 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunId = (String)context.get("workEffortId");
String productionRunId = (String) context.get("workEffortId");
// Optional input fields
BigDecimal quantity = (BigDecimal) context.get("quantity");
String inventoryItemTypeId = (String)context.get("inventoryItemTypeId");
String lotId = (String)context.get("lotId");
String inventoryItemTypeId = (String) context.get("inventoryItemTypeId");
String lotId = (String) context.get("lotId");
String uomId = (String) context.get("quantityUomId");
String locationSeqId = (String) context.get("locationSeqId");
Boolean createLotIfNeeded = (Boolean)context.get("createLotIfNeeded");
Boolean autoCreateLot = (Boolean)context.get("autoCreateLot");
Boolean createLotIfNeeded = (Boolean) context.get("createLotIfNeeded");
Boolean autoCreateLot = (Boolean) context.get("autoCreateLot");
// The default is non-serialized inventory item
if (UtilValidate.isEmpty(inventoryItemTypeId)) {
@@ -1829,11 +1828,9 @@ public class ProductionRunServices {
unitCost = BigDecimal.ZERO;
}
}
// Before creating InvntoryItem and InventoryItemDetails, check weather the record of ProductFacility exist in the system or not
GenericValue productFacility = EntityQuery.use(delegator). from("ProductFacility").where("productId", productionRun.getProductProduced().getString("productId")
, "facilityId", facility.get("facilityId")).queryOne();
GenericValue productFacility = EntityQuery.use(delegator). from("ProductFacility").where("productId", productionRun.getProductProduced().getString("productId"),
"facilityId", facility.get("facilityId")).queryOne();
if (productFacility == null) {
Map<String, Object> createProductFacilityCtx = new HashMap<>();
createProductFacilityCtx.put("productId", productionRun.getProductProduced().getString("productId"));
@@ -1849,7 +1846,7 @@ public class ProductionRunServices {
Debug.logWarning(gse.getMessage(), MODULE);
return ServiceUtil.returnError(gse.getMessage());
}
if ("SERIALIZED_INV_ITEM".equals(inventoryItemTypeId)) {
try {
int numOfItems = quantity.intValue();
@@ -1986,10 +1983,10 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunId = (String)context.get("workEffortId");
String productionRunId = (String) context.get("workEffortId");
// Optional input fields
BigDecimal quantity = (BigDecimal)context.get("quantity");
BigDecimal quantity = (BigDecimal) context.get("quantity");
Map<GenericPK, Object> componentsLocationMap = UtilGenerics.cast(context.get("componentsLocationMap"));
// The production run is loaded
@@ -2057,18 +2054,18 @@ public class ProductionRunServices {
LocalDispatcher dispatcher = ctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunTaskId = (String)context.get("workEffortId");
String productId = (String)context.get("productId");
BigDecimal quantity = (BigDecimal)context.get("quantity");
String productionRunTaskId = (String) context.get("workEffortId");
String productId = (String) context.get("productId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
// Optional input fields
String facilityId = (String)context.get("facilityId");
String currencyUomId = (String)context.get("currencyUomId");
BigDecimal unitCost = (BigDecimal)context.get("unitCost");
String inventoryItemTypeId = (String)context.get("inventoryItemTypeId");
String lotId = (String)context.get("lotId");
String facilityId = (String) context.get("facilityId");
String currencyUomId = (String) context.get("currencyUomId");
BigDecimal unitCost = (BigDecimal) context.get("unitCost");
String inventoryItemTypeId = (String) context.get("inventoryItemTypeId");
String lotId = (String) context.get("lotId");
String uomId = (String) context.get("quantityUomId");
String isReturned = (String)context.get("isReturned");
String isReturned = (String) context.get("isReturned");
// The default is non-serialized inventory item
if (UtilValidate.isEmpty(inventoryItemTypeId)) {
@@ -2198,11 +2195,11 @@ public class ProductionRunServices {
LocalDispatcher dispatcher = ctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunTaskId = (String)context.get("workEffortId");
String productId = (String)context.get("productId");
String productionRunTaskId = (String) context.get("workEffortId");
String productId = (String) context.get("productId");
// Optional input fields
BigDecimal quantity = (BigDecimal)context.get("quantity");
String lotId = (String)context.get("lotId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
String lotId = (String) context.get("lotId");
String uomId = (String) context.get("quantityUomId");
Locale locale = (Locale) context.get("locale");
if (quantity == null || quantity.compareTo(ZERO) == 0) {
@@ -2240,7 +2237,7 @@ public class ProductionRunServices {
} catch (GenericEntityException gee) {
return ServiceUtil.returnError(gee.getMessage());
}
String inventoryItemTypeId = (String)context.get("inventoryItemTypeId");
String inventoryItemTypeId = (String) context.get("inventoryItemTypeId");
// TODO: if the task is not running, then return an error message.
@@ -2265,22 +2262,22 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String productionRunId = (String)context.get("productionRunId");
String workEffortId = (String)context.get("productionRunTaskId");
String partyId = (String)context.get("partyId");
String productionRunId = (String) context.get("productionRunId");
String workEffortId = (String) context.get("productionRunTaskId");
String partyId = (String) context.get("partyId");
if (UtilValidate.isEmpty(partyId)) {
partyId = userLogin.getString("partyId");
}
// Optional input fields
Timestamp fromDate = (Timestamp)context.get("fromDate");
Timestamp toDate = (Timestamp)context.get("toDate");
BigDecimal addQuantityProduced = (BigDecimal)context.get("addQuantityProduced");
BigDecimal addQuantityRejected = (BigDecimal)context.get("addQuantityRejected");
BigDecimal addSetupTime = (BigDecimal)context.get("addSetupTime");
BigDecimal addTaskTime = (BigDecimal)context.get("addTaskTime");
String comments = (String)context.get("comments");
Boolean issueRequiredComponents = (Boolean)context.get("issueRequiredComponents");
Timestamp fromDate = (Timestamp) context.get("fromDate");
Timestamp toDate = (Timestamp) context.get("toDate");
BigDecimal addQuantityProduced = (BigDecimal) context.get("addQuantityProduced");
BigDecimal addQuantityRejected = (BigDecimal) context.get("addQuantityRejected");
BigDecimal addSetupTime = (BigDecimal) context.get("addSetupTime");
BigDecimal addTaskTime = (BigDecimal) context.get("addTaskTime");
String comments = (String) context.get("comments");
Boolean issueRequiredComponents = (Boolean) context.get("issueRequiredComponents");
Map<GenericPK, Object> componentsLocationMap = UtilGenerics.cast(context.get("componentsLocationMap"));
if (issueRequiredComponents == null) {
@@ -2430,7 +2427,7 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String requirementId = (String)context.get("requirementId");
String requirementId = (String) context.get("requirementId");
GenericValue requirement = null;
try {
requirement = EntityQuery.use(delegator).from("Requirement").where("requirementId", requirementId).queryOne();
@@ -2464,9 +2461,9 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String requirementId = (String)context.get("requirementId");
String requirementId = (String) context.get("requirementId");
// Optional input fields
BigDecimal quantity = (BigDecimal)context.get("quantity");
BigDecimal quantity = (BigDecimal) context.get("quantity");
GenericValue requirement = null;
try {
@@ -2530,13 +2527,13 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String facilityId = (String)context.get("facilityId");
String facilityId = (String) context.get("facilityId");
// Optional input fields
String configId = (String)context.get("configId");
String configId = (String) context.get("configId");
ProductConfigWrapper config = (ProductConfigWrapper)context.get("config");
BigDecimal quantity = (BigDecimal)context.get("quantity");
String orderId = (String)context.get("orderId");
String orderItemSeqId = (String)context.get("orderItemSeqId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
String orderId = (String) context.get("orderId");
String orderItemSeqId = (String) context.get("orderItemSeqId");
if (config == null && configId == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingConfigurationNotAvailable", locale));
@@ -2702,9 +2699,9 @@ public class ProductionRunServices {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
// Mandatory input fields
String facilityId = (String)context.get("facilityId");
String orderId = (String)context.get("orderId");
String orderItemSeqId = (String)context.get("orderItemSeqId");
String facilityId = (String) context.get("facilityId");
String orderId = (String) context.get("orderId");
String orderItemSeqId = (String) context.get("orderItemSeqId");
// Check if the order is to be immediately fulfilled, in which case the inventory
// hasn't been reserved and ATP not yet decreased
@@ -2911,7 +2908,7 @@ public class ProductionRunServices {
if ("OrderItemShipGroupAssoc".equals(orderItemOrShipGroupAssoc.getEntityName())) {
try {
orderItem = orderItemOrShipGroupAssoc.getRelatedOne("OrderItem", false);
} catch(GenericEntityException gee) {
} catch (GenericEntityException gee) {
Debug.logInfo("Unable to find order item for " + orderItemOrShipGroupAssoc, MODULE);
}
} else {
@@ -2935,7 +2932,6 @@ public class ProductionRunServices {
}
try {
List<GenericValue> existingProductionRuns = null;
if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
existingProductionRuns = EntityQuery.use(delegator).from("WorkAndOrderItemFulfillment")
.where(
@@ -2980,13 +2976,13 @@ public class ProductionRunServices {
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericValue userLogin =(GenericValue)context.get("userLogin");
Locale locale = (Locale) context.get("locale");
String productId = (String)context.get("productId");
Timestamp startDate = (Timestamp)context.get("startDate");
BigDecimal quantity = (BigDecimal)context.get("quantity");
String facilityId = (String)context.get("facilityId");
String workEffortName = (String)context.get("workEffortName");
String description = (String)context.get("description");
String routingId = (String)context.get("routingId");
String productId = (String) context.get("productId");
Timestamp startDate = (Timestamp) context.get("startDate");
BigDecimal quantity = (BigDecimal) context.get("quantity");
String facilityId = (String) context.get("facilityId");
String workEffortName = (String) context.get("workEffortName");
String description = (String) context.get("description");
String routingId = (String) context.get("routingId");
String workEffortId = null;
if (quantity == null) {
quantity = BigDecimal.ONE;
@@ -3285,7 +3281,7 @@ public class ProductionRunServices {
Delegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
String inventoryItemId = (String)context.get("inventoryItemId");
String inventoryItemId = (String) context.get("inventoryItemId");
Locale locale = (Locale) context.get("locale");
Map<String, Object> serviceResult = new HashMap<>();
try {
@@ -3326,8 +3322,8 @@ public class ProductionRunServices {
GenericValue userLogin = (GenericValue) context.get("userLogin");
Locale locale = (Locale) context.get("locale");
// Mandatory input fields
String inventoryItemId = (String)context.get("inventoryItemId");
BigDecimal quantity = (BigDecimal)context.get("quantity");
String inventoryItemId = (String) context.get("inventoryItemId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
List<String> inventoryItemIds = new LinkedList<>();
try {
GenericValue inventoryItem = EntityQuery.use(delegator).from("InventoryItem")
@@ -54,9 +54,9 @@ public class InventoryEventPlannedServices {
"productId", context.get("productId"),
"eventDate", context.get("eventDate"),
"mrpEventTypeId", context.get("mrpEventTypeId"));
BigDecimal quantity = (BigDecimal)context.get("quantity");
BigDecimal quantity = (BigDecimal) context.get("quantity");
try {
createOrUpdateMrpEvent(parameters, quantity, (String)context.get("facilityId"), (String)context.get("eventName"), false, delegator);
createOrUpdateMrpEvent(parameters, quantity, (String) context.get("facilityId"), (String) context.get("eventName"), false, delegator);
} catch (GenericEntityException e) {
Debug.logError(e,"Error : findOne(\"MrpEvent\", parameters =)"+parameters, MODULE);
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent", UtilMisc.toMap("parameters", parameters), locale));
@@ -65,9 +65,9 @@ public class MrpServices {
LocalDispatcher dispatcher = ctx.getDispatcher();
Timestamp now = UtilDateTime.nowTimestamp();
Locale locale = (Locale) context.get("locale");
String facilityId = (String)context.get("facilityId");
String facilityId = (String) context.get("facilityId");
Integer defaultYearsOffset = (Integer)context.get("defaultYearsOffset");
String mrpId = (String)context.get("mrpId");
String mrpId = (String) context.get("mrpId");
//Erases the old table for the moment and initializes it with the new orders,
//Does not modify the old one now.
@@ -286,7 +286,6 @@ public class MrpServices {
} catch (GenericEntityException e) {
Debug.logWarning(e, MODULE);
}
GenericValue orderItemDeliverySchedule = null;
orderItemDeliverySchedule = EntityQuery.use(delegator).from("OrderDeliverySchedule").where("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")).queryOne();
Timestamp estimatedShipDate = null;
@@ -598,10 +597,10 @@ public class MrpServices {
GenericValue userLogin = (GenericValue) context.get("userLogin");
Timestamp now = UtilDateTime.nowTimestamp();
Locale locale = (Locale) context.get("locale");
String mrpName = (String)context.get("mrpName");
String mrpName = (String) context.get("mrpName");
Integer defaultYearsOffset = (Integer)context.get("defaultYearsOffset");
String facilityGroupId = (String)context.get("facilityGroupId");
String facilityId = (String)context.get("facilityId");
String facilityGroupId = (String) context.get("facilityGroupId");
String facilityId = (String) context.get("facilityId");
String manufacturingFacilityId = null;
if (UtilValidate.isEmpty(facilityId) && UtilValidate.isEmpty(facilityGroupId)) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpFacilityNotAvailable", locale));
@@ -34,7 +34,7 @@ public final class ReportHelper {
private static final String MODULE = ReportHelper.class.getName();
private ReportHelper() {}
private ReportHelper() { }
/**
* Calculate conversion rates based on a List of visits and orders. Designed to be used for reporting on
@@ -40,7 +40,7 @@ public final class OrderChangeHelper {
private static final String MODULE = OrderChangeHelper.class.getName();
private OrderChangeHelper() {}
private OrderChangeHelper() { }
public static boolean approveOrder(LocalDispatcher dispatcher, GenericValue userLogin, String orderId) {
return approveOrder(dispatcher, userLogin, orderId, false);
@@ -88,7 +88,7 @@ public class OrderReadHelper {
protected List<GenericValue> orderItemAttributes = null;
protected BigDecimal totalPrice = null;
protected OrderReadHelper() {}
protected OrderReadHelper() { }
public OrderReadHelper(GenericValue orderHeader, List<GenericValue> adjustments, List<GenericValue> orderItems) {
this.orderHeader = orderHeader;
@@ -435,7 +435,7 @@ public class OrderReturnServices {
}
String returnStatus = returnHeader.getString("statusId");
if (!"RETURN_CANCELLED".equals(returnStatus)) {
if (UtilValidate.isNotEmpty(returnItem.getBigDecimal("returnQuantity"))){
if (UtilValidate.isNotEmpty(returnItem.getBigDecimal("returnQuantity"))) {
returnedQty = returnedQty.add(returnItem.getBigDecimal("returnQuantity"));
}
}
@@ -1264,8 +1264,8 @@ public class OrderReturnServices {
// Assemble a map of orderPaymentPreferenceId -> list of maps of (OPP and availableAmountForRefunding)
// where availableAmountForRefunding = receivedAmount - alreadyRefundedAmount
// We break the OPPs down this way because we need to process the refunds to payment methods in a particular order
Map<String, BigDecimal> receivedPaymentTotalsByPaymentMethod = orderReadHelper.getReceivedPaymentTotalsByPaymentMethod() ;
Map<String, BigDecimal> refundedTotalsByPaymentMethod = orderReadHelper.getReturnedTotalsByPaymentMethod() ;
Map<String, BigDecimal> receivedPaymentTotalsByPaymentMethod = orderReadHelper.getReceivedPaymentTotalsByPaymentMethod();
Map<String, BigDecimal> refundedTotalsByPaymentMethod = orderReadHelper.getReturnedTotalsByPaymentMethod();
// getOrderPaymentPreferenceTotalByType has been called because getReceivedPaymentTotalsByPaymentMethod does not
// return payments captured from Billing Account.This is because when payment is captured from Billing Account
@@ -3563,7 +3563,7 @@ public class OrderServices {
try {
//For quantity we should test if we allow to add decimal quantity for this product an productStore :
// if not and if quantity is in decimal format then return error.
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())) {
BigDecimal remainder = quantity.remainder(BigDecimal.ONE);
if (remainder.compareTo(BigDecimal.ZERO) != 0) {
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", locale));
@@ -3572,7 +3572,7 @@ public class OrderServices {
} else {
quantity = quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), UtilNumber.getRoundingMode("order.rounding"));
}
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
quantity = BigDecimal.ONE;
}
@@ -3735,7 +3735,7 @@ public class OrderServices {
try {
//For quantity we should test if we allow to add decimal quantity for this product an productStore :
// if not and if quantity is in decimal format then return error.
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, cartItem.getProductId(), cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, cartItem.getProductId(), cart.getProductStoreId())) {
BigDecimal remainder = qty.remainder(BigDecimal.ONE);
if (remainder.compareTo(BigDecimal.ZERO) != 0) {
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", locale));
@@ -3744,7 +3744,7 @@ public class OrderServices {
} else {
qty = qty.setScale(UtilNumber.getBigDecimalScale("order.decimals"), UtilNumber.getRoundingMode("order.rounding"));
}
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
qty = BigDecimal.ONE;
}
@@ -3898,7 +3898,7 @@ public class OrderServices {
try {
//For quantity we should test if we allow to add decimal quantity for this product an productStore :
// if not and if quantity is in decimal format then return error.
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, cartItem.getProductId(), cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, cartItem.getProductId(), cart.getProductStoreId())) {
BigDecimal remainder = groupQty.remainder(BigDecimal.ONE);
if (remainder.compareTo(BigDecimal.ZERO) != 0) {
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", locale));
@@ -3907,7 +3907,7 @@ public class OrderServices {
} else {
groupQty = groupQty.setScale(UtilNumber.getBigDecimalScale("order.decimals"), UtilNumber.getRoundingMode("order.rounding"));
}
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
groupQty = BigDecimal.ONE;
}
@@ -5960,7 +5960,7 @@ public class OrderServices {
* @throws GeneralException
*/
public static Map<String, Object> updateOrderItemShipGroupAssoc(DispatchContext dctx, Map<String, Object> context)
throws GeneralException{
throws GeneralException {
Map<String, Object> result = ServiceUtil.returnSuccess();
String message = null;
Delegator delegator = dctx.getDelegator();
@@ -6387,17 +6387,17 @@ public class OrderServices {
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue)context.get("userLogin");
String orderId = (String)context.get("orderId");
String shipGroupSeqId = (String)context.get("shipGroupSeqId");
String contactMechId = (String)context.get("contactMechId");
String oldContactMechId = (String)context.get("oldContactMechId");
String shipmentMethod = (String)context.get("shipmentMethod");
String orderId = (String) context.get("orderId");
String shipGroupSeqId = (String) context.get("shipGroupSeqId");
String contactMechId = (String) context.get("contactMechId");
String oldContactMechId = (String) context.get("oldContactMechId");
String shipmentMethod = (String) context.get("shipmentMethod");
//load cart from order to update new shipping method or address
ShoppingCart shoppingCart = null;
try {
shoppingCart = loadCartForUpdate(dispatcher, delegator, userLogin, orderId);
} catch(GeneralException e) {
} catch (GeneralException e) {
Debug.logError(e, MODULE);
}
@@ -6457,7 +6457,7 @@ public class OrderServices {
try {
shipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shipmentMethodTypeId).queryOne().getString("description");
newShipMethTypeDesc = EntityQuery.use(delegator).from("ShipmentMethodType").where("shipmentMethodTypeId", shippingMethods.get(0).getString("shipmentMethodTypeId")).queryOne().getString("description");
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
}
// message to notify user for not applicability of shipping method
@@ -6471,7 +6471,7 @@ public class OrderServices {
Map<String, Object> changeMap = new HashMap<>();
try {
saveUpdatedCartToOrder(dispatcher, delegator, shoppingCart, locale, userLogin, orderId, changeMap, true, false);
} catch(GeneralException e) {
} catch (GeneralException e) {
Debug.logError(e, MODULE);
}
@@ -7013,7 +7013,7 @@ public class OrderServices {
serviceCtx.clear();
//Create Allocation Plan Items
for (int i=0; i<itemListSize; i++) {
for (int i = 0; i<itemListSize; i++) {
String orderId = itemOrderIdMap.get(String.valueOf(i));
String orderItemSeqId = itemOrderItemSeqIdMap.get(String.valueOf(i));
String allocatedQuantityStr = itemAllocatedQuantityMap.get(String.valueOf(i));
@@ -356,7 +356,7 @@ public class RequirementServices {
String orderId = (String) context.get("orderId");
OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
try {
for(GenericValue orderItem: orh.getOrderItems()){
for (GenericValue orderItem: orh.getOrderItems()) {
GenericValue orderRequirementCommitment = EntityQuery.use(delegator).from("OrderRequirementCommitment")
.where(UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItem.getString("orderItemSeqId")))
.queryFirst();
@@ -371,7 +371,7 @@ public class RequirementServices {
}
}
}
} catch(GenericEntityException | GenericServiceException e){
} catch (GenericEntityException | GenericServiceException e) {
Debug.logError(e, MODULE);
}
return ServiceUtil.returnSuccess();
@@ -38,7 +38,7 @@ public class CartEventListener implements HttpSessionListener {
private static final String MODULE = CartEventListener.class.getName();
public CartEventListener() {}
public CartEventListener() { }
@Override
public void sessionCreated(HttpSessionEvent event) {
@@ -832,9 +832,9 @@ public class CheckOutEvents {
String facilityId = request.getParameter(shipGroupIndex + "_shipGroupFacilityId");
if (shippingContactMechId == null) {
shippingContactMechId = (String) request.getAttribute("contactMechId");
} else if ("PURCHASE_ORDER".equals(cart.getOrderType())){
} else if ("PURCHASE_ORDER".equals(cart.getOrderType())) {
String[] shipInfo = shippingContactMechId.split("_@_");
if (shipInfo.length > 1){
if (shipInfo.length > 1) {
shippingContactMechId = shipInfo[0];
facilityId = shipInfo[1];
}
@@ -199,7 +199,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
protected Timestamp cancelBackOrderDate = null;
/** don't allow empty constructor */
protected ShoppingCart() {}
protected ShoppingCart() { }
/** Creates a new cloned ShoppingCart Object. */
public ShoppingCart(ShoppingCart cart) {
@@ -796,7 +796,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
List<ShoppingCartItem> localList = new LinkedList<>();
localList.addAll(multipleItems);
// the ones to keep...
for (int i=0; i<maxItems; i++) {
for (int i = 0; i < maxItems; i++) {
localList.remove(0);
}
for (ShoppingCartItem item : localList) {
@@ -2238,7 +2238,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
public int getShipInfoIndex (String shipGroupSeqId) {
int idx = -1;
for (int i=0; i<shipInfo.size(); i++) {
for (int i = 0; i < shipInfo.size(); i++) {
CartShipInfo csi = shipInfo.get(i);
if (shipGroupSeqId.equals(csi.shipGroupSeqId)) {
idx = i;
@@ -4260,14 +4260,14 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
GenericValue productFacility = null;
try {
productFacility = EntityQuery.use(delegator).from("ProductFacility").where("productId", productId, "facilityId", shipInfo.getFacilityId()).queryOne();
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError("Error :" +e.getMessage(), MODULE);
e.printStackTrace();
}
String requirementMethodEnumId = storeRequirementMethodEnumId;
if (productFacility != null && UtilValidate.isNotEmpty(productFacility.getString("requirementMethodEnumId"))){
if (productFacility != null && UtilValidate.isNotEmpty(productFacility.getString("requirementMethodEnumId"))) {
requirementMethodEnumId = productFacility.getString("requirementMethodEnumId");
}
@@ -4357,7 +4357,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
for (Entry<String, Map<ShoppingCartItem, Map<Integer, BigDecimal>>> supplierPartyEntry : dropShipItems.entrySet()) {
String supplierPartyId = supplierPartyEntry.getKey();
CartShipInfo shipInfo = null;
int newShipGroupIndex = -1 ;
int newShipGroupIndex = -1;
// Attempt to get the first ship group for the supplierPartyId
TreeMap<Integer, CartShipInfo> supplierShipGroups = this.getShipGroupsBySupplier(supplierPartyId);
@@ -4426,7 +4426,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
// don't allow empty constructor
@SuppressWarnings("unused")
private ShoppingCartItemGroup() {}
private ShoppingCartItemGroup() { }
protected ShoppingCartItemGroup(long groupNumber, String groupName) {
this(groupNumber, groupName, null);
@@ -466,7 +466,7 @@ public class ShoppingCartEvents {
quantity = (BigDecimal) ObjectType.simpleTypeOrObjectConvert(quantityStr, "BigDecimal", null, locale);
//For quantity we should test if we allow to add decimal quantity for this product an productStore :
// if not and if quantity is in decimal format then return error.
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())) {
BigDecimal remainder = quantity.remainder(BigDecimal.ONE);
if (remainder.compareTo(BigDecimal.ZERO) != 0) {
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", locale));
@@ -640,7 +640,7 @@ public class ShoppingCartEvents {
}
// check for alternative packing
if (ProductWorker.isAlternativePacking(delegator, productId , parentProductId)){
if (ProductWorker.isAlternativePacking(delegator, productId , parentProductId)) {
GenericValue parentProduct = null;
try {
parentProduct = EntityQuery.use(delegator).from("Product").where("productId", parentProductId).queryOne();
@@ -648,7 +648,7 @@ public class ShoppingCartEvents {
Debug.logError(e, "Error getting parent product", MODULE);
}
BigDecimal piecesIncluded = BigDecimal.ZERO;
if (parentProduct != null){
if (parentProduct != null) {
piecesIncluded = new BigDecimal(parentProduct.getLong("piecesIncluded"));
quantity = quantity.multiply(piecesIncluded);
}
@@ -1764,7 +1764,7 @@ public class ShoppingCartEvents {
Map<String, Object> context = UtilHttp.getParameterMap(request);
String keyPrefix = "productPromoId_";
for (int i = 1; i <= 50; i++) {
String productPromoId = (String)context.get(keyPrefix + i);
String productPromoId = (String) context.get(keyPrefix + i);
if (UtilValidate.isNotEmpty(productPromoId)) {
try {
GenericValue promo = EntityQuery.use(delegator).from("ProductPromo").where("productPromoId", productPromoId).queryOne();
@@ -1840,7 +1840,7 @@ public class ShoppingCartEvents {
try {
//For quantity we should test if we allow to add decimal quantity for this product an productStore :
// if not and if quantity is in decimal format then return error.
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())) {
BigDecimal remainder = quantity.remainder(BigDecimal.ONE);
if (remainder.compareTo(BigDecimal.ZERO) != 0) {
request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", cart.getLocale()));
@@ -438,7 +438,7 @@ public class ShoppingCartHelper {
}
if (quantity.compareTo(BigDecimal.ZERO) > 0) {
// check for alternative packing
if (ProductWorker.isAlternativePacking(delegator, null , productId)){
if (ProductWorker.isAlternativePacking(delegator, null , productId)) {
GenericValue originalProduct = null;
originalProductId = productId;
productId = ProductWorker.getOriginalProductId(delegator, productId);
@@ -447,7 +447,7 @@ public class ShoppingCartHelper {
} catch (GenericEntityException e) {
Debug.logError(e, "Error getting parent product", MODULE);
}
if (originalProduct != null){
if (originalProduct != null) {
BigDecimal piecesIncluded = new BigDecimal(originalProduct.getLong("piecesIncluded"));
quantity = quantity.multiply(piecesIncluded);
}
@@ -456,7 +456,7 @@ public class ShoppingCartHelper {
try {
//For quantity we should test if we allow to add decimal quantity for this product an productStore :
// if not and if quantity is in decimal format then return error.
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, productId, cart.getProductStoreId())) {
BigDecimal remainder = quantity.remainder(BigDecimal.ONE);
if (remainder.compareTo(BigDecimal.ZERO) != 0) {
return ServiceUtil.returnError(UtilProperties.getMessage(RES_ERROR, "cart.addToCart.quantityInDecimalNotAllowed", this.cart.getLocale()));
@@ -465,7 +465,7 @@ public class ShoppingCartHelper {
} else {
quantity = quantity.setScale(UtilNumber.getBigDecimalScale("order.decimals"), UtilNumber.getRoundingMode("order.rounding"));
}
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError(e.getMessage(), MODULE);
quantity = BigDecimal.ONE;
}
@@ -496,7 +496,7 @@ public class ShoppingCartHelper {
String itemGroupNumber = (String) context.get("itemGroupNumber");
// check if we are using per row submit
boolean useRowSubmit = (!context.containsKey("_useRowSubmit"))? false :
"Y".equalsIgnoreCase((String)context.get("_useRowSubmit"));
"Y".equalsIgnoreCase((String) context.get("_useRowSubmit"));
// The number of multi form rows is retrieved
int rowCount = UtilHttp.getMultiFormRowCount(context);
@@ -514,7 +514,7 @@ public class ShoppingCartHelper {
String requirementId = null;
String thisSuffix = UtilHttp.getMultiRowDelimiter() + i;
boolean rowSelected = (!context.containsKey("_rowSubmit" + thisSuffix))? false :
"Y".equalsIgnoreCase((String)context.get("_rowSubmit" + thisSuffix));
"Y".equalsIgnoreCase((String) context.get("_rowSubmit" + thisSuffix));
// make sure we are to process this row
if (useRowSubmit && !rowSelected) {
@@ -709,7 +709,7 @@ public class ShoppingCartItem implements java.io.Serializable {
}
/** Cannot create shopping cart item with no parameters */
protected ShoppingCartItem() {}
protected ShoppingCartItem() { }
/** Creates new ShoppingCartItem object.
* @deprecated Use {@link #ShoppingCartItem(GenericValue, Map, Map, String, Locale, String, ShoppingCartItemGroup, LocalDispatcher)} instead*/
@@ -1086,11 +1086,11 @@ public class ShoppingCartItem implements java.io.Serializable {
Boolean updatedDepositAmount = false;
BigDecimal adjustmentAmount = depositAmount.getBigDecimal("price").multiply(this.getQuantity(), generalRounding);
// itemAdjustments is a reference so directly setting updated amount to the same.
for(GenericValue itemAdjustment : itemAdjustments) {
for (GenericValue itemAdjustment : itemAdjustments) {
if ("DEPOSIT_ADJUSTMENT".equals(itemAdjustment.getString("orderAdjustmentTypeId"))) {
itemAdjustment.set("amount", adjustmentAmount);
updatedDepositAmount = true;
}
itemAdjustment.set("amount", adjustmentAmount);
updatedDepositAmount = true;
}
}
if (!updatedDepositAmount) {
GenericValue orderAdjustment = delegator.makeValue("OrderAdjustment");
@@ -1100,11 +1100,10 @@ public class ShoppingCartItem implements java.io.Serializable {
this.addAdjustment(orderAdjustment);
}
}
} catch (GenericEntityException e){
} catch (GenericEntityException e) {
Debug.logError("Error in fetching deposite price details!!", MODULE);
}
}
public void updatePrice(LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException {
// set basePrice using the calculateProductPrice service
if (_product != null && isModifiedPrice == false) {
@@ -1127,14 +1126,14 @@ public class ShoppingCartItem implements java.io.Serializable {
// check alternative packaging
boolean isAlternativePacking = ProductWorker.isAlternativePacking(delegator, this.productId , this.getParentProductId());
BigDecimal pieces = BigDecimal.ONE;
if (isAlternativePacking && UtilValidate.isNotEmpty(this.getParentProduct())){
if (isAlternativePacking && UtilValidate.isNotEmpty(this.getParentProduct())) {
GenericValue originalProduct = this.getParentProduct();
if (originalProduct != null) {
pieces = new BigDecimal(originalProduct.getLong("piecesIncluded"));
}
priceContext.put("product", originalProduct);
this._parentProduct = null;
}else{
} else {
priceContext.put("product", this.getProduct());
}
@@ -1155,9 +1154,9 @@ public class ShoppingCartItem implements java.io.Serializable {
throw new CartItemModifyException("Could not find a valid price for the product with ID [" + this.getProductId() + "] and supplier with ID [" + partyId + "], not adding to cart.");
}
if (isAlternativePacking){
if (isAlternativePacking) {
this.setBasePrice(((BigDecimal) priceResult.get("price")).divide(pieces, RoundingMode.HALF_UP));
}else{
} else {
this.setBasePrice(((BigDecimal) priceResult.get("price")));
}
@@ -1180,7 +1179,7 @@ public class ShoppingCartItem implements java.io.Serializable {
}
}
}
if ("true".equals(EntityUtilProperties.getPropertyValue("catalog", "convertProductPriceCurrency", delegator))){
if ("true".equals(EntityUtilProperties.getPropertyValue("catalog", "convertProductPriceCurrency", delegator))) {
priceContext.put("currencyUomIdTo", cart.getCurrency());
} else {
priceContext.put("currencyUomId", cart.getCurrency());
@@ -1210,7 +1209,7 @@ public class ShoppingCartItem implements java.io.Serializable {
}
//set alternative product price
if (isAlternativePacking){
if (isAlternativePacking) {
int decimals = 2;
if (priceResult.get("listPrice") != null) {
this.listPrice = ((BigDecimal) priceResult.get("listPrice")).divide(pieces, decimals, RoundingMode.HALF_UP);
@@ -1227,7 +1226,7 @@ public class ShoppingCartItem implements java.io.Serializable {
if (priceResult.get("specialPromoPrice") != null) {
this.setSpecialPromoPrice(((BigDecimal) priceResult.get("specialPromoPrice")).divide(pieces, decimals, RoundingMode.HALF_UP));
}
}else{
} else {
if (priceResult.get("listPrice") != null) {
this.listPrice = ((BigDecimal) priceResult.get("listPrice"));
}
@@ -313,7 +313,7 @@ public class ShoppingCartServices {
if (UtilValidate.isNotEmpty(orderTerms)) {
for (GenericValue orderTerm : orderTerms) {
BigDecimal termValue = BigDecimal.ZERO;
if (UtilValidate.isNotEmpty(orderTerm.getString("termValue"))){
if (UtilValidate.isNotEmpty(orderTerm.getString("termValue"))) {
termValue = new BigDecimal(orderTerm.getString("termValue"));
}
long termDays = 0;
@@ -511,7 +511,7 @@ public class ShoppingCartServices {
return ServiceUtil.returnError(e.getMessage());
}
// attach surveyResponseId for each item
if (UtilValidate.isNotEmpty(surveyResponseResult)){
if (UtilValidate.isNotEmpty(surveyResponseResult)) {
cartItem.setAttribute("surveyResponses", UtilMisc.toList(surveyResponseResult.get("surveyResponseId")));
}
// attach addition item information
@@ -762,7 +762,7 @@ public class ShoppingCartServices {
// create order term from quote term
for (GenericValue quoteTerm : quoteTerms) {
BigDecimal termValue = BigDecimal.ZERO;
if (UtilValidate.isNotEmpty(quoteTerm.getString("termValue"))){
if (UtilValidate.isNotEmpty(quoteTerm.getString("termValue"))) {
termValue = new BigDecimal(quoteTerm.getString("termValue"));
}
long termDays = 0;
@@ -783,7 +783,7 @@ public class ShoppingCartServices {
// Convert the quote adjustment to order header adjustments and
// put them in a map: the key/values pairs are quoteItemSeqId/List of adjs
Map<String, List<GenericValue>> orderAdjsMap = new HashMap<>() ;
Map<String, List<GenericValue>> orderAdjsMap = new HashMap<>();
for (GenericValue quoteAdj : quoteAdjs) {
List<GenericValue> orderAdjs = orderAdjsMap.get(UtilValidate.isNotEmpty(quoteAdj.getString("quoteItemSeqId")) ? quoteAdj.getString("quoteItemSeqId") : quoteId);
if (orderAdjs == null) {
@@ -52,7 +52,7 @@ public final class ProductDisplayWorker {
private static final String MODULE = ProductDisplayWorker.class.getName();
private ProductDisplayWorker() {}
private ProductDisplayWorker() { }
/* ========================================================================================*/
@@ -271,7 +271,7 @@ public final class ProductDisplayWorker {
Integer quantity = entry.getValue();
BigDecimal occs = productQuantities.get(prodId);
//For quantity we should test if we allow to add decimal quantity for this product an productStore : if not then round to 0
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, prodId, cart.getProductStoreId())){
if (! ProductWorker.isDecimalQuantityOrderAllowed(delegator, prodId, cart.getProductStoreId())) {
occs = occs.setScale(0, UtilNumber.getRoundingMode("order.rounding"));
}
else {
@@ -1067,7 +1067,7 @@ public final class ProductPromoWorker {
return res;
}
public static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) throws GenericEntityException{
public static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) throws GenericEntityException {
List<GenericValue> partyRelationshipList = EntityQuery.use(delegator).from("PartyRelationship").where("partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP").cache(true).filterByDate(nowTimestamp).queryList();
for (GenericValue genericValue : partyRelationshipList) {
String partyIdFrom = (String)genericValue.get("partyIdFrom");
@@ -1221,7 +1221,7 @@ public final class ProductPromoWorker {
boolean addNewAdjustment = true;
List<GenericValue> adjustments = cartItem.getAdjustments();
if (UtilValidate.isNotEmpty(adjustments)) {
for(GenericValue adjustment : adjustments) {
for (GenericValue adjustment : adjustments) {
if ("PROMOTION_ADJUSTMENT".equals(adjustment.getString("orderAdjustmentTypeId")) &&
productPromoAction.get("productPromoId").equals(adjustment.getString("productPromoId")) &&
productPromoAction.get("productPromoRuleId").equals(adjustment.getString("productPromoRuleId")) &&
@@ -269,7 +269,7 @@ public class ShippingEvents {
// Check if minimum price is set for any Shipping Option, if yes,
// compare it with total shipping and use greater of the two.
BigDecimal minimumPrice = storeShipMethod.getBigDecimal("minimumPrice");
if (UtilValidate.isNotEmpty(minimumPrice) && shippingTotal.compareTo(minimumPrice) < 0){
if (UtilValidate.isNotEmpty(minimumPrice) && shippingTotal.compareTo(minimumPrice) < 0) {
shippingTotal = minimumPrice;
}
@@ -619,7 +619,7 @@ public class ShoppingListEvents {
/**
* Create the guest cookies for a shopping list
*/
public static String createGuestShoppingListCookies (HttpServletRequest request, HttpServletResponse response){
public static String createGuestShoppingListCookies (HttpServletRequest request, HttpServletResponse response) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession(true);
@@ -689,7 +689,7 @@ public class ShoppingListEvents {
/**
* Clear the guest cookies for a shopping list
*/
public static String clearGuestShoppingListCookies (HttpServletRequest request, HttpServletResponse response){
public static String clearGuestShoppingListCookies (HttpServletRequest request, HttpServletResponse response) {
Properties systemProps = System.getProperties();
String guestShoppingUserName = "GuestShoppingListId_" + systemProps.getProperty("user.name").replace(" ", "_");
Cookie guestShoppingListCookie = new Cookie(guestShoppingUserName, null);
@@ -33,7 +33,7 @@ public final class TaskWorker {
private static final String MODULE = TaskWorker.class.getName();
private static final Map<String, String> statusMapping = UtilMisc.toMap("WF_NOT_STARTED", "Waiting", "WF_RUNNING", "Active", "WF_COMPLETE", "Complete", "WF_SUSPENDED", "Hold");
private TaskWorker() {}
private TaskWorker() { }
public static String getCustomerName(GenericValue orderTaskList) {
String lastName = orderTaskList.getString("customerLastName");
@@ -35,9 +35,9 @@ public class OrderTest extends OFBizTestCase {
}
public void testAdminGetNextOrderSeqId() throws Exception {
Map <String, Object> ctx = new HashMap<>();
Map<String, Object> ctx = new HashMap<>();
ctx.put("partyId", "admin"); //party with no AcctgPref prefix
Map <String, Object> resp = dispatcher.runSync("getNextOrderId", ctx);
Map<String, Object> resp = dispatcher.runSync("getNextOrderId", ctx);
if (ServiceUtil.isError(resp)) {
Debug.logError(ServiceUtil.getErrorMessage(resp), MODULE);
return;
@@ -48,9 +48,9 @@ public class OrderTest extends OFBizTestCase {
}
public void testCompanyGetNextOrderSeqId() throws Exception {
Map <String, Object> ctx = new HashMap<>();
Map<String, Object> ctx = new HashMap<>();
ctx.put("partyId", "Company"); //party with AcctgPref prefix : CO
Map <String, Object> resp = dispatcher.runSync("getNextOrderId", ctx);
Map<String, Object> resp = dispatcher.runSync("getNextOrderId", ctx);
if (ServiceUtil.isError(resp)) {
Debug.logError(ServiceUtil.getErrorMessage(resp), MODULE);
return;
@@ -61,10 +61,10 @@ public class OrderTest extends OFBizTestCase {
}
public void testCompleteGetNextOrderSeqId() throws Exception {
Map <String, Object> ctx = new HashMap<>();
Map<String, Object> ctx = new HashMap<>();
ctx.put("partyId", "Company"); //party with AcctgPref prefix : CO
ctx.put("productStoreId", "9000"); // prefix WS
Map <String, Object> resp = dispatcher.runSync("getNextOrderId", ctx);
Map<String, Object> resp = dispatcher.runSync("getNextOrderId", ctx);
if (ServiceUtil.isError(resp)) {
Debug.logError(ServiceUtil.getErrorMessage(resp), MODULE);
return;
@@ -977,19 +977,19 @@ public class CommunicationEventServices {
if (ServiceUtil.isError(result)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
}
partyIdTo = (String)result.get("partyId");
contactMechIdTo = (String)result.get("contactMechId");
partyIdTo = (String) result.get("partyId");
contactMechIdTo = (String) result.get("contactMechId");
}
if (userLogin.get("partyId") == null && partyIdTo != null) {
int ch = 0;
for (ch=partyIdTo.length(); ch > 0 && Character.isDigit(partyIdTo.charAt(ch-1)); ch--) {}
for (ch = partyIdTo.length(); ch > 0 && Character.isDigit(partyIdTo.charAt(ch - 1)); ch--) { }
userLogin.put("partyId", partyIdTo.substring(0, ch)); //allow services to be called to have prefix
}
// get the 'from' partyId
result = getParyInfoFromEmailAddress(addressesFrom, userLogin, dispatcher);
partyIdFrom = (String)result.get("partyId");
contactMechIdFrom = (String)result.get("contactMechId");
partyIdFrom = (String) result.get("partyId");
contactMechIdFrom = (String) result.get("contactMechId");
Map<String, Object> commEventMap = new HashMap<>();
commEventMap.put("communicationEventTypeId", "AUTO_EMAIL_COMM");
@@ -1017,7 +1017,7 @@ public class CommunicationEventServices {
// select the plain text bodypart
String messageBody = null;
if (wrapper.getMainPartCount() > 1) {
for (int ind=0; ind < wrapper.getMainPartCount(); ind++) {
for (int ind = 0; ind < wrapper.getMainPartCount(); ind++) {
BodyPart p = wrapper.getPart(ind + "");
if (p.getContentType().toLowerCase(Locale.getDefault()).indexOf("text/plain") > -1) {
messageBody = (String) p.getContent();
@@ -1062,21 +1062,21 @@ public class CommunicationEventServices {
commEventMap.put("partyIdFrom", partyIdFrom);
commEventMap.put("contactMechIdFrom", contactMechIdFrom);
} else {
commNote += "Sent from: " + ((InternetAddress)addressesFrom[0]).getAddress() + "; ";
commNote += "Sent Name from: " + ((InternetAddress)addressesFrom[0]).getPersonal() + "; ";
commNote += "Sent from: " + ((InternetAddress) addressesFrom[0]).getAddress() + "; ";
commNote += "Sent Name from: " + ((InternetAddress) addressesFrom[0]).getPersonal() + "; ";
}
if (partyIdTo != null) {
commEventMap.put("partyIdTo", partyIdTo);
commEventMap.put("contactMechIdTo", contactMechIdTo);
} else {
commNote += "Sent to: " + ((InternetAddress)addressesTo[0]).getAddress() + "; ";
commNote += "Sent to: " + ((InternetAddress) addressesTo[0]).getAddress() + "; ";
if (deliveredTo != null) {
commNote += "Delivered-To: " + deliveredTo + "; ";
}
}
commNote += "Sent to: " + ((InternetAddress)addressesTo[0]).getAddress() + "; ";
commNote += "Sent to: " + ((InternetAddress) addressesTo[0]).getAddress() + "; ";
commNote += "Delivered-To: " + deliveredTo + "; ";
if (partyIdTo != null && partyIdFrom != null) {
@@ -1222,7 +1222,7 @@ public class CommunicationEventServices {
attachmentMap.put("mimeTypeId", "text/html");
attachmentMap.put("userLogin", userLogin);
if (subject != null && subject.length() > 80) {
subject = subject.substring(0,80); // make sure not too big for database field. (20 characters for filename)
subject = subject.substring(0, 80); // make sure not too big for database field. (20 characters for filename)
}
String attContentType = wrapper.getPartContentType(attachmentIdx);
@@ -1321,7 +1321,7 @@ public class CommunicationEventServices {
if (addresses.length > 0) {
Address addr = addresses[0];
if (addr instanceof InternetAddress) {
emailAddress = (InternetAddress)addr;
emailAddress = (InternetAddress) addr;
}
}
@@ -1343,7 +1343,7 @@ public class CommunicationEventServices {
/*
* Calls findPartyFromEmailAddress service and returns a List of the results for the array of addresses
*/
private static List<Map<String, Object>> buildListOfPartyInfoFromEmailAddresses(Address [] addresses, GenericValue userLogin, LocalDispatcher dispatcher) throws GenericServiceException {
private static List<Map<String, Object>> buildListOfPartyInfoFromEmailAddresses(Address[] addresses, GenericValue userLogin, LocalDispatcher dispatcher) throws GenericServiceException {
InternetAddress emailAddress = null;
Map<String, Object> result = null;
List<Map<String, Object>> tempResults = new LinkedList<>();
@@ -1351,7 +1351,7 @@ public class CommunicationEventServices {
if (addresses != null) {
for (Address addr: addresses) {
if (addr instanceof InternetAddress) {
emailAddress = (InternetAddress)addr;
emailAddress = (InternetAddress) addr;
result = dispatcher.runSync("findPartyFromEmailAddress",
UtilMisc.toMap("address", emailAddress.getAddress(), "userLogin", userLogin));
@@ -1372,7 +1372,7 @@ public class CommunicationEventServices {
/*
* Gets WorkEffort info from e-mail address and returns a List of the results for the array of addresses
*/
private static List<Map<String, Object>> buildListOfWorkEffortInfoFromEmailAddresses(Address [] addresses, GenericValue userLogin, LocalDispatcher dispatcher) throws GenericServiceException {
private static List<Map<String, Object>> buildListOfWorkEffortInfoFromEmailAddresses(Address[] addresses, GenericValue userLogin, LocalDispatcher dispatcher) throws GenericServiceException {
InternetAddress emailAddress = null;
Map<String, Object> result = null;
Delegator delegator = dispatcher.getDelegator();
@@ -1382,7 +1382,7 @@ public class CommunicationEventServices {
if (addresses != null) {
for (Address addr: addresses) {
if (addr instanceof InternetAddress) {
emailAddress = (InternetAddress)addr;
emailAddress = (InternetAddress) addr;
Map<String, String> inputFields = new HashMap<>();
inputFields.put("infoString", emailAddress.getAddress());
inputFields.put("infoString_ic", caseInsensitiveEmail);
@@ -36,7 +36,7 @@ public class ContactHelper {
private static final String MODULE = ContactHelper.class.getName();
private ContactHelper() {}
private ContactHelper() { }
public static Collection<GenericValue> getContactMech(GenericValue party, boolean includeOld) {
return getContactMech(party, null, null, includeOld);
@@ -883,7 +883,7 @@ public class ContactMechServices {
Map<String, Object> result = ServiceUtil.returnSuccess();
Delegator delegator = ctx.getDelegator();
GenericValue userLogin = (GenericValue) context.get("userLogin");
String partyId = (String)context.get("partyId");
String partyId = (String) context.get("partyId");
Locale locale = (Locale) context.get("locale");
if (UtilValidate.isEmpty(partyId)) {
if (userLogin != null) {
@@ -893,9 +893,9 @@ public class ContactMechServices {
"PartyCannotGetPartyContactMech", locale));
}
}
Boolean bShowOld = (Boolean)context.get("showOld");
Boolean bShowOld = (Boolean) context.get("showOld");
boolean showOld = (bShowOld != null && bShowOld) ? true : false;
String contactMechTypeId = (String)context.get("contactMechTypeId");
String contactMechTypeId = (String) context.get("contactMechTypeId");
List<Map<String, Object>> valueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, partyId, showOld, contactMechTypeId);
result.put("valueMaps", valueMaps);
return result;
@@ -57,7 +57,7 @@ public class ContactMechWorker {
private static final String MODULE = ContactMechWorker.class.getName();
private ContactMechWorker() {}
private ContactMechWorker() { }
/**
* Check the contactMechTypeId value on toAnalyzeFields map and if is a PostalAddress, a TelecomNumber or FtpAddress
@@ -34,7 +34,7 @@ public class PartyHelper {
private static final String MODULE = PartyHelper.class.getName();
private PartyHelper() {}
private PartyHelper() { }
public static String getPartyName(GenericValue partyObject) {
return getPartyName(partyObject, false);
@@ -41,7 +41,7 @@ import org.apache.ofbiz.entity.util.EntityQuery;
public final class PartyRelationshipHelper {
private static final String MODULE = PartyRelationshipHelper.class.getName();
private PartyRelationshipHelper() {}
private PartyRelationshipHelper() { }
/** Return A List of the active Party Relationships (ie with valid from and thru dates)
*@param delegator needed Delegator
@@ -49,11 +49,11 @@ public final class PartyRelationshipHelper {
*@return List of the active Party Relationships
*/
public static List<GenericValue> getActivePartyRelationships(Delegator delegator, Map<String, ?> partyRelationshipValues) {
String partyIdFrom = (String) partyRelationshipValues.get("partyIdFrom") ;
String partyIdTo = (String) partyRelationshipValues.get("partyIdTo") ;
String roleTypeIdFrom = (String) partyRelationshipValues.get("roleTypeIdFrom") ;
String roleTypeIdTo = (String) partyRelationshipValues.get("roleTypeIdTo") ;
String partyRelationshipTypeId = (String) partyRelationshipValues.get("partyRelationshipTypeId") ;
String partyIdFrom = (String) partyRelationshipValues.get("partyIdFrom");
String partyIdTo = (String) partyRelationshipValues.get("partyIdTo");
String roleTypeIdFrom = (String) partyRelationshipValues.get("roleTypeIdFrom");
String roleTypeIdTo = (String) partyRelationshipValues.get("roleTypeIdTo");
String partyRelationshipTypeId = (String) partyRelationshipValues.get("partyRelationshipTypeId");
Timestamp fromDate = UtilDateTime.nowTimestamp();
List<EntityCondition> condList = new LinkedList<>();
@@ -117,12 +117,12 @@ public class PartyRelationshipServices {
try {
List<GenericValue> partyRelationShipList = PartyRelationshipHelper.getActivePartyRelationships(delegator, context);
if (UtilValidate.isEmpty(partyRelationShipList)) { // If already exists and active nothing to do: keep the current one
String partyId = (String) context.get("partyId") ;
String partyIdFrom = (String) context.get("partyIdFrom") ;
String partyIdTo = (String) context.get("partyIdTo") ;
String roleTypeIdFrom = (String) context.get("roleTypeIdFrom") ;
String roleTypeIdTo = (String) context.get("roleTypeIdTo") ;
String partyRelationshipTypeId = (String) context.get("partyRelationshipTypeId") ;
String partyId = (String) context.get("partyId");
String partyIdFrom = (String) context.get("partyIdFrom");
String partyIdTo = (String) context.get("partyIdTo");
String roleTypeIdFrom = (String) context.get("roleTypeIdFrom");
String roleTypeIdTo = (String) context.get("roleTypeIdTo");
String partyRelationshipTypeId = (String) context.get("partyRelationshipTypeId");
// Before creating the partyRelationShip, create the partyRoles if they don't exist
GenericValue partyToRole = null;
@@ -1463,7 +1463,7 @@ public class PartyServices {
Debug.logInfo("In findParty mainCond=" + mainCond, MODULE);
String sortField = (String) context.get("sortField");
if (UtilValidate.isNotEmpty(sortField)){
if (UtilValidate.isNotEmpty(sortField)) {
orderBy.add(sortField);
}
@@ -1548,7 +1548,7 @@ public class PartyServices {
List<String> orderBy = new ArrayList<>();
String sortField = (String) context.get("sortField");
if (UtilValidate.isNotEmpty(sortField)){
if (UtilValidate.isNotEmpty(sortField)) {
orderBy.add(sortField);
}
List<String> fieldsToSelect = new ArrayList<>();
@@ -33,7 +33,7 @@ public final class PartyTypeHelper {
private static final String MODULE = PartyTypeHelper.class.getName();
private PartyTypeHelper () {}
private PartyTypeHelper() { }
/** Check if a related party is of the right party type (PERSON or PARTY_GROUP)
*@param delegator needed Delegator
@@ -52,7 +52,7 @@ public class PartyWorker {
private static final String MODULE = PartyWorker.class.getName();
private PartyWorker() {}
private PartyWorker() { }
public static Map<String, GenericValue> getPartyOtherValues(ServletRequest request, String partyId, String partyAttr, String personAttr, String partyGroupAttr) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
@@ -48,7 +48,7 @@ public final class CatalogWorker {
private static final String MODULE = CatalogWorker.class.getName();
private CatalogWorker () {}
private CatalogWorker() { }
/**
@@ -440,7 +440,7 @@ public class CategoryServices {
// Please note : the structure of map in this function is according to the JSON data map of the jsTree
@SuppressWarnings("unchecked")
public static String getChildCategoryTree(HttpServletRequest request, HttpServletResponse response){
public static String getChildCategoryTree(HttpServletRequest request, HttpServletResponse response) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
String productCategoryId = request.getParameter("productCategoryId");
String isCatalog = request.getParameter("isCatalog");
@@ -471,7 +471,7 @@ public class CategoryServices {
CategoryWorker.getRelatedCategories(request, "ChildCatalogList", CatalogWorker.getCatalogTopCategoryId(request, productCategoryId), true);
childOfCats = EntityUtil.filterByDate((List<GenericValue>) request.getAttribute("ChildCatalogList"));
} else if ("false".equals(isCatalog) && "false".equals(isCategoryType)){
} else if ("false".equals(isCatalog) && "false".equals(isCategoryType)) {
childOfCats = EntityQuery.use(delegator).from("ProductCategoryRollupAndChild").where("parentProductCategoryId", productCategoryId).filterByDate().queryList();
} else {
childOfCats = EntityQuery.use(delegator).from("ProdCatalogCategory").where("prodCatalogId", productCategoryId).filterByDate().queryList();
@@ -53,7 +53,7 @@ public final class CategoryWorker {
private static final String MODULE = CategoryWorker.class.getName();
private CategoryWorker () {}
private CategoryWorker() { }
public static String getCatalogTopCategory(ServletRequest request, String defaultTopCategory) {
HttpServletRequest httpRequest = (HttpServletRequest) request;
@@ -94,7 +94,7 @@ public final class SeoConfigUtil {
private static final String DEFAULT_CATEGORY_NAME_VALUE = "disable";
private static final String ALLOWED_CONTEXT_PATHS_SEPERATOR = ":";
private SeoConfigUtil() {}
private SeoConfigUtil() { }
/**
* Initialize url regular express configuration.
@@ -22,7 +22,7 @@ import org.apache.ofbiz.base.util.UtilValidate;
public final class SeoUrlUtil {
private SeoUrlUtil() {}
private SeoUrlUtil() { }
public static String replaceSpecialCharsUrl(String url) {
if (UtilValidate.isEmpty(url)) {
@@ -120,7 +120,7 @@ public class OfbizCatalogAltUrlTransform implements TemplateTransformModel {
url = CatalogUrlFilter.makeCategoryUrl(request, previousCategoryId, productCategoryId, productId, viewSize, viewIndex, viewSort, searchString);
}
// make the link
if (fullPath){
if (fullPath) {
OfbizUrlBuilder builder = OfbizUrlBuilder.from(request);
builder.buildHostPart(newURL, url, secure);
}
@@ -50,7 +50,7 @@ public final class ProductConfigWorker {
private static final String MODULE = ProductConfigWorker.class.getName();
private static final String SEPARATOR = "::"; // cache key separator
private ProductConfigWorker () {}
private ProductConfigWorker() { }
private static final UtilCache<String, ProductConfigWrapper> productConfigCache = UtilCache.createUtilCache("product.config", true); // use soft reference to free up memory if needed
@@ -315,7 +315,7 @@ public class ScaleImage {
filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf('/') + 1); // adding 1 to include the trailing slash
}
if (context.get("contentId") != null){
if (context.get("contentId") != null) {
resultBufImgMap.putAll(ImageTransform.getBufferedImage(imageServerPath + "/" + context.get("productId") + "/" + context.get("clientFileName"), locale));
} else {
/* get original BUFFERED IMAGE */
@@ -223,8 +223,7 @@ public class FrameImage {
result = ServiceUtil.returnError(e.getMessage());
result.putAll(context);
}
}
else{
} else {
String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseSelectImage", locale);
Debug.logFatal(errMsg, MODULE);
result = ServiceUtil.returnError(errMsg);
@@ -418,8 +417,7 @@ public class FrameImage {
String mimeType = imageName.substring(imageName.lastIndexOf('.') + 1);
ImageIO.write(bufNewImg, mimeType, new File(imageServerPath + "/preview/" + "/previewImage.jpg"));
}
else{
} else {
String errMsg = "Please select Image.";
request.setAttribute("_EVENT_MESSAGE_", errMsg);
return "error";
@@ -34,7 +34,7 @@ import org.apache.ofbiz.entity.util.EntityUtil;
public final class ImageManagementHelper {
static String MODULE = ImageManagementHelper.class.getName();
private ImageManagementHelper() {}
private ImageManagementHelper() { }
public static String getInternalImageUrl(HttpServletRequest request, String productId) {
String internalImageUrl = null;
@@ -276,7 +276,7 @@ public class ImageManagementServices {
return result;
}
public static Map<String, Object> removeImageFileForImageManagement(DispatchContext dctx, Map<String, ? extends Object> context){
public static Map<String, Object> removeImageFileForImageManagement(DispatchContext dctx, Map<String, ? extends Object> context) {
String productId = (String) context.get("productId");
String contentId = (String) context.get("contentId");
String dataResourceName = (String) context.get("dataResourceName");
@@ -415,7 +415,7 @@ public class ImageManagementServices {
return ServiceUtil.returnError(errMsg);
}
public static Map<String, Object> createContentAndDataResource(DispatchContext dctx, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId, String fileContentType){
public static Map<String, Object> createContentAndDataResource(DispatchContext dctx, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId, String fileContentType) {
Map<String, Object> result = new HashMap<>();
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
@@ -492,7 +492,7 @@ public class ImageManagementServices {
return result;
}
public static Map<String, Object> createContentThumbnail(DispatchContext dctx, Map<String, ? extends Object> context, GenericValue userLogin, ByteBuffer imageData, String productId, String imageName){
public static Map<String, Object> createContentThumbnail(DispatchContext dctx, Map<String, ? extends Object> context, GenericValue userLogin, ByteBuffer imageData, String productId, String imageName) {
Map<String, Object> result = new HashMap<>();
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
@@ -73,7 +73,7 @@ public class ImageUrlServlet extends HttpServlet {
String lastTagElement = tagElements.get(tagElements.size() - 1);
String contentId = lastTagElement.substring(0, lastTagElement.lastIndexOf('.'));
String sizeTagElement = null;
if (tagElements.size() > 2){
if (tagElements.size() > 2) {
sizeTagElement = tagElements.get(tagElements.size() - 2);
}
@@ -42,7 +42,7 @@ import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;
public class ReplaceImage{
public class ReplaceImage {
private static final String MODULE = ReplaceImage.class.getName();
private static final String RES_ERROR = "ProductErrorUiLabels";
@@ -67,14 +67,12 @@ public class ReplaceImage{
Debug.logError(errMsg, MODULE);
return ServiceUtil.returnError(errMsg);
}
}
else{
} else {
String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseChooseImageToReplace", locale);
Debug.logError(errMsg, MODULE);
return ServiceUtil.returnError(errMsg);
}
}
else{
} else {
String errMsg = UtilProperties.getMessage(RES_ERROR, "ProductPleaseChooseReplacementImage", locale);
Debug.logError(errMsg, MODULE);
return ServiceUtil.returnError(errMsg);
@@ -98,8 +96,7 @@ public class ReplaceImage{
if (UtilValidate.isNotEmpty(dataResourceAssocExist)) {
BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName")));
ImageIO.write(bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceAssocExist.get("drDataResourceName")));
}
else{
} else {
BufferedImage bufImgAssocReplace = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceAssocReplace.get("drDataResourceName")));
ImageIO.write(bufImgAssocReplace, "jpg", new File(imageServerPath + "/" + productId + "/" + dataResourceNameExist.substring(0, dataResourceNameExist.length() - 4) + "-" + contentAssocReplace.get("mapKey") + ".jpg"));
}
@@ -678,8 +678,8 @@ public class InventoryServices {
public static Map<String, Object> getProductInventoryAvailableFromAssocProducts(DispatchContext dctx, Map<String, ? extends Object> context) {
LocalDispatcher dispatcher = dctx.getDispatcher();
List<GenericValue> productAssocList = UtilGenerics.cast(context.get("assocProducts"));
String facilityId = (String)context.get("facilityId");
String statusId = (String)context.get("statusId");
String facilityId = (String) context.get("facilityId");
String statusId = (String) context.get("statusId");
BigDecimal availableToPromiseTotal = BigDecimal.ZERO;
BigDecimal quantityOnHandTotal = BigDecimal.ZERO;
@@ -852,11 +852,11 @@ public class InventoryServices {
public static Map<String, Object> getProductInventoryAndFacilitySummary(DispatchContext dctx, Map<String, ? extends Object> context) {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Timestamp checkTime = (Timestamp)context.get("checkTime");
String facilityId = (String)context.get("facilityId");
String productId = (String)context.get("productId");
BigDecimal minimumStock = (BigDecimal)context.get("minimumStock");
String statusId = (String)context.get("statusId");
Timestamp checkTime = (Timestamp) context.get("checkTime");
String facilityId = (String) context.get("facilityId");
String productId = (String) context.get("productId");
BigDecimal minimumStock = (BigDecimal) context.get("minimumStock");
String statusId = (String) context.get("statusId");
Map<String, Object> result = new HashMap<>();
Map<String, Object> resultOutput = new HashMap<>();
@@ -41,7 +41,7 @@ public final class InventoryWorker {
public final static String MODULE = InventoryWorker.class.getName();
private InventoryWorker () {}
private InventoryWorker() { }
/**
* Finds all outstanding Purchase orders for a productId. The orders and the items cannot be completed, cancelled, or rejected
@@ -1184,7 +1184,7 @@ public class PriceServices {
return false;
}
private static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) throws GenericEntityException{
private static int checkConditionPartyHierarchy(Delegator delegator, Timestamp nowTimestamp, String groupPartyId, String partyId) throws GenericEntityException {
List<GenericValue> partyRelationshipList = EntityQuery.use(delegator).from("PartyRelationship").where("partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP").cache(true).filterByDate(nowTimestamp).queryList();
for (GenericValue genericValue : partyRelationshipList) {
String partyIdFrom = (String)genericValue.get("partyIdFrom");
@@ -1213,10 +1213,10 @@ public class PriceServices {
GenericValue product = (GenericValue)context.get("product");
String productId = product.getString("productId");
String agreementId = (String)context.get("agreementId");
String currencyUomId = (String)context.get("currencyUomId");
String partyId = (String)context.get("partyId");
BigDecimal quantity = (BigDecimal)context.get("quantity");
String agreementId = (String) context.get("agreementId");
String currencyUomId = (String) context.get("currencyUomId");
String partyId = (String) context.get("partyId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
Locale locale = (Locale)context.get("locale");
// a) Get the Price from the Agreement* data model
@@ -78,7 +78,7 @@ public class ProductSearchEvents {
GenericValue searchResultView = null;
while ((searchResultView = eli.next()) != null) {
String productId = searchResultView.getString("mainProductId");
numRemoved += delegator.removeByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId)) ;
numRemoved += delegator.removeByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId));
}
Map<String, String> messageMap = UtilMisc.toMap("numRemoved", Integer.toString(numRemoved));
errMsg = UtilProperties.getMessage(RESOURCE,"productsearchevents.removed_x_items", messageMap, UtilHttp.getLocale(request));
@@ -306,7 +306,7 @@ public class ProductSearchSession {
for (ProductSearchConstraint productSearchConstraint: productSearchConstraintList) {
if (productSearchConstraint == null) {
continue;
}
}
String constraintString = productSearchConstraint.prettyPrintConstraint(dispatcher, detailed, locale);
if (UtilValidate.isNotEmpty(constraintString)) {
constraintStrings.add(constraintString);
@@ -892,7 +892,7 @@ public class ProductSearchSession {
List<String> keywordTypeIds = new LinkedList<>();
if (requestParams.get("keywordTypeId") instanceof String) {
keywordTypeIds.add((String) requestParams.get("keywordTypeId"));
} else if (requestParams.get("keywordTypeId") instanceof List){
} else if (requestParams.get("keywordTypeId") instanceof List) {
keywordTypeIds = (List<String>) requestParams.get("keywordTypeId");
}
String statusId = (String) requestParams.get("statusId");
@@ -1107,7 +1107,7 @@ public class ProductServices {
return result;
}
}
} catch(GenericEntityException e) {
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
}
@@ -61,7 +61,7 @@ public final class ProductUtilServices {
private static final String RESOURCE = "ProductUiLabels";
private static final String RES_ERROR = "ProductErrorUiLabels";
private ProductUtilServices () {}
private ProductUtilServices() { }
/** First expire all ProductAssocs for all disc variants, then disc all virtuals that have all expired variant ProductAssocs */
public static Map<String, Object> discVirtualsWithDiscVariants(DispatchContext dctx, Map<String, ? extends Object> context) {
@@ -59,7 +59,7 @@ public final class ProductWorker {
private static final MathContext generalRounding = new MathContext(10);
private ProductWorker () {}
private ProductWorker() { }
public static boolean shippingApplies(GenericValue product) {
String errMsg = "";
@@ -1151,7 +1151,7 @@ nextProd:
public static boolean isAlternativePacking(Delegator delegator, String productId, String virtualVariantId) {
boolean isAlternativePacking = false;
if (productId != null || virtualVariantId != null){
if (productId != null || virtualVariantId != null) {
List<GenericValue> alternativePackingProds = null;
try {
List<EntityCondition> condList = new LinkedList<>();
@@ -1174,7 +1174,7 @@ nextProd:
return isAlternativePacking;
}
public static String getOriginalProductId(Delegator delegator, String productId){
public static String getOriginalProductId(Delegator delegator, String productId) {
boolean isAlternativePacking = isAlternativePacking(delegator, null, productId);
if (isAlternativePacking) {
List<GenericValue> productAssocs = null;
@@ -1201,15 +1201,15 @@ nextProd:
* @return true if it can be ordered by decimal quantity
* @throws GenericEntityException to catch
*/
public static Boolean isDecimalQuantityOrderAllowed(Delegator delegator, String productId, String productStoreId) throws GenericEntityException{
public static Boolean isDecimalQuantityOrderAllowed(Delegator delegator, String productId, String productStoreId) throws GenericEntityException {
//sometime productStoreId may be null (ie PO), then return default value which is TRUE
if (UtilValidate.isEmpty(productStoreId)){
if (UtilValidate.isEmpty(productStoreId)) {
return Boolean.TRUE;
}
String allowDecimalStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).cache(true).queryOne().getString("orderDecimalQuantity");
String allowDecimalProduct = EntityQuery.use(delegator).from("Product").where("productId", productId).cache(true).queryOne().getString("orderDecimalQuantity");
if ("N".equals(allowDecimalProduct) || (UtilValidate.isEmpty(allowDecimalProduct) && "N".equals(allowDecimalStore))){
if ("N".equals(allowDecimalProduct) || (UtilValidate.isEmpty(allowDecimalProduct) && "N".equals(allowDecimalStore))) {
return Boolean.FALSE;
}
return Boolean.TRUE;
@@ -32,7 +32,7 @@ import org.apache.ofbiz.entity.util.EntityQuery;
public final class ImportProductHelper {
private static final String MODULE = ImportProductHelper.class.getName();
private ImportProductHelper() {}
private ImportProductHelper() { }
// prepare the product map
public static Map<String, Object> prepareProduct(String productId) {
@@ -39,7 +39,7 @@ public class ProductStoreEvents {
private static final String MODULE = ProductStoreWorker.class.getName();
// Please note : the structure of map in this function is according to the JSON data map of the jsTree
public static String getChildProductStoreGroupTree(HttpServletRequest request, HttpServletResponse response){
public static String getChildProductStoreGroupTree(HttpServletRequest request, HttpServletResponse response) {
Delegator delegator = (Delegator) request.getAttribute("delegator");
String parentGroupId = request.getParameter("parentGroupId");
String onclickFunction = request.getParameter("onclickFunction");
@@ -37,7 +37,7 @@ public class ProductStoreSurveyWrapper extends SurveyWrapper {
protected String resultTemplate = null;
protected boolean callResult = false;
protected ProductStoreSurveyWrapper() {}
protected ProductStoreSurveyWrapper() { }
public ProductStoreSurveyWrapper(GenericValue productStoreSurveyAppl, String partyId, Map<String, Object> passThru, Map<String, Object> defaultValues) {
this.productStoreSurveyAppl = productStoreSurveyAppl;
@@ -81,7 +81,7 @@ public final class ProductStoreWorker {
defaultProductStoreEmailScreenLocation.put("PRDS_CUST_REGISTER", "component://securityext/widget/EmailSecurityScreens.xml#PasswordEmail");
}
private ProductStoreWorker() {}
private ProductStoreWorker() { }
public static GenericValue getProductStore(String productStoreId, Delegator delegator) {
if (productStoreId == null || delegator == null) {
@@ -182,7 +182,7 @@ public class SubscriptionServices {
return result;
}
public static Map<String, Object> processExtendSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> processExtendSubscriptionByProduct(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
String productId = (String) context.get("productId");
@@ -244,7 +244,7 @@ public class SubscriptionServices {
return ServiceUtil.returnSuccess();
}
public static Map<String, Object> processExtendSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
public static Map<String, Object> processExtendSubscriptionByOrder(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException {
Delegator delegator = dctx.getDelegator();
LocalDispatcher dispatcher = dctx.getDispatcher();
Map<String, Object> subContext = UtilMisc.makeMapWritable(context);
@@ -69,7 +69,7 @@ public class ShipmentServices {
Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
List<GenericValue> storeAll = new LinkedList<>();
String productStoreShipMethId = (String)context.get("productStoreShipMethId");
String productStoreShipMethId = (String) context.get("productStoreShipMethId");
GenericValue productStoreShipMeth = null;
try {
@@ -594,7 +594,7 @@ public class ShipmentServices {
List<GenericValue> packages = null;
try {
packages = shipment.getRelated("ShipmentPackage", null, null, false) ;
packages = shipment.getRelated("ShipmentPackage", null, null, false);
} catch (GenericEntityException e) {
Debug.logError(e, MODULE);
return ServiceUtil.returnError(e.getMessage());
@@ -998,7 +998,7 @@ public class ShipmentServices {
// Get the value of the orderItem by calling the getOrderItemInvoicedAmountAndQuantity service
Map<String, Object> getOrderItemValueResult = dispatcher.runSync("getOrderItemInvoicedAmountAndQuantity", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId, "userLogin", userLogin, "locale", locale));
if (ServiceUtil.isError(getOrderItemValueResult)){
if (ServiceUtil.isError(getOrderItemValueResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(getOrderItemValueResult));
}
BigDecimal invoicedAmount = (BigDecimal) getOrderItemValueResult.get("invoicedAmount");
@@ -1045,7 +1045,7 @@ public class ShipmentServices {
// prepare the shipment information
Map<String, Object> sendMap = new HashMap<>();
GenericValue shipment = null ;
GenericValue shipment = null;
GenericValue orderHeader = null;
try {
shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne();
@@ -47,7 +47,7 @@ public final class ShipmentWorker {
private static final String MODULE = ShipmentWorker.class.getName();
private static final MathContext generalRounding = new MathContext(10);
private ShipmentWorker() {}
private ShipmentWorker() { }
/*
* Returns the value of a given ShipmentPackageContent record. Calculated by working out the total value (from the OrderItems) of all ItemIssuances
@@ -1877,7 +1877,7 @@ public class UpsServices {
String shippingCountryCode = (String) context.get("shippingCountryCode");
List<BigDecimal> packageWeights = UtilGenerics.cast(context.get("packageWeights"));
List<Map<String, Object>> shippableItemInfo = UtilGenerics.cast(context.get("shippableItemInfo"));
String isResidentialAddress = (String)context.get("isResidentialAddress");
String isResidentialAddress = (String) context.get("isResidentialAddress");
// Important: DO NOT returnError here or you could trigger a transaction rollback and break other services.
if (UtilValidate.isEmpty(shippingPostalCode)) {

Some files were not shown because too many files have changed in this diff Show More