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

📄 contentmanagementevents.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.ofbiz.content;import java.sql.Timestamp;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import javax.servlet.ServletContext;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.GeneralException;import org.ofbiz.base.util.StringUtil;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.base.util.UtilHttp;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.security.Security;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.service.ModelService;/** * ContentManagementEvents Class * * @author     <a href="mailto:byersa@automationgroups.com">Al Byers</a> * @version    $Rev: 5462 $ * @since      3.0 * *  */public class ContentManagementEvents {    public static final String module = ContentManagementEvents.class.getName();    public static String updateStaticValues(HttpServletRequest request, HttpServletResponse response) {        HttpSession session = request.getSession();        Security security = (Security)request.getAttribute("security");        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        ServletContext servletContext = session.getServletContext();        String webSiteId = (String) servletContext.getAttribute("webSiteId");        GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");        LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");        Map paramMap = UtilHttp.getParameterMap(request);                //if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, paramMap:" + paramMap , module);        String parentPlaceholderId = (String)paramMap.get("ph");        if ( UtilValidate.isEmpty(parentPlaceholderId)) {            request.setAttribute("_ERROR_MESSAGE_", "ParentPlaceholder is empty.");            return "error";        }        List allPublishPointList = null;        List permittedPublishPointList = null;        List valueList = null;        try {            allPublishPointList = ContentManagementWorker.getAllPublishPoints(delegator, webSiteId);            permittedPublishPointList = ContentManagementWorker.getPermittedPublishPoints(delegator, allPublishPointList, userLogin, security, "_ADMIN", null, null);            valueList = ContentManagementWorker.getStaticValues(delegator, parentPlaceholderId, permittedPublishPointList);        } catch(GeneralException e) {            Debug.logError(e.getMessage(), module);            request.setAttribute("_ERROR_MESSAGE_", e.getMessage());            return "error";        }/*        Set keySet = paramMap.keySet();        Iterator itKeySet = keySet.iterator();        Map contentIdLookup = new HashMap();        while (itKeySet.hasNext()) {            String idxAndContentId = (String)itKeySet.next();            int pos = idxAndContentId.indexOf("_");            if (pos > 0) {                String idxStr = idxAndContentId.substring(0, pos);                int idx = Integer.parseInt(idxStr);                String contentId = idxAndContentId.substring(pos + 1);                contentIdLookup.put(contentId, new Integer(idx));            }        }*/        Iterator it = valueList.iterator();        int counter = 0;        while (it.hasNext()) {            Map map = (Map)it.next();            String contentId = (String)map.get("contentId");            //Integer idxObj = (Integer)contentIdLookup.get(contentId);            //int idx = idxObj.intValue();            Iterator itPubPt = permittedPublishPointList.iterator();            while (itPubPt.hasNext()) {                String [] pubArr = (String [])itPubPt.next();                String pubContentId = (String)pubArr[0];                String pubValue = (String)map.get(pubContentId);                String paramName = Integer.toString(counter)  + "_" + pubContentId;                String paramValue = (String)paramMap.get(paramName);                //if (Debug.infoOn()) Debug.logInfo("in updateStaticValues, contentId:" + contentId + " pubContentId:" + pubContentId + " pubValue:" + pubValue + " paramName:" + paramName + " paramValue:" + paramValue, module);                Map serviceIn = new HashMap();                serviceIn.put("userLogin", userLogin);                serviceIn.put("contentIdTo", contentId);                serviceIn.put("contentId", pubContentId);                serviceIn.put("contentAssocTypeId", "SUBSITE");                try {                    if (UtilValidate.isNotEmpty(paramValue)) {                        if (!paramValue.equals(pubValue)) {                            if (paramValue.equalsIgnoreCase("Y")) {                                serviceIn.put("fromDate", UtilDateTime.nowTimestamp());                                Map results = dispatcher.runSync("createContentAssoc", serviceIn);                            } else if (paramValue.equalsIgnoreCase("N") && pubValue.equalsIgnoreCase("Y")) {                                serviceIn.put("thruDate", UtilDateTime.nowTimestamp());                                Timestamp fromDate = (Timestamp)map.get(pubContentId + "FromDate");                                serviceIn.put("fromDate", fromDate);                                Map results = dispatcher.runSync("updateContentAssoc", serviceIn);                            }                        }                    } else if ( UtilValidate.isNotEmpty(pubValue)) {                        if (pubValue.equalsIgnoreCase("Y")) {                                serviceIn.put("thruDate", UtilDateTime.nowTimestamp());                                Timestamp fromDate = (Timestamp)map.get(pubContentId + "FromDate");                                serviceIn.put("fromDate", fromDate);                                Map results = dispatcher.runSync("updateContentAssoc", serviceIn);                        }                    }                } catch(GenericServiceException e) {                    Debug.logError(e.getMessage(), module);                    request.setAttribute("_ERROR_MESSAGE_", e.getMessage());                    return "error";                }            }            counter++;        }        return "success";    }    public static String createStaticValue(HttpServletRequest request, HttpServletResponse response) {        String retValue = "success";        return retValue;    }    public static String updatePublishLinks(HttpServletRequest request, HttpServletResponse response) {        HttpSession session = request.getSession();        Security security = (Security)request.getAttribute("security");        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        ServletContext servletContext = session.getServletContext();        String webSiteId = (String) servletContext.getAttribute("webSiteId");        GenericDelegator delegator = (GenericDelegator)request.getAttribute("delegator");        LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");        Map paramMap = UtilHttp.getParameterMap(request);                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, paramMap:" + paramMap , module);        String targContentId = (String)paramMap.get("contentId"); // The content to be linked to one or more sites        String roles = null;        String authorId = null;        GenericValue authorContent = ContentManagementWorker.getAuthorContent(delegator, targContentId);        if (authorContent != null) {            authorId = authorContent.getString("contentId");        } else {            request.setAttribute("_ERROR_MESSAGE_", "authorContent is empty.");            return "error";        }        // Determine if user is owner of target content        String userLoginId = userLogin.getString("userLoginId");                //if (Debug.infoOn()) Debug.logInfo("in updatePublishLinks, userLoginId:" + userLoginId + " authorId:" + authorId , module);        List roleTypeList = null;        if (authorId != null && userLoginId != null && authorId.equals(userLoginId)) {            roles = "OWNER";

⌨️ 快捷键说明

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