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

📄 contentmanagementservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * $Id: ContentManagementServices.java 7074 2006-03-25 00:04:33Z jonesde $ * *  Copyright (c) 2003-2005 The Open For Business Project - www.ofbiz.org * *  Permission is hereby granted, free of charge, to any person obtaining a *  copy of this software and associated documentation files (the "Software"), *  to deal in the Software without restriction, including without limitation *  the rights to use, copy, modify, merge, publish, distribute, sublicense, *  and/or sell copies of the Software, and to permit persons to whom the *  Software is furnished to do so, subject to the following conditions: * *  The above copyright notice and this permission notice shall be included *  in all copies or substantial portions of the Software. * *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *  THE USE OR OTHER DEALINGS IN THE SOFTWARE. */package org.ofbiz.content;import java.sql.Timestamp;import java.util.Calendar;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.base.util.StringUtil;import org.ofbiz.base.util.cache.UtilCache;import org.ofbiz.content.content.ContentServices;import org.ofbiz.content.content.ContentWorker;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericPK;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.condition.EntityCondition;import org.ofbiz.entity.condition.EntityConditionList;import org.ofbiz.entity.condition.EntityExpr;import org.ofbiz.entity.condition.EntityOperator;import org.ofbiz.entity.model.ModelUtil;import org.ofbiz.entity.util.ByteWrapper;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.security.Security;import org.ofbiz.service.DispatchContext;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.service.ModelService;import org.ofbiz.service.ServiceAuthException;import org.ofbiz.service.ServiceUtil;/** * ContentManagementServices Class * * @author     <a href="mailto:byersa@automationgroups.com">Al Byers</a> * @version    $Rev: 7074 $ * @since      3.0 */public class ContentManagementServices {    public static final String module = ContentManagementServices.class.getName();    /**     * getSubContent     * Finds the related subContent given the template Content and the mapKey.     * This service calls a same-named method in ContentWorker to do the work.     */    public static Map getSubContent(DispatchContext dctx, Map context) {        //Security security = dctx.getSecurity();        GenericDelegator delegator = dctx.getDelegator();        //LocalDispatcher dispatcher = dctx.getDispatcher();        String contentId = (String) context.get("contentId");         String subContentId = (String) context.get("subContentId");         String mapKey = (String) context.get("mapKey");         GenericValue userLogin = (GenericValue)context.get("userLogin");        Timestamp fromDate = (Timestamp)context.get("fromDate");        List assocTypes = (List) context.get("assocTypes");         String assocTypesString = (String)context.get("assocTypesString");        if (UtilValidate.isNotEmpty(assocTypesString)) {            List lst = StringUtil.split(assocTypesString, "|");            if (assocTypes == null) {                assocTypes = new ArrayList();               }            assocTypes.addAll(lst);        }        GenericValue content = null;        GenericValue view = null;        try {            view = ContentWorker.getSubContentCache( delegator, contentId, mapKey, subContentId, userLogin, assocTypes, fromDate, new Boolean(false), null);            content = ContentWorker.getContentFromView(view);        } catch(GenericEntityException e) {            return ServiceUtil.returnError(e.getMessage());        }        Map results = ServiceUtil.returnSuccess();        results.put("view", view);        results.put("content", content);        return results;    }    /**     * getContent     * This service calls a same-named method in ContentWorker to do the work.     */    public static Map getContent(DispatchContext dctx, Map context) {        //Security security = dctx.getSecurity();        GenericDelegator delegator = dctx.getDelegator();        String contentId = (String) context.get("contentId");         //GenericValue userLogin = (GenericValue)context.get("userLogin");        GenericValue view = null;        try {            view = ContentWorker.getContentCache( delegator, contentId);        } catch(GenericEntityException e) {            return ServiceUtil.returnError(e.getMessage());        }        Map results = ServiceUtil.returnSuccess();        results.put("view", view);        return results;    }    /**     * addMostRecent     * A service for adding the most recently used of an entity class to the cache.     * Entities make it to the most recently used list primarily by being selected for editing,     * either by being created or being selected from a list.     */    public static Map addMostRecent(DispatchContext dctx, Map context) {        //Security security = dctx.getSecurity();        //GenericDelegator delegator = dctx.getDelegator();        //LocalDispatcher dispatcher = dctx.getDispatcher();        //HttpServletRequest request = (HttpServletRequest)context.get("request");          //String suffix = (String) context.get("suffix");         GenericValue val = (GenericValue)context.get("pk");        GenericPK pk = val.getPrimaryKey();        HttpSession session = (HttpSession)context.get("session");        ContentManagementWorker.mruAdd(session, pk);        return ServiceUtil.returnSuccess();    }    /**     * persistContentAndAssoc     * A combination method that will create or update all or one of the following     * a Content entity, a ContentAssoc related to the Content and      * the ElectronicText that may be associated with the Content.     * The keys for determining if each entity is created is the presence     * of the contentTypeId, contentAssocTypeId and dataResourceTypeId.     * This service tries to handle DataResource and ContentAssoc fields with and     * without "dr" and "ca" prefixes.     * Assumes binary data is always in field, "imageData".     */    public static Map persistContentAndAssoc(DispatchContext dctx, Map context) throws GenericServiceException {        GenericDelegator delegator = dctx.getDelegator();        LocalDispatcher dispatcher = dctx.getDispatcher();                // Knowing why a request fails permission check is one of the more difficult        // aspects of content management. Setting "displayFailCond" to true will        // put an html table in result.errorMessage that will show what tests were performed        Boolean bDisplayFailCond = (Boolean)context.get("displayFailCond");        String mapKey = (String) context.get("mapKey");                 // If "deactivateExisting" is set, other Contents that are tied to the same        // contentIdTo will be deactivated (thruDate set to now)        String deactivateExisting = (String) context.get("deactivateExisting");         if (UtilValidate.isEmpty(deactivateExisting)) {            if (UtilValidate.isEmpty(mapKey))                 deactivateExisting = "false";            else                 deactivateExisting = "true";        }        if (Debug.infoOn()) Debug.logInfo("in persist... mapKey(0):" + mapKey, null);        // ContentPurposes can get passed in as a delimited string or a list. Combine.        List contentPurposeList = (List)context.get("contentPurposeList");        if (contentPurposeList == null)            contentPurposeList = new ArrayList();        String contentPurposeString = (String) context.get("contentPurposeString");        if (UtilValidate.isNotEmpty(contentPurposeString)) {            List tmpPurposes = StringUtil.split(contentPurposeString, "|");            contentPurposeList.addAll(tmpPurposes);        }        if (contentPurposeList != null ) {            context.put("contentPurposeList", contentPurposeList);               context.put("contentPurposeString", null);           }        if (Debug.infoOn()) Debug.logInfo("in persist... contentPurposeList(0):" + contentPurposeList, null);        if (Debug.infoOn()) Debug.logInfo("in persist... textData(0):" + context.get("textData"), null);                GenericValue content = delegator.makeValue("Content", null);        content.setPKFields(context);        content.setNonPKFields(context);        String contentId = (String) content.get("contentId");        String contentTypeId = (String) content.get("contentTypeId");        String origContentId = (String) content.get("contentId");        String origDataResourceId = (String) content.get("dataResourceId");        if (Debug.infoOn()) Debug.logInfo("in persist... contentId(0):" + contentId, null);        GenericValue dataResource = delegator.makeValue("DataResource", null);        dataResource.setPKFields(context);        dataResource.setNonPKFields(context);        dataResource.setAllFields(context, false, "dr", null);        context.putAll(dataResource);        String dataResourceId = (String) dataResource.get("dataResourceId");        String dataResourceTypeId = (String) dataResource.get("dataResourceTypeId");        if (Debug.infoOn()) Debug.logInfo("in persist... dataResourceId(0):" + dataResourceId, null);        GenericValue contentAssoc = delegator.makeValue("ContentAssoc", null);        contentAssoc.setPKFields(context);        contentAssoc.setNonPKFields(context);        contentAssoc.setAllFields(context, false, "ca", null);        context.putAll(contentAssoc);        GenericValue electronicText = delegator.makeValue("ElectronicText", null);        electronicText.setPKFields(context);        electronicText.setNonPKFields(context);                // save expected primary keys on result now in case there is no operation that uses them        Map results = ServiceUtil.returnSuccess();        results.put("contentId", content.get("contentId"));        results.put("dataResourceId", dataResource.get("dataResourceId"));        results.put("contentIdTo", contentAssoc.get("contentIdTo"));        results.put("fromDate", contentAssoc.get("fromDate"));        results.put("contentAssocTypeId", contentAssoc.get("contentAssocTypeId"));        results.put("drDataResourceId", dataResource.get("dataResourceId"));        results.put("caContentIdTo", contentAssoc.get("contentIdTo"));        results.put("caFromDate", contentAssoc.get("fromDate"));        results.put("caContentAssocTypeId", contentAssoc.get("contentAssocTypeId"));                // get user info for multiple use        GenericValue userLogin = (GenericValue) context.get("userLogin");         // TODO: DEJ20060221 Should these be used somewhere?        //String textData = (String)electronicText.get("textData");        //String userLoginId = (String)userLogin.get("userLoginId");        

⌨️ 快捷键说明

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