Skip to content
Permalink
Browse files
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
  • Loading branch information
mthl committed Jul 20, 2019
1 parent 17da80d commit 83fd206
Show file tree
Hide file tree
Showing 79 changed files with 207 additions and 211 deletions.
@@ -40,7 +40,7 @@ public static Map<String, Object> createUpdateCostCenter(DispatchContext dctx, M
Map<String, Object> createGlAcctCatMemFromCostCentersMap = null;
String glAccountId = (String) context.get("glAccountId");
GenericValue userLogin = (GenericValue) context.get("userLogin");
Map<String, String> amountPercentageMap = UtilGenerics.checkMap(context.get("amountPercentageMap"));
Map<String, String> amountPercentageMap = UtilGenerics.cast(context.get("amountPercentageMap"));
BigDecimal totalAmountPercentage = GeneralLedgerServices.calculateCostCenterTotal(amountPercentageMap);
Map<String, Object> result = ServiceUtil.returnSuccess();
for (Map.Entry<String, String> rowEntry : amountPercentageMap.entrySet()) {
@@ -706,7 +706,7 @@ private static Document buildPrimaryTxRequest(Map<String, Object> context, Strin

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

Map<String, Object> pbOrder = UtilGenerics.checkMap(context.get("pbOrder"));
Map<String, Object> pbOrder = UtilGenerics.cast(context.get("pbOrder"));
if (pbOrder != null) {
if (Debug.verboseOn()) {
Debug.logVerbose("pbOrder Map not empty:" + pbOrder.toString(), module);
@@ -81,7 +81,7 @@ public static void mruAdd(HttpSession session, GenericEntity pk) {
return;
}

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

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

public static void getCurrentValue(HttpServletRequest request, Delegator delegator) {
HttpSession session = request.getSession();
Map<String, GenericPK> currentEntityMap = UtilGenerics.checkMap(session.getAttribute("currentEntityMap"));
Map<String, GenericPK> currentEntityMap = UtilGenerics.cast(session.getAttribute("currentEntityMap"));
if (currentEntityMap == null) {
currentEntityMap = new HashMap<>();
session.setAttribute("currentEntityMap", currentEntityMap);
@@ -145,7 +145,7 @@ public static Map<String, Object> findContentParents(DispatchContext dctx, Map<S
if (ServiceUtil.isError(thisResults)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(thisResults));
}
Map<String, Object> nodeMap = UtilGenerics.checkMap(thisResults.get("nodeMap"));
Map<String, Object> nodeMap = UtilGenerics.cast(thisResults.get("nodeMap"));
walkParentTree(nodeMap, parentList);
} catch (GenericServiceException e) {
return ServiceUtil.returnFailure(e.getMessage());
@@ -385,7 +385,7 @@ public static Map<String, Object> renderSubContentAsText(DispatchContext dctx, M
Map<String, Object> results = new HashMap<>();
LocalDispatcher dispatcher = dctx.getDispatcher();

Map<String,Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
Map<String,Object> templateContext = UtilGenerics.cast(context.get("templateContext"));
String contentId = (String) context.get("contentId");

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

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

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.checkMap(context.get("mapIn"));
Map<String, Object> mapIn = UtilGenerics.cast(context.get("mapIn"));
String prefix = (String)context.get("prefix");
Map<String, Object> mapOut = new HashMap<>();
result.put("mapOut", mapOut);
@@ -602,7 +602,7 @@ public static Map<String, Object> joinString(DispatchContext dctx, Map<String, ?
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.checkMap(context.get("mapIn"));
Map<String, Object> mapIn = UtilGenerics.cast(context.get("mapIn"));
if (mapIn != null) {
Set<Map.Entry<String, Object>> entrySet = mapIn.entrySet();
for (Map.Entry<String, Object> entry : entrySet) {
@@ -201,7 +201,7 @@ public static void renderContentAsText(LocalDispatcher dispatcher, GenericValue
if (service != null) {
//put all requestParameters into templateContext to use them as IN service parameters
Map<String,Object> tempTemplateContext = new HashMap<>();
tempTemplateContext.putAll(UtilGenerics.<String,Object>checkMap(templateContext.get("requestParameters")));
tempTemplateContext.putAll(UtilGenerics.cast(templateContext.get("requestParameters")));
tempTemplateContext.putAll(templateContext);
Map<String,Object> serviceCtx = service.makeValid(tempTemplateContext, ModelService.IN_PARAM);
Map<String,Object> serviceRes;
@@ -702,7 +702,7 @@ public static void selectKids(Map<String, Object> currentNode, Map<String, Objec
String contentTypeId = (String) ctx.get("contentTypeId");
String mapKey = (String) ctx.get("mapKey");
String parentContentId = (String) parentContent.get("contentId");
Map<String, Object> whenMap = UtilGenerics.checkMap(ctx.get("whenMap"));
Map<String, Object> whenMap = UtilGenerics.cast(ctx.get("whenMap"));
List<Map<String, Object>> kids = new LinkedList<>();
currentNode.put("kids", kids);
String direction = (String) ctx.get("direction");
@@ -1595,7 +1595,7 @@ public static StringBuilder logMap(StringBuilder s, String lbl, Map<String, Obje
indent.setLength(indent.length() - 1);
} else if (obj instanceof Map<?, ?>) {
indent.append(' ');
logMap(s, "MAP[" + key + "]", UtilGenerics.<String, Object>checkMap(obj), indent);
logMap(s, "MAP[" + key + "]", UtilGenerics.cast(obj), indent);
indent.setLength(indent.length() - 1);
} else if (obj != null) {
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
indent.setLength(indent.length() - 1);
} else if (obj instanceof Map<?, ?>) {
indent.append(' ');
logMap(s, "MAP[]", UtilGenerics.<String, Object>checkMap(obj), indent);
logMap(s, "MAP[]", UtilGenerics.cast(obj), indent);
indent.setLength(indent.length() - 1);
} else if (obj != null) {
s.append(obj).append(sep).append(obj.getClass()).append(eol);
@@ -793,7 +793,7 @@ public static void renderDataResourceAsText(LocalDispatcher dispatcher, Delegato
}
} else if ("FORM_COMBINED".equals(dataTemplateTypeId)){
try {
Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("globalContext"));
Map<String, Object> context = UtilGenerics.cast(templateContext.get("globalContext"));
context.put("locale", locale);
context.put("simpleEncoder", UtilCodec.getEncoder(modelTheme.getEncoder("screen")));
HttpServletRequest request = (HttpServletRequest) context.get("request");
@@ -838,7 +838,7 @@ public static String getDataResourceText(GenericValue dataResource, String mimeT

public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map<String, Object> templateContext,
Delegator delegator, Appendable out, boolean cache) throws IOException, GeneralException {
Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("context"));
Map<String, Object> context = UtilGenerics.cast(templateContext.get("context"));
if (context == null) {
context = new HashMap<>();
}
@@ -469,7 +469,7 @@ public static Map<String, Object> renderDataResourceAsText(DispatchContext dctx,
Map<String, Object> results = new HashMap<>();
//LocalDispatcher dispatcher = dctx.getDispatcher();
Writer out = (Writer) context.get("outWriter");
Map<String, Object> templateContext = UtilGenerics.checkMap(context.get("templateContext"));
Map<String, Object> templateContext = UtilGenerics.cast(context.get("templateContext"));
//GenericValue userLogin = (GenericValue) context.get("userLogin");
String dataResourceId = (String) context.get("dataResourceId");
if (templateContext != null && UtilValidate.isEmpty(dataResourceId)) {
@@ -66,7 +66,7 @@ public static String createLayoutImage(HttpServletRequest request, HttpServletRe
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
HttpSession session = request.getSession();
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
Map<String, Object> formInput = UtilGenerics.checkMap(uploadResults.get("formInput"));
Map<String, Object> formInput = UtilGenerics.cast(uploadResults.get("formInput"));
Map<String, Object> context = new HashMap<>();
ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData");
if (byteWrap == null) {
@@ -177,7 +177,7 @@ public static String updateLayoutImage(HttpServletRequest request, HttpServletRe
Delegator delegator = (Delegator) request.getAttribute("delegator");
HttpSession session = request.getSession();
Map<String, Object> uploadResults = LayoutWorker.uploadImageAndParameters(request, "imageData");
Map<String, Object> context = UtilGenerics.checkMap(uploadResults.get("formInput"));
Map<String, Object> context = UtilGenerics.cast(uploadResults.get("formInput"));
ByteBuffer byteWrap = (ByteBuffer) uploadResults.get("imageData");
if (byteWrap == null) {
String errMsg = UtilProperties.getMessage(LayoutEvents.err_resource, "layoutEvents.image_data_null", locale);
@@ -94,7 +94,7 @@ public static Map<String, Object> sendPrintFromScreen(DispatchContext dctx, Map<
visualTheme = ThemeFactory.resolveVisualTheme(null);
}
String screenLocation = (String) serviceContext.remove("screenLocation");
Map<String, Object> screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext"));
Map<String, Object> screenContext = UtilGenerics.cast(serviceContext.remove("screenContext"));
String contentType = (String) serviceContext.remove("contentType");
String printerContentType = (String) serviceContext.remove("printerContentType");

@@ -212,7 +212,7 @@ public static Map<String, Object> createFileFromScreen(DispatchContext dctx, Map
visualTheme = ThemeFactory.resolveVisualTheme(null);
}
String screenLocation = (String) serviceContext.remove("screenLocation");
Map<String, Object> screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext"));
Map<String, Object> screenContext = UtilGenerics.cast(serviceContext.remove("screenContext"));
String contentType = (String) serviceContext.remove("contentType");
String filePath = (String) serviceContext.remove("filePath");
String fileName = (String) serviceContext.remove("fileName");
@@ -89,7 +89,7 @@ public static Map<String, Object> buildSurveyFromPdf(DispatchContext dctx, Map<S
PdfReader pdfReader = new PdfReader(byteBuffer.array());
PdfStamper pdfStamper = new PdfStamper(pdfReader, os);
AcroFields acroFields = pdfStamper.getAcroFields();
Map<String, Object> acroFieldMap = UtilGenerics.checkMap(acroFields.getFields());
Map<String, Object> acroFieldMap = UtilGenerics.cast(acroFields.getFields());

String contentId = (String) context.get("contentId");
GenericValue survey = null;
@@ -246,7 +246,7 @@ public static Map<String, Object> buildSurveyResponseFromPdf(DispatchContext dct
PdfReader r = new PdfReader(byteBuffer.array());
PdfStamper s = new PdfStamper(r,os);
AcroFields fs = s.getAcroFields();
Map<String, Object> hm = UtilGenerics.checkMap(fs.getFields());
Map<String, Object> hm = UtilGenerics.cast(fs.getFields());
s.setFormFlattening(true);
for (String fieldName : hm.keySet()) {
//AcroFields.Item item = fs.getFieldItem(fieldName);
@@ -291,7 +291,7 @@ public static Map<String, Object> getAcroFieldsFromPdf(DispatchContext dctx, Map
PdfReader r = new PdfReader(byteBuffer.array());
PdfStamper s = new PdfStamper(r,os);
AcroFields fs = s.getAcroFields();
Map<String, Object> map = UtilGenerics.checkMap(fs.getFields());
Map<String, Object> map = UtilGenerics.cast(fs.getFields());
s.setFormFlattening(true);

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

for (String fieldName : map.keySet()) {
@@ -150,7 +150,7 @@ public void close() throws IOException {
if (UtilValidate.isNotEmpty(wrapTemplateId)) {
templateCtx.put("wrappedContent", wrappedContent);
Map<String, Object> templateRoot = null;
Map<String, Object> templateRootTemplate = UtilGenerics.checkMap(templateCtx.get("templateRootTemplate"));
Map<String, Object> templateRootTemplate = UtilGenerics.cast(templateCtx.get("templateRootTemplate"));
if (templateRootTemplate == null) {
Map<String, Object> templateRootTmp = FreeMarkerWorker.createEnvironmentMap(env);
templateRoot = UtilMisc.makeMapWritable(templateRootTmp);
@@ -220,7 +220,7 @@ public boolean prepCtx(Delegator delegator, Map<String, Object> ctx, Environment

String mimeTypeId = ContentWorker.getMimeTypeId(delegator, view, ctx);
Map<String, Object> trailNode = ContentWorker.makeNode(view);
Map<String, Object> whenMap = UtilGenerics.checkMap(ctx.get("whenMap"));
Map<String, Object> whenMap = UtilGenerics.cast(ctx.get("whenMap"));
ContentWorker.checkConditions(delegator, trailNode, null, whenMap);
Boolean isReturnBeforeObj = (Boolean) trailNode.get("isReturnBefore");
Boolean isPickObj = (Boolean) trailNode.get("isPick");
@@ -140,7 +140,7 @@ public void renderSubContent() throws IOException {
if (view != null) {
thisView = view;
} else if (passedGlobalNodeTrail.size() > 0) {
Map<String, ? extends Object> map = UtilGenerics.checkMap(passedGlobalNodeTrail.get(passedGlobalNodeTrail.size() - 1));
Map<String, ? extends Object> map = UtilGenerics.cast(passedGlobalNodeTrail.get(passedGlobalNodeTrail.size() - 1));
if (Debug.infoOn()) {
Debug.logInfo("in Render(3), map ." + map , module);
}
@@ -153,9 +153,9 @@ public int onStart() throws TemplateModelException, IOException {
if (globalNodeTrail.size() > 0) {
int sz = globalNodeTrail.size() ;
nodeTrail = new LinkedList<>();
node = UtilGenerics.checkMap(globalNodeTrail.get(sz - 1));
node = UtilGenerics.cast(globalNodeTrail.get(sz - 1));
Boolean checkedObj = (Boolean)node.get("checked");
Map<String, Object> whenMap = UtilGenerics.checkMap(templateRoot.get("whenMap"));
Map<String, Object> whenMap = UtilGenerics.cast(templateRoot.get("whenMap"));
if (checkedObj == null || !checkedObj) {
ContentWorker.checkConditions(delegator, node, null, whenMap);
}
@@ -248,7 +248,7 @@ private boolean checkWhen (GenericValue thisContent, String contentAssocTypeId)
return false;
}
assocContext.put("typeAncestry", contentTypeAncestry);
Map<String, Object> whenMap = UtilGenerics.checkMap(traverseContext.get("whenMap"));
Map<String, Object> whenMap = UtilGenerics.cast(traverseContext.get("whenMap"));
List<Map<String, ? extends Object>> nodeTrail = UtilGenerics.checkList(traverseContext.get("nodeTrail"));
int indentSz = indent + nodeTrail.size();
assocContext.put("indentObj", indentSz);

0 comments on commit 83fd206

Please sign in to comment.