⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contentworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        renderContentAsText(delegator, contentId, out, templateContext, subContentDataResourceView, locale, mimeTypeId);        return results;    }    public static String renderSubContentAsTextCache(GenericDelegator delegator, String contentId,  String mapKey,  GenericValue subContentDataResourceView,             Map templateRoot, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate) throws GeneralException, IOException {        Boolean nullThruDatesOnly = new Boolean(false);        Writer outWriter = new StringWriter();        Map map = renderSubContentAsTextCache(delegator, contentId, outWriter, mapKey, subContentDataResourceView, templateRoot, locale, mimeTypeId, userLogin, fromDate, nullThruDatesOnly);        return outWriter.toString();    }    public static Map renderSubContentAsTextCache(GenericDelegator delegator, String contentId, Writer out, String mapKey,  GenericValue subContentDataResourceView,             Map templateRoot, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate) throws GeneralException, IOException {        Boolean nullThruDatesOnly = new Boolean(false);        return renderSubContentAsTextCache(delegator, contentId, out, mapKey, subContentDataResourceView,             templateRoot, locale, mimeTypeId, userLogin, fromDate, nullThruDatesOnly);    }    /**      */    public static Map renderSubContentAsTextCache(GenericDelegator delegator, String contentId, Writer out, String mapKey,  GenericValue subContentDataResourceView,             Map templateRoot, Locale locale, String mimeTypeId, GenericValue userLogin, Timestamp fromDate, Boolean nullThruDatesOnly) throws GeneralException, IOException {        Map results = new HashMap();        //GenericValue content = null;        if (subContentDataResourceView == null) {            String contentAssocPredicateId = null;            try {                subContentDataResourceView = getSubContentCache(delegator, contentId, mapKey, userLogin, null, fromDate, nullThruDatesOnly, contentAssocPredicateId );            } catch(GenericEntityException e) {                throw new GeneralException(e.getMessage());            }        }        results.put("view", subContentDataResourceView);        if (subContentDataResourceView == null) {            //throw new IOException("SubContentDataResourceView is null.");            return results;        }        String contentIdSub = (String) subContentDataResourceView.get("contentId");        if (templateRoot == null) {            templateRoot = new HashMap();        }        //templateRoot.put("contentId", contentIdSub);        //templateRoot.put("subContentId", null);        renderContentAsTextCache(delegator, contentIdSub, out, templateRoot, subContentDataResourceView, locale, mimeTypeId);        return results;    }    public static Map renderContentAsText(GenericDelegator delegator, String contentId, Writer out, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException {        //Map context = (Map) FreeMarkerWorker.get(templateContext, "context");        Map results = new HashMap();        GenericValue content = null;        if (view == null) {            if (contentId == null) {                throw new IOException("ContentId is null");            }            try {                List lst = delegator.findByAnd("SubContentDataResourceView", UtilMisc.toMap("contentId", contentId));                if (lst != null && lst.size() > 0) {                    view = (GenericValue) lst.get(0);                } else {                    throw new IOException("SubContentDataResourceView not found in renderSubContentAsText" + " for contentId=" + contentId);                }            } catch (GenericEntityException e) {                throw new IOException(e.getMessage());            }        }        if (view != null) {            Map contentMap = new HashMap();            try {                SimpleMapProcessor.runSimpleMapProcessor("org/ofbiz/content/ContentManagementMapProcessors.xml", "contentIn", view, contentMap, new ArrayList(), locale);            } catch (MiniLangException e) {                throw new IOException(e.getMessage());            }            content = delegator.makeValue("Content", contentMap);        }        results.put("view", view);        results.put("content", content);        if (locale != null) {            String targetLocaleString = locale.toString();            String thisLocaleString = (String) view.get("localeString");            thisLocaleString = (thisLocaleString != null) ? thisLocaleString : "";            if (targetLocaleString != null && !targetLocaleString.equalsIgnoreCase(thisLocaleString)) {                view = findAlternateLocaleContent(delegator, view, locale);            }        }        //String contentTypeId = (String) view.get("contentTypeId");        String dataResourceId = null;        try {            dataResourceId = (String) view.get("drDataResourceId");        } catch (Exception e) {            dataResourceId = (String) view.get("dataResourceId");        }        if (templateContext == null) {            templateContext = new HashMap();        }        // TODO: what should we REALLY do here? looks like there is no decision between Java and Service style error handling...        //try {        if (UtilValidate.isNotEmpty(dataResourceId) || view != null)            DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, out, templateContext, view, locale, mimeTypeId);        //} catch (IOException e) {        //    return ServiceUtil.returnError(e.getMessage());        //}        return results;    }    public static String renderContentAsTextCache(GenericDelegator delegator, String contentId,  Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException {        Writer outWriter = new StringWriter();        renderContentAsTextCache(delegator, contentId, outWriter, templateContext, view, locale, mimeTypeId);        return outWriter.toString();    }    public static Map renderContentAsTextCache(GenericDelegator delegator, String contentId, Writer out, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException {        Map results = new HashMap();         GenericValue content = null;        if (view == null) {            if (contentId == null) {                throw new GeneralException("ContentId is null");            }            try {                List lst = delegator.findByAndCache("SubContentDataResourceView", UtilMisc.toMap("contentId", contentId), null);                if (lst != null && lst.size() > 0) {                    view = (GenericValue) lst.get(0);                } else {                    throw new GeneralException("SubContentDataResourceView not found in renderSubContentAsText" + " for contentId=" + contentId);                }            } catch (GenericEntityException e) {                throw new GeneralException(e.getMessage());            }        }        if (view != null) {            Map contentMap = new HashMap();            try {                SimpleMapProcessor.runSimpleMapProcessor("org/ofbiz/content/ContentManagementMapProcessors.xml", "contentIn", view, contentMap, new ArrayList(), locale);            } catch (MiniLangException e) {                throw new IOException(e.getMessage());            }            content = delegator.makeValue("Content", contentMap);        }        results.put("view", view);        results.put("content", content);        if (locale != null) {            String targetLocaleString = locale.toString();            String thisLocaleString = (String) view.get("localeString");            thisLocaleString = (thisLocaleString != null) ? thisLocaleString : "";            //if (Debug.infoOn()) Debug.logInfo("renderContentAsTextCache, thisLocaleString(2):" + thisLocaleString, "");            //if (Debug.infoOn()) Debug.logInfo("renderContentAsTextCache, targetLocaleString(2):" + targetLocaleString, "");            if (UtilValidate.isNotEmpty(targetLocaleString) && !targetLocaleString.equalsIgnoreCase(thisLocaleString)) {                GenericValue localeView = findAlternateLocaleContent(delegator, view, locale);                if (localeView != null)                    view = localeView;            }        }        String templateDataResourceId = (String)view.get("templateDataResourceId");        //String contentTypeId = (String) view.get("contentTypeId");        String dataResourceId = null;        try {            dataResourceId = (String) view.get("drDataResourceId");        } catch (Exception e) {            dataResourceId = (String) view.get("dataResourceId");            view = null; // renderDataResourceAsText will expect DataResource values if not null        }        if (templateContext == null) {            templateContext = new HashMap();        }        // TODO: what should we REALLY do here? looks like there is no decision between Java and Service style error handling...        if (UtilValidate.isEmpty(templateDataResourceId)) {            if (UtilValidate.isNotEmpty(dataResourceId) || view != null)                DataResourceWorker.renderDataResourceAsTextCache(delegator, dataResourceId, out, templateContext, view, locale, mimeTypeId);        } else {            if (UtilValidate.isNotEmpty(dataResourceId) || view != null) {                StringWriter sw = new StringWriter();                DataResourceWorker.renderDataResourceAsTextCache(delegator, dataResourceId, sw, templateContext, view, locale, mimeTypeId);                String s = sw.toString();                if (UtilValidate.isNotEmpty(s))                    s = s.trim();                //if (Debug.infoOn()) Debug.logInfo("renderTextAsStringCache, s:" + s, "");                                if (Debug.infoOn()) Debug.logInfo("renderContentAsTextCache, dataResourceId(2):" + dataResourceId, "");                //if (Debug.infoOn()) Debug.logInfo("renderTextAsStringCache, view(3):" + view, "");                String reqdType = null;                try {                    reqdType = DataResourceWorker.getDataResourceMimeType(delegator, dataResourceId, view);                } catch(GenericEntityException e) {                    throw new GeneralException(e.getMessage());                }                if (Debug.infoOn()) Debug.logInfo("renderContentAsTextCache, reqdType(2):" + reqdType, "");                if (UtilValidate.isNotEmpty(reqdType)) {                    if (reqdType.toLowerCase().indexOf("xml") >= 0) {                        StringReader sr = new StringReader(s);                        try {                            NodeModel nodeModel = NodeModel.parse(new InputSource(sr));                            if (Debug.infoOn()) Debug.logInfo("renderTextAsStringCache, doc:" + nodeModel, "");                            templateContext.put("doc", nodeModel);                        } catch(SAXException e) {                            throw new GeneralException(e.getMessage());                        } catch(ParserConfigurationException e2) {                            throw new GeneralException(e2.getMessage());                        }                    } else {                        // must be text                        templateContext.put("textData", sw.toString());                    }                } else {                    templateContext.put("textData", sw.toString());                }            }            DataResourceWorker.renderDataResourceAsTextCache(delegator, templateDataResourceId, out, templateContext, null, locale, mimeTypeId);        }        return results;    }    public static Map buildPickContext(GenericDelegator delegator, String contentAssocTypeId, String assocContentId, String direction, GenericValue thisContent) throws GenericEntityException {        Map ctx = new HashMap();        ctx.put("contentAssocTypeId", contentAssocTypeId);        ctx.put("contentId", assocContentId);        String assocRelation = null;        // This needs to be the opposite        if (direction != null && direction.equalsIgnoreCase("From")) {            ctx.put("contentIdFrom", assocContentId);            assocRelation = "FromContent";        } else {            ctx.put("contentIdTo", assocContentId);            assocRelation = "ToContent";        }        if (thisContent == null)            thisContent = delegator.findByPrimaryKeyCache("Content",                                   UtilMisc.toMap("contentId", assocContentId));        ctx.put("content", thisContent);        List purposes = getPurposes(thisContent);        ctx.put("purposes", purposes);        List contentTypeAncestry = new ArrayList();        String contentTypeId = (String)thisContent.get("contentTypeId");        getContentTypeAncestry(delegator, contentTypeId, contentTypeAncestry);       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -