|
|
|
@ -97,7 +97,7 @@ public class WorkflowToDocCus {
|
|
|
|
|
try {
|
|
|
|
|
cookie = (String)class_MultiLangFilter.getMethod("getThreadlocalCookies").invoke(class_MultiLangFilter);
|
|
|
|
|
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -129,7 +129,7 @@ public class WorkflowToDocCus {
|
|
|
|
|
* @param userid
|
|
|
|
|
* 用户id
|
|
|
|
|
* @param requestname
|
|
|
|
|
* 流程名 流程名作为文档的文档名
|
|
|
|
|
* 流程名 流程名作为文档的文档名
|
|
|
|
|
* @param workflowid
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -336,7 +336,7 @@ public class WorkflowToDocCus {
|
|
|
|
|
params[3] = new String(loginid.getBytes(), "8859_1");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
params[3] = PoppupRemindInfoUtil.encrypt(loginid);//解决中文账号问题
|
|
|
|
|
params[4] = password;
|
|
|
|
@ -363,28 +363,33 @@ public class WorkflowToDocCus {
|
|
|
|
|
public void getWorkflowHtml(String url[], String requestid,
|
|
|
|
|
String requestname, String workflowid, String wfdocpath,String userid, String cookie,LinkedHashMap<String, String> fileids) {
|
|
|
|
|
|
|
|
|
|
HttpClient client = FWHttpConnectionManager.getHttpClient();
|
|
|
|
|
HttpClient client = FWHttpConnectionManager.getHttpClient();
|
|
|
|
|
|
|
|
|
|
PostMethod method = new PostMethod(url[0]);//oa地址
|
|
|
|
|
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
|
|
|
|
|
new DefaultHttpMethodRetryHandler(3, false));
|
|
|
|
|
BufferedWriter bw = null;
|
|
|
|
|
BufferedReader in = null;
|
|
|
|
|
OutputStream os = null;
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
OutputStreamWriter output = null;
|
|
|
|
|
try {
|
|
|
|
|
NameValuePair[] params = {
|
|
|
|
|
new NameValuePair("urlfrom", url[1]),//urlfrom
|
|
|
|
|
new NameValuePair("para1",url[2]),//requesturl
|
|
|
|
|
new NameValuePair("para2",url[3] ),//loginid
|
|
|
|
|
new NameValuePair("para3",url[4])};//url4密码
|
|
|
|
|
new NameValuePair("para1", url[2]),//requesturl
|
|
|
|
|
new NameValuePair("para2", url[3]),//loginid
|
|
|
|
|
new NameValuePair("para3", url[4])};//url4密码
|
|
|
|
|
method.setRequestBody(params);
|
|
|
|
|
//log.info("----workflowtodoc----"+url[0] + "?urlfrom="+url[1]+"¶1="+url[2]+"¶2="+url[3]+"¶3="+url[4]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int statusCode = client.executeMethod(method);
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc statusCode :"+statusCode);
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc statusCode :" + statusCode);
|
|
|
|
|
String temppath = getFileSavePath();
|
|
|
|
|
String filename = System.currentTimeMillis() + "";
|
|
|
|
|
String htmlname = temppath + filename;
|
|
|
|
|
File _temppath = new File(temppath);
|
|
|
|
|
if(!_temppath.exists()){
|
|
|
|
|
if (!_temppath.exists()) {
|
|
|
|
|
_temppath.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -393,7 +398,7 @@ public class WorkflowToDocCus {
|
|
|
|
|
Header locationHeader = method.getResponseHeader("location");
|
|
|
|
|
if (locationHeader != null) {
|
|
|
|
|
String tempurl = locationHeader.getValue();
|
|
|
|
|
if(!tempurl.startsWith("http://") && !tempurl.startsWith("https://")) {
|
|
|
|
|
if (!tempurl.startsWith("http://") && !tempurl.startsWith("https://")) {
|
|
|
|
|
//GET PORT
|
|
|
|
|
String port_string = "";
|
|
|
|
|
Matcher matcher = port_pattern.matcher(url[0]);
|
|
|
|
@ -402,23 +407,23 @@ public class WorkflowToDocCus {
|
|
|
|
|
}
|
|
|
|
|
tempurl = "http://"
|
|
|
|
|
// + (port_string.isEmpty()? "" : "localhost"+port_string)
|
|
|
|
|
+ (port_string.isEmpty()? "" : "127.0.0.1"+port_string)
|
|
|
|
|
+ (port_string.isEmpty() ? "" : "127.0.0.1" + port_string)
|
|
|
|
|
+ tempurl;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc cookie :"+cookie);
|
|
|
|
|
tempurl = getFinallyUrl(client, tempurl,cookie);
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc cookie :" + cookie);
|
|
|
|
|
tempurl = getFinallyUrl(client, tempurl, cookie);
|
|
|
|
|
tempurl = tempurl.replaceFirst(".jsp", "Iframe.jsp");
|
|
|
|
|
tempurl = tempurl+"&urlfrom=workflowtodoc";
|
|
|
|
|
tempurl = tempurl + "&urlfrom=workflowtodoc";
|
|
|
|
|
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) start :"+System.currentTimeMillis());
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc tempurl :"+tempurl);
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) start :" + System.currentTimeMillis());
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc tempurl :" + tempurl);
|
|
|
|
|
GetMethod g = new GetMethod(tempurl);
|
|
|
|
|
g.setRequestHeader("cookie", cookie);
|
|
|
|
|
client.executeMethod(g);
|
|
|
|
|
OutputStream os=new FileOutputStream(htmlname);
|
|
|
|
|
os = new FileOutputStream(htmlname);
|
|
|
|
|
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) end :"+System.currentTimeMillis());
|
|
|
|
|
new BaseBean().writeLog("WorkflowToDoc client.executeMethod(g) end :" + System.currentTimeMillis());
|
|
|
|
|
// SystemComInfo syscominfo=new SystemComInfo() ;
|
|
|
|
|
// this.isaesencrypt = syscominfo.getIsaesencrypt();
|
|
|
|
|
// this.aescode = Util.getRandomString(13);
|
|
|
|
@ -429,31 +434,31 @@ public class WorkflowToDocCus {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
OutputStreamWriter output = new OutputStreamWriter(os, "UTF-8");
|
|
|
|
|
BufferedWriter bw = new BufferedWriter(output);
|
|
|
|
|
output = new OutputStreamWriter(os, "UTF-8");
|
|
|
|
|
bw = new BufferedWriter(output);
|
|
|
|
|
|
|
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(g.getResponseBodyAsStream(), "UTF-8"));
|
|
|
|
|
StringBuffer sb=new StringBuffer();
|
|
|
|
|
in = new BufferedReader(new InputStreamReader(g.getResponseBodyAsStream(), "UTF-8"));
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
String line = in.readLine();
|
|
|
|
|
while (line != null) {
|
|
|
|
|
line = line.trim();
|
|
|
|
|
if(line.indexOf("</a>")>=0&&line.indexOf("openSignPrint()")>=0&&line.indexOf("onclick")>=0){
|
|
|
|
|
if (line.indexOf("</a>") >= 0 && line.indexOf("openSignPrint()") >= 0 && line.indexOf("onclick") >= 0) {
|
|
|
|
|
//去掉转发按钮
|
|
|
|
|
}else if(line.indexOf("<img")>=0&&line.indexOf("class=\"transto\"")>=0&&line.indexOf("onclick")>=0&&line.indexOf("transtoClick(this)")>=0){
|
|
|
|
|
} else if (line.indexOf("<img") >= 0 && line.indexOf("class=\"transto\"") >= 0 && line.indexOf("onclick") >= 0 && line.indexOf("transtoClick(this)") >= 0) {
|
|
|
|
|
|
|
|
|
|
}else if(line.indexOf("var")>=0&&line.indexOf("bar")>=0&&line.indexOf("eval")>=0&&line.indexOf("handler")>=0&&line.indexOf("text")>=0){
|
|
|
|
|
} else if (line.indexOf("var") >= 0 && line.indexOf("bar") >= 0 && line.indexOf("eval") >= 0 && line.indexOf("handler") >= 0 && line.indexOf("text") >= 0) {
|
|
|
|
|
sb.append("var bar=eval(\"[]\");\n");
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
sb.append(line + "\n");
|
|
|
|
|
}
|
|
|
|
|
line = in.readLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加水印
|
|
|
|
|
if(WfWaterMark4WfToDocBiz.isOpenWaterMark(Util.getIntValue(workflowid))){
|
|
|
|
|
if (WfWaterMark4WfToDocBiz.isOpenWaterMark(Util.getIntValue(workflowid))) {
|
|
|
|
|
WfWaterMark4WfToDocBiz wfWaterMark4WfToDocBizCus = new WfWaterMark4WfToDocBiz(new User(Util.getIntValue(userid)));
|
|
|
|
|
wfWaterMark4WfToDocBizCus.generateFormData(requestid);
|
|
|
|
|
String watetmarkhtml = wfWaterMark4WfToDocBizCus.getWaterMarkHtml(false,Util.getIntValue(workflowid),Util.getIntValue(requestid),true);
|
|
|
|
|
String watetmarkhtml = wfWaterMark4WfToDocBizCus.getWaterMarkHtml(false, Util.getIntValue(workflowid), Util.getIntValue(requestid), true);
|
|
|
|
|
int begIndex = sb.lastIndexOf("</body>");
|
|
|
|
|
String frontcontent = sb.substring(0, begIndex);
|
|
|
|
|
String behindcontent = sb.substring(begIndex);
|
|
|
|
@ -472,8 +477,8 @@ public class WorkflowToDocCus {
|
|
|
|
|
sb.append("window.attachEvent(\"onload\", drm4request2doc);\n");
|
|
|
|
|
sb.append("</script>");
|
|
|
|
|
|
|
|
|
|
String sdata=sb.toString();
|
|
|
|
|
bw.write(sdata,0,sdata.length());
|
|
|
|
|
String sdata = sb.toString();
|
|
|
|
|
bw.write(sdata, 0, sdata.length());
|
|
|
|
|
|
|
|
|
|
// long size = 0l;
|
|
|
|
|
// File f = new File(htmlname);
|
|
|
|
@ -482,21 +487,21 @@ public class WorkflowToDocCus {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
bw.flush();
|
|
|
|
|
bw.close();
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
|
|
|
|
|
byte[] buffer = null;
|
|
|
|
|
File file = new File(htmlname);
|
|
|
|
|
if (file.exists()){
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
try {
|
|
|
|
|
inputStream = new FileInputStream(file);
|
|
|
|
|
buffer = new byte[(int) file.length()];
|
|
|
|
|
inputStream.read(buffer);
|
|
|
|
|
inputStream.close();
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
inputStream.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -530,23 +535,23 @@ public class WorkflowToDocCus {
|
|
|
|
|
ImageFileManager imageFileManager = new ImageFileManager();
|
|
|
|
|
imageFileManager.setComefrom("WorkflowToDoc");
|
|
|
|
|
imageFileManager.setData(buffer);
|
|
|
|
|
imageFileManager.setImagFileName(requestname+".html");
|
|
|
|
|
imageFileManager.setImagFileName(requestname + ".html");
|
|
|
|
|
int imagefileid = imageFileManager.saveImageFile();
|
|
|
|
|
// System.out.println("-在线-imagefileid----"+imagefileid);
|
|
|
|
|
// 保存imagefile
|
|
|
|
|
//int imagefileid = saveImageFile(requestname, htmlname, size,false);
|
|
|
|
|
if (imagefileid <= 0) {
|
|
|
|
|
log.error("保存在线HTML文件失败");
|
|
|
|
|
return ;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//把fileid存入fileidsmap中最后一起保存文档-附件关联关系
|
|
|
|
|
fileids.put("online_html",imagefileid+"");
|
|
|
|
|
fileids.put("online_html", imagefileid + "");
|
|
|
|
|
//saveDocDetail(requestname, htmlname, size, workflowid,requestid, wfdocpath,userid);
|
|
|
|
|
|
|
|
|
|
if(g!=null){
|
|
|
|
|
if (g != null) {
|
|
|
|
|
g.releaseConnection();
|
|
|
|
|
}
|
|
|
|
|
if(method!=null){
|
|
|
|
|
if (method != null) {
|
|
|
|
|
method.releaseConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -554,15 +559,38 @@ public class WorkflowToDocCus {
|
|
|
|
|
|
|
|
|
|
} catch (HttpException e) {
|
|
|
|
|
log.error("Fatal protocol violation: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("Fatal transport error: " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
new BaseBean().writeLog(e);
|
|
|
|
|
}finally {
|
|
|
|
|
} finally {
|
|
|
|
|
method.releaseConnection();
|
|
|
|
|
try {
|
|
|
|
|
if (bw != null){
|
|
|
|
|
bw.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (in != null){
|
|
|
|
|
in.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (os != null){
|
|
|
|
|
os.close();
|
|
|
|
|
}
|
|
|
|
|
if (inputStream != null){
|
|
|
|
|
inputStream.close();
|
|
|
|
|
}
|
|
|
|
|
if (output != null){
|
|
|
|
|
output.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.info("error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -581,7 +609,7 @@ public class WorkflowToDocCus {
|
|
|
|
|
}
|
|
|
|
|
client.executeMethod(g);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
Header locationHeader = g.getResponseHeader("location");
|
|
|
|
@ -1413,7 +1441,7 @@ public class WorkflowToDocCus {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
|
|
log.info("error");
|
|
|
|
|
}
|
|
|
|
|
if(wfdocowner <= 0){
|
|
|
|
|
wfdocowner = 1;
|
|
|
|
|