BF [ 2736995 ] - toURL() in java.io.File has been deprecated

This commit is contained in:
mjudd 2009-04-06 10:58:29 +00:00
parent 4e48dd6b54
commit e3eca6fdb1
4 changed files with 30 additions and 26 deletions

View File

@ -19,7 +19,7 @@ package org.compiere.model;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URI;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
@ -33,6 +33,7 @@ import org.compiere.util.DB;
* Product Download Model
* @author Jorg Janke
* @version $Id: MProductDownload.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $
* @author Michael Judd BF [ 2736995 ] - toURL() in java.io.File has been deprecated
*/
public class MProductDownload extends X_M_ProductDownload
{
@ -169,22 +170,22 @@ public class MProductDownload extends X_M_ProductDownload
* @param directory optional directory
* @return url
*/
public URL getDownloadURL (String directory)
public URI getDownloadURL (String directory)
{
String dl_url = getDownloadURL();
if (dl_url == null || !isActive())
return null;
URL url = null;
URI url = null;
try
{
if (dl_url.indexOf ("://") != -1)
url = new URL (dl_url);
url = new URI (dl_url);
else
{
File f = getDownloadFile (directory);
if (f != null)
url = f.toURL ();
url = f.toURI ();
}
}
catch (Exception ex)
@ -239,8 +240,8 @@ public class MProductDownload extends X_M_ProductDownload
{
if (dl_url.indexOf ("://") != -1)
{
URL url = new URL (dl_url);
in = url.openStream();
URI url = new URI (dl_url);
in = url.toURL().openStream();
}
else // file
{

View File

@ -32,7 +32,7 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.logging.Logger;
@ -46,6 +46,7 @@ import com.sun.image.codec.jpeg.JPEGImageDecoder;
*
* @author Jorg Janke
* @version $Id: AdempiereUtils.java,v 1.2 2006/07/30 00:52:23 jjanke Exp $
* @author Michael Judd BF [ 2736995 ] - toURL() in java.io.File has been deprecated
*/
public class CompiereUtils
{
@ -55,7 +56,7 @@ public class CompiereUtils
/**
* Fill Background with Color.
* (Ususlly called from update methods)
* (Usually called from update methods)
*
* @param g2D Graphics
* @param c Component
@ -242,10 +243,10 @@ public class CompiereUtils
try
{
File file = new File(path);
URL url = file.toURL();
image = loadImage(url);
URI url = file.toURI();
image = loadImage(url.toString());
}
catch (MalformedURLException e)
catch (SecurityException e)
{
log.severe("Path= " + path + " - " + e.getMessage());
}
@ -315,10 +316,10 @@ public class CompiereUtils
BufferedImage image = null;
try
{
URL url = file.toURL();
image = loadBufferedImage(url, imageType);
URI url = file.toURI();
image = loadBufferedImage(url.toString(), imageType);
}
catch (MalformedURLException e)
catch (SecurityException e)
{
log.severe("File: " + file + " - " + e.getMessage());
}
@ -342,10 +343,10 @@ public class CompiereUtils
BufferedImage image = null;
try
{
URL url = file.toURL();
image = loadBufferedImage(url, imageType);
URI url = file.toURI();
image = loadBufferedImage(url.toString(), imageType);
}
catch (MalformedURLException e)
catch (SecurityException e)
{
log.severe("Path: " + path + " - " + e.getMessage());
}

View File

@ -16,7 +16,7 @@
*****************************************************************************/
package org.compiere.process;
import java.net.URL;
import java.net.URI;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
@ -37,6 +37,7 @@ import org.compiere.util.EMail;
*
* @author Jorg Janke
* @version $Id: AssetDelivery.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
* @author Michael Judd BF [ 2736995 ] - toURL() in java.io.File has been deprecated
*/
public class AssetDelivery extends SvrProcess
{
@ -274,7 +275,7 @@ public class AssetDelivery extends SvrProcess
{
for (int i = 0; i < pdls.length; i++)
{
URL url = pdls[i].getDownloadURL(m_client.getDocumentDir());
URI url = pdls[i].getDownloadURL(m_client.getDocumentDir());
if (url != null)
email.addAttachment(url);
}

View File

@ -19,7 +19,7 @@ package org.compiere.util;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.URL;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
@ -62,6 +62,7 @@ import com.sun.mail.smtp.SMTPMessage;
*
* @author Jorg Janke
* @version $Id: EMail.java,v 1.4 2006/07/30 00:54:35 jjanke Exp $
* @author Michael Judd BF [ 2736995 ] - toURL() in java.io.File has been deprecated
*/
public final class EMail implements Serializable
{
@ -799,9 +800,9 @@ public final class EMail implements Serializable
/**
* Add url based file Attachment
* @param url url content to attach
* @param uri url content to attach
*/
public void addAttachment (URL url)
public void addAttachment (URI url)
{
if (url == null)
return;
@ -894,10 +895,10 @@ public final class EMail implements Serializable
continue;
}
}
else if (attachment instanceof URL)
else if (attachment instanceof URI)
{
URL url = (URL)attachment;
ds = new URLDataSource (url);
URI url = (URI)attachment;
ds = new URLDataSource (url.toURL());
}
else if (attachment instanceof DataSource)
ds = (DataSource)attachment;