com.wonders.bud.freshmommy.web.content.controller.ContentController.java Source code

Java tutorial

Introduction

Here is the source code for com.wonders.bud.freshmommy.web.content.controller.ContentController.java

Source

/** 
 * 
 * Copyright (c) 1995-2012 Wonders Information Co.,Ltd. 
 * 1518 Lianhang Rd,Shanghai 201112.P.R.C.
 * All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of Wonders Group.
 * (Social Security Department). You shall not disclose such
 * Confidential Information and shall use it only in accordance with 
 * the terms of the license agreement you entered into with Wonders Group. 
 *
 * Distributable under GNU LGPL license by gnu.org
 */

package com.wonders.bud.freshmommy.web.content.controller;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.wonders.bud.framework.common.page.Page;
import com.wonders.bud.framework.common.page.PageUtil;
import com.wonders.bud.framework.common.page.PageVO;
import com.wonders.bud.framework.common.util.FileUtil;
import com.wonders.bud.framework.common.util.QueryParam;
import com.wonders.bud.framework.common.util.RestMsg;
import com.wonders.bud.freshmommy.service.content.model.po.ContentExtPO;
import com.wonders.bud.freshmommy.service.content.model.po.ContentPO;
import com.wonders.bud.freshmommy.service.content.service.ContentService;
import com.wonders.bud.freshmommy.web.content.vo.ContentVO;
import com.wonders.bud.freshmommy.web.utils.Constant;

/**
 * <p>
 * Title: freshmommy_[]_[?]
 * </p>
 * <p>
 * Description: [?Controller]
 * </p>
 * 
 * @author HYH
 * @version $Revision$ 20141124
 * @author (lastest modification by $Author$)
 * @since 20100901
 */

@Controller
@RequestMapping("api/content")
public class ContentController {
    protected Logger log = Logger.getLogger(ContentController.class);

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    private static final String CONTENT_TEMP_FILE = "temps/";// 
    private static final String CONTENT_VE_FILE = "realfiles/";// 

    private static final String CONTENT_TITLE_IMG = "tempimages/cache/titleimgs/";//
    private static final String CONTENT_CONTENT_IMG = "tempimages/cache/imgs/";//
    private static final String[] TARGET_PATH = { "images/content/titleimgs/", "images/content/contentimgs/" };

    @Autowired
    private ContentService contentService;

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141124] Midified by [] []
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Object> addContent(HttpServletRequest request, HttpServletResponse response,
            HttpSession session) {
        RestMsg<Object> rm = new RestMsg<Object>();
        String channelId = request.getParameter("content_channelId");
        String title = request.getParameter("title");
        String shortTitle = request.getParameter("shortTitle");
        String isDisplay = request.getParameter("isDisplay");
        String txt = request.getParameter("txt");
        String priority = request.getParameter("priority");
        String contentImg = request.getParameter("contentImg");
        String titleImg = request.getParameter("titleImg");
        String audio = request.getParameter("audio");
        String video = request.getParameter("video");

        // 
        if (StringUtils.isBlank(title)) {
            rm.errorMsg("?");
        } else {
            try {
                ContentPO po = new ContentPO();

                //?
                if (StringUtils.isNotBlank(contentImg)) {
                    String actionPath = request.getSession().getServletContext().getRealPath("");
                    List<String> paths = ChannelController.moveImg(new String[] { titleImg, contentImg },
                            TARGET_PATH, actionPath);

                    if (paths != null && paths.size() > 0) {
                        po.setContentImg(paths.get(1));
                        po.setTitleImg(paths.get(0));
                    } else {
                        return rm.errorMsg("??");
                    }
                }

                po.setChannelId(Integer.valueOf(channelId));
                po.setTxt(txt);
                po.setTitle(title);
                po.setIsDisplay(Integer.valueOf(isDisplay));
                po.setPriority(Integer.valueOf(priority));
                po.setShortTitle(shortTitle);
                po.setContentImg(po.getContentImg());

                List<ContentExtPO> exts = new ArrayList<ContentExtPO>();
                if (StringUtils.isNotBlank(video) || StringUtils.isNotBlank(audio)) {
                    po.setIsInclude(Constant.IS_INCLUDE);
                    // 
                    String actionPath = request.getSession().getServletContext().getRealPath("");

                    // 
                    ContentExtPO extpo = new ContentExtPO();
                    if (StringUtils.isNotBlank(video)) {
                        extpo = new ContentExtPO();
                        extpo.setType(Constant.TYPE_VIDEO);
                        extpo.setPath(moveFile(video, actionPath));
                        exts.add(extpo);
                    }

                    // 
                    if (StringUtils.isNotBlank(audio)) {
                        extpo = new ContentExtPO();
                        extpo.setType(Constant.TYPE_AUDIO);
                        extpo.setPath(moveFile(audio, actionPath));
                        exts.add(extpo);
                    }

                } else {
                    po.setIsInclude(Constant.IS_NOT_INCLUDE);
                }

                po = contentService.save(po, exts);
                rm.successMsg();
                rm.setMsg("??");
            } catch (Exception e) {
                log.error(e.getLocalizedMessage());
                rm.errorMsg("??");
            }
        }

        return rm;
    }

    /**
     * <p>
     * Description:[?]
     * </p>
     * Created by [HYH] [20141124] Midified by [] []
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    @ResponseBody
    public RestMsg<PageVO<ContentVO>> contentPage(HttpServletRequest request, HttpServletResponse response,
            HttpSession session) {
        RestMsg<PageVO<ContentVO>> rm = new RestMsg<PageVO<ContentVO>>();
        // ???
        String channelId = request.getParameter("content_channelId");
        String title = request.getParameter("title");
        String starttime = request.getParameter("starttime");// 
        String endtime = request.getParameter("endtime");// ?
        String priority = request.getParameter("priority");
        String row = request.getParameter("row");
        String start = request.getParameter("start");
        String sortorder = request.getParameter("sortorder");
        String sortfield = request.getParameter("sortfield");
        String isDisplay = request.getParameter("isDisplay");
        try {
            Page<ContentPO> page = new Page<ContentPO>();
            QueryParam query = new QueryParam();
            // ?
            Map<String, Object> like = new HashMap<String, Object>();
            Map<String, Object> eq = new HashMap<String, Object>();
            if (StringUtils.isNotEmpty(starttime) && StringUtils.isNotEmpty(endtime)) {
                Map<String, Object[]> between = new HashMap<String, Object[]>();
                Object obj[] = new Object[2];
                obj[0] = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(starttime.trim() + " 00:00:00");
                obj[1] = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(endtime.trim() + " 23:59:59");
                between.put("date", obj);
                query.setBetween(between);
            }

            if (StringUtils.isNotBlank(title)) {
                like.put("title", title);
                query.setLike(like);
            }
            if (StringUtils.isNotBlank(priority)) {
                eq.put("priority", Integer.valueOf(priority));
            }
            if (StringUtils.isNotBlank(isDisplay)) {
                eq.put("isDisplay", Integer.valueOf(isDisplay));
            }
            eq.put("channelId", Integer.valueOf(channelId));
            query.setEq(eq);
            page.setParam(query);
            PageUtil.pageSplit(page, start, row, sortorder, sortfield, null);

            // ?
            page = contentService.findByPage(page);

            // povo?
            List<ContentVO> data = new ArrayList<ContentVO>();
            List<ContentPO> list = page.getResult();
            PageVO<ContentVO> pageVo = new PageVO<ContentVO>();
            if (null != list && list.size() > 0) {
                for (ContentPO po : list) {
                    ContentVO vo = new ContentVO();
                    vo.setChannelId(po.getChannelId());
                    vo.setCid(po.getCid());
                    vo.setContentImg(po.getContentImg());
                    vo.setContentType(po.getContentType());
                    vo.setIsDisplay(po.getIsDisplay());
                    vo.setPriority(po.getPriority());
                    vo.setShortTitle(po.getShortTitle());
                    vo.setTxt(po.getTxt());
                    vo.setTitle(po.getTitle());
                    vo.setDate(sdf.format(po.getDate()));
                    data.add(vo);
                }
            }
            pageVo.setData(data);
            PageUtil.pageVOSplit(page, pageVo);
            rm = rm.successMsg();
            rm.setResult(pageVo);
        } catch (Exception e) {
            rm.errorMsg(e.getLocalizedMessage());
            log.error(e.getLocalizedMessage());
        }

        return rm;
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141124] Midified by [] []
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Object> deleteContent(HttpServletRequest request, HttpServletResponse response,
            HttpSession session) {
        RestMsg<Object> rm = new RestMsg<Object>();
        String cid = request.getParameter("cid");
        try {
            contentService.deleteById(cid);
            rm = rm.successMsg();
            rm.setMsg("??");
        } catch (Exception e) {
            rm = rm.errorMsg();
            log.error(e);
            rm.setMsg("?");
        }
        return rm;
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141127] 
     * Midified by [] []
     * 
     * @param request
     * @param response
     * @param session
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Object> updateContent(HttpServletRequest request, HttpServletResponse response,
            HttpSession session) {
        RestMsg<Object> rm = new RestMsg<Object>();
        String cid = request.getParameter("cid");
        String channelId = request.getParameter("content_channelId");
        String txt = request.getParameter("txt");
        String title = request.getParameter("title");
        String isDisplay = request.getParameter("isDisplay");
        String priority = request.getParameter("priority");
        String shortTitle = request.getParameter("shortTitle");
        String titleImg = request.getParameter("titleImg");
        String contentImg = request.getParameter("contentImg");
        String audio = request.getParameter("audio");
        String video = request.getParameter("video");

        // ?
        if (StringUtils.isBlank(title)) {
            rm.errorMsg("?");
            return rm;
        }
        try {
            ContentPO result = contentService.getById(cid);// ?cid?
            //?
            String actionPath = request.getSession().getServletContext().getRealPath("");
            if (!contentImg.equals(result.getContentImg())) {
                if (StringUtils.isNotBlank(contentImg)) {
                    List<String> paths = ChannelController.moveImg(new String[] { titleImg, contentImg },
                            TARGET_PATH, actionPath);

                    if (paths != null && paths.size() > 0) {

                        //?
                        deleteImg(actionPath, result);
                        result.setContentImg(paths.get(1));
                        result.setTitleImg(paths.get(0));
                    } else {
                        rm.errorMsg("??");
                        return rm;
                    }
                } else {

                    //?
                    deleteImg(actionPath, result);
                    result.setContentImg("");
                    result.setTitleImg("");
                }

            }

            result.setChannelId(Integer.valueOf(channelId));
            result.setTxt(txt);
            result.setTitle(title);
            result.setIsDisplay(Integer.valueOf(isDisplay));
            result.setPriority(Integer.valueOf(priority));

            result.setShortTitle(shortTitle);

            List<ContentExtPO> exts = new ArrayList<ContentExtPO>();
            // ????contentExt????
            if (StringUtils.isNotBlank(video) || StringUtils.isNotBlank(audio)) {
                result.setIsInclude(Constant.IS_INCLUDE);

                // 
                if (StringUtils.isNotBlank(video)) {
                    ContentExtPO extpo = new ContentExtPO();
                    extpo.setCid(result.getCid());
                    extpo.setType(Constant.TYPE_VIDEO);
                    extpo.setPath(moveFile(video, actionPath));
                    exts.add(extpo);
                }

                // 
                if (StringUtils.isNotBlank(audio)) {
                    ContentExtPO extpo = new ContentExtPO();
                    extpo.setCid(result.getCid());
                    extpo.setType(Constant.TYPE_AUDIO);
                    extpo.setPath(moveFile(audio, actionPath));
                    exts.add(extpo);
                }

            } else {
                result.setIsInclude(Constant.IS_NOT_INCLUDE);
            }

            contentService.update(result, exts);

            rm.successMsg("??");
        } catch (Exception e) {
            log.error(e.getLocalizedMessage());
            rm.errorMsg("?");
        }
        return rm;
    }

    /**
     * <p>
     * Description:[?]
     * </p>
     * Created by [HYH] [20141127] Midified by [] []
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ResponseBody
    public RestMsg<ContentVO> getById(HttpServletRequest request) {
        RestMsg<ContentVO> rm = new RestMsg<ContentVO>();

        String cid = request.getParameter("cid");

        try {
            if (StringUtils.isBlank(cid)) {
                rm.errorMsg("?id");
                return rm;
            }
            ContentPO po = contentService.getById(cid);
            ContentVO vo = new ContentVO();
            // ?
            List<ContentExtPO> extlist = contentService.getByCid(cid);
            if (null != extlist && extlist.size() > 0) {
                for (ContentExtPO extpo : extlist) {
                    if (extpo.getType().equals(Constant.IS_VIDEO)) {
                        vo.setVideoPath(extpo.getPath());
                    } else if (extpo.getType().equals(Constant.IS_AUDIO)) {
                        vo.setAudioPath(extpo.getPath());
                    }
                }
            }

            vo.setCid(cid);
            vo.setChannelId(po.getChannelId());
            vo.setContentType(po.getContentType());
            vo.setPriority(po.getPriority());
            vo.setTitle(po.getTitle());
            vo.setShortTitle(po.getShortTitle());
            vo.setIsDisplay(po.getIsDisplay());
            vo.setTitleImg(po.getTitleImg());
            vo.setContentImg(po.getContentImg());
            vo.setIsInclude(po.getIsInclude());
            vo.setTxt(po.getTxt());
            rm.successMsg();
            rm.setResult(vo);
        } catch (Exception e) {
            rm.errorMsg(e.getLocalizedMessage());
            log.error(e.getLocalizedMessage());
        }
        return rm;
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141128] Midified by [] []
     * 
     * @param request
     * @param response
     * @param session
     * @return
     * @throws Exception
     * @throws IOException
     */
    @RequestMapping(value = "/video", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<RestMsg<String>> video(HttpServletRequest request, HttpServletResponse response,
            HttpSession session) throws Exception, IOException {

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.TEXT_PLAIN);
        // MultipartHttpRequest
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        // 
        MultipartFile file = multipartRequest.getFile("videofile");
        RestMsg<String> rm = new RestMsg<String>();
        String fileType = file.getContentType();
        if (fileType.toLowerCase().indexOf("video") < 0) {
            rm = rm.errorMsg();
            rm.setMsg("??");
            return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
        }
        // ??
        String filename = file.getOriginalFilename();
        String[] temp1 = filename.split("\\.");
        String extenName = temp1[temp1.length - 1];
        StringBuffer fileNameBuffer = new StringBuffer();
        fileNameBuffer.append(UUID.randomUUID()).append(".").append(extenName);

        InputStream input = file.getInputStream();
        String actionPath = request.getSession().getServletContext().getRealPath("");
        String path = actionPath + File.separator + CONTENT_TEMP_FILE;
        File savePath = new File(path);
        if (!savePath.exists()) { // 
            savePath.mkdir();
        }
        FileUtil.SaveFileFromInputStream(input, savePath.toString(), fileNameBuffer.toString());
        String filePath = "temps/" + fileNameBuffer;
        rm = rm.successMsg();
        rm.setResult(filePath);
        return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
    }

    /**
     * audiofile
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141128] Midified by [] []
     * 
     * @param request
     * @param response
     * @param session
     * @return
     * @throws Exception
     * @throws IOException
     */
    @RequestMapping(value = "/audio", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<RestMsg<String>> audio(HttpServletRequest request, HttpServletResponse response,
            HttpSession session) throws Exception, IOException {

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.TEXT_PLAIN);
        // MultipartHttpRequest
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        // 
        MultipartFile file = multipartRequest.getFile("audiofile");
        RestMsg<String> rm = new RestMsg<String>();
        String fileType = file.getContentType();
        if ((fileType.toLowerCase().indexOf("audio") < 0)) {
            rm = rm.errorMsg();
            rm.setMsg("??");
            return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
        }
        // ??
        String filename = file.getOriginalFilename();
        String[] temp1 = filename.split("\\.");
        String extenName = temp1[temp1.length - 1];
        StringBuffer fileNameBuffer = new StringBuffer();
        fileNameBuffer.append(UUID.randomUUID()).append(".").append(extenName);

        InputStream input = file.getInputStream();
        String actionPath = request.getSession().getServletContext().getRealPath("");
        String path = actionPath + File.separator + CONTENT_TEMP_FILE;
        File savePath = new File(path);
        if (!savePath.exists()) { // 
            savePath.mkdir();
        }
        FileUtil.SaveFileFromInputStream(input, savePath.toString(), fileNameBuffer.toString());
        String filePath = "temps/" + fileNameBuffer;
        rm = rm.successMsg();
        rm.setResult(filePath);
        return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141128] Midified by [] []
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/deleteVideo", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Object> deleteVideo(HttpServletRequest request) {
        RestMsg<Object> rm = new RestMsg<Object>();

        String filepath = request.getParameter("filepath");
        try {

            String actionPath = request.getSession().getServletContext().getRealPath("");
            // 
            FileUtil.deleteFiles(actionPath, filepath);
            rm.successMsg();
        } catch (Exception e) {
            log.error(e.getLocalizedMessage());
            rm.errorMsg("?");
        }
        return rm;
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141128] Midified by [] []
     * 
     * @param request
     * @return
     */
    @RequestMapping(value = "/deleteAudio", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Object> deleteAudio(HttpServletRequest request) {
        RestMsg<Object> rm = new RestMsg<Object>();

        String filepath = request.getParameter("filepath");
        try {

            String actionPath = request.getSession().getServletContext().getRealPath("");
            // 
            FileUtil.deleteFiles(actionPath, filepath);
            rm.successMsg();
        } catch (Exception e) {
            log.error(e.getLocalizedMessage());
            rm.errorMsg("?");
        }
        return rm;
    }

    /**
     * <p>
     * Description:[?]
     * </p>
     * 
     * Created by [Dy] [20141124]
     * Midified by [] []
     * @param request
     * @param response
     * @param session
     * @return
     * @throws Exception
     * @throws IOException
     */
    @RequestMapping(value = "/addImg", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Map<String, String>> addImg(HttpServletRequest request) throws Exception, IOException {

        RestMsg<Map<String, String>> rm = new RestMsg<Map<String, String>>();
        try {
            // MultipartHttpRequest
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            // 
            MultipartFile file = multipartRequest.getFile("imgfile");

            if (file.getContentType().toLowerCase().indexOf("image") < 0) {
                rm = rm.errorMsg("??");
            } else {

                // ??
                String actionPath = request.getSession().getServletContext().getRealPath("");
                String uuid = UUID.randomUUID().toString();
                //
                StringBuffer fileName = new StringBuffer();
                fileName.append(actionPath).append(File.separator).append(CONTENT_CONTENT_IMG).append(uuid)
                        .append(".png");
                //
                StringBuffer minFileName = new StringBuffer();
                minFileName.append(actionPath).append(File.separator).append(CONTENT_TITLE_IMG).append(uuid)
                        .append(".png");

                File imgFolder = new File(fileName.toString());
                if (!imgFolder.getParentFile().exists()) { // 
                    imgFolder.getParentFile().mkdirs();
                }

                File minImgFolder = new File(minFileName.toString());
                if (!minImgFolder.getParentFile().exists()) { // 
                    minImgFolder.getParentFile().mkdirs();
                }

                //
                BufferedImage sourceImg = ImageIO.read(file.getInputStream());
                float heigth = sourceImg.getHeight();
                float width = sourceImg.getWidth();
                double scale = 1;
                double sH = heigth / 150;
                double sW = width / 150;
                scale = sH < sW ? sH : sW;
                int rheigth = new Double(scale * 200).intValue();
                int rwidth = new Double(scale * 200).intValue();

                //?

                Thumbnails.of(file.getInputStream()).scale(1).toFile(fileName.toString());
                Thumbnails.of(file.getInputStream()).sourceRegion(Positions.CENTER, rwidth, rheigth).size(200, 200)
                        .keepAspectRatio(false).toFile(minFileName.toString());

                Map<String, String> map = new HashMap<String, String>();
                map.put("titleImg", CONTENT_TITLE_IMG + uuid + ".png");
                map.put("contentImg", CONTENT_CONTENT_IMG + uuid + ".png");
                rm = rm.successMsg();
                rm.setResult(map);
            }
        } catch (Exception e) {
            log.error(e.getLocalizedMessage());
            rm.errorMsg("?");
        }
        return rm;
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * 
     * Created by [Dy] [20141124]
     * Midified by [] []
     * @param request
     * @return
     */
    @RequestMapping(value = "/deleteImg", method = RequestMethod.POST)
    @ResponseBody
    public RestMsg<Object> deleteImg(HttpServletRequest request) {
        RestMsg<Object> rm = new RestMsg<Object>();

        String contentImg = request.getParameter("contentImg");
        String titleImg = request.getParameter("titleImg");
        try {

            String actionPath = request.getSession().getServletContext().getRealPath("");
            //
            FileUtil.deleteFiles(actionPath, contentImg);
            FileUtil.deleteFiles(actionPath, titleImg);
            rm.successMsg();
        } catch (Exception e) {
            log.error(e.getLocalizedMessage());
            rm.errorMsg("?");
        }
        return rm;
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * 
     * Created by [Dy] [20141127]
     * Midified by [] []
     * @param actionPath 
     * @param channel 
     */
    private void deleteImg(String actionPath, ContentPO content) {
        //?
        if (StringUtils.isNotBlank(content.getContentImg())) {
            FileUtil.deleteFiles(actionPath, content.getContentImg());
        }
        if (StringUtils.isNotBlank(content.getTitleImg())) {
            FileUtil.deleteFiles(actionPath, content.getTitleImg());
        }
    }

    /**
     * <p>
     * Description:[]
     * </p>
     * Created by [HYH] [20141124] Midified by [] []
     * 
     * @param path ?
     * @param actionPath 
     * @return 
     */
    private String moveFile(String path, String actionPath) throws Exception {
        try {

            if (path.startsWith(CONTENT_TEMP_FILE)) {
                // 
                StringBuffer realFileBuffer = new StringBuffer();
                realFileBuffer.append(actionPath).append(File.separator).append(CONTENT_VE_FILE);
                File savePath = new File(realFileBuffer.toString());
                if (!savePath.exists()) { // 
                    savePath.mkdir();
                }

                // ???
                StringBuffer oldFileBuffer = new StringBuffer();
                oldFileBuffer.append(actionPath).append(File.separator).append(path);
                File oldFile = new File(oldFileBuffer.toString());
                // ??
                String filename = oldFile.getName();
                FileUtil.SaveFileFromInputStream(new FileInputStream(oldFile), savePath.toString(), filename);
                // 
                if (oldFile.isFile() && oldFile.exists()) {
                    oldFile.delete();
                }

                // ?
                StringBuffer realPath = new StringBuffer();
                realPath.append(CONTENT_VE_FILE).append(filename);
                return realPath.toString();
            } else {
                return path;
            }

        } catch (Exception e) {
            throw e;
        }
    }
}