APP下载及路径过滤。
This commit is contained in:
parent
2b7e7ec24b
commit
bd42a5cd7d
@ -41,7 +41,7 @@
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ExcludedURLs</param-name>
|
||||
<param-value>^/.*Logon.jsp,^/.*SaveGraphAjax.jsp</param-value>
|
||||
<param-value>^/.*Logon.jsp,^/.*SaveGraphAjax.jsp,^/.*appDownload.jsp</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
|
||||
@ -1,84 +1,84 @@
|
||||
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="gb2312" />
|
||||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width,height=device-height">
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<meta http-equiv="Cache-Control" content="no-transform" />
|
||||
<title>App应用下载</title>
|
||||
<meta name="keywords" content="" />
|
||||
<meta name="description" content="" />
|
||||
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.11.0.min.js"></script>
|
||||
<style type="text/css">
|
||||
#weixin-tip{display:none;position:fixed;left:0;top:0;background:rgba(0,0,0,0.8);filter:alpha(opacity=80);width:100%;height:100%;z-index:100;}
|
||||
#weixin-tip p{text-align:center;margin-top:10%;padding:0 5%;position:relative;}
|
||||
#weixin-tip .close{color:#fff;padding:5px;font:bold 20px/24px simsun;text-shadow:0 1px 0 #ddd;position:absolute;top:0;left:5%;}
|
||||
.butonpanle{width: 100%;margin-top:10%; height: 20%}
|
||||
.android-btn{width:80%;height: 30%;padding-top: 2%;padding-bottom: 3%;border:0.5;background-color: #8DB6CD;color:white;fount-size:16;display: block;margin: 0 auto;}
|
||||
img{display: block;margin: 0 auto;}
|
||||
#tips{margin: 0 auto;width: 100%;color:red; white-space: pre-wrap; text-align: center;}
|
||||
</style>
|
||||
</head>
|
||||
<%
|
||||
String devType="android";
|
||||
String userAgent = request.getHeader("user-agent");
|
||||
if(userAgent.toLowerCase().indexOf("iphone")>=0){
|
||||
devType="ios";
|
||||
}
|
||||
%>
|
||||
<body style="background-color: #F4F4F4;width: 100%">
|
||||
<div id="img-content">
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<img src="${pageContext.request.contextPath}/AppMain/Logon/appDownloadLogo.png"/>
|
||||
<div class="butonpanle">
|
||||
<button id="J_weixin" class="android-btn">
|
||||
<labe>下载安装</label>
|
||||
</button>
|
||||
</div>
|
||||
<br/>
|
||||
<label id="tips"></label>
|
||||
</div>
|
||||
<div id="weixin-tip">
|
||||
<p><img src="${pageContext.request.contextPath}/AppMain/AppLogo/down_wx_t.png" alt="微信扫描打开APP下载链接提示代码优化" alt="微信打开"/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
var is_weixin = (function(){
|
||||
return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
|
||||
}
|
||||
)();
|
||||
window.onload = function() {
|
||||
var winHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight; //兼容IOS,不需要的可以去掉
|
||||
var btn = document.getElementById('J_weixin');
|
||||
var Testbtn = document.getElementById('J_Test');
|
||||
var tip = document.getElementById('weixin-tip');
|
||||
var close = document.getElementById('close');
|
||||
var show = function(){
|
||||
tip.style.height = winHeight + 'px'; //兼容IOS弹窗整屏
|
||||
tip.style.display = 'block';
|
||||
return false;
|
||||
};
|
||||
tip.onclick = function() {
|
||||
tip.style.display = 'none';
|
||||
};
|
||||
btn.onclick = function(e) {
|
||||
if(is_weixin){
|
||||
show();
|
||||
}else{
|
||||
<%if("android".equalsIgnoreCase(devType)){%>
|
||||
location.href="${pageContext.request.contextPath}/webapi/resf/files/downloadApp?devType=<%=devType%>";
|
||||
<%}else{%>
|
||||
/* location.href="itms-services:///?action=download-manifest&url=http://139.196.252.5:9090/maotai/webapi/resf/files/downloadPlist"; */
|
||||
<%}%>
|
||||
setTimeout(function(){
|
||||
$("#tips").html("");
|
||||
},1000)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
<%@ page contentType="text/html; charset=GBK"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="gb2312" />
|
||||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width,height=device-height">
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<meta http-equiv="Cache-Control" content="no-transform" />
|
||||
<title>App应用下载</title>
|
||||
<meta name="keywords" content="" />
|
||||
<meta name="description" content="" />
|
||||
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.11.0.min.js"></script>
|
||||
<style type="text/css">
|
||||
#weixin-tip{display:none;position:fixed;left:0;top:0;background:rgba(0,0,0,0.8);filter:alpha(opacity=80);width:100%;height:100%;z-index:100;}
|
||||
#weixin-tip p{text-align:center;margin-top:10%;padding:0 5%;position:relative;}
|
||||
#weixin-tip .close{color:#fff;padding:5px;font:bold 20px/24px simsun;text-shadow:0 1px 0 #ddd;position:absolute;top:0;left:5%;}
|
||||
.butonpanle{width: 100%;margin-top:10%; height: 20%}
|
||||
.android-btn{width:80%;height: 30%;padding-top: 2%;padding-bottom: 3%;border:0.5;background-color: #8DB6CD;color:white;fount-size:16;display: block;margin: 0 auto;}
|
||||
img{display: block;margin: 0 auto;}
|
||||
#tips{margin: 0 auto;width: 100%;color:red; white-space: pre-wrap; text-align: center;}
|
||||
</style>
|
||||
</head>
|
||||
<%
|
||||
String devType="android";
|
||||
String userAgent = request.getHeader("user-agent");
|
||||
if(userAgent.toLowerCase().indexOf("iphone")>=0){
|
||||
devType="ios";
|
||||
}
|
||||
%>
|
||||
<body style="background-color: #F4F4F4;width: 100%">
|
||||
<div id="img-content">
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<img src="${pageContext.request.contextPath}/AppMain/Logon/logo_amarsoft.png"/>
|
||||
<div class="butonpanle">
|
||||
<button id="J_weixin" class="android-btn">
|
||||
<labe>下载安装</label>
|
||||
</button>
|
||||
</div>
|
||||
<br/>
|
||||
<label id="tips"></label>
|
||||
</div>
|
||||
<div id="weixin-tip">
|
||||
<p><img src="${pageContext.request.contextPath}/AppMain/AppLogo/down_wx_t.png" alt="微信扫描打开APP下载链接提示代码优化" alt="微信打开"/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
var is_weixin = (function(){
|
||||
return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
|
||||
}
|
||||
)();
|
||||
window.onload = function() {
|
||||
var winHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight; //兼容IOS,不需要的可以去掉
|
||||
var btn = document.getElementById('J_weixin');
|
||||
var Testbtn = document.getElementById('J_Test');
|
||||
var tip = document.getElementById('weixin-tip');
|
||||
var close = document.getElementById('close');
|
||||
var show = function(){
|
||||
tip.style.height = winHeight + 'px'; //兼容IOS弹窗整屏
|
||||
tip.style.display = 'block';
|
||||
return false;
|
||||
};
|
||||
tip.onclick = function() {
|
||||
tip.style.display = 'none';
|
||||
};
|
||||
btn.onclick = function(e) {
|
||||
if(is_weixin){
|
||||
show();
|
||||
}else{
|
||||
<%if("android".equalsIgnoreCase(devType)){%>
|
||||
location.href="${pageContext.request.contextPath}/webapi/resf/files/downloadApp?devType=<%=devType%>";
|
||||
<%}else{%>
|
||||
/* location.href="itms-services:///?action=download-manifest&url=http://139.196.252.5:9090/maotai/webapi/resf/files/downloadPlist"; */
|
||||
<%}%>
|
||||
setTimeout(function(){
|
||||
$("#tips").html("");
|
||||
},1000)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -1,159 +1,159 @@
|
||||
//package apx.com.amarsoft.als.doc.controller;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.FileInputStream;
|
||||
//import java.io.InputStream;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import javax.ws.rs.GET;
|
||||
//import javax.ws.rs.Path;
|
||||
//import javax.ws.rs.core.Context;
|
||||
//
|
||||
//import org.apache.commons.io.FileUtils;
|
||||
//
|
||||
//import com.amarsoft.are.ARE;
|
||||
//import com.amarsoft.are.jbo.BizObject;
|
||||
//import com.amarsoft.are.jbo.JBOFactory;
|
||||
//import com.amarsoft.are.jbo.JBOTransaction;
|
||||
//import com.amarsoft.awe.util.Transaction;
|
||||
//import com.base.constant.RestfullConstant;
|
||||
//import com.base.helper.AppHelper;
|
||||
//import com.base.util.DownloadAttUtil;
|
||||
//import com.base.util.ReturnMapUtil;
|
||||
//
|
||||
//import apx.com.amarsoft.als.doc.AppAtt;
|
||||
//import apx.com.amarsoft.als.doc.service.DocManageService;
|
||||
//
|
||||
//@Path("/files")
|
||||
//public class DocManageController {
|
||||
// DocManageService service = new DocManageService();
|
||||
//
|
||||
// @Path("/down/docById")
|
||||
// @GET
|
||||
// public AppAtt attachmentDownloadById(@Context HttpServletRequest request,
|
||||
// @Context HttpServletResponse response) throws Exception {
|
||||
// String sId = request.getParameter("id");
|
||||
// return service.attachmentDownloadById(sId, request, response);
|
||||
// }
|
||||
//
|
||||
// @Path("/remove/docById")
|
||||
// @GET
|
||||
// public Map<String, Object> removeDocById(
|
||||
// @Context HttpServletRequest request,
|
||||
// @Context HttpServletResponse response, @Context Transaction sqlca,
|
||||
// JBOTransaction tx) throws Exception {
|
||||
// ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca);
|
||||
// try {
|
||||
// String sId = request.getParameter("id");
|
||||
//
|
||||
// if (service.removeDocById(sId, tx)) {
|
||||
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
// .get("SUCCESS").toString(), "文件移除成功!");
|
||||
// } else {
|
||||
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
// .get("FAIL").toString(), "文件移除失败!");
|
||||
// }
|
||||
// return ReturnMapUtil.getReturnMap();
|
||||
// } catch (Exception e) {
|
||||
// return ReturnMapUtil.rollback(e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Path("/downloadPlist")
|
||||
// @GET
|
||||
// public void downloadPlist(@Context HttpServletResponse response,
|
||||
// @Context HttpServletRequest request) throws Exception {
|
||||
// String sFileName = "ios-com.ceb-fl.eleasing-app.plist";
|
||||
// String sPath = request.getSession().getServletContext().getRealPath("/")
|
||||
// + "/plist/" + sFileName;
|
||||
// ARE.getLog().debug("文件名:" + sFileName);
|
||||
// ARE.getLog().debug("路径:" + sPath);
|
||||
// DownloadAttUtil.setCharset(response, null);
|
||||
// try {
|
||||
// DownloadAttUtil.downloadAppIOS(sFileName, sPath, response);
|
||||
// } catch (Exception e) {
|
||||
// String contextPath = request.getContextPath();
|
||||
// response.setHeader("Refresh", "1;url=" + contextPath + "/404.html");
|
||||
// ARE.getLog().error("app应用下载失败", e);
|
||||
// throw new Exception("------Timeout------");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Path("/downloadAppById")
|
||||
// @GET
|
||||
// public void downloadAppApplication(@Context HttpServletRequest request,
|
||||
// @Context HttpServletResponse response, @Context Transaction sqlca)
|
||||
// throws Exception {
|
||||
// String id = request.getParameter("id");
|
||||
// String path = "";
|
||||
// String fileName = "";
|
||||
// String sql = "SELECT O.IMAGE_PATH, O.FILE_NAME "
|
||||
// + "FROM O WHERE 1=1 AND id=" + "'" + id + "'";
|
||||
// List<BizObject> bolist = JBOFactory.getFactory()
|
||||
// .getManager("jbo.app.APP_VERSION").createQuery(sql)
|
||||
// .getResultList(false);
|
||||
// if (bolist != null && bolist.size() > 0) {
|
||||
// BizObject bo = bolist.get(0);
|
||||
// path = bo.getAttribute("IMAGE_PATH") == null ? "" : bo
|
||||
// .getAttribute("IMAGE_PATH").toString().trim();
|
||||
// fileName = bo.getAttribute("FILE_NAME") == null ? "" : bo
|
||||
// .getAttribute("FILE_NAME").toString().trim();
|
||||
// }
|
||||
// // fileName = URLEncoder.encode(fileName, "GBK");
|
||||
// fileName = new String(fileName.getBytes(), "ISO-8859-1");
|
||||
// response.reset();
|
||||
// response.setHeader("Content-disposition", "attachment; filename="
|
||||
// + fileName);
|
||||
// response.setContentType("text/html; charset=UTF-8");
|
||||
// File file = new File(path);
|
||||
// response.setContentLength((int) file.length());
|
||||
//
|
||||
// try (InputStream in = new FileInputStream(path)) {
|
||||
// FileUtils.copyFile(new File(path), response.getOutputStream());
|
||||
// } catch (Exception e) {
|
||||
// ARE.getLog().error("app应用下载失败", e);
|
||||
// ARE.getLog().error("------Timeout------");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Path("/downloadApp")
|
||||
// @GET
|
||||
// public void downloadFileApp(@Context HttpServletRequest request,
|
||||
// @Context HttpServletResponse response, @Context Transaction sqlca)
|
||||
// throws Exception {
|
||||
// String sDevType = request.getParameter("devType");
|
||||
// sDevType = request.getParameter("devType") == null ? "ios"
|
||||
// : request.getParameter("devType").toString();
|
||||
// String userAgent = request.getHeader("user-agent");
|
||||
// if (null != userAgent) {
|
||||
// if (userAgent.toLowerCase().indexOf("iphone") >= 0) {
|
||||
// sDevType = "ios";
|
||||
// } else {
|
||||
// sDevType = "android";
|
||||
// }
|
||||
// }
|
||||
// Map<String, Object> appMap = AppHelper.getNewVersionByPhoneType(sDevType);
|
||||
// String sFileName = "";
|
||||
// String sPath = "";
|
||||
// if (null != appMap) {
|
||||
// sFileName = appMap.get("FILE_NAME".toLowerCase()) == null ? "" : appMap.get("FILE_NAME".toLowerCase()).toString();
|
||||
// sPath = appMap.get("IMAGE_PATH".toLowerCase()) == null ? "" : appMap.get("IMAGE_PATH".toLowerCase()).toString();
|
||||
// }
|
||||
// ARE.getLog().debug("文件名:" + sFileName);
|
||||
// ARE.getLog().debug("路径:" + sPath);
|
||||
// DownloadAttUtil.setCharset(response, null);
|
||||
// try {
|
||||
// DownloadAttUtil.downloadAppAndroid(sFileName, sPath, response);
|
||||
// } catch (Exception e) {
|
||||
// String contextPath = request.getContextPath();
|
||||
// response.setHeader("Refresh", "1;url=" + contextPath + "/404.html");
|
||||
// ARE.getLog().error("app应用下载失败", e);
|
||||
// throw new Exception("------Timeout------");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package apx.com.amarsoft.als.doc.controller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import com.amarsoft.are.ARE;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.base.constant.RestfullConstant;
|
||||
import com.base.helper.AppHelper;
|
||||
import com.base.util.DownloadAttUtil;
|
||||
import com.base.util.ReturnMapUtil;
|
||||
|
||||
import apx.com.amarsoft.als.doc.AppAtt;
|
||||
import apx.com.amarsoft.als.doc.service.DocManageService;
|
||||
|
||||
@Path("/files")
|
||||
public class DocManageController {
|
||||
DocManageService service = new DocManageService();
|
||||
|
||||
@Path("/down/docById")
|
||||
@GET
|
||||
public AppAtt attachmentDownloadById(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response) throws Exception {
|
||||
String sId = request.getParameter("id");
|
||||
return service.attachmentDownloadById(sId, request, response);
|
||||
}
|
||||
|
||||
// @Path("/remove/docById")
|
||||
// @GET
|
||||
// public Map<String, Object> removeDocById(
|
||||
// @Context HttpServletRequest request,
|
||||
// @Context HttpServletResponse response, @Context Transaction sqlca,
|
||||
// JBOTransaction tx) throws Exception {
|
||||
// ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca);
|
||||
// try {
|
||||
// String sId = request.getParameter("id");
|
||||
//
|
||||
// if (service.removeDocById(sId, tx)) {
|
||||
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
// .get("SUCCESS").toString(), "文件移除成功!");
|
||||
// } else {
|
||||
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
|
||||
// .get("FAIL").toString(), "文件移除失败!");
|
||||
// }
|
||||
// return ReturnMapUtil.getReturnMap();
|
||||
// } catch (Exception e) {
|
||||
// return ReturnMapUtil.rollback(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Path("/downloadPlist")
|
||||
@GET
|
||||
public void downloadPlist(@Context HttpServletResponse response,
|
||||
@Context HttpServletRequest request) throws Exception {
|
||||
String sFileName = "ios-com.ceb-fl.eleasing-app.plist";
|
||||
String sPath = request.getSession().getServletContext().getRealPath("/")
|
||||
+ "/plist/" + sFileName;
|
||||
ARE.getLog().debug("文件名:" + sFileName);
|
||||
ARE.getLog().debug("路径:" + sPath);
|
||||
DownloadAttUtil.setCharset(response, null);
|
||||
try {
|
||||
DownloadAttUtil.downloadAppIOS(sFileName, sPath, response);
|
||||
} catch (Exception e) {
|
||||
String contextPath = request.getContextPath();
|
||||
response.setHeader("Refresh", "1;url=" + contextPath + "/404.html");
|
||||
ARE.getLog().error("app应用下载失败", e);
|
||||
throw new Exception("------Timeout------");
|
||||
}
|
||||
}
|
||||
|
||||
@Path("/downloadAppById")
|
||||
@GET
|
||||
public void downloadAppApplication(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response, @Context Transaction sqlca)
|
||||
throws Exception {
|
||||
String id = request.getParameter("id");
|
||||
String path = "";
|
||||
String fileName = "";
|
||||
String sql = "SELECT O.IMAGE_PATH, O.FILE_NAME "
|
||||
+ "FROM O WHERE 1=1 AND id=" + "'" + id + "'";
|
||||
List<BizObject> bolist = JBOFactory.getFactory()
|
||||
.getManager("jbo.app.APP_VERSION").createQuery(sql)
|
||||
.getResultList(false);
|
||||
if (bolist != null && bolist.size() > 0) {
|
||||
BizObject bo = bolist.get(0);
|
||||
path = bo.getAttribute("IMAGE_PATH") == null ? "" : bo
|
||||
.getAttribute("IMAGE_PATH").toString().trim();
|
||||
fileName = bo.getAttribute("FILE_NAME") == null ? "" : bo
|
||||
.getAttribute("FILE_NAME").toString().trim();
|
||||
}
|
||||
// fileName = URLEncoder.encode(fileName, "GBK");
|
||||
fileName = new String(fileName.getBytes(), "ISO-8859-1");
|
||||
response.reset();
|
||||
response.setHeader("Content-disposition", "attachment; filename="
|
||||
+ fileName);
|
||||
response.setContentType("text/html; charset=UTF-8");
|
||||
File file = new File(path);
|
||||
response.setContentLength((int) file.length());
|
||||
|
||||
try (InputStream in = new FileInputStream(path)) {
|
||||
FileUtils.copyFile(new File(path), response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
ARE.getLog().error("app应用下载失败", e);
|
||||
ARE.getLog().error("------Timeout------");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Path("/downloadApp")
|
||||
@GET
|
||||
public void downloadFileApp(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response, @Context Transaction sqlca)
|
||||
throws Exception {
|
||||
String sDevType = request.getParameter("devType");
|
||||
sDevType = request.getParameter("devType") == null ? "ios"
|
||||
: request.getParameter("devType").toString();
|
||||
String userAgent = request.getHeader("user-agent");
|
||||
if (null != userAgent) {
|
||||
if (userAgent.toLowerCase().indexOf("iphone") >= 0) {
|
||||
sDevType = "ios";
|
||||
} else {
|
||||
sDevType = "android";
|
||||
}
|
||||
}
|
||||
Map<String, Object> appMap = AppHelper.getNewVersionByPhoneType(sDevType);
|
||||
String sFileName = "";
|
||||
String sPath = "";
|
||||
if (null != appMap) {
|
||||
sFileName = appMap.get("FILE_NAME".toLowerCase()) == null ? "" : appMap.get("FILE_NAME".toLowerCase()).toString();
|
||||
sPath = appMap.get("IMAGE_PATH".toLowerCase()) == null ? "" : appMap.get("IMAGE_PATH".toLowerCase()).toString();
|
||||
}
|
||||
ARE.getLog().debug("文件名:" + sFileName);
|
||||
ARE.getLog().debug("路径:" + sPath);
|
||||
DownloadAttUtil.setCharset(response, null);
|
||||
try {
|
||||
DownloadAttUtil.downloadAppAndroid(sFileName, sPath, response);
|
||||
} catch (Exception e) {
|
||||
String contextPath = request.getContextPath();
|
||||
response.setHeader("Refresh", "1;url=" + contextPath + "/404.html");
|
||||
ARE.getLog().error("app应用下载失败", e);
|
||||
throw new Exception("------Timeout------");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,85 +1,85 @@
|
||||
//package apx.com.amarsoft.als.doc.service;
|
||||
//
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import javax.ws.rs.core.Context;
|
||||
//
|
||||
//import jbo.app.tenwa.doc.DOC_ATTRIBUTE;
|
||||
//import apx.com.amarsoft.als.doc.AppAtt;
|
||||
//
|
||||
//import com.amarsoft.are.ARE;
|
||||
//import com.amarsoft.are.jbo.BizObject;
|
||||
//import com.amarsoft.are.jbo.BizObjectManager;
|
||||
//import com.amarsoft.are.jbo.JBOFactory;
|
||||
//import com.amarsoft.are.jbo.JBOTransaction;
|
||||
//import com.base.helper.LBDocHelper;
|
||||
//import com.base.util.DownloadAttUtil;
|
||||
//
|
||||
//public class DocManageService {
|
||||
// public AppAtt attachmentDownloadById(String sId,
|
||||
// @Context HttpServletRequest request,
|
||||
// @Context HttpServletResponse response) throws Exception {
|
||||
// DownloadAttUtil.setCharset(response, null);
|
||||
// // LB_DOCATTRIBUTE >. ID
|
||||
// String sDevType = request.getParameter("devType") == null ? "ios"
|
||||
// : request.getParameter("devType").toString();
|
||||
// String userAgent = request.getHeader("user-agent");
|
||||
// if (null != userAgent) {
|
||||
// if (userAgent.toLowerCase().indexOf("iphone") >= 0) {
|
||||
// sDevType = "ios";
|
||||
// } else {
|
||||
// sDevType = "android";
|
||||
// }
|
||||
// }
|
||||
// Map<String, Object> lbDocMap = LBDocHelper.getDocById2(sId);
|
||||
// if (null != lbDocMap) {
|
||||
// String sFileName = lbDocMap.get("FILENAME".toLowerCase()) == null ? ""
|
||||
// : lbDocMap.get("FILENAME".toLowerCase()).toString();
|
||||
// String sFilePath = lbDocMap.get("FILEPATH".toLowerCase()) == null ? ""
|
||||
// : lbDocMap.get("FILEPATH".toLowerCase()).toString();
|
||||
// String sFileSize = lbDocMap.get("CONTENTLENGTH".toLowerCase()) == null ? ""
|
||||
// : lbDocMap.get("CONTENTLENGTH".toLowerCase()).toString();
|
||||
//
|
||||
// try {
|
||||
// DownloadAttUtil.downloadAtt(sFileName, sFilePath, sFileSize,
|
||||
// response, request, sDevType);
|
||||
// } catch (Exception e) {
|
||||
// String contextPath = request.getContextPath();
|
||||
// response.setHeader("Refresh", "1;url=" + contextPath
|
||||
// + "/404.html");
|
||||
// ARE.getLog().error(e);
|
||||
// throw new Exception("------Timeout------");
|
||||
// }
|
||||
// } else {
|
||||
// String contextPath = request.getContextPath();
|
||||
// response.setHeader("Refresh", "1;url=" + contextPath + "/404.html");
|
||||
// throw new Exception("------Timeout------");
|
||||
// }
|
||||
// return new AppAtt();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ¸ù¾Ý attachment no ÒÆ³ý ¸½¼þ
|
||||
// * @param sId
|
||||
// * @param tx
|
||||
// * @return
|
||||
// */
|
||||
// public boolean removeDocById(String sId, JBOTransaction tx) {
|
||||
// try {
|
||||
// BizObjectManager manage = JBOFactory
|
||||
// .getBizObjectManager(DOC_ATTRIBUTE.CLASS_NAME);
|
||||
// BizObject bo = manage.createQuery("attachmentno=:id").setParameter("id", sId)
|
||||
// .getSingleResult(true);
|
||||
// if (null == bo)
|
||||
// return true;
|
||||
// manage.deleteObject(bo);
|
||||
// return true;
|
||||
// } catch (Exception e) {
|
||||
// ARE.getLog().error(e);
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package apx.com.amarsoft.als.doc.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
//import jbo.app.tenwa.doc.DOC_ATTRIBUTE;
|
||||
import apx.com.amarsoft.als.doc.AppAtt;
|
||||
|
||||
import com.amarsoft.are.ARE;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.BizObjectManager;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.base.helper.LBDocHelper;
|
||||
import com.base.util.DownloadAttUtil;
|
||||
|
||||
public class DocManageService {
|
||||
public AppAtt attachmentDownloadById(String sId,
|
||||
@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response) throws Exception {
|
||||
DownloadAttUtil.setCharset(response, null);
|
||||
// LB_DOCATTRIBUTE >. ID
|
||||
String sDevType = request.getParameter("devType") == null ? "ios"
|
||||
: request.getParameter("devType").toString();
|
||||
String userAgent = request.getHeader("user-agent");
|
||||
if (null != userAgent) {
|
||||
if (userAgent.toLowerCase().indexOf("iphone") >= 0) {
|
||||
sDevType = "ios";
|
||||
} else {
|
||||
sDevType = "android";
|
||||
}
|
||||
}
|
||||
Map<String, Object> lbDocMap = LBDocHelper.getDocById2(sId);
|
||||
if (null != lbDocMap) {
|
||||
String sFileName = lbDocMap.get("FILENAME".toLowerCase()) == null ? ""
|
||||
: lbDocMap.get("FILENAME".toLowerCase()).toString();
|
||||
String sFilePath = lbDocMap.get("FILEPATH".toLowerCase()) == null ? ""
|
||||
: lbDocMap.get("FILEPATH".toLowerCase()).toString();
|
||||
String sFileSize = lbDocMap.get("CONTENTLENGTH".toLowerCase()) == null ? ""
|
||||
: lbDocMap.get("CONTENTLENGTH".toLowerCase()).toString();
|
||||
|
||||
try {
|
||||
DownloadAttUtil.downloadAtt(sFileName, sFilePath, sFileSize,
|
||||
response, request, sDevType);
|
||||
} catch (Exception e) {
|
||||
String contextPath = request.getContextPath();
|
||||
response.setHeader("Refresh", "1;url=" + contextPath
|
||||
+ "/404.html");
|
||||
ARE.getLog().error(e);
|
||||
throw new Exception("------Timeout------");
|
||||
}
|
||||
} else {
|
||||
String contextPath = request.getContextPath();
|
||||
response.setHeader("Refresh", "1;url=" + contextPath + "/404.html");
|
||||
throw new Exception("------Timeout------");
|
||||
}
|
||||
return new AppAtt();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * ¸ù¾Ý attachment no ÒÆ³ý ¸½¼þ
|
||||
// * @param sId
|
||||
// * @param tx
|
||||
// * @return
|
||||
// */
|
||||
// public boolean removeDocById(String sId, JBOTransaction tx) {
|
||||
// try {
|
||||
// BizObjectManager manage = JBOFactory
|
||||
// .getBizObjectManager(DOC_ATTRIBUTE.CLASS_NAME);
|
||||
// BizObject bo = manage.createQuery("attachmentno=:id").setParameter("id", sId)
|
||||
// .getSingleResult(true);
|
||||
// if (null == bo)
|
||||
// return true;
|
||||
// manage.deleteObject(bo);
|
||||
// return true;
|
||||
// } catch (Exception e) {
|
||||
// ARE.getLog().error(e);
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user