IDEMPIERE-1083 Print shipping label applet is not working - Allow system admin to define a network share folder to save shipping label temp files in load-balanced environment

This commit is contained in:
Elaine Tan 2013-09-30 19:53:16 +08:00
parent 1d50a92f1d
commit 6cd592e409
4 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Sep 30, 2013 7:12:21 PM SGT
-- IDEMPIERE-1083 Print shipping label applet is not working
INSERT INTO AD_SysConfig (AD_SysConfig_ID,ConfigurationLevel,Value,AD_SysConfig_UU,Created,Updated,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name,AD_Client_ID,EntityType) VALUES (200036,'S',' ','3d792b55-0ca5-467c-b666-c642103efb28',TO_DATE('2013-09-30 19:12:20','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-09-30 19:12:20','YYYY-MM-DD HH24:MI:SS'),0,100,'Y',100,'ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER',0,'D')
;
SELECT register_migration_script('201309301915_IDEMPIERE-1083.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- Sep 30, 2013 7:12:21 PM SGT
-- IDEMPIERE-1083 Print shipping label applet is not working
INSERT INTO AD_SysConfig (AD_SysConfig_ID,ConfigurationLevel,Value,AD_SysConfig_UU,Created,Updated,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name,AD_Client_ID,EntityType) VALUES (200036,'S',' ','3d792b55-0ca5-467c-b666-c642103efb28',TO_TIMESTAMP('2013-09-30 19:12:20','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-09-30 19:12:20','YYYY-MM-DD HH24:MI:SS'),0,100,'Y',100,'ZK_PRINT_SHIPPING_LABEL_SHARED_TEMP_FOLDER',0,'D')
;
SELECT register_migration_script('201309301915_IDEMPIERE-1083.sql') FROM dual
;

View File

@ -118,6 +118,7 @@ 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

View File

@ -19,6 +19,8 @@ import java.util.List;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -31,11 +33,12 @@ import org.zkoss.zul.Div;
*
*/
public class LabelAppletWindow extends Window implements EventListener<Event>
{
{
/**
*
*/
private static final long serialVersionUID = -8980224912104404397L;
private static final long serialVersionUID = -592770994381511142L;
private final static CLogger log = CLogger.getCLogger(LabelAppletWindow.class);
public LabelAppletWindow(List<byte[]> list)
{
@ -57,7 +60,23 @@ public class LabelAppletWindow extends Window implements EventListener<Event>
{
try
{
tempFile = File.createTempFile("lblapp", Long.toString(System.nanoTime()));
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));