Improved: General refactoring and code improvements, package
org.apache.ofbiz.product.subscription.
Thanks Julian Leichert for reporting and providing the patch.
@@ -76,7 +76,9 @@ public class SubscriptionServices {
try {
Map<String, String> subscriptionFindMap = UtilMisc.toMap("partyId", partyId, "subscriptionResourceId", subscriptionResourceId);
// if this subscription is attached to something the customer owns, filter by that too
- if (UtilValidate.isNotEmpty(inventoryItemId)) subscriptionFindMap.put("inventoryItemId", inventoryItemId);
+ if (UtilValidate.isNotEmpty(inventoryItemId)) {
+ subscriptionFindMap.put("inventoryItemId", inventoryItemId);
+ }
List<GenericValue> subscriptionList = EntityQuery.use(delegator).from("Subscription").where(subscriptionFindMap).queryList();
// DEJ20070718 DON'T filter by date, we want to consider all subscriptions: List listFiltered = EntityUtil.filterByDate(subscriptionList, true);
List<GenericValue> listOrdered = EntityUtil.orderBy(subscriptionList, UtilMisc.toList("-fromDate"));
@@ -149,7 +151,7 @@ public class SubscriptionServices {
null, null, updateSubscriptionResult);
}
} else {
- Map<String, Object> ensurePartyRoleMap = new HashMap<String, Object>();
+ Map<String, Object> ensurePartyRoleMap = new HashMap<>();
if (UtilValidate.isNotEmpty(roleTypeId)) {
ensurePartyRoleMap.put("partyId", partyId);
ensurePartyRoleMap.put("roleTypeId", roleTypeId);
@@ -174,9 +176,7 @@ public class SubscriptionServices {
}
result.put("subscriptionId", createSubscriptionResult.get("subscriptionId"));
}
- } catch (GenericEntityException e) {
- return ServiceUtil.returnError(e.toString());
- } catch (GenericServiceException e) {
+ } catch (GenericEntityException | GenericServiceException e) {
return ServiceUtil.returnError(e.toString());
}
return result;
@@ -310,8 +310,8 @@ public class SubscriptionServices {
Delegator delegator = dctx.getDelegator();
Locale locale =(Locale)context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
- Map<String, Object> result = new HashMap<String, Object>();
- Map<String, Object> expiryMap = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
+ Map<String, Object> expiryMap = new HashMap<>();
String gracePeriodOnExpiry = null;
String gracePeriodOnExpiryUomId = null;
String subscriptionId = null;
@@ -397,7 +397,7 @@ public class SubscriptionServices {
DispatchContext dctx, Map<String, ? extends Object> context) {
Locale locale = (Locale)context.get("locale");
String subscriptionId = (String) context.get("subscriptionId");
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
if (subscriptionId != null) {
return ServiceUtil.returnSuccess(UtilProperties.getMessage(resource, "ProductRunSubscriptionExpiredServiceCalledSuccessfully", locale));
}
