Improved: General refactoring and code improvements, package
org.apache.ofbiz.product.promo.
Thanks Dennis Balkir for reporting and providing the patches.
@@ -131,7 +131,7 @@ public class PromoServices {
Locale locale = (Locale) context.get("locale");
Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
- List<EntityCondition> condList = new LinkedList<EntityCondition>();
+ List<EntityCondition> condList = new LinkedList<>();
if (UtilValidate.isEmpty(productStoreId)) {
condList.add(EntityCondition.makeCondition("productStoreId", EntityOperator.EQUALS, productStoreId));
}
@@ -182,7 +182,7 @@ public class PromoServices {
// read the bytes into a reader
BufferedReader reader = new BufferedReader(new StringReader(file));
- List<Object> errors = new LinkedList<Object>();
+ List<Object> errors = new LinkedList<>();
int lines = 0;
String line;
@@ -193,7 +193,7 @@ public class PromoServices {
if (line.length() > 0 && !line.startsWith("#")) {
if (line.length() <= 20) {
// valid promo code
- Map<String, Object> inContext = new HashMap<String, Object>();
+ Map<String, Object> inContext = new HashMap<>();
inContext.putAll(invokeCtx);
inContext.put("productPromoCodeId", line);
Map<String, Object> result = dispatcher.runSync("createProductPromoCode", inContext);
@@ -207,10 +207,7 @@ public class PromoServices {
++lines;
}
}
- } catch (IOException e) {
- Debug.logError(e, module);
- return ServiceUtil.returnError(e.getMessage());
- } catch (GenericServiceException e) {
+ } catch (IOException | GenericServiceException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
} finally {
@@ -248,7 +245,7 @@ public class PromoServices {
// read the bytes into a reader
BufferedReader reader = new BufferedReader(new StringReader(new String(wrapper, UtilIO.getUtf8())));
- List<Object> errors = new LinkedList<Object>();
+ List<Object> errors = new LinkedList<>();
int lines = 0;
String line;
@@ -270,10 +267,7 @@ public class PromoServices {
++lines;
}
}
- } catch (IOException e) {
- Debug.logError(e, module);
- return ServiceUtil.returnError(e.getMessage());
- } catch (GenericServiceException e) {
+ } catch (IOException | GenericServiceException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
} finally {
