Merge with release-1.0c

This commit is contained in:
Elaine Tan 2013-11-07 16:22:34 +08:00
commit 5a8a5e05cd
7 changed files with 62 additions and 81 deletions

View File

@ -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
;

View File

@ -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
;

View File

@ -120,7 +120,6 @@ public class MSysConfig extends X_AD_SysConfig
public static final String ZK_REPORT_JASPER_OUTPUT_TYPE = "ZK_REPORT_JASPER_OUTPUT_TYPE"; public static final String ZK_REPORT_JASPER_OUTPUT_TYPE = "ZK_REPORT_JASPER_OUTPUT_TYPE";
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String TAX_SAVE_REQUEST_RESPONSE_LOG = "TAX_SAVE_REQUEST_RESPONSE_LOG"; public static final String TAX_SAVE_REQUEST_RESPONSE_LOG = "TAX_SAVE_REQUEST_RESPONSE_LOG";
public static final String ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER = "ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER";
public static final String ADDRESS_SAVE_REQUEST_RESPONSE_LOG = "ADDRESS_SAVE_REQUEST_RESPONSE_LOG"; public static final String ADDRESS_SAVE_REQUEST_RESPONSE_LOG = "ADDRESS_SAVE_REQUEST_RESPONSE_LOG";
/** /**

View File

@ -25,8 +25,8 @@ public class PrintLabelApplet extends JApplet {
/** /**
* *
*/ */
private static final long serialVersionUID = -3107445661561669767L; private static final long serialVersionUID = 6576464056530627273L;
private ArrayList<String> filepaths = new ArrayList<String>(); private ArrayList<String> fileids = new ArrayList<String>();
private int listSize = 0; private int listSize = 0;
@Override @Override
@ -40,7 +40,7 @@ public class PrintLabelApplet extends JApplet {
} }
for (int i = 0; i < listSize; i++) for (int i = 0; i < listSize; i++)
filepaths.add(getParameter("file_" + i)); fileids.add(getParameter("file_" + i));
super.init(); super.init();
} }
@ -56,21 +56,11 @@ public class PrintLabelApplet extends JApplet {
int count = 0; int count = 0;
while (true) { while (true) {
URL url = new URL(getCodeBase(), "labeldata.jsp?filepath=" + filepaths.get(count) + "&count=" + (count + 1)); URL url = new URL(getCodeBase(), "labeldata.jsp?fileid=" + fileids.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());
URLConnection conn = url.openConnection(); URLConnection conn = url.openConnection();
int contentLength = conn.getContentLength();
System.out.println("ContentLength="+contentLength);
InputStream is = conn.getInputStream(); InputStream is = conn.getInputStream();
System.out.println("InputStream="+is.available());
byte[] data = null; byte[] data = null;
BufferedInputStream bis = new BufferedInputStream(is); BufferedInputStream bis = new BufferedInputStream(is);
System.out.println("BufferedInputStream="+bis.available());
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
while(bis.available() > 0) { while(bis.available() > 0) {
baos.write(bis.read()); baos.write(bis.read());
@ -79,7 +69,6 @@ public class PrintLabelApplet extends JApplet {
bis.close(); bis.close();
data = baos.toByteArray(); data = baos.toByteArray();
baos.close(); baos.close();
System.out.println("ByteArrayOutputStream="+data.length);
if (data.length > 0) { if (data.length > 0) {
count ++; count ++;
if (pjob == null) { if (pjob == null) {

View File

@ -13,14 +13,14 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.webui; package org.adempiere.webui;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window; 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.CLogger;
import org.compiere.util.Env;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -54,33 +54,17 @@ public class LabelAppletWindow extends Window implements EventListener<Event>
applet.setHeight("0"); applet.setHeight("0");
applet.setParam("size", list.size() + ""); applet.setParam("size", list.size() + "");
File tempFile = null;
FileOutputStream fos = null;
for(int i = 0; i < list.size(); i++) for(int i = 0; i < list.size(); i++)
{ {
try try
{ {
File directory = null; MArchive archive = new MArchive(Env.getCtx(), 0, null);
String tempFolder = MSysConfig.getValue(MSysConfig.ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER, null); archive.setName("file_" + i);
if (tempFolder != null && tempFolder.trim().length() > 0) archive.setBinaryData(list.get(i));
{ archive.saveEx();
directory = new File(tempFolder.trim()); applet.setParam("file_" + i, archive.getAD_Archive_ID() + "");
if (!directory.exists()) if (log.isLoggable(Level.INFO))
{ log.info("file_" + i + "=" + archive.getAD_Archive_ID());
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();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -12,6 +12,8 @@
<jar destfile="labelapplet.jar" basedir="bin"> <jar destfile="labelapplet.jar" basedir="bin">
<manifest> <manifest>
<attribute name="Built-By" value="Trek Global"/> <attribute name="Built-By" value="Trek Global"/>
<attribute name="Permissions" value="all-permissions" />
<attribute name="Codebase" value="*" />
</manifest> </manifest>
</jar> </jar>
</target> </target>

View File

@ -1,33 +1,29 @@
<%@ page language="java" contentType="application/octet-stream"%>
<%@ page trimDirectiveWhitespaces="true" %> <%@ page trimDirectiveWhitespaces="true" %>
<%@page import="org.compiere.model.MArchive"%>
<%@page import="org.compiere.util.Env"%>
<%@page import="java.io.ByteArrayOutputStream"%> <%@page import="java.io.ByteArrayOutputStream"%>
<%@page import="java.io.FileInputStream"%> <%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%> <%@page import="java.io.File"%>
<%@page import="java.io.BufferedOutputStream"%> <%@page import="java.io.BufferedOutputStream"%>
<%@page import="java.io.OutputStream"%> <%@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 try
{ {
fis = new FileInputStream (file); String fileid = request.getParameter("fileid");
baos = new ByteArrayOutputStream(); if (fileid == null || fileid.trim().length() == 0)
byte[] buffer = new byte[1024*8]; // 8kB {
int length = -1; response.setContentLength(0);
while ((length = fis.read(buffer)) != -1) return;
baos.write(buffer, 0, length); }
data = baos.toByteArray();
fis.close();
baos.close();
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); response.setContentLength(data.length);
OutputStream os = response.getOutputStream(); OutputStream os = response.getOutputStream();
@ -36,17 +32,13 @@
bos.flush(); bos.flush();
bos.close(); bos.close();
file.delete(); archive.delete(false);
}
}
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
response.setContentLength(0); response.setContentLength(0);
} }
}
else
{
System.out.println("file not found=" + filepath);
response.setContentLength(0);
}
%> %>