From e006ace1d2de2490862453abb3ded5087cca0290 Mon Sep 17 00:00:00 2001 From: fpanizza Date: Wed, 24 Jul 2019 11:44:44 -0300 Subject: [PATCH 1/2] add overload to setBlobFile and setGxDbFileURI to support downloadContent property. --- .../src/main/java/com/genexus/db/ForEachCursor.java | 8 +++++--- common/src/main/java/com/genexus/db/IFieldSetter.java | 6 ++++-- java/src/main/java/com/genexus/db/ForEachCursor.java | 8 +++++--- .../com/genexus/db/driver/GXPreparedStatement.java | 11 +++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/genexus/db/ForEachCursor.java b/android/src/main/java/com/genexus/db/ForEachCursor.java index 4074d2fae..9f6f230b6 100644 --- a/android/src/main/java/com/genexus/db/ForEachCursor.java +++ b/android/src/main/java/com/genexus/db/ForEachCursor.java @@ -205,7 +205,8 @@ public void setString(int index, String value, int length) throws SQLException { public void setString(int index, String value) throws SQLException {} public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException {} public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException {} - public void setBytes(int index, byte value[]) throws SQLException {} + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException {} + public void setBytes(int index, byte value[]) throws SQLException {} public void setDateTime(int index, java.util.Date value, boolean onlyTime) throws SQLException {} public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean hasmilliseconds) throws SQLException {} public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean onlyDate, boolean hasmilliseconds) throws SQLException {} @@ -215,8 +216,9 @@ public void setTime(int index, java.sql.Time value) throws SQLException {} public void setTimestamp(int index, java.sql.Timestamp value) throws SQLException {} public void setBLOBFile(int index, String fileName) throws SQLException {} public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException {} - - public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {} + public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException {} + + public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {} public void setLongVarchar(int index, String value, boolean allowsNull) throws SQLException {} public void setNLongVarchar(int index, String value, boolean allowsNull) throws SQLException {} public void setLongVarchar(int index, String value, int maxLength, boolean allowsNull) throws SQLException {} diff --git a/common/src/main/java/com/genexus/db/IFieldSetter.java b/common/src/main/java/com/genexus/db/IFieldSetter.java index 67fd263c4..0eafd787e 100644 --- a/common/src/main/java/com/genexus/db/IFieldSetter.java +++ b/common/src/main/java/com/genexus/db/IFieldSetter.java @@ -21,9 +21,10 @@ public interface IFieldSetter public void setLongVarchar(int index, String value, int maxLength) throws SQLException; public void setString(int index, String value, int length) throws SQLException; public void setString(int index, String value) throws SQLException; - public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException; public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException; - public void setBytes(int index, byte value[]) throws SQLException; + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException; + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException; + public void setBytes(int index, byte value[]) throws SQLException; public void setDateTime(int index, java.util.Date value, boolean onlyTime) throws SQLException; public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean hasmilliseconds) throws SQLException; public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean onlyDate, boolean hasmilliseconds) throws SQLException; @@ -33,6 +34,7 @@ public interface IFieldSetter public void setTimestamp(int index, java.sql.Timestamp value) throws SQLException; public void setBLOBFile(int index, String fileName) throws SQLException; public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException; + public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException; public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException; public void setLongVarchar(int index, String value, boolean allowsNull) throws SQLException; diff --git a/java/src/main/java/com/genexus/db/ForEachCursor.java b/java/src/main/java/com/genexus/db/ForEachCursor.java index cf80401bc..328b14b87 100644 --- a/java/src/main/java/com/genexus/db/ForEachCursor.java +++ b/java/src/main/java/com/genexus/db/ForEachCursor.java @@ -313,7 +313,8 @@ public void setString(int index, String value, int length) throws SQLException { public void setString(int index, String value) throws SQLException {} public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException {} public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException {} - public void setBytes(int index, byte value[]) throws SQLException {} + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException {} + public void setBytes(int index, byte value[]) throws SQLException {} public void setDateTime(int index, java.util.Date value, boolean onlyTime) throws SQLException {} public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean hasmilliseconds) throws SQLException{} @@ -325,8 +326,9 @@ public void setTime(int index, java.sql.Time value) throws SQLException {} public void setTimestamp(int index, java.sql.Timestamp value) throws SQLException {} public void setBLOBFile(int index, String fileName) throws SQLException {} public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException {} - - public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {} + public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContet) throws SQLException {} + + public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {} public void setLongVarchar(int index, String value, boolean allowsNull) throws SQLException {} public void setNLongVarchar(int index, String value, boolean allowsNull) throws SQLException {} public void setLongVarchar(int index, String value, int maxLength, boolean allowsNull) throws SQLException {} diff --git a/java/src/main/java/com/genexus/db/driver/GXPreparedStatement.java b/java/src/main/java/com/genexus/db/driver/GXPreparedStatement.java index a6e5decf7..da73ed3e8 100644 --- a/java/src/main/java/com/genexus/db/driver/GXPreparedStatement.java +++ b/java/src/main/java/com/genexus/db/driver/GXPreparedStatement.java @@ -927,6 +927,12 @@ public void setGXDbFileURI(int index, String fileName, String blobPath, int leng { setGXDbFileURI(index, fileName, blobPath, length, null, null); } + + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException + { + setGXDbFileURI(index, fileName, blobPath, length, tableName, fieldName); + } + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException { @@ -1349,6 +1355,11 @@ public void setBLOBFile(int index, String fileName) throws SQLException setBLOBFile(index, fileName, false); } + public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException + { + setBLOBFile(index, fileName, isMultiMedia); + } + public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException { if (isMultiMedia && Application.getGXServices().get(GXServices.STORAGE_SERVICE) != null) From 0d268d8406608490db9f7ca7bcb26d4b80ee43c3 Mon Sep 17 00:00:00 2001 From: fpanizza Date: Wed, 24 Jul 2019 11:48:31 -0300 Subject: [PATCH 2/2] add implementation of overload to setBlobFile and setGxDbFileURI to support downloadContent property in android. --- .../db/driver/GXPreparedStatement.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/genexus/db/driver/GXPreparedStatement.java b/android/src/main/java/com/genexus/db/driver/GXPreparedStatement.java index 2cb4880d3..f6d93fef7 100644 --- a/android/src/main/java/com/genexus/db/driver/GXPreparedStatement.java +++ b/android/src/main/java/com/genexus/db/driver/GXPreparedStatement.java @@ -727,10 +727,15 @@ public void setString(int index, String value) throws SQLException public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException { - setGXDbFileURI(index, fileName, blobPath, length, null, null); + setGXDbFileURI(index, fileName, blobPath, length, null, null, false); } - public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException + { + setGXDbFileURI(index, fileName, blobPath, length, null, null, false); + } + + public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException { if (blobPath.trim().length() == 0) setVarchar(index, fileName, length, false); @@ -799,7 +804,9 @@ public void setGXDbFileURI(int index, String fileName, String blobPath, int leng } } - if (isLocalFile) + if (isLocalFile + || (downloadContent && (blobPath.toLowerCase().startsWith("http://") || blobPath.toLowerCase().startsWith("https://")) ) + ) { // Local path in sdcard. //fileNameNew = blobBasePath + "/" + GXutil.getFileName(fileName)+ "." + GXutil.getFileType(fileName); @@ -1113,10 +1120,15 @@ public void setBLOBFile(java.sql.Blob blob, String fileName) throws SQLException public void setBLOBFile(int index, String fileName) throws SQLException { - setBLOBFile(index, fileName, false); + setBLOBFile(index, fileName, false, false); + } + + public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException + { + setBLOBFile(index, fileName, isMultiMedia, false); } - public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException + public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException { if(skipSetBlobs) { @@ -1174,10 +1186,11 @@ else if(blobFiles.length < index) // add token if necesary? //Boolean addToken = (fileName.compareTo(GXDbFile.removeTokenFromFileName(fileName)) == 0); - if (fileName.toLowerCase().startsWith("http") && isLocalFile) + if ( (fileName.toLowerCase().startsWith("http://") || fileName.toLowerCase().startsWith("https://")) + && isLocalFile || downloadContent) { URL fileURL = new URL(fileName); - + //fileNameNew = GXDbFile.generateUri(fileName, addToken); fileNameNew = blobBasePath + "/" + CommonUtil.getFileName(fileName)+ "." + CommonUtil.getFileType(fileName); //fileName = com.genexus.PrivateUtilities.getTempFileName(blobPath, GXutil.getFileName(fileName), GXutil.getFileType(fileName));