Accept patch [2788801] MAttachementEntry.java patch
Thanks to Muhammad Faisal Shahzad (ro2)
This commit is contained in:
parent
fa69ebfcef
commit
73efd701fd
|
@ -603,7 +603,7 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
||||||
MAttachmentEntry[] entries = attachment.getEntries();
|
MAttachmentEntry[] entries = attachment.getEntries();
|
||||||
for(int i = 0; i < entries.length; i++) {
|
for(int i = 0; i < entries.length; i++) {
|
||||||
if (!entries[i].getName().equals(name) &&
|
if (!entries[i].getName().equals(name) &&
|
||||||
(entries[i].getName().endsWith(".jrxml") || entries[i].getName().endsWith(".jasper"))) {
|
(entries[i].getName().toLowerCase().endsWith(".jrxml") || entries[i].getName().toLowerCase().endsWith(".jasper"))) {
|
||||||
File reportFile = getAttachmentEntryFile(entries[i]);
|
File reportFile = getAttachmentEntryFile(entries[i]);
|
||||||
if (reportFile != null)
|
if (reportFile != null)
|
||||||
subreports.add(reportFile);
|
subreports.add(reportFile);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* This file is part of Adempiere ERP Bazaar *
|
* This file is part of Adempiere ERP Bazaar *
|
||||||
* http://www.adempiere.org *
|
* http://www.adempiere.org *
|
||||||
* *
|
* *
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
* *
|
* *
|
||||||
* Sponsors: *
|
* Sponsors: *
|
||||||
* - Company (http://www.faire.com.br) *
|
* - Company (http://www.faire.com.br) *
|
||||||
***********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
package org.adempiere.process;
|
package org.adempiere.process;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class PrepareMigrationScripts extends SvrProcess {
|
||||||
|
|
||||||
FilenameFilter filter = new FilenameFilter() {
|
FilenameFilter filter = new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.endsWith(".sql");
|
return name.toLowerCase().endsWith(".sql");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
dirList = dir.listFiles(filter);
|
dirList = dir.listFiles(filter);
|
||||||
|
|
|
@ -1,296 +1,297 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* See the GNU General Public License for more details. *
|
* See the GNU General Public License for more details. *
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* You should have received a copy of the GNU General Public License along *
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.MimeType;
|
import org.compiere.util.MimeType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Individual Attachment Entry of MAttachment
|
* Individual Attachment Entry of MAttachment
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MAttachmentEntry.java,v 1.2 2006/07/30 00:58:18 jjanke Exp $
|
* @version $Id: MAttachmentEntry.java,v 1.2 2006/07/30 00:58:18 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class MAttachmentEntry
|
public class MAttachmentEntry
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Attachment Entry
|
* Attachment Entry
|
||||||
* @param name name
|
* @param name name
|
||||||
* @param data binary data
|
* @param data binary data
|
||||||
* @param index optional index
|
* @param index optional index
|
||||||
*/
|
*/
|
||||||
public MAttachmentEntry (String name, byte[] data, int index)
|
public MAttachmentEntry (String name, byte[] data, int index)
|
||||||
{
|
{
|
||||||
super ();
|
super ();
|
||||||
setName (name);
|
setName (name);
|
||||||
setData (data);
|
setData (data);
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
m_index = index;
|
m_index = index;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (s_seed+3600000l < now) // older then 1 hour
|
if (s_seed+3600000l < now) // older then 1 hour
|
||||||
{
|
{
|
||||||
s_seed = now;
|
s_seed = now;
|
||||||
s_random = new Random(s_seed);
|
s_random = new Random(s_seed);
|
||||||
}
|
}
|
||||||
m_index = s_random.nextInt();
|
m_index = s_random.nextInt();
|
||||||
}
|
}
|
||||||
} // MAttachmentItem
|
} // MAttachmentItem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment Entry
|
* Attachment Entry
|
||||||
* @param name name
|
* @param name name
|
||||||
* @param data binary data
|
* @param data binary data
|
||||||
*/
|
*/
|
||||||
public MAttachmentEntry (String name, byte[] data)
|
public MAttachmentEntry (String name, byte[] data)
|
||||||
{
|
{
|
||||||
this (name, data, 0);
|
this (name, data, 0);
|
||||||
} // MAttachmentItem
|
} // MAttachmentItem
|
||||||
|
|
||||||
/** The Name */
|
/** The Name */
|
||||||
private String m_name = "?";
|
private String m_name = "?";
|
||||||
/** The Data */
|
/** The Data */
|
||||||
private byte[] m_data = null;
|
private byte[] m_data = null;
|
||||||
|
|
||||||
/** Random Seed */
|
/** Random Seed */
|
||||||
private static long s_seed = System.currentTimeMillis();
|
private static long s_seed = System.currentTimeMillis();
|
||||||
/** Random Number */
|
/** Random Number */
|
||||||
private static Random s_random = new Random(s_seed);
|
private static Random s_random = new Random(s_seed);
|
||||||
/** Index */
|
/** Index */
|
||||||
private int m_index = 0;
|
private int m_index = 0;
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
protected CLogger log = CLogger.getCLogger(getClass());
|
protected CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the data.
|
* @return Returns the data.
|
||||||
*/
|
*/
|
||||||
public byte[] getData ()
|
public byte[] getData ()
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param data The data to set.
|
* @param data The data to set.
|
||||||
*/
|
*/
|
||||||
public void setData (byte[] data)
|
public void setData (byte[] data)
|
||||||
{
|
{
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return Returns the name.
|
* @return Returns the name.
|
||||||
*/
|
*/
|
||||||
public String getName ()
|
public String getName ()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name to set.
|
* @param name The name to set.
|
||||||
*/
|
*/
|
||||||
public void setName (String name)
|
public void setName (String name)
|
||||||
{
|
{
|
||||||
if (name != null)
|
if (name != null)
|
||||||
m_name = name;
|
m_name = name;
|
||||||
if (m_name == null)
|
if (m_name == null)
|
||||||
m_name = "?";
|
m_name = "?";
|
||||||
} // setName
|
} // setName
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Attachment Index
|
* Get Attachment Index
|
||||||
* @return timestamp
|
* @return timestamp
|
||||||
*/
|
*/
|
||||||
public int getIndex()
|
public int getIndex()
|
||||||
{
|
{
|
||||||
return m_index;
|
return m_index;
|
||||||
} // getIndex
|
} // getIndex
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To String
|
* To String
|
||||||
* @return name
|
* @return name
|
||||||
*/
|
*/
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To String Extended
|
* To String Extended
|
||||||
* @return name (length)
|
* @return name (length)
|
||||||
*/
|
*/
|
||||||
public String toStringX ()
|
public String toStringX ()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer (m_name);
|
StringBuffer sb = new StringBuffer (m_name);
|
||||||
if (m_data != null)
|
if (m_data != null)
|
||||||
{
|
{
|
||||||
sb.append(" (");
|
sb.append(" (");
|
||||||
//
|
//
|
||||||
float size = m_data.length;
|
float size = m_data.length;
|
||||||
if (size <= 1024)
|
if (size <= 1024)
|
||||||
sb.append(m_data.length).append(" B");
|
sb.append(m_data.length).append(" B");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size /= 1024;
|
size /= 1024;
|
||||||
if (size > 1024)
|
if (size > 1024)
|
||||||
{
|
{
|
||||||
size /= 1024;
|
size /= 1024;
|
||||||
sb.append(size).append(" MB");
|
sb.append(size).append(" MB");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sb.append(size).append(" kB");
|
sb.append(size).append(" kB");
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
}
|
}
|
||||||
sb.append(" - ").append(getContentType());
|
sb.append(" - ").append(getContentType());
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} // toStringX
|
} // toStringX
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump Data
|
* Dump Data
|
||||||
*/
|
*/
|
||||||
public void dump ()
|
public void dump ()
|
||||||
{
|
{
|
||||||
String hdr = "----- " + getName() + " -----";
|
String hdr = "----- " + getName() + " -----";
|
||||||
System.out.println (hdr);
|
System.out.println (hdr);
|
||||||
if (m_data == null)
|
if (m_data == null)
|
||||||
{
|
{
|
||||||
System.out.println ("----- no data -----");
|
System.out.println ("----- no data -----");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// raw data
|
// raw data
|
||||||
for (int i = 0; i < m_data.length; i++)
|
for (int i = 0; i < m_data.length; i++)
|
||||||
{
|
{
|
||||||
char data = (char)m_data[i];
|
char data = (char)m_data[i];
|
||||||
System.out.print(data);
|
System.out.print(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println ();
|
System.out.println ();
|
||||||
System.out.println (hdr);
|
System.out.println (hdr);
|
||||||
// Count nulls at end
|
// Count nulls at end
|
||||||
int ii = m_data.length -1;
|
int ii = m_data.length -1;
|
||||||
int nullCount = 0;
|
int nullCount = 0;
|
||||||
while (m_data[ii--] == 0)
|
while (m_data[ii--] == 0)
|
||||||
nullCount++;
|
nullCount++;
|
||||||
System.out.println("----- Length=" + m_data.length + ", EndNulls=" + nullCount
|
System.out.println("----- Length=" + m_data.length + ", EndNulls=" + nullCount
|
||||||
+ ", RealLength=" + (m_data.length-nullCount));
|
+ ", RealLength=" + (m_data.length-nullCount));
|
||||||
/**
|
/**
|
||||||
// Dump w/o nulls
|
// Dump w/o nulls
|
||||||
if (nullCount > 0)
|
if (nullCount > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_data.length-nullCount; i++)
|
for (int i = 0; i < m_data.length-nullCount; i++)
|
||||||
System.out.print((char)m_data[i]);
|
System.out.print((char)m_data[i]);
|
||||||
System.out.println ();
|
System.out.println ();
|
||||||
System.out.println (hdr);
|
System.out.println (hdr);
|
||||||
}
|
}
|
||||||
/** **/
|
/** **/
|
||||||
} // dump
|
} // dump
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get File with default name
|
* Get File with default name
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public File getFile ()
|
public File getFile ()
|
||||||
{
|
{
|
||||||
return getFile (getName());
|
return getFile (getName());
|
||||||
} // getFile
|
} // getFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get File with name
|
* Get File with name
|
||||||
* @param fileName optional file name
|
* @param fileName optional file name
|
||||||
* @return file
|
* @return file
|
||||||
*/
|
*/
|
||||||
public File getFile (String fileName)
|
public File getFile (String fileName)
|
||||||
{
|
{
|
||||||
if (fileName == null || fileName.length() == 0)
|
if (fileName == null || fileName.length() == 0)
|
||||||
fileName = getName();
|
fileName = getName();
|
||||||
return getFile (new File(fileName));
|
return getFile (new File(fileName));
|
||||||
} // getFile
|
} // getFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get File
|
* Get File
|
||||||
* @param file out file
|
* @param file out file
|
||||||
* @return file
|
* @return file
|
||||||
*/
|
*/
|
||||||
public File getFile (File file)
|
public File getFile (File file)
|
||||||
{
|
{
|
||||||
if (m_data == null || m_data.length == 0)
|
if (m_data == null || m_data.length == 0)
|
||||||
return null;
|
return null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
fos.write(m_data);
|
fos.write(m_data);
|
||||||
fos.close();
|
fos.close();
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "getFile", ioe);
|
log.log(Level.SEVERE, "getFile", ioe);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
} // getFile
|
} // getFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is attachment entry a PDF
|
* Is attachment entry a PDF
|
||||||
* @return true if PDF
|
* @return true if PDF
|
||||||
*/
|
*/
|
||||||
public boolean isPDF()
|
public boolean isPDF()
|
||||||
{
|
{
|
||||||
return m_name.endsWith(".pdf");
|
return m_name.toLowerCase().endsWith(".pdf");
|
||||||
} // isPDF
|
} // isPDF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Isattachment entry a Graphic
|
* Is attachment entry a Graphic
|
||||||
* @return true if *.gif, *.jpg, *.png
|
* @return true if *.gif, *.jpg, *.png
|
||||||
*/
|
*/
|
||||||
public boolean isGraphic()
|
public boolean isGraphic()
|
||||||
{
|
{
|
||||||
return m_name.endsWith(".gif") || m_name.endsWith(".jpg") || m_name.endsWith(".png");
|
String m_lowname = m_name.toLowerCase();
|
||||||
} // isGraphic
|
return m_lowname.endsWith(".gif") || m_lowname.endsWith(".jpg") || m_lowname.endsWith(".png");
|
||||||
|
} // isGraphic
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Content (Mime) Type
|
/**
|
||||||
* @return content type
|
* Get Content (Mime) Type
|
||||||
*/
|
* @return content type
|
||||||
public String getContentType()
|
*/
|
||||||
{
|
public String getContentType()
|
||||||
return MimeType.getMimeType(m_name);
|
{
|
||||||
} // getContentType
|
return MimeType.getMimeType(m_name);
|
||||||
|
} // getContentType
|
||||||
/**
|
|
||||||
* Get Data as Input Stream
|
/**
|
||||||
* @return input stream
|
* Get Data as Input Stream
|
||||||
*/
|
* @return input stream
|
||||||
public InputStream getInputStream()
|
*/
|
||||||
{
|
public InputStream getInputStream()
|
||||||
if (m_data == null)
|
{
|
||||||
return null;
|
if (m_data == null)
|
||||||
return new ByteArrayInputStream(m_data);
|
return null;
|
||||||
} // getInputStream
|
return new ByteArrayInputStream(m_data);
|
||||||
|
} // getInputStream
|
||||||
} // MAttachmentItem
|
|
||||||
|
} // MAttachmentItem
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class GetReportAction extends POSAction
|
||||||
|
|
||||||
String mimeType = null;
|
String mimeType = null;
|
||||||
|
|
||||||
if(reportName.endsWith(".csv"))
|
if(reportName.toLowerCase().endsWith(".csv"))
|
||||||
{
|
{
|
||||||
mimeType = "text/comma-separated-values";
|
mimeType = "text/comma-separated-values";
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,10 +139,12 @@ public final class WFilter implements javax.servlet.Filter
|
||||||
|
|
||||||
// Get URI
|
// Get URI
|
||||||
String uri = "";
|
String uri = "";
|
||||||
|
String urilow = "";
|
||||||
if (request instanceof HttpServletRequest)
|
if (request instanceof HttpServletRequest)
|
||||||
{
|
{
|
||||||
HttpServletRequest req = (HttpServletRequest)request;
|
HttpServletRequest req = (HttpServletRequest)request;
|
||||||
uri = req.getRequestURI();
|
uri = req.getRequestURI();
|
||||||
|
urilow = uri.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,9 +173,9 @@ public final class WFilter implements javax.servlet.Filter
|
||||||
else
|
else
|
||||||
pass = false;
|
pass = false;
|
||||||
else if (!uri.startsWith(WebEnv.DIR_BASE) // not requesting /adempiere/...
|
else if (!uri.startsWith(WebEnv.DIR_BASE) // not requesting /adempiere/...
|
||||||
|| uri.endsWith(".gif") || uri.endsWith(".jpg") || uri.endsWith(".png")
|
|| urilow.endsWith(".gif") || urilow.endsWith(".jpg") || urilow.endsWith(".png")
|
||||||
|| uri.endsWith(".html") || uri.endsWith(".css")
|
|| urilow.endsWith(".html") || urilow.endsWith(".css")
|
||||||
|| uri.endsWith(".js"))
|
|| urilow.endsWith(".js"))
|
||||||
check = false;
|
check = false;
|
||||||
else
|
else
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue