Skip to content

Commit 83fd206

Browse files
committed
Improved: Inline ‘UtilGenerics#checkMap’
(OFBIZ-11141) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863500 13f79535-47bb-0310-9956-ffa450edef68
1 parent 17da80d commit 83fd206

File tree

79 files changed

+207
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+207
-211
lines changed

applications/accounting/src/main/java/org/apache/ofbiz/accounting/ledger/GeneralLedgerServices.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static Map<String, Object> createUpdateCostCenter(DispatchContext dctx, M
4040
Map<String, Object> createGlAcctCatMemFromCostCentersMap = null;
4141
String glAccountId = (String) context.get("glAccountId");
4242
GenericValue userLogin = (GenericValue) context.get("userLogin");
43-
Map<String, String> amountPercentageMap = UtilGenerics.checkMap(context.get("amountPercentageMap"));
43+
Map<String, String> amountPercentageMap = UtilGenerics.cast(context.get("amountPercentageMap"));
4444
BigDecimal totalAmountPercentage = GeneralLedgerServices.calculateCostCenterTotal(amountPercentageMap);
4545
Map<String, Object> result = ServiceUtil.returnSuccess();
4646
for (Map.Entry<String, String> rowEntry : amountPercentageMap.entrySet()) {

applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/clearcommerce/CCPaymentServices.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ private static Document buildPrimaryTxRequest(Map<String, Object> context, Strin
706706

707707
// TODO: determine if adding OrderItemList is worthwhile - JFE 2004.02.14
708708

709-
Map<String, Object> pbOrder = UtilGenerics.checkMap(context.get("pbOrder"));
709+
Map<String, Object> pbOrder = UtilGenerics.cast(context.get("pbOrder"));
710710
if (pbOrder != null) {
711711
if (Debug.verboseOn()) {
712712
Debug.logVerbose("pbOrder Map not empty:" + pbOrder.toString(), module);

applications/content/src/main/java/org/apache/ofbiz/content/ContentManagementWorker.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static void mruAdd(HttpSession session, GenericEntity pk) {
8181
return;
8282
}
8383

84-
Map<String, LifoSet<Object>> lookupCaches = UtilGenerics.checkMap(session.getAttribute("lookupCaches"));
84+
Map<String, LifoSet<Object>> lookupCaches = UtilGenerics.cast(session.getAttribute("lookupCaches"));
8585
if (lookupCaches == null) {
8686
lookupCaches = new HashMap<>();
8787
session.setAttribute("lookupCaches", lookupCaches);
@@ -154,7 +154,7 @@ public static void setCurrentEntityMap(HttpServletRequest request, GenericEntity
154154

155155
public static void setCurrentEntityMap(HttpServletRequest request, String entityName, GenericEntity ent) {
156156
HttpSession session = request.getSession();
157-
Map<String, GenericEntity> currentEntityMap = UtilGenerics.checkMap(session.getAttribute("currentEntityMap"));
157+
Map<String, GenericEntity> currentEntityMap = UtilGenerics.cast(session.getAttribute("currentEntityMap"));
158158
if (currentEntityMap == null) {
159159
currentEntityMap = new HashMap<>();
160160
session.setAttribute("currentEntityMap", currentEntityMap);
@@ -183,7 +183,7 @@ public static String getFromSomewhere(String name, Map<String, Object> paramMap,
183183

184184
public static void getCurrentValue(HttpServletRequest request, Delegator delegator) {
185185
HttpSession session = request.getSession();
186-
Map<String, GenericPK> currentEntityMap = UtilGenerics.checkMap(session.getAttribute("currentEntityMap"));
186+
Map<String, GenericPK> currentEntityMap = UtilGenerics.cast(session.getAttribute("currentEntityMap"));
187187
if (currentEntityMap == null) {
188188
currentEntityMap = new HashMap<>();
189189
session.setAttribute("currentEntityMap", currentEntityMap);

applications/content/src/main/java/org/apache/ofbiz/content/content/ContentServices.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static Map<String, Object> findContentParents(DispatchContext dctx, Map<S
145145
if (ServiceUtil.isError(thisResults)) {
146146
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResults));
147147
}
148-
Map<String, Object> nodeMap = UtilGenerics.checkMap(thisResults.get("nodeMap"));
148+
Map<String, Object> nodeMap = UtilGenerics.cast(thisResults.get("nodeMap"));
149149
walkParentTree(nodeMap, parentList);
150150
} catch (GenericServiceException e) {
151151
return ServiceUtil.returnFailure(e.getMessage());
@@ -385,7 +385,7 @@ public static Map<String, Object> renderSubContentAsText(DispatchContext dctx, M
385385
Map<String, Object> results = new HashMap<>();
386386
LocalDispatcher dispatcher = dctx.getDispatcher();
387387

388-
Map<String,Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
388+
Map<String,Object> templateContext = UtilGenerics.cast(context.get("templateContext"));
389389
String contentId = (String) context.get("contentId");
390390

391391
if (templateContext != null && UtilValidate.isEmpty(contentId)) {
@@ -436,7 +436,7 @@ public static Map<String, Object> renderContentAsText(DispatchContext dctx, Map<
436436
LocalDispatcher dispatcher = dctx.getDispatcher();
437437
Writer out = (Writer) context.get("outWriter");
438438

439-
Map<String,Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
439+
Map<String,Object> templateContext = UtilGenerics.cast(context.get("templateContext"));
440440
String contentId = (String) context.get("contentId");
441441
if (templateContext != null && UtilValidate.isEmpty(contentId)) {
442442
contentId = (String) templateContext.get("contentId");
@@ -558,7 +558,7 @@ public static Map<String, Object> publishContent(DispatchContext dctx, Map<Strin
558558

559559
public static Map<String, Object> getPrefixedMembers(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
560560
Map<String, Object> result = new HashMap<>();
561-
Map<String, Object> mapIn = UtilGenerics.checkMap(context.get("mapIn"));
561+
Map<String, Object> mapIn = UtilGenerics.cast(context.get("mapIn"));
562562
String prefix = (String)context.get("prefix");
563563
Map<String, Object> mapOut = new HashMap<>();
564564
result.put("mapOut", mapOut);
@@ -602,7 +602,7 @@ public static Map<String, Object> joinString(DispatchContext dctx, Map<String, ?
602602
public static Map<String, Object> urlEncodeArgs(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericServiceException{
603603
Map<String, Object> result = new HashMap<>();
604604
Map<String, Object> mapFiltered = new HashMap<>();
605-
Map<String, Object> mapIn = UtilGenerics.checkMap(context.get("mapIn"));
605+
Map<String, Object> mapIn = UtilGenerics.cast(context.get("mapIn"));
606606
if (mapIn != null) {
607607
Set<Map.Entry<String, Object>> entrySet = mapIn.entrySet();
608608
for (Map.Entry<String, Object> entry : entrySet) {

applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public static void renderContentAsText(LocalDispatcher dispatcher, GenericValue
201201
if (service != null) {
202202
//put all requestParameters into templateContext to use them as IN service parameters
203203
Map<String,Object> tempTemplateContext = new HashMap<>();
204-
tempTemplateContext.putAll(UtilGenerics.<String,Object>checkMap(templateContext.get("requestParameters")));
204+
tempTemplateContext.putAll(UtilGenerics.cast(templateContext.get("requestParameters")));
205205
tempTemplateContext.putAll(templateContext);
206206
Map<String,Object> serviceCtx = service.makeValid(tempTemplateContext, ModelService.IN_PARAM);
207207
Map<String,Object> serviceRes;
@@ -702,7 +702,7 @@ public static void selectKids(Map<String, Object> currentNode, Map<String, Objec
702702
String contentTypeId = (String) ctx.get("contentTypeId");
703703
String mapKey = (String) ctx.get("mapKey");
704704
String parentContentId = (String) parentContent.get("contentId");
705-
Map<String, Object> whenMap = UtilGenerics.checkMap(ctx.get("whenMap"));
705+
Map<String, Object> whenMap = UtilGenerics.cast(ctx.get("whenMap"));
706706
List<Map<String, Object>> kids = new LinkedList<>();
707707
currentNode.put("kids", kids);
708708
String direction = (String) ctx.get("direction");
@@ -1595,7 +1595,7 @@ public static StringBuilder logMap(StringBuilder s, String lbl, Map<String, Obje
15951595
indent.setLength(indent.length() - 1);
15961596
} else if (obj instanceof Map<?, ?>) {
15971597
indent.append(' ');
1598-
logMap(s, "MAP[" + key + "]", UtilGenerics.<String, Object>checkMap(obj), indent);
1598+
logMap(s, "MAP[" + key + "]", UtilGenerics.cast(obj), indent);
15991599
indent.setLength(indent.length() - 1);
16001600
} else if (obj != null) {
16011601
s.append(obj).append(sep).append(obj.getClass()).append(eol);
@@ -1639,7 +1639,7 @@ public static StringBuilder logList(StringBuilder s, String lbl, List<Object> ls
16391639
indent.setLength(indent.length() - 1);
16401640
} else if (obj instanceof Map<?, ?>) {
16411641
indent.append(' ');
1642-
logMap(s, "MAP[]", UtilGenerics.<String, Object>checkMap(obj), indent);
1642+
logMap(s, "MAP[]", UtilGenerics.cast(obj), indent);
16431643
indent.setLength(indent.length() - 1);
16441644
} else if (obj != null) {
16451645
s.append(obj).append(sep).append(obj.getClass()).append(eol);

applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ public static void renderDataResourceAsText(LocalDispatcher dispatcher, Delegato
793793
}
794794
} else if ("FORM_COMBINED".equals(dataTemplateTypeId)){
795795
try {
796-
Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("globalContext"));
796+
Map<String, Object> context = UtilGenerics.cast(templateContext.get("globalContext"));
797797
context.put("locale", locale);
798798
context.put("simpleEncoder", UtilCodec.getEncoder(modelTheme.getEncoder("screen")));
799799
HttpServletRequest request = (HttpServletRequest) context.get("request");
@@ -838,7 +838,7 @@ public static String getDataResourceText(GenericValue dataResource, String mimeT
838838

839839
public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map<String, Object> templateContext,
840840
Delegator delegator, Appendable out, boolean cache) throws IOException, GeneralException {
841-
Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("context"));
841+
Map<String, Object> context = UtilGenerics.cast(templateContext.get("context"));
842842
if (context == null) {
843843
context = new HashMap<>();
844844
}

applications/content/src/main/java/org/apache/ofbiz/content/data/DataServices.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public static Map<String, Object> renderDataResourceAsText(DispatchContext dctx,
469469
Map<String, Object> results = new HashMap<>();
470470
//LocalDispatcher dispatcher = dctx.getDispatcher();
471471
Writer out = (Writer) context.get("outWriter");
472-
Map<String, Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
472+
Map<String, Object> templateContext = UtilGenerics.cast(context.get("templateContext"));
473473
//GenericValue userLogin = (GenericValue) context.get("userLogin");
474474
String dataResourceId = (String) context.get("dataResourceId");
475475
if (templateContext != null && UtilValidate.isEmpty(dataResourceId)) {

applications/content/src/main/java/org/apache/ofbiz/content/layout/LayoutEvents.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static String createLayoutImage(HttpServletRequest request, HttpServletRe
6666
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
6767
HttpSession session = request.getSession();
6868
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
69-
Map<String, Object> formInput = UtilGenerics.checkMap(uploadResults.get("formInput"));
69+
Map<String, Object> formInput = UtilGenerics.cast(uploadResults.get("formInput"));
7070
Map<String, Object> context = new HashMap<>();
7171
ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData");
7272
if (byteWrap == null) {
@@ -177,7 +177,7 @@ public static String updateLayoutImage(HttpServletRequest request, HttpServletRe
177177
Delegator delegator = (Delegator) request.getAttribute("delegator");
178178
HttpSession session = request.getSession();
179179
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
180-
Map<String, Object> context = UtilGenerics.checkMap(uploadResults.get("formInput"));
180+
Map<String, Object> context = UtilGenerics.cast(uploadResults.get("formInput"));
181181
ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData");
182182
if (byteWrap == null) {
183183
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale);

applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static Map<String, Object> sendPrintFromScreen(DispatchContext dctx, Map<
9494
visualTheme = ThemeFactory.resolveVisualTheme(null);
9595
}
9696
String screenLocation = (String) serviceContext.remove("screenLocation");
97-
Map<String, Object> screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext"));
97+
Map<String, Object> screenContext = UtilGenerics.cast(serviceContext.remove("screenContext"));
9898
String contentType = (String) serviceContext.remove("contentType");
9999
String printerContentType = (String) serviceContext.remove("printerContentType");
100100

@@ -212,7 +212,7 @@ public static Map<String, Object> createFileFromScreen(DispatchContext dctx, Map
212212
visualTheme = ThemeFactory.resolveVisualTheme(null);
213213
}
214214
String screenLocation = (String) serviceContext.remove("screenLocation");
215-
Map<String, Object> screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext"));
215+
Map<String, Object> screenContext = UtilGenerics.cast(serviceContext.remove("screenContext"));
216216
String contentType = (String) serviceContext.remove("contentType");
217217
String filePath = (String) serviceContext.remove("filePath");
218218
String fileName = (String) serviceContext.remove("fileName");

applications/content/src/main/java/org/apache/ofbiz/content/survey/PdfSurveyServices.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static Map<String, Object> buildSurveyFromPdf(DispatchContext dctx, Map<S
8989
PdfReader pdfReader = new PdfReader(byteBuffer.array());
9090
PdfStamper pdfStamper = new PdfStamper(pdfReader, os);
9191
AcroFields acroFields = pdfStamper.getAcroFields();
92-
Map<String, Object> acroFieldMap = UtilGenerics.checkMap(acroFields.getFields());
92+
Map<String, Object> acroFieldMap = UtilGenerics.cast(acroFields.getFields());
9393

9494
String contentId = (String) context.get("contentId");
9595
GenericValue survey = null;
@@ -246,7 +246,7 @@ public static Map<String, Object> buildSurveyResponseFromPdf(DispatchContext dct
246246
PdfReader r = new PdfReader(byteBuffer.array());
247247
PdfStamper s = new PdfStamper(r,os);
248248
AcroFields fs = s.getAcroFields();
249-
Map<String, Object> hm = UtilGenerics.checkMap(fs.getFields());
249+
Map<String, Object> hm = UtilGenerics.cast(fs.getFields());
250250
s.setFormFlattening(true);
251251
for (String fieldName : hm.keySet()) {
252252
//AcroFields.Item item = fs.getFieldItem(fieldName);
@@ -291,7 +291,7 @@ public static Map<String, Object> getAcroFieldsFromPdf(DispatchContext dctx, Map
291291
PdfReader r = new PdfReader(byteBuffer.array());
292292
PdfStamper s = new PdfStamper(r,os);
293293
AcroFields fs = s.getAcroFields();
294-
Map<String, Object> map = UtilGenerics.checkMap(fs.getFields());
294+
Map<String, Object> map = UtilGenerics.cast(fs.getFields());
295295
s.setFormFlattening(true);
296296

297297
for (String fieldName : map.keySet()) {
@@ -315,13 +315,13 @@ public static Map<String, Object> setAcroFields(DispatchContext dctx, Map<String
315315
Map<String, Object> results = ServiceUtil.returnSuccess();
316316
Delegator delegator = dctx.getDelegator();
317317
try {
318-
Map<String, Object> acroFieldMap = UtilGenerics.checkMap(context.get("acroFieldMap"));
318+
Map<String, Object> acroFieldMap = UtilGenerics.cast(context.get("acroFieldMap"));
319319
ByteBuffer byteBuffer = getInputByteBuffer(context, delegator);
320320
PdfReader r = new PdfReader(byteBuffer.array());
321321
ByteArrayOutputStream baos = new ByteArrayOutputStream();
322322
PdfStamper s = new PdfStamper(r, baos);
323323
AcroFields fs = s.getAcroFields();
324-
Map<String, Object> map = UtilGenerics.checkMap(fs.getFields());
324+
Map<String, Object> map = UtilGenerics.cast(fs.getFields());
325325
s.setFormFlattening(true);
326326

327327
for (String fieldName : map.keySet()) {

applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void close() throws IOException {
150150
if (UtilValidate.isNotEmpty(wrapTemplateId)) {
151151
templateCtx.put("wrappedContent", wrappedContent);
152152
Map<String, Object> templateRoot = null;
153-
Map<String, Object> templateRootTemplate = UtilGenerics.checkMap(templateCtx.get("templateRootTemplate"));
153+
Map<String, Object> templateRootTemplate = UtilGenerics.cast(templateCtx.get("templateRootTemplate"));
154154
if (templateRootTemplate == null) {
155155
Map<String, Object> templateRootTmp = FreeMarkerWorker.createEnvironmentMap(env);
156156
templateRoot = UtilMisc.makeMapWritable(templateRootTmp);

applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public boolean prepCtx(Delegator delegator, Map<String, Object> ctx, Environment
220220

221221
String mimeTypeId = ContentWorker.getMimeTypeId(delegator, view, ctx);
222222
Map<String, Object> trailNode = ContentWorker.makeNode(view);
223-
Map<String, Object> whenMap = UtilGenerics.checkMap(ctx.get("whenMap"));
223+
Map<String, Object> whenMap = UtilGenerics.cast(ctx.get("whenMap"));
224224
ContentWorker.checkConditions(delegator, trailNode, null, whenMap);
225225
Boolean isReturnBeforeObj = (Boolean) trailNode.get("isReturnBefore");
226226
Boolean isPickObj = (Boolean) trailNode.get("isPick");

applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void renderSubContent() throws IOException {
140140
if (view != null) {
141141
thisView = view;
142142
} else if (passedGlobalNodeTrail.size() > 0) {
143-
Map<String, ? extends Object> map = UtilGenerics.checkMap(passedGlobalNodeTrail.get(passedGlobalNodeTrail.size() - 1));
143+
Map<String, ? extends Object> map = UtilGenerics.cast(passedGlobalNodeTrail.get(passedGlobalNodeTrail.size() - 1));
144144
if (Debug.infoOn()) {
145145
Debug.logInfo("in Render(3), map ." + map , module);
146146
}

applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentCacheTransform.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ public int onStart() throws TemplateModelException, IOException {
153153
if (globalNodeTrail.size() > 0) {
154154
int sz = globalNodeTrail.size() ;
155155
nodeTrail = new LinkedList<>();
156-
node = UtilGenerics.checkMap(globalNodeTrail.get(sz - 1));
156+
node = UtilGenerics.cast(globalNodeTrail.get(sz - 1));
157157
Boolean checkedObj = (Boolean)node.get("checked");
158-
Map<String, Object> whenMap = UtilGenerics.checkMap(templateRoot.get("whenMap"));
158+
Map<String, Object> whenMap = UtilGenerics.cast(templateRoot.get("whenMap"));
159159
if (checkedObj == null || !checkedObj) {
160160
ContentWorker.checkConditions(delegator, node, null, whenMap);
161161
}

applications/content/src/main/java/org/apache/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private boolean checkWhen (GenericValue thisContent, String contentAssocTypeId)
248248
return false;
249249
}
250250
assocContext.put("typeAncestry", contentTypeAncestry);
251-
Map<String, Object> whenMap = UtilGenerics.checkMap(traverseContext.get("whenMap"));
251+
Map<String, Object> whenMap = UtilGenerics.cast(traverseContext.get("whenMap"));
252252
List<Map<String, ? extends Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail"));
253253
int indentSz = indent + nodeTrail.size();
254254
assocContext.put("indentObj", indentSz);

0 commit comments

Comments
 (0)