WebOffice 开发文档--code


public class WebOfficeAction extends AuthenticAction {
/**
* 附件在线编辑
*/
protected ActionForward doService(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 获取所在区域ID
String catalogId = request.getParameter("catalogId");
// 获取文档ID
String docId = request.getParameter("docId");
// 获取附件ID
String aid = request.getParameter("aid");

// 校验是否有权限编辑 只有文控员和应用管理员有权限
if (!GenericValidator.isBlankOrNull(catalogId)) {
boolean permission = UserPermHandler.getInstance().hasPermission(
request, catalogId, UserPermHandler.INFO_BPA_CONTROLLER);
if (!permission) {
return mapping.findForward("applyperm");
}
}

if (!GenericValidator.isBlankOrNull(docId)
&& !GenericValidator.isBlankOrNull(aid)) {
try {
DocHandler docHandler = new DocHandler();
// 获取附件信息
AttachmentVO attachment = (AttachmentVO) docHandler
.getAttachment(Integer.parseInt(docId), Integer
.parseInt(aid));

// 从配置文件读取文件的存放路径
String dir = DAOService.getPatterConfigValue("file_document",
"upload_dir");
String uploadPath = dir + File.separator
+ attachment.getImageUrl() + File.separator
+ attachment.getOverview();

// 校验附件是否存在
File file = new File(uploadPath);
if (!file.exists() || !file.isFile()) {
return mapping.findForward("sourceNotFound");
}

String flag = request.getParameter("flag");
// 初始化附件编辑页面
if (!GenericValidator.isBlankOrNull(flag)
&& DocumentConstants.WEB_OFFICE_PAGE_INIT_FLAG
.equals(flag)) {
this.initOnlineEdit(request, response, attachment,
uploadPath);
return null;
}

// 编辑后上传处理
if (!GenericValidator.isBlankOrNull(flag)
&& DocumentConstants.WEB_OFFICE_FILE_SAVE_FLAG
.equals(flag)) {
int res = this.uploadAttachment(request, response,
attachment, dir);
// 返回服务端处理信息
PrintWriter writer = response.getWriter();
String msg = null;
if (res > 0) {
msg = "succeed";
// 记录日志
BPAHandler handler = new BPAHandler();
String reviewLog = "Edit Attachments:"
+ this.getLoginUser(request).getName() + "<br>";
handler.updateDocument(Integer.parseInt(docId),
reviewLog);
} else {
msg = "failed";
}
writer.write(msg);
return null;
}

// 附件名
String fileName = attachment.getOverview();
fileName = fileName.substring(0, fileName.indexOf("."));

request.setAttribute("docId", docId);
request.setAttribute("aid", aid);
request.setAttribute("attachmentName", fileName);
request.setAttribute("attachmentType", attachment.getResType());
} catch (ApplicationException e) {
return mapping.findForward("failure");
} catch (Exception e) {
return mapping.findForward("failure");
}
}
return mapping.findForward("toDealPage");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值