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

📄 editcategory.bsh

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 BSH
字号:
/* *  Copyright (c) 2003 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. * *@author     David E. Jones *@author     Brad Steiner *@version    $Rev: 5462 $ *@since      2.2 */import org.ofbiz.base.util.*;import org.ofbiz.base.util.string.*;import org.ofbiz.entity.*;productCategoryType = null;if (productCategory != null) {    productCategoryType = productCategory.getRelatedOne("ProductCategoryType");    context.put("productCategoryType", productCategoryType);}primaryParentCategory = null;primParentCatIdParam = request.getParameter("primaryParentCategoryId");if(productCategory != null) {    primaryParentCategory = productCategory.getRelatedOne("PrimaryParentProductCategory");} else if (primParentCatIdParam != null && primParentCatIdParam.length() > 0) {    primaryParentCategory = delegator.findByPrimaryKey("ProductCategory", UtilMisc.toMap("productCategoryId", primParentCatIdParam));}context.put("primaryParentCategory", primaryParentCategory);// make the image file formatsString imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format");String imageServerPath = UtilProperties.getPropertyValue("catalog", "image.server.path");String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix");context.put("imageFilenameFormat", imageFilenameFormat);context.put("imageServerPath", imageServerPath);context.put("imageUrlPrefix", imageUrlPrefix);FlexibleStringExpander filenameExpander = new FlexibleStringExpander(imageFilenameFormat);context.put("imageNameCategory", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("location","categories", "type", "category", "id", productCategoryId)));context.put("imageNameLinkOne", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("location","categories", "type", "linkOne", "id", productCategoryId)));context.put("imageNameLinkTwo", imageUrlPrefix + "/" + filenameExpander.expandString(UtilMisc.toMap("location","categories", "type", "linkTwo", "id", productCategoryId)));// UPLOADING STUFFObject forLock = new Object();String contentType = null;String fileType = request.getParameter("upload_file_type");if (fileType != null) {    context.put("fileType", fileType);    String fileLocation = filenameExpander.expandString(UtilMisc.toMap("location", "categories", "type", fileType, "id", productCategoryId));    String filePathPrefix = "";    String filenameToUse = fileLocation;    if (fileLocation.lastIndexOf("/") != -1) {        filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash        filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1);    }    int i1;    if (contentType != null && (i1 = contentType.indexOf("boundary=")) != -1) {        contentType = contentType.substring(i1 + 9);        contentType = "--" + contentType;    }    String defaultFileName = filenameToUse + "_temp";    HttpRequestFileUpload uploadObject = new HttpRequestFileUpload();    uploadObject.setOverrideFilename(defaultFileName);    uploadObject.setSavePath(imageServerPath + "/" + filePathPrefix);    uploadObject.doUpload(request);    String clientFileName = uploadObject.getFilename();    if (clientFileName != null) context.put("clientFileName", clientFileName);    if (clientFileName != null && clientFileName.length() > 0) {        if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) {            filenameToUse += clientFileName.substring(clientFileName.lastIndexOf("."));        } else {            filenameToUse += ".jpg";        }        context.put("clientFileName", clientFileName);        context.put("filenameToUse", filenameToUse);        String characterEncoding = request.getCharacterEncoding();        String imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding);        try {            File file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName);            File file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse);            try {                file1.delete();            } catch(Exception e) {                System.out.println("error deleting existing file (not neccessarily a problem)");            }            file.renameTo(file1);        } catch(Exception e) {            e.printStackTrace();        }        if (imageUrl != null && imageUrl.length() > 0) {            context.put("imageUrl", imageUrl);            productCategory.set(fileType + "ImageUrl", imageUrl);            productCategory.store();        }    }}

⌨️ 快捷键说明

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