IDEMPIERE-390 Attachments/archives on load balancer scenario
This commit is contained in:
parent
1c0b1ebd9e
commit
28008f2737
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -290,6 +290,6 @@ Import-Package: com.sun.mail.auth;version="1.4.5",
|
||||||
Eclipse-BuddyPolicy: registered
|
Eclipse-BuddyPolicy: registered
|
||||||
Eclipse-ExtensibleAPI: true
|
Eclipse-ExtensibleAPI: true
|
||||||
Bundle-Activator: org.adempiere.base.BaseActivator
|
Bundle-Activator: org.adempiere.base.BaseActivator
|
||||||
Service-Component: OSGI-INF/eventmanager.xml, OSGI-INF/dslocator.xml, OSGI-INF/extensionlocator.xml, OSGI-INF/serverbean.xml, OSGI-INF/statusbean.xml, OSGI-INF/defaultmodelfactory.xml, OSGI-INF/defaultdocfactory.xml
|
Service-Component: OSGI-INF/eventmanager.xml, OSGI-INF/dslocator.xml, OSGI-INF/extensionlocator.xml, OSGI-INF/serverbean.xml, OSGI-INF/statusbean.xml, OSGI-INF/defaultmodelfactory.xml, OSGI-INF/defaultdocfactory.xml, OSGI-INF/AttachmentFile.xml, OSGI-INF/AttachmentDB.xml
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Require-Bundle: org.eclipse.equinox.app;bundle-version="1.3.1"
|
Require-Bundle: org.eclipse.equinox.app;bundle-version="1.3.1"
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.base.AttachmentDB">
|
||||||
|
<implementation class="org.compiere.model.AttachmentDBSystem"/>
|
||||||
|
<service>
|
||||||
|
<provide interface="org.compiere.model.IAttachmentStore"/>
|
||||||
|
</service>
|
||||||
|
<property name="method" type="String" value="DB"/>
|
||||||
|
</scr:component>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.base.AttachmentFile">
|
||||||
|
<implementation class="org.compiere.model.AttachmentFileSystem"/>
|
||||||
|
<service>
|
||||||
|
<provide interface="org.compiere.model.IAttachmentStore"/>
|
||||||
|
</service>
|
||||||
|
<property name="method" type="String" value="FileSystem"/>
|
||||||
|
</scr:component>
|
|
@ -0,0 +1,135 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2012 Trek Global *
|
||||||
|
* 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 *
|
||||||
|
* 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 *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
|
||||||
|
public class AttachmentDBSystem implements IAttachmentStore
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Indicator for zip data */
|
||||||
|
public static final String ZIP = "zip";
|
||||||
|
private final CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean loadLOBData(MAttachment attach, MStorageProvider prov) {
|
||||||
|
// Reset
|
||||||
|
attach.m_items = new ArrayList<MAttachmentEntry>();
|
||||||
|
//
|
||||||
|
byte[] data = attach.getBinaryData();
|
||||||
|
if (data == null)
|
||||||
|
return true;
|
||||||
|
log.fine("ZipSize=" + data.length);
|
||||||
|
if (data.length == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Old Format - single file
|
||||||
|
if (!ZIP.equals(attach.getTitle()))
|
||||||
|
{
|
||||||
|
attach.m_items.add (new MAttachmentEntry(attach.getTitle(), data, 1));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ByteArrayInputStream in = new ByteArrayInputStream(data);
|
||||||
|
ZipInputStream zip = new ZipInputStream (in);
|
||||||
|
ZipEntry entry = zip.getNextEntry();
|
||||||
|
while (entry != null)
|
||||||
|
{
|
||||||
|
String name = entry.getName();
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[2048];
|
||||||
|
int length = zip.read(buffer);
|
||||||
|
while (length != -1)
|
||||||
|
{
|
||||||
|
out.write(buffer, 0, length);
|
||||||
|
length = zip.read(buffer);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
byte[] dataEntry = out.toByteArray();
|
||||||
|
log.fine(name
|
||||||
|
+ " - size=" + dataEntry.length + " - zip="
|
||||||
|
+ entry.getCompressedSize() + "(" + entry.getSize() + ") "
|
||||||
|
+ (entry.getCompressedSize()*100/entry.getSize())+ "%");
|
||||||
|
//
|
||||||
|
attach.m_items.add (new MAttachmentEntry (name, dataEntry, attach.m_items.size()+1));
|
||||||
|
entry = zip.getNextEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "loadLOBData", e);
|
||||||
|
attach.m_items = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean save(MAttachment attach, MStorageProvider prov) {
|
||||||
|
if (attach.m_items == null || attach.m_items.size() == 0)
|
||||||
|
{
|
||||||
|
attach.setBinaryData(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
ZipOutputStream zip = new ZipOutputStream(out);
|
||||||
|
zip.setMethod(ZipOutputStream.DEFLATED);
|
||||||
|
zip.setLevel(Deflater.BEST_COMPRESSION);
|
||||||
|
zip.setComment("adempiere");
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < attach.m_items.size(); i++)
|
||||||
|
{
|
||||||
|
MAttachmentEntry item = attach.getEntry(i);
|
||||||
|
ZipEntry entry = new ZipEntry(item.getName());
|
||||||
|
entry.setTime(System.currentTimeMillis());
|
||||||
|
entry.setMethod(ZipEntry.DEFLATED);
|
||||||
|
zip.putNextEntry(entry);
|
||||||
|
byte[] data = item.getData();
|
||||||
|
zip.write (data, 0, data.length);
|
||||||
|
zip.closeEntry();
|
||||||
|
log.fine(entry.getName() + " - "
|
||||||
|
+ entry.getCompressedSize() + " (" + entry.getSize() + ") "
|
||||||
|
+ (entry.getCompressedSize()*100/entry.getSize())+ "%");
|
||||||
|
}
|
||||||
|
// zip.finish();
|
||||||
|
zip.close();
|
||||||
|
byte[] zipData = out.toByteArray();
|
||||||
|
log.fine("Length=" + zipData.length);
|
||||||
|
attach.setBinaryData(zipData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "saveLOBData", e);
|
||||||
|
}
|
||||||
|
attach.setBinaryData(null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,251 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 2012 Trek Global *
|
||||||
|
* 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 *
|
||||||
|
* 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 *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.nio.channels.FileChannel;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.transform.Result;
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.w3c.dom.NamedNodeMap;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author juliana
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AttachmentFileSystem implements IAttachmentStore {
|
||||||
|
|
||||||
|
private final CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
|
public String m_attachmentPathRoot;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean save(MAttachment attach,MStorageProvider prov) {
|
||||||
|
|
||||||
|
/*if(File.separatorChar == '\\'){
|
||||||
|
m_attachmentPathRoot = prov.getWi;
|
||||||
|
} else {
|
||||||
|
m_attachmentPathRoot = prov.getUnixAttachmentPath();
|
||||||
|
}*/
|
||||||
|
m_attachmentPathRoot=prov.getFolder();
|
||||||
|
if("".equals(m_attachmentPathRoot)){
|
||||||
|
log.severe("no attachmentPath defined");
|
||||||
|
} else if (!m_attachmentPathRoot.endsWith(File.separator)){
|
||||||
|
log.warning("attachment path doesn't end with " + File.separator);
|
||||||
|
m_attachmentPathRoot = m_attachmentPathRoot + File.separator;
|
||||||
|
log.fine(m_attachmentPathRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attach.m_items == null || attach.m_items.size() == 0) {
|
||||||
|
attach.setBinaryData(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
try {
|
||||||
|
final DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
final Document document = builder.newDocument();
|
||||||
|
final Element root = document.createElement("attachments");
|
||||||
|
document.appendChild(root);
|
||||||
|
document.setXmlStandalone(true);
|
||||||
|
// create xml entries
|
||||||
|
for (int i = 0; i < attach.m_items.size(); i++) {
|
||||||
|
log.fine(attach.m_items.get(i).toString());
|
||||||
|
File entryFile = attach.m_items.get(i).getFile();
|
||||||
|
final String path = entryFile.getAbsolutePath();
|
||||||
|
// if local file - copy to central attachment folder
|
||||||
|
log.fine(path + " - " + attach.m_attachmentPathRoot);
|
||||||
|
if (!path.startsWith(attach.m_attachmentPathRoot)) {
|
||||||
|
log.fine("move file: " + path);
|
||||||
|
FileChannel in = null;
|
||||||
|
FileChannel out = null;
|
||||||
|
try {
|
||||||
|
//create destination folder
|
||||||
|
StringBuilder msgfile = new StringBuilder().append(attach.m_attachmentPathRoot).append(File.separator).append(attach.getAttachmentPathSnippet());
|
||||||
|
final File destFolder = new File(msgfile.toString());
|
||||||
|
if(!destFolder.exists()){
|
||||||
|
if(!destFolder.mkdirs()){
|
||||||
|
log.warning("unable to create folder: " + destFolder.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msgfile = new StringBuilder().append(attach.m_attachmentPathRoot).append(File.separator)
|
||||||
|
.append(attach.getAttachmentPathSnippet()).append(File.separator).append(entryFile.getName());
|
||||||
|
final File destFile = new File(msgfile.toString());
|
||||||
|
in = new FileInputStream(entryFile).getChannel();
|
||||||
|
out = new FileOutputStream(destFile).getChannel();
|
||||||
|
in.transferTo(0, in.size(), out);
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
if(entryFile.exists()){
|
||||||
|
if(!entryFile.delete()){
|
||||||
|
entryFile.deleteOnExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entryFile = destFile;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.severe("unable to copy file " + entryFile.getAbsolutePath() + " to "
|
||||||
|
+ attach.m_attachmentPathRoot + File.separator +
|
||||||
|
attach.getAttachmentPathSnippet() + File.separator + entryFile.getName());
|
||||||
|
} finally {
|
||||||
|
if (in != null && in.isOpen()) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
if (out != null && out.isOpen()) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final Element entry = document.createElement("entry");
|
||||||
|
//entry.setAttribute("name", m_items.get(i).getName());
|
||||||
|
entry.setAttribute("name", attach.getEntryName(i));
|
||||||
|
String filePathToStore = entryFile.getAbsolutePath();
|
||||||
|
filePathToStore = filePathToStore.replaceFirst(attach.m_attachmentPathRoot.replaceAll("\\\\","\\\\\\\\"), attach.ATTACHMENT_FOLDER_PLACEHOLDER);
|
||||||
|
log.fine(filePathToStore);
|
||||||
|
entry.setAttribute("file", filePathToStore);
|
||||||
|
root.appendChild(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Source source = new DOMSource(document);
|
||||||
|
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
final Result result = new StreamResult(bos);
|
||||||
|
final Transformer xformer = TransformerFactory.newInstance().newTransformer();
|
||||||
|
xformer.transform(source, result);
|
||||||
|
final byte[] xmlData = bos.toByteArray();
|
||||||
|
log.fine(bos.toString());
|
||||||
|
attach.setBinaryData(xmlData);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.log(Level.SEVERE, "saveLOBData", e);
|
||||||
|
}
|
||||||
|
attach.setBinaryData(null);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean loadLOBData(MAttachment attach,MStorageProvider prov) {
|
||||||
|
if("".equals(attach.m_attachmentPathRoot)){
|
||||||
|
log.severe("no attachmentPath defined");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Reset
|
||||||
|
attach.m_items = new ArrayList<MAttachmentEntry>();
|
||||||
|
//
|
||||||
|
byte[] data = attach.getBinaryData();
|
||||||
|
if (data == null)
|
||||||
|
return true;
|
||||||
|
log.fine("TextFileSize=" + data.length);
|
||||||
|
if (data.length == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
|
||||||
|
try {
|
||||||
|
final DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
final Document document = builder.parse(new ByteArrayInputStream(data));
|
||||||
|
final NodeList entries = document.getElementsByTagName("entry");
|
||||||
|
for (int i = 0; i < entries.getLength(); i++) {
|
||||||
|
final Node entryNode = entries.item(i);
|
||||||
|
final NamedNodeMap attributes = entryNode.getAttributes();
|
||||||
|
final Node fileNode = attributes.getNamedItem("file");
|
||||||
|
final Node nameNode = attributes.getNamedItem("name");
|
||||||
|
if(fileNode==null || nameNode==null){
|
||||||
|
log.severe("no filename for entry " + i);
|
||||||
|
attach.m_items = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
log.fine("name: " + nameNode.getNodeValue());
|
||||||
|
String filePath = fileNode.getNodeValue();
|
||||||
|
log.fine("filePath: " + filePath);
|
||||||
|
if(filePath!=null){
|
||||||
|
filePath = filePath.replaceFirst(attach.ATTACHMENT_FOLDER_PLACEHOLDER, attach.m_attachmentPathRoot.replaceAll("\\\\","\\\\\\\\"));
|
||||||
|
//just to be shure...
|
||||||
|
String replaceSeparator = File.separator;
|
||||||
|
if(!replaceSeparator.equals("/")){
|
||||||
|
replaceSeparator = "\\\\";
|
||||||
|
}
|
||||||
|
filePath = filePath.replaceAll("/", replaceSeparator);
|
||||||
|
filePath = filePath.replaceAll("\\\\", replaceSeparator);
|
||||||
|
}
|
||||||
|
log.fine("filePath: " + filePath);
|
||||||
|
final File file = new File(filePath);
|
||||||
|
if (file.exists()) {
|
||||||
|
// read files into byte[]
|
||||||
|
final byte[] dataEntry = new byte[(int) file.length()];
|
||||||
|
try {
|
||||||
|
final FileInputStream fileInputStream = new FileInputStream(file);
|
||||||
|
fileInputStream.read(dataEntry);
|
||||||
|
fileInputStream.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
log.severe("File Not Found.");
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
log.severe("Error Reading The File.");
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
final MAttachmentEntry entry = new MAttachmentEntry(filePath,
|
||||||
|
dataEntry, attach.m_items.size() + 1);
|
||||||
|
attach.m_items.add(entry);
|
||||||
|
} else {
|
||||||
|
log.severe("file not found: " + file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SAXException sxe) {
|
||||||
|
// Error generated during parsing)
|
||||||
|
Exception x = sxe;
|
||||||
|
if (sxe.getException() != null)
|
||||||
|
x = sxe.getException();
|
||||||
|
x.printStackTrace();
|
||||||
|
log.severe(x.getMessage());
|
||||||
|
|
||||||
|
} catch (ParserConfigurationException pce) {
|
||||||
|
// Parser with specified options can't be built
|
||||||
|
pce.printStackTrace();
|
||||||
|
log.severe(pce.getMessage());
|
||||||
|
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
// I/O error
|
||||||
|
ioe.printStackTrace();
|
||||||
|
log.severe(ioe.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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 *
|
||||||
|
* 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 *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* 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 *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IAttachmentStore {
|
||||||
|
|
||||||
|
public boolean loadLOBData(MAttachment attach,MStorageProvider prov);
|
||||||
|
|
||||||
|
boolean save(MAttachment attach, MStorageProvider prov);
|
||||||
|
}
|
|
@ -408,15 +408,6 @@ public interface I_AD_Client
|
||||||
/** Get Store Archive On File System */
|
/** Get Store Archive On File System */
|
||||||
public boolean isStoreArchiveOnFileSystem();
|
public boolean isStoreArchiveOnFileSystem();
|
||||||
|
|
||||||
/** Column name StoreAttachmentsOnFileSystem */
|
|
||||||
public static final String COLUMNNAME_StoreAttachmentsOnFileSystem = "StoreAttachmentsOnFileSystem";
|
|
||||||
|
|
||||||
/** Set Store Attachments On File System */
|
|
||||||
public void setStoreAttachmentsOnFileSystem (boolean StoreAttachmentsOnFileSystem);
|
|
||||||
|
|
||||||
/** Get Store Attachments On File System */
|
|
||||||
public boolean isStoreAttachmentsOnFileSystem();
|
|
||||||
|
|
||||||
/** Column name UnixArchivePath */
|
/** Column name UnixArchivePath */
|
||||||
public static final String COLUMNNAME_UnixArchivePath = "UnixArchivePath";
|
public static final String COLUMNNAME_UnixArchivePath = "UnixArchivePath";
|
||||||
|
|
||||||
|
@ -426,15 +417,6 @@ public interface I_AD_Client
|
||||||
/** Get Unix Archive Path */
|
/** Get Unix Archive Path */
|
||||||
public String getUnixArchivePath();
|
public String getUnixArchivePath();
|
||||||
|
|
||||||
/** Column name UnixAttachmentPath */
|
|
||||||
public static final String COLUMNNAME_UnixAttachmentPath = "UnixAttachmentPath";
|
|
||||||
|
|
||||||
/** Set Unix Attachment Path */
|
|
||||||
public void setUnixAttachmentPath (String UnixAttachmentPath);
|
|
||||||
|
|
||||||
/** Get Unix Attachment Path */
|
|
||||||
public String getUnixAttachmentPath();
|
|
||||||
|
|
||||||
/** Column name Updated */
|
/** Column name Updated */
|
||||||
public static final String COLUMNNAME_Updated = "Updated";
|
public static final String COLUMNNAME_Updated = "Updated";
|
||||||
|
|
||||||
|
@ -472,13 +454,4 @@ public interface I_AD_Client
|
||||||
|
|
||||||
/** Get Windows Archive Path */
|
/** Get Windows Archive Path */
|
||||||
public String getWindowsArchivePath();
|
public String getWindowsArchivePath();
|
||||||
|
|
||||||
/** Column name WindowsAttachmentPath */
|
|
||||||
public static final String COLUMNNAME_WindowsAttachmentPath = "WindowsAttachmentPath";
|
|
||||||
|
|
||||||
/** Set Windows Attachment Path */
|
|
||||||
public void setWindowsAttachmentPath (String WindowsAttachmentPath);
|
|
||||||
|
|
||||||
/** Get Windows Attachment Path */
|
|
||||||
public String getWindowsAttachmentPath();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,17 @@ public interface I_AD_ClientInfo
|
||||||
*/
|
*/
|
||||||
public int getAD_Org_ID();
|
public int getAD_Org_ID();
|
||||||
|
|
||||||
|
/** Column name AD_StorageProvider_ID */
|
||||||
|
public static final String COLUMNNAME_AD_StorageProvider_ID = "AD_StorageProvider_ID";
|
||||||
|
|
||||||
|
/** Set AD_StorageProvider_ID */
|
||||||
|
public void setAD_StorageProvider_ID (int AD_StorageProvider_ID);
|
||||||
|
|
||||||
|
/** Get AD_StorageProvider_ID */
|
||||||
|
public int getAD_StorageProvider_ID();
|
||||||
|
|
||||||
|
public org.compiere.model.I_AD_StorageProvider getAD_StorageProvider() throws RuntimeException;
|
||||||
|
|
||||||
/** Column name AD_Tree_Activity_ID */
|
/** Column name AD_Tree_Activity_ID */
|
||||||
public static final String COLUMNNAME_AD_Tree_Activity_ID = "AD_Tree_Activity_ID";
|
public static final String COLUMNNAME_AD_Tree_Activity_ID = "AD_Tree_Activity_ID";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,201 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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 *
|
||||||
|
* 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 *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* 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 *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
|
||||||
|
/** Generated Interface for AD_StorageProvider
|
||||||
|
* @author iDempiere (generated)
|
||||||
|
* @version Release 1.0a
|
||||||
|
*/
|
||||||
|
public interface I_AD_StorageProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/** TableName=AD_StorageProvider */
|
||||||
|
public static final String Table_Name = "AD_StorageProvider";
|
||||||
|
|
||||||
|
/** AD_Table_ID=200037 */
|
||||||
|
public static final int Table_ID = 200037;
|
||||||
|
|
||||||
|
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||||
|
|
||||||
|
/** AccessLevel = 3 - Client - Org
|
||||||
|
*/
|
||||||
|
BigDecimal accessLevel = BigDecimal.valueOf(3);
|
||||||
|
|
||||||
|
/** Load Meta Data */
|
||||||
|
|
||||||
|
/** Column name AD_Client_ID */
|
||||||
|
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||||
|
|
||||||
|
/** Get Client.
|
||||||
|
* Client/Tenant for this installation.
|
||||||
|
*/
|
||||||
|
public int getAD_Client_ID();
|
||||||
|
|
||||||
|
/** Column name AD_Org_ID */
|
||||||
|
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
|
||||||
|
|
||||||
|
/** Set Organization.
|
||||||
|
* Organizational entity within client
|
||||||
|
*/
|
||||||
|
public void setAD_Org_ID (int AD_Org_ID);
|
||||||
|
|
||||||
|
/** Get Organization.
|
||||||
|
* Organizational entity within client
|
||||||
|
*/
|
||||||
|
public int getAD_Org_ID();
|
||||||
|
|
||||||
|
/** Column name AD_StorageProvider_ID */
|
||||||
|
public static final String COLUMNNAME_AD_StorageProvider_ID = "AD_StorageProvider_ID";
|
||||||
|
|
||||||
|
/** Set AD_StorageProvider_ID */
|
||||||
|
public void setAD_StorageProvider_ID (int AD_StorageProvider_ID);
|
||||||
|
|
||||||
|
/** Get AD_StorageProvider_ID */
|
||||||
|
public int getAD_StorageProvider_ID();
|
||||||
|
|
||||||
|
/** Column name AD_StorageProvider_UU */
|
||||||
|
public static final String COLUMNNAME_AD_StorageProvider_UU = "AD_StorageProvider_UU";
|
||||||
|
|
||||||
|
/** Set AD_StorageProvider_UU */
|
||||||
|
public void setAD_StorageProvider_UU (String AD_StorageProvider_UU);
|
||||||
|
|
||||||
|
/** Get AD_StorageProvider_UU */
|
||||||
|
public String getAD_StorageProvider_UU();
|
||||||
|
|
||||||
|
/** Column name Created */
|
||||||
|
public static final String COLUMNNAME_Created = "Created";
|
||||||
|
|
||||||
|
/** Get Created.
|
||||||
|
* Date this record was created
|
||||||
|
*/
|
||||||
|
public Timestamp getCreated();
|
||||||
|
|
||||||
|
/** Column name CreatedBy */
|
||||||
|
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
|
||||||
|
|
||||||
|
/** Get Created By.
|
||||||
|
* User who created this records
|
||||||
|
*/
|
||||||
|
public int getCreatedBy();
|
||||||
|
|
||||||
|
/** Column name Folder */
|
||||||
|
public static final String COLUMNNAME_Folder = "Folder";
|
||||||
|
|
||||||
|
/** Set Folder.
|
||||||
|
* A folder on a local or remote system to store data into
|
||||||
|
*/
|
||||||
|
public void setFolder (String Folder);
|
||||||
|
|
||||||
|
/** Get Folder.
|
||||||
|
* A folder on a local or remote system to store data into
|
||||||
|
*/
|
||||||
|
public String getFolder();
|
||||||
|
|
||||||
|
/** Column name IsActive */
|
||||||
|
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||||
|
|
||||||
|
/** Set Active.
|
||||||
|
* The record is active in the system
|
||||||
|
*/
|
||||||
|
public void setIsActive (boolean IsActive);
|
||||||
|
|
||||||
|
/** Get Active.
|
||||||
|
* The record is active in the system
|
||||||
|
*/
|
||||||
|
public boolean isActive();
|
||||||
|
|
||||||
|
/** Column name Method */
|
||||||
|
public static final String COLUMNNAME_Method = "Method";
|
||||||
|
|
||||||
|
/** Set Method */
|
||||||
|
public void setMethod (String Method);
|
||||||
|
|
||||||
|
/** Get Method */
|
||||||
|
public String getMethod();
|
||||||
|
|
||||||
|
/** Column name Name */
|
||||||
|
public static final String COLUMNNAME_Name = "Name";
|
||||||
|
|
||||||
|
/** Set Name.
|
||||||
|
* Alphanumeric identifier of the entity
|
||||||
|
*/
|
||||||
|
public void setName (String Name);
|
||||||
|
|
||||||
|
/** Get Name.
|
||||||
|
* Alphanumeric identifier of the entity
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
/** Column name Password */
|
||||||
|
public static final String COLUMNNAME_Password = "Password";
|
||||||
|
|
||||||
|
/** Set Password.
|
||||||
|
* Password of any length (case sensitive)
|
||||||
|
*/
|
||||||
|
public void setPassword (String Password);
|
||||||
|
|
||||||
|
/** Get Password.
|
||||||
|
* Password of any length (case sensitive)
|
||||||
|
*/
|
||||||
|
public String getPassword();
|
||||||
|
|
||||||
|
/** Column name Updated */
|
||||||
|
public static final String COLUMNNAME_Updated = "Updated";
|
||||||
|
|
||||||
|
/** Get Updated.
|
||||||
|
* Date this record was updated
|
||||||
|
*/
|
||||||
|
public Timestamp getUpdated();
|
||||||
|
|
||||||
|
/** Column name UpdatedBy */
|
||||||
|
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
|
||||||
|
|
||||||
|
/** Get Updated By.
|
||||||
|
* User who updated this records
|
||||||
|
*/
|
||||||
|
public int getUpdatedBy();
|
||||||
|
|
||||||
|
/** Column name URL */
|
||||||
|
public static final String COLUMNNAME_URL = "URL";
|
||||||
|
|
||||||
|
/** Set URL.
|
||||||
|
* Full URL address - e.g. http://www.idempiere.org
|
||||||
|
*/
|
||||||
|
public void setURL (String URL);
|
||||||
|
|
||||||
|
/** Get URL.
|
||||||
|
* Full URL address - e.g. http://www.idempiere.org
|
||||||
|
*/
|
||||||
|
public String getURL();
|
||||||
|
|
||||||
|
/** Column name UserName */
|
||||||
|
public static final String COLUMNNAME_UserName = "UserName";
|
||||||
|
|
||||||
|
/** Set Registered EMail.
|
||||||
|
* Email of the responsible for the System
|
||||||
|
*/
|
||||||
|
public void setUserName (String UserName);
|
||||||
|
|
||||||
|
/** Get Registered EMail.
|
||||||
|
* Email of the responsible for the System
|
||||||
|
*/
|
||||||
|
public String getUserName();
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ import java.io.IOException;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.zip.Deflater;
|
import java.util.zip.Deflater;
|
||||||
|
@ -43,6 +44,8 @@ import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.adempiere.base.Service;
|
||||||
|
import org.adempiere.base.ServiceQuery;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.MimeType;
|
import org.compiere.util.MimeType;
|
||||||
|
@ -71,8 +74,7 @@ public class MAttachment extends X_AD_Attachment
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -1948066627503677516L;
|
private static final long serialVersionUID = 1415801644995116959L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Attachment (if there are more than one attachment it gets the first in no specific order)
|
* Get Attachment (if there are more than one attachment it gets the first in no specific order)
|
||||||
|
@ -92,6 +94,8 @@ public class MAttachment extends X_AD_Attachment
|
||||||
|
|
||||||
/** Static Logger */
|
/** Static Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MAttachment.class);
|
private static CLogger s_log = CLogger.getCLogger (MAttachment.class);
|
||||||
|
|
||||||
|
public MStorageProvider provider;
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -145,25 +149,38 @@ public class MAttachment extends X_AD_Attachment
|
||||||
public static final String XML = "xml";
|
public static final String XML = "xml";
|
||||||
|
|
||||||
/** List of Entry Data */
|
/** List of Entry Data */
|
||||||
private ArrayList<MAttachmentEntry> m_items = null;
|
public ArrayList<MAttachmentEntry> m_items = null;
|
||||||
|
|
||||||
|
|
||||||
/** is this client using the file system for attachments */
|
/** is this client using the file system for attachments */
|
||||||
private boolean isStoreAttachmentsOnFileSystem = false;
|
private boolean isStoreAttachmentsOnFileSystem = false;
|
||||||
|
|
||||||
/** attachment (root) path - if file system is used */
|
/** attachment (root) path - if file system is used */
|
||||||
private String m_attachmentPathRoot = "";
|
public String m_attachmentPathRoot = "";
|
||||||
|
|
||||||
/** string replaces the attachment root in stored xml file
|
/** string replaces the attachment root in stored xml file
|
||||||
* to allow the changing of the attachment root. */
|
* to allow the changing of the attachment root. */
|
||||||
private final String ATTACHMENT_FOLDER_PLACEHOLDER = "%ATTACHMENT_FOLDER%";
|
public final String ATTACHMENT_FOLDER_PLACEHOLDER = "%ATTACHMENT_FOLDER%";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the isStoreAttachmentsOnFileSystem and attachmentPath for the client.
|
* Get the isStoreAttachmentsOnFileSystem and attachmentPath for the client.
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @param trxName
|
* @param trxName
|
||||||
*/
|
*/
|
||||||
private void initAttachmentStoreDetails(Properties ctx, String trxName){
|
private void initAttachmentStoreDetails(Properties ctx, String trxName)
|
||||||
final MClient client = new MClient(ctx, this.getAD_Client_ID(), trxName);
|
{
|
||||||
|
|
||||||
|
MClientInfo clientInfo = MClientInfo.get(ctx);
|
||||||
|
|
||||||
|
provider=new MStorageProvider(ctx, clientInfo.getAD_StorageProvider_ID(), trxName);
|
||||||
|
|
||||||
|
m_attachmentPathRoot=provider.getFolder();
|
||||||
|
|
||||||
|
if(m_attachmentPathRoot == null){
|
||||||
|
log.severe("no attachmentPath defined");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* final MClient client = new MClient(ctx, this.getAD_Client_ID(), trxName);
|
||||||
isStoreAttachmentsOnFileSystem = client.isStoreAttachmentsOnFileSystem();
|
isStoreAttachmentsOnFileSystem = client.isStoreAttachmentsOnFileSystem();
|
||||||
if(isStoreAttachmentsOnFileSystem){
|
if(isStoreAttachmentsOnFileSystem){
|
||||||
if(File.separatorChar == '\\'){
|
if(File.separatorChar == '\\'){
|
||||||
|
@ -178,7 +195,7 @@ public class MAttachment extends X_AD_Attachment
|
||||||
m_attachmentPathRoot = m_attachmentPathRoot + File.separator;
|
m_attachmentPathRoot = m_attachmentPathRoot + File.separator;
|
||||||
log.fine(m_attachmentPathRoot);
|
log.fine(m_attachmentPathRoot);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,6 +261,7 @@ public class MAttachment extends X_AD_Attachment
|
||||||
*/
|
*/
|
||||||
public boolean addEntry (File file)
|
public boolean addEntry (File file)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (file == null)
|
if (file == null)
|
||||||
{
|
{
|
||||||
log.warning("No File");
|
log.warning("No File");
|
||||||
|
@ -411,11 +429,14 @@ public class MAttachment extends X_AD_Attachment
|
||||||
* @return name or null
|
* @return name or null
|
||||||
*/
|
*/
|
||||||
public String getEntryName(int index) {
|
public String getEntryName(int index) {
|
||||||
|
String method=provider.getMethod();
|
||||||
|
if(method == null)
|
||||||
|
method="DB";
|
||||||
MAttachmentEntry item = getEntry(index);
|
MAttachmentEntry item = getEntry(index);
|
||||||
if (item != null){
|
if (item != null){
|
||||||
//strip path
|
//strip path
|
||||||
String name = item.getName();
|
String name = item.getName();
|
||||||
if(name!=null && isStoreAttachmentsOnFileSystem){
|
if(name!=null && "FileSystem".equals(method)){
|
||||||
name = name.substring(name.lastIndexOf(File.separator)+1);
|
name = name.substring(name.lastIndexOf(File.separator)+1);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
@ -491,10 +512,24 @@ public class MAttachment extends X_AD_Attachment
|
||||||
*/
|
*/
|
||||||
private boolean saveLOBData()
|
private boolean saveLOBData()
|
||||||
{
|
{
|
||||||
if(isStoreAttachmentsOnFileSystem){
|
ServiceQuery query=new ServiceQuery();
|
||||||
|
String method=provider.getMethod();
|
||||||
|
if(method == null)
|
||||||
|
method="DB";
|
||||||
|
query.put("method", method);
|
||||||
|
List<IAttachmentStore> storelist = Service.locator().list(IAttachmentStore.class, query).getServices();
|
||||||
|
|
||||||
|
if(storelist != null){
|
||||||
|
for(IAttachmentStore prov:storelist){
|
||||||
|
return prov.save(this,provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*if(isStoreAttachmentsOnFileSystem){
|
||||||
return saveLOBDataToFileSystem();
|
return saveLOBDataToFileSystem();
|
||||||
}
|
}
|
||||||
return saveLOBDataToDB();
|
return saveLOBDataToDB();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -648,10 +683,25 @@ public class MAttachment extends X_AD_Attachment
|
||||||
*/
|
*/
|
||||||
private boolean loadLOBData ()
|
private boolean loadLOBData ()
|
||||||
{
|
{
|
||||||
if(isStoreAttachmentsOnFileSystem){
|
|
||||||
|
ServiceQuery query=new ServiceQuery();
|
||||||
|
String method=provider.getMethod();
|
||||||
|
if(method == null)
|
||||||
|
method="DB";
|
||||||
|
query.put("method", method);
|
||||||
|
|
||||||
|
List<IAttachmentStore> storelist = Service.locator().list(IAttachmentStore.class, query).getServices();
|
||||||
|
|
||||||
|
if(storelist != null){
|
||||||
|
for(IAttachmentStore prov:storelist){
|
||||||
|
return prov.loadLOBData(this,provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
/*if(isStoreAttachmentsOnFileSystem){
|
||||||
return loadLOBDataFromFileSystem();
|
return loadLOBDataFromFileSystem();
|
||||||
}
|
}
|
||||||
return loadLOBDataFromDB();
|
return loadLOBDataFromDB();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -717,7 +767,7 @@ public class MAttachment extends X_AD_Attachment
|
||||||
* Load Data from file system
|
* Load Data from file system
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
private boolean loadLOBDataFromFileSystem(){
|
public boolean loadLOBDataFromFileSystem(){
|
||||||
if("".equals(m_attachmentPathRoot)){
|
if("".equals(m_attachmentPathRoot)){
|
||||||
log.severe("no attachmentPath defined");
|
log.severe("no attachmentPath defined");
|
||||||
return false;
|
return false;
|
||||||
|
@ -812,7 +862,7 @@ public class MAttachment extends X_AD_Attachment
|
||||||
* Returns a path snippet, containing client, org, table and record id.
|
* Returns a path snippet, containing client, org, table and record id.
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
private String getAttachmentPathSnippet(){
|
public String getAttachmentPathSnippet(){
|
||||||
|
|
||||||
StringBuilder msgreturn = new StringBuilder().append(this.getAD_Client_ID()).append(File.separator)
|
StringBuilder msgreturn = new StringBuilder().append(this.getAD_Client_ID()).append(File.separator)
|
||||||
.append(this.getAD_Org_ID()).append(File.separator)
|
.append(this.getAD_Org_ID()).append(File.separator)
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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 *
|
||||||
|
* 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 *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* 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 *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class MStorageProvider extends X_AD_StorageProvider {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -4048103579840786187L;
|
||||||
|
|
||||||
|
public MStorageProvider(Properties ctx, int AD_StorageProvider_ID,
|
||||||
|
String trxName) {
|
||||||
|
super(ctx, AD_StorageProvider_ID, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MStorageProvider(Properties ctx, ResultSet rs, String trxName) {
|
||||||
|
super(ctx, rs, trxName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class X_AD_Client extends PO implements I_AD_Client, I_Persistent
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20121031L;
|
private static final long serialVersionUID = 20121127L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_AD_Client (Properties ctx, int AD_Client_ID, String trxName)
|
public X_AD_Client (Properties ctx, int AD_Client_ID, String trxName)
|
||||||
|
@ -56,7 +56,6 @@ public class X_AD_Client extends PO implements I_AD_Client, I_Persistent
|
||||||
// F
|
// F
|
||||||
setName (null);
|
setName (null);
|
||||||
setStoreArchiveOnFileSystem (false);
|
setStoreArchiveOnFileSystem (false);
|
||||||
setStoreAttachmentsOnFileSystem (false);
|
|
||||||
setValue (null);
|
setValue (null);
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
@ -612,27 +611,6 @@ public class X_AD_Client extends PO implements I_AD_Client, I_Persistent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set Store Attachments On File System.
|
|
||||||
@param StoreAttachmentsOnFileSystem Store Attachments On File System */
|
|
||||||
public void setStoreAttachmentsOnFileSystem (boolean StoreAttachmentsOnFileSystem)
|
|
||||||
{
|
|
||||||
set_Value (COLUMNNAME_StoreAttachmentsOnFileSystem, Boolean.valueOf(StoreAttachmentsOnFileSystem));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get Store Attachments On File System.
|
|
||||||
@return Store Attachments On File System */
|
|
||||||
public boolean isStoreAttachmentsOnFileSystem ()
|
|
||||||
{
|
|
||||||
Object oo = get_Value(COLUMNNAME_StoreAttachmentsOnFileSystem);
|
|
||||||
if (oo != null)
|
|
||||||
{
|
|
||||||
if (oo instanceof Boolean)
|
|
||||||
return ((Boolean)oo).booleanValue();
|
|
||||||
return "Y".equals(oo);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set Unix Archive Path.
|
/** Set Unix Archive Path.
|
||||||
@param UnixArchivePath Unix Archive Path */
|
@param UnixArchivePath Unix Archive Path */
|
||||||
public void setUnixArchivePath (String UnixArchivePath)
|
public void setUnixArchivePath (String UnixArchivePath)
|
||||||
|
@ -647,20 +625,6 @@ public class X_AD_Client extends PO implements I_AD_Client, I_Persistent
|
||||||
return (String)get_Value(COLUMNNAME_UnixArchivePath);
|
return (String)get_Value(COLUMNNAME_UnixArchivePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set Unix Attachment Path.
|
|
||||||
@param UnixAttachmentPath Unix Attachment Path */
|
|
||||||
public void setUnixAttachmentPath (String UnixAttachmentPath)
|
|
||||||
{
|
|
||||||
set_Value (COLUMNNAME_UnixAttachmentPath, UnixAttachmentPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get Unix Attachment Path.
|
|
||||||
@return Unix Attachment Path */
|
|
||||||
public String getUnixAttachmentPath ()
|
|
||||||
{
|
|
||||||
return (String)get_Value(COLUMNNAME_UnixAttachmentPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set Search Key.
|
/** Set Search Key.
|
||||||
@param Value
|
@param Value
|
||||||
Search key for the record in the format required - must be unique
|
Search key for the record in the format required - must be unique
|
||||||
|
@ -691,18 +655,4 @@ public class X_AD_Client extends PO implements I_AD_Client, I_Persistent
|
||||||
{
|
{
|
||||||
return (String)get_Value(COLUMNNAME_WindowsArchivePath);
|
return (String)get_Value(COLUMNNAME_WindowsArchivePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set Windows Attachment Path.
|
|
||||||
@param WindowsAttachmentPath Windows Attachment Path */
|
|
||||||
public void setWindowsAttachmentPath (String WindowsAttachmentPath)
|
|
||||||
{
|
|
||||||
set_Value (COLUMNNAME_WindowsAttachmentPath, WindowsAttachmentPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get Windows Attachment Path.
|
|
||||||
@return Windows Attachment Path */
|
|
||||||
public String getWindowsAttachmentPath ()
|
|
||||||
{
|
|
||||||
return (String)get_Value(COLUMNNAME_WindowsAttachmentPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ public class X_AD_ClientInfo extends PO implements I_AD_ClientInfo, I_Persistent
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20121031L;
|
private static final long serialVersionUID = 20121127L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_AD_ClientInfo (Properties ctx, int AD_ClientInfo_ID, String trxName)
|
public X_AD_ClientInfo (Properties ctx, int AD_ClientInfo_ID, String trxName)
|
||||||
|
@ -83,6 +83,31 @@ public class X_AD_ClientInfo extends PO implements I_AD_ClientInfo, I_Persistent
|
||||||
return (String)get_Value(COLUMNNAME_AD_ClientInfo_UU);
|
return (String)get_Value(COLUMNNAME_AD_ClientInfo_UU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public org.compiere.model.I_AD_StorageProvider getAD_StorageProvider() throws RuntimeException
|
||||||
|
{
|
||||||
|
return (org.compiere.model.I_AD_StorageProvider)MTable.get(getCtx(), org.compiere.model.I_AD_StorageProvider.Table_Name)
|
||||||
|
.getPO(getAD_StorageProvider_ID(), get_TrxName()); }
|
||||||
|
|
||||||
|
/** Set AD_StorageProvider_ID.
|
||||||
|
@param AD_StorageProvider_ID AD_StorageProvider_ID */
|
||||||
|
public void setAD_StorageProvider_ID (int AD_StorageProvider_ID)
|
||||||
|
{
|
||||||
|
if (AD_StorageProvider_ID < 1)
|
||||||
|
set_Value (COLUMNNAME_AD_StorageProvider_ID, null);
|
||||||
|
else
|
||||||
|
set_Value (COLUMNNAME_AD_StorageProvider_ID, Integer.valueOf(AD_StorageProvider_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get AD_StorageProvider_ID.
|
||||||
|
@return AD_StorageProvider_ID */
|
||||||
|
public int getAD_StorageProvider_ID ()
|
||||||
|
{
|
||||||
|
Integer ii = (Integer)get_Value(COLUMNNAME_AD_StorageProvider_ID);
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
public org.compiere.model.I_AD_Tree getAD_Tree_Activity() throws RuntimeException
|
public org.compiere.model.I_AD_Tree getAD_Tree_Activity() throws RuntimeException
|
||||||
{
|
{
|
||||||
return (org.compiere.model.I_AD_Tree)MTable.get(getCtx(), org.compiere.model.I_AD_Tree.Table_Name)
|
return (org.compiere.model.I_AD_Tree)MTable.get(getCtx(), org.compiere.model.I_AD_Tree.Table_Name)
|
||||||
|
|
|
@ -0,0 +1,210 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||||
|
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
|
||||||
|
* 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 *
|
||||||
|
* 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 *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* 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., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
* 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 *
|
||||||
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
|
*****************************************************************************/
|
||||||
|
/** Generated Model - DO NOT CHANGE */
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/** Generated Model for AD_StorageProvider
|
||||||
|
* @author iDempiere (generated)
|
||||||
|
* @version Release 1.0a - $Id$ */
|
||||||
|
public class X_AD_StorageProvider extends PO implements I_AD_StorageProvider, I_Persistent
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 20121123L;
|
||||||
|
|
||||||
|
/** Standard Constructor */
|
||||||
|
public X_AD_StorageProvider (Properties ctx, int AD_StorageProvider_ID, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, AD_StorageProvider_ID, trxName);
|
||||||
|
/** if (AD_StorageProvider_ID == 0)
|
||||||
|
{
|
||||||
|
} */
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load Constructor */
|
||||||
|
public X_AD_StorageProvider (Properties ctx, ResultSet rs, String trxName)
|
||||||
|
{
|
||||||
|
super (ctx, rs, trxName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** AccessLevel
|
||||||
|
* @return 3 - Client - Org
|
||||||
|
*/
|
||||||
|
protected int get_AccessLevel()
|
||||||
|
{
|
||||||
|
return accessLevel.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load Meta Data */
|
||||||
|
protected POInfo initPO (Properties ctx)
|
||||||
|
{
|
||||||
|
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
|
||||||
|
return poi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuffer sb = new StringBuffer ("X_AD_StorageProvider[")
|
||||||
|
.append(get_ID()).append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set AD_StorageProvider_ID.
|
||||||
|
@param AD_StorageProvider_ID AD_StorageProvider_ID */
|
||||||
|
public void setAD_StorageProvider_ID (int AD_StorageProvider_ID)
|
||||||
|
{
|
||||||
|
if (AD_StorageProvider_ID < 1)
|
||||||
|
set_Value (COLUMNNAME_AD_StorageProvider_ID, null);
|
||||||
|
else
|
||||||
|
set_Value (COLUMNNAME_AD_StorageProvider_ID, Integer.valueOf(AD_StorageProvider_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get AD_StorageProvider_ID.
|
||||||
|
@return AD_StorageProvider_ID */
|
||||||
|
public int getAD_StorageProvider_ID ()
|
||||||
|
{
|
||||||
|
Integer ii = (Integer)get_Value(COLUMNNAME_AD_StorageProvider_ID);
|
||||||
|
if (ii == null)
|
||||||
|
return 0;
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set AD_StorageProvider_UU.
|
||||||
|
@param AD_StorageProvider_UU AD_StorageProvider_UU */
|
||||||
|
public void setAD_StorageProvider_UU (String AD_StorageProvider_UU)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_AD_StorageProvider_UU, AD_StorageProvider_UU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get AD_StorageProvider_UU.
|
||||||
|
@return AD_StorageProvider_UU */
|
||||||
|
public String getAD_StorageProvider_UU ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_AD_StorageProvider_UU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set Folder.
|
||||||
|
@param Folder
|
||||||
|
A folder on a local or remote system to store data into
|
||||||
|
*/
|
||||||
|
public void setFolder (String Folder)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_Folder, Folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Folder.
|
||||||
|
@return A folder on a local or remote system to store data into
|
||||||
|
*/
|
||||||
|
public String getFolder ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_Folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Method AD_Reference_ID=200019 */
|
||||||
|
public static final int METHOD_AD_Reference_ID=200019;
|
||||||
|
/** File System = FileSystem */
|
||||||
|
public static final String METHOD_FileSystem = "FileSystem";
|
||||||
|
/** Database = DB */
|
||||||
|
public static final String METHOD_Database = "DB";
|
||||||
|
/** Set Method.
|
||||||
|
@param Method Method */
|
||||||
|
public void setMethod (String Method)
|
||||||
|
{
|
||||||
|
|
||||||
|
set_Value (COLUMNNAME_Method, Method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Method.
|
||||||
|
@return Method */
|
||||||
|
public String getMethod ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_Method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set Name.
|
||||||
|
@param Name
|
||||||
|
Alphanumeric identifier of the entity
|
||||||
|
*/
|
||||||
|
public void setName (String Name)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_Name, Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Name.
|
||||||
|
@return Alphanumeric identifier of the entity
|
||||||
|
*/
|
||||||
|
public String getName ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set Password.
|
||||||
|
@param Password
|
||||||
|
Password of any length (case sensitive)
|
||||||
|
*/
|
||||||
|
public void setPassword (String Password)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_Password, Password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Password.
|
||||||
|
@return Password of any length (case sensitive)
|
||||||
|
*/
|
||||||
|
public String getPassword ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_Password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set URL.
|
||||||
|
@param URL
|
||||||
|
Full URL address - e.g. http://www.idempiere.org
|
||||||
|
*/
|
||||||
|
public void setURL (String URL)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_URL, URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get URL.
|
||||||
|
@return Full URL address - e.g. http://www.idempiere.org
|
||||||
|
*/
|
||||||
|
public String getURL ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set Registered EMail.
|
||||||
|
@param UserName
|
||||||
|
Email of the responsible for the System
|
||||||
|
*/
|
||||||
|
public void setUserName (String UserName)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_UserName, UserName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Registered EMail.
|
||||||
|
@return Email of the responsible for the System
|
||||||
|
*/
|
||||||
|
public String getUserName ()
|
||||||
|
{
|
||||||
|
return (String)get_Value(COLUMNNAME_UserName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,9 @@ package org.adempiere.webui.panel;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -35,6 +37,7 @@ import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.event.DialogEvents;
|
import org.adempiere.webui.event.DialogEvents;
|
||||||
import org.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
|
import org.codehaus.groovy.vmplugin.v6.Java6;
|
||||||
import org.compiere.model.MAttachment;
|
import org.compiere.model.MAttachment;
|
||||||
import org.compiere.model.MAttachmentEntry;
|
import org.compiere.model.MAttachmentEntry;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
@ -58,6 +61,8 @@ import org.zkoss.zul.Filedownload;
|
||||||
import org.zkoss.zul.Hbox;
|
import org.zkoss.zul.Hbox;
|
||||||
import org.zkoss.zul.Iframe;
|
import org.zkoss.zul.Iframe;
|
||||||
|
|
||||||
|
import com.lowagie.text.pdf.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
|
@ -574,24 +579,27 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getMediaData(Media media) {
|
private byte[] getMediaData(Media media) {
|
||||||
byte[] bytes = null;
|
byte[] bytes = null;
|
||||||
|
|
||||||
if (media.inMemory())
|
try{
|
||||||
bytes = media.getByteData();
|
|
||||||
else {
|
if (media.inMemory())
|
||||||
InputStream is = media.getStreamData();
|
bytes = media.isBinary() ? media.getByteData() : media.getStringData().getBytes(getCharset(media.getContentType()));
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
else {
|
||||||
byte[] buf = new byte[ 1000 ];
|
InputStream is = media.getStreamData();
|
||||||
int byteread = 0;
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
try {
|
byte[] buf = new byte[ 1000 ];
|
||||||
while (( byteread=is.read(buf) )!=-1)
|
int byteread = 0;
|
||||||
|
|
||||||
|
while (( byteread=is.read(buf) )!=-1)
|
||||||
baos.write(buf,0,byteread);
|
baos.write(buf,0,byteread);
|
||||||
} catch (IOException e) {
|
|
||||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
|
||||||
throw new IllegalStateException(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
bytes = baos.toByteArray();
|
bytes = baos.toByteArray();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||||
|
throw new IllegalStateException(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
|
@ -673,4 +681,16 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // saveAttachmentToFile
|
} // saveAttachmentToFile
|
||||||
|
|
||||||
|
|
||||||
|
static private String getCharset(String contentType) {
|
||||||
|
if (contentType != null) {
|
||||||
|
int j = contentType.indexOf("charset=");
|
||||||
|
if (j >= 0) {
|
||||||
|
String cs = contentType.substring(j + 8).trim();
|
||||||
|
if (cs.length() > 0) return cs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "UTF-8";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue