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

📄 contentservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        context.put("entityOperation", "_UPDATE");        List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE");        List contentPurposeList = ContentWorker.prepContentPurposeList(context);        context.put("targetOperationList", targetOperationList);        context.put("contentPurposeList", contentPurposeList);        GenericValue content = null;        //Locale locale = (Locale) context.get("locale");        String contentId = (String) context.get("contentId");        try {            content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId));        } catch (GenericEntityException e) {            Debug.logWarning(e, module);            return ServiceUtil.returnError("content.update.read_failure" + e.getMessage());        }        context.put("currentContent", content);        Map permResults = ContentWorker.callContentPermissionCheckResult(delegator, dispatcher, context);        String permissionStatus = (String) permResults.get("permissionStatus");        if (permissionStatus != null && permissionStatus.equalsIgnoreCase("granted")) {            GenericValue userLogin = (GenericValue) context.get("userLogin");            String userLoginId = (String) userLogin.get("userLoginId");            String lastModifiedByUserLogin = userLoginId;            Timestamp lastModifiedDate = UtilDateTime.nowTimestamp();            content.setNonPKFields(context);            content.put("lastModifiedByUserLogin", lastModifiedByUserLogin);            content.put("lastModifiedDate", lastModifiedDate);            try {                content.store();            } catch (GenericEntityException e) {                return ServiceUtil.returnError(e.getMessage());            }        } else {            String errorMsg = ContentWorker.prepPermissionErrorMsg(permResults);            return ServiceUtil.returnError(errorMsg);        }        return result;    }    /**     * Update a ContentAssoc service. The work is done in a separate method so that complex services that need this functionality do not need to incur the     * reflection performance penalty.     */    public static Map updateContentAssoc(DispatchContext dctx, Map context) {        context.put("entityOperation", "_UPDATE");        List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE");        List contentPurposeList = ContentWorker.prepContentPurposeList(context);        context.put("targetOperationList", targetOperationList);        context.put("contentPurposeList", contentPurposeList);        context.put("skipPermissionCheck", null);        Map result = updateContentAssocMethod(dctx, context);        return result;    }    /**     * Update a ContentAssoc method. The work is done in this separate method so that complex services that need this functionality do not need to incur the     * reflection performance penalty.     */    public static Map updateContentAssocMethod(DispatchContext dctx, Map context) {        GenericDelegator delegator = dctx.getDelegator();        LocalDispatcher dispatcher = dctx.getDispatcher();        Map result = new HashMap();        context.put("entityOperation", "_UPDATE");        List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE");        List contentPurposeList = ContentWorker.prepContentPurposeList(context);        context.put("targetOperationList", targetOperationList);        context.put("contentPurposeList", contentPurposeList);        // This section guesses how contentId should be used (From or To) if        // only a contentIdFrom o contentIdTo is passed in        String contentIdFrom = (String) context.get("contentId");        String contentIdTo = (String) context.get("contentIdTo");        String contentId = (String) context.get("contentId");        String contentAssocTypeId = (String) context.get("contentAssocTypeId");        Timestamp fromDate = (Timestamp) context.get("fromDate");        GenericValue contentAssoc = null;        try {            contentAssoc = delegator.findByPrimaryKey("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", contentIdTo, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate));        } catch (GenericEntityException e) {            System.out.println("Entity Error:" + e.getMessage());            return ServiceUtil.returnError("Error in retrieving Content. " + e.getMessage());        }        if (contentAssoc == null) {            return ServiceUtil.returnError("Error in updating ContentAssoc. Entity is null.");        }        contentAssoc.put("contentAssocPredicateId", context.get("contentAssocPredicateId"));        contentAssoc.put("dataSourceId", context.get("dataSourceId"));        contentAssoc.set("thruDate", context.get("thruDate"));        contentAssoc.set("sequenceNum", context.get("sequenceNum"));        contentAssoc.put("mapKey", context.get("mapKey"));        String upperCoordinateStr = (String) context.get("upperCoordinate");        if (UtilValidate.isEmpty(upperCoordinateStr)) {            contentAssoc.put("upperCoordinate", null);        } else {            contentAssoc.setString("upperCoordinate", upperCoordinateStr);        }        String leftCoordinateStr = (String) context.get("leftCoordinate");        if (UtilValidate.isEmpty(leftCoordinateStr)) {            contentAssoc.put("leftCoordinate", null);        } else {            contentAssoc.setString("leftCoordinate", leftCoordinateStr);        }        GenericValue userLogin = (GenericValue) context.get("userLogin");        String userLoginId = (String) userLogin.get("userLoginId");        String lastModifiedByUserLogin = userLoginId;        Timestamp lastModifiedDate = UtilDateTime.nowTimestamp();        contentAssoc.put("lastModifiedByUserLogin", lastModifiedByUserLogin);        contentAssoc.put("lastModifiedDate", lastModifiedDate);        String permissionStatus = null;        Map serviceInMap = new HashMap();        serviceInMap.put("userLogin", context.get("userLogin"));        serviceInMap.put("targetOperationList", targetOperationList);        serviceInMap.put("contentPurposeList", contentPurposeList);        serviceInMap.put("entityOperation", context.get("entityOperation"));        serviceInMap.put("contentIdTo", contentIdTo);        serviceInMap.put("contentIdFrom", contentIdFrom);        Map permResults = null;        try {            permResults = dispatcher.runSync("checkAssocPermission", serviceInMap);        } catch (GenericServiceException e) {            Debug.logError(e, "Problem checking permissions", "ContentServices");            return ServiceUtil.returnError("Problem checking association permissions");        }        permissionStatus = (String) permResults.get("permissionStatus");        if (permissionStatus != null && permissionStatus.equals("granted")) {            try {                contentAssoc.store();            } catch (GenericEntityException e) {                return ServiceUtil.returnError(e.getMessage());            }        } else {            String errorMsg = ContentWorker.prepPermissionErrorMsg(permResults);            return ServiceUtil.returnError(errorMsg);        }        return result;    }    /**     * Update a ContentAssoc service. The work is done in a separate method so that complex services that need this functionality do not need to incur the     * reflection performance penalty.     */    public static Map deactivateContentAssoc(DispatchContext dctx, Map context) {        context.put("entityOperation", "_UPDATE");        List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE");        List contentPurposeList = ContentWorker.prepContentPurposeList(context);        context.put("targetOperationList", targetOperationList);        context.put("contentPurposeList", contentPurposeList);        context.put("skipPermissionCheck", null);        Map result = deactivateContentAssocMethod(dctx, context);        return result;    }    /**     * Update a ContentAssoc method. The work is done in this separate method so that complex services that need this functionality do not need to incur the     * reflection performance penalty.     */    public static Map deactivateContentAssocMethod(DispatchContext dctx, Map context) {        GenericDelegator delegator = dctx.getDelegator();        LocalDispatcher dispatcher = dctx.getDispatcher();        Map result = new HashMap();        context.put("entityOperation", "_UPDATE");        List targetOperationList = ContentWorker.prepTargetOperationList(context, "_UPDATE");        List contentPurposeList = ContentWorker.prepContentPurposeList(context);        context.put("targetOperationList", targetOperationList);        context.put("contentPurposeList", contentPurposeList);        GenericValue pk = delegator.makeValue("ContentAssoc",null);        pk.setAllFields(context, false, null, new Boolean(true));        pk.setAllFields(context, false, "ca", new Boolean(true));        //String contentIdFrom = (String) context.get("contentId");        //String contentIdTo = (String) context.get("contentIdTo");        //String contentId = (String) context.get("contentId");        //String contentAssocTypeId = (String) context.get("contentAssocTypeId");        //Timestamp fromDate = (Timestamp) context.get("fromDate");        GenericValue contentAssoc = null;        try {            //contentAssoc = delegator.findByPrimaryKey("ContentAssoc", UtilMisc.toMap("contentId", contentId, "contentIdTo", contentIdTo, "contentAssocTypeId", contentAssocTypeId, "fromDate", fromDate));            contentAssoc = delegator.findByPrimaryKey("ContentAssoc", pk);        } catch (GenericEntityException e) {            System.out.println("Entity Error:" + e.getMessage());            return ServiceUtil.returnError("Error in retrieving Content. " + e.getMessage());        }        if (contentAssoc == null) {            return ServiceUtil.returnError("Error in deactivating ContentAssoc. Entity is null.");        }        GenericValue userLogin = (GenericValue) context.get("userLogin");        String userLoginId = (String) userLogin.get("userLoginId");        String lastModifiedByUserLogin = userLoginId;        Timestamp lastModifiedDate = UtilDateTime.nowTimestamp();        contentAssoc.put("lastModifiedByUserLogin", lastModifiedByUserLogin);        contentAssoc.put("lastModifiedDate", lastModifiedDate);        contentAssoc.put("thruDate", UtilDateTime.nowTimestamp());        String permissionStatus = null;        Map serviceInMap = new HashMap();        serviceInMap.put("userLogin", context.get("userLogin"));        serviceInMap.put("targetOperationList", targetOperationList);        serviceInMap.put("contentPurposeList", contentPurposeList);        serviceInMap.put("entityOperation", context.get("entityOperation"));        serviceInMap.put("contentIdTo", contentAssoc.get("contentIdTo"));        serviceInMap.put("contentIdFrom", contentAssoc.get("contentId"));        Map permResults = null;        try {            permResults = dispatcher.runSync("checkAssocPermission", serviceInMap);        } catch (GenericServiceException e) {            Debug.logError(e, "Problem checking permissions", "ContentServices");            return ServiceUtil.returnError("Problem checking association permissions");        }        permissionStatus = (String) permResults.get("permissionStatus");        if (permissionStatus != null && permissionStatus.equals("granted")) {            try {                contentAssoc.store();            } catch (GenericEntityException e) {                return ServiceUtil.returnError(e.getMessage());            }        } else {            String errorMsg = ContentWorker.prepPermissionErrorMsg(permResults);            return ServiceUtil.returnError(errorMsg);        }        return result;    }    /**     * Deactivates any active ContentAssoc (except the current one) that is associated with the passed in template/layout contentId and mapKey.     */    public static Map deactivateAssocs(DispatchContext dctx, Map context) {        GenericDelegator delegator = dctx.getDelegator();        String contentIdTo = (String) context.get("contentIdTo");        String mapKey = (String) context.get("mapKey");        String contentAssocTypeId = (String) context.get("contentAssocTypeId");        String activeContentId = (String) context.get("activeContentId");        String contentId = (String) context.get("contentId");        Timestamp fromDate = (Timestamp) context.get("fromDate");        Timestamp nowTimestamp = UtilDateTime.nowTimestamp();        String sequenceNum = null;        Map results = new HashMap();        try {            GenericValue activeAssoc = null;            if (fromDate != null) {

⌨️ 快捷键说明

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