IDEMPIERE-1083 Print shipping label applet is not working
This commit is contained in:
parent
bee9d53562
commit
2e3e4fc61f
|
@ -0,0 +1,9 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-1083 Print shipping label applet is not working
|
||||
DELETE FROM AD_SysConfig WHERE AD_SysConfig_ID = 200036
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201311061318_IDEMPIERE-1083.sql') FROM dual
|
||||
;
|
|
@ -0,0 +1,6 @@
|
|||
-- IDEMPIERE-1083 Print shipping label applet is not working
|
||||
DELETE FROM AD_SysConfig WHERE AD_SysConfig_ID = 200036
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201311061318_IDEMPIERE-1083.sql') FROM dual
|
||||
;
|
|
@ -118,7 +118,6 @@ public class MSysConfig extends X_AD_SysConfig
|
|||
public static final String ZK_MAX_UPLOAD_SIZE = "ZK_MAX_UPLOAD_SIZE";
|
||||
public static final String CALENDAR_ALTERNATE_TIMEZONE = "CALENDAR_ALTERNATE_TIMEZONE";
|
||||
public static final String ZK_REPORT_JASPER_OUTPUT_TYPE = "ZK_REPORT_JASPER_OUTPUT_TYPE";
|
||||
public static final String ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER = "ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER";
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
|
|
|
@ -25,8 +25,8 @@ public class PrintLabelApplet extends JApplet {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3107445661561669767L;
|
||||
private ArrayList<String> filepaths = new ArrayList<String>();
|
||||
private static final long serialVersionUID = 6576464056530627273L;
|
||||
private ArrayList<String> fileids = new ArrayList<String>();
|
||||
private int listSize = 0;
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public class PrintLabelApplet extends JApplet {
|
|||
}
|
||||
|
||||
for (int i = 0; i < listSize; i++)
|
||||
filepaths.add(getParameter("file_" + i));
|
||||
fileids.add(getParameter("file_" + i));
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
@ -56,21 +56,11 @@ public class PrintLabelApplet extends JApplet {
|
|||
int count = 0;
|
||||
|
||||
while (true) {
|
||||
URL url = new URL(getCodeBase(), "labeldata.jsp?filepath=" + filepaths.get(count) + "&count=" + (count + 1));
|
||||
System.out.println("Protocol="+url.getProtocol());
|
||||
System.out.println("Host="+url.getHost());
|
||||
System.out.println("Port="+url.getPort());
|
||||
System.out.println("Default Port="+url.getDefaultPort());
|
||||
System.out.println("Path"+url.getPath());
|
||||
System.out.println("URL="+url.toString());
|
||||
URL url = new URL(getCodeBase(), "labeldata.jsp?fileid=" + fileids.get(count) + "&count=" + (count + 1));
|
||||
URLConnection conn = url.openConnection();
|
||||
int contentLength = conn.getContentLength();
|
||||
System.out.println("ContentLength="+contentLength);
|
||||
InputStream is = conn.getInputStream();
|
||||
System.out.println("InputStream="+is.available());
|
||||
byte[] data = null;
|
||||
BufferedInputStream bis = new BufferedInputStream(is);
|
||||
System.out.println("BufferedInputStream="+bis.available());
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
while(bis.available() > 0) {
|
||||
baos.write(bis.read());
|
||||
|
@ -79,7 +69,6 @@ public class PrintLabelApplet extends JApplet {
|
|||
bis.close();
|
||||
data = baos.toByteArray();
|
||||
baos.close();
|
||||
System.out.println("ByteArrayOutputStream="+data.length);
|
||||
if (data.length > 0) {
|
||||
count ++;
|
||||
if (pjob == null) {
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MArchive;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
@ -54,33 +54,17 @@ public class LabelAppletWindow extends Window implements EventListener<Event>
|
|||
applet.setHeight("0");
|
||||
applet.setParam("size", list.size() + "");
|
||||
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
File directory = null;
|
||||
String tempFolder = MSysConfig.getValue(MSysConfig.ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER, null);
|
||||
if (tempFolder != null && tempFolder.trim().length() > 0)
|
||||
{
|
||||
directory = new File(tempFolder.trim());
|
||||
if (!directory.exists())
|
||||
{
|
||||
log.severe("Directory doesn't exists " + tempFolder);
|
||||
directory = null;
|
||||
}
|
||||
else if (!directory.canWrite())
|
||||
{
|
||||
log.severe("Directory cannot write " + tempFolder);
|
||||
directory = null;
|
||||
}
|
||||
}
|
||||
tempFile = File.createTempFile("lblapp", Long.toString(System.nanoTime()), directory);
|
||||
fos = new FileOutputStream(tempFile);
|
||||
applet.setParam("file_" + i, tempFile.getAbsolutePath());
|
||||
fos.write(list.get(i));
|
||||
fos.close();
|
||||
MArchive archive = new MArchive(Env.getCtx(), 0, null);
|
||||
archive.setName("file_" + i);
|
||||
archive.setBinaryData(list.get(i));
|
||||
archive.saveEx();
|
||||
applet.setParam("file_" + i, archive.getAD_Archive_ID() + "");
|
||||
if (log.isLoggable(Level.INFO))
|
||||
log.info("file_" + i + "=" + archive.getAD_Archive_ID());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
<jar destfile="labelapplet.jar" basedir="bin">
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="Trek Global"/>
|
||||
<attribute name="Permissions" value="all-permissions" />
|
||||
<attribute name="Codebase" value="*" />
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
|
|
@ -1,33 +1,29 @@
|
|||
<%@ page language="java" contentType="application/octet-stream"%>
|
||||
<%@ page trimDirectiveWhitespaces="true" %>
|
||||
<%@page import="org.compiere.model.MArchive"%>
|
||||
<%@page import="org.compiere.util.Env"%>
|
||||
<%@page import="java.io.ByteArrayOutputStream"%>
|
||||
<%@page import="java.io.FileInputStream"%>
|
||||
<%@page import="java.io.File"%>
|
||||
<%@page import="java.io.BufferedOutputStream"%>
|
||||
<%@page import="java.io.OutputStream"%>
|
||||
<%@ page language="java" contentType="application/octet-stream"%>
|
||||
<%
|
||||
String filepath = request.getParameter("filepath");
|
||||
if (filepath == null || filepath.trim().length() == 0 )
|
||||
return;
|
||||
|
||||
File file = new File(filepath);
|
||||
if (file.exists())
|
||||
{
|
||||
FileInputStream fis = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
byte[] data = null;
|
||||
try
|
||||
{
|
||||
fis = new FileInputStream (file);
|
||||
baos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024*8]; // 8kB
|
||||
int length = -1;
|
||||
while ((length = fis.read(buffer)) != -1)
|
||||
baos.write(buffer, 0, length);
|
||||
data = baos.toByteArray();
|
||||
fis.close();
|
||||
baos.close();
|
||||
String fileid = request.getParameter("fileid");
|
||||
if (fileid == null || fileid.trim().length() == 0)
|
||||
{
|
||||
response.setContentLength(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int AD_Archive_ID = Integer.parseInt(fileid);
|
||||
if (AD_Archive_ID > 0)
|
||||
{
|
||||
MArchive archive = new MArchive(Env.getCtx(), AD_Archive_ID, null);
|
||||
if (archive != null && archive.getAD_Archive_ID() > 0)
|
||||
{
|
||||
byte[] data = archive.getBinaryData();
|
||||
response.setContentLength(data.length);
|
||||
|
||||
OutputStream os = response.getOutputStream();
|
||||
|
@ -36,17 +32,13 @@
|
|||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
file.delete();
|
||||
archive.delete(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
response.setContentLength(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("file not found=" + filepath);
|
||||
response.setContentLength(0);
|
||||
}
|
||||
%>
|
||||
|
|
Loading…
Reference in New Issue