Skip to content

Commit f536d13

Browse files
fpanizzajechague
authored andcommitted
Support download content in offline apps (#90)
Issue [#57791](https://issues.genexus.com/viewissue.aspx?57791)
1 parent 386b7bc commit f536d13

File tree

5 files changed

+45
-15
lines changed

5 files changed

+45
-15
lines changed

android/src/main/java/com/genexus/db/ForEachCursor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ public void setString(int index, String value, int length) throws SQLException {
205205
public void setString(int index, String value) throws SQLException {}
206206
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException {}
207207
public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException {}
208-
public void setBytes(int index, byte value[]) throws SQLException {}
208+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException {}
209+
public void setBytes(int index, byte value[]) throws SQLException {}
209210
public void setDateTime(int index, java.util.Date value, boolean onlyTime) throws SQLException {}
210211
public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean hasmilliseconds) throws SQLException {}
211212
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 {}
215216
public void setTimestamp(int index, java.sql.Timestamp value) throws SQLException {}
216217
public void setBLOBFile(int index, String fileName) throws SQLException {}
217218
public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException {}
218-
219-
public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {}
219+
public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException {}
220+
221+
public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {}
220222
public void setLongVarchar(int index, String value, boolean allowsNull) throws SQLException {}
221223
public void setNLongVarchar(int index, String value, boolean allowsNull) throws SQLException {}
222224
public void setLongVarchar(int index, String value, int maxLength, boolean allowsNull) throws SQLException {}

android/src/main/java/com/genexus/db/driver/GXPreparedStatement.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,15 @@ public void setString(int index, String value) throws SQLException
727727

728728
public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException
729729
{
730-
setGXDbFileURI(index, fileName, blobPath, length, null, null);
730+
setGXDbFileURI(index, fileName, blobPath, length, null, null, false);
731731
}
732732

733-
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException
733+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException
734+
{
735+
setGXDbFileURI(index, fileName, blobPath, length, null, null, false);
736+
}
737+
738+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException
734739
{
735740
if (blobPath.trim().length() == 0)
736741
setVarchar(index, fileName, length, false);
@@ -799,7 +804,9 @@ public void setGXDbFileURI(int index, String fileName, String blobPath, int leng
799804
}
800805
}
801806

802-
if (isLocalFile)
807+
if (isLocalFile
808+
|| (downloadContent && (blobPath.toLowerCase().startsWith("http://") || blobPath.toLowerCase().startsWith("https://")) )
809+
)
803810
{
804811
// Local path in sdcard.
805812
//fileNameNew = blobBasePath + "/" + GXutil.getFileName(fileName)+ "." + GXutil.getFileType(fileName);
@@ -1113,10 +1120,15 @@ public void setBLOBFile(java.sql.Blob blob, String fileName) throws SQLException
11131120

11141121
public void setBLOBFile(int index, String fileName) throws SQLException
11151122
{
1116-
setBLOBFile(index, fileName, false);
1123+
setBLOBFile(index, fileName, false, false);
1124+
}
1125+
1126+
public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException
1127+
{
1128+
setBLOBFile(index, fileName, isMultiMedia, false);
11171129
}
11181130

1119-
public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException
1131+
public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException
11201132
{
11211133
if(skipSetBlobs)
11221134
{
@@ -1174,10 +1186,11 @@ else if(blobFiles.length < index)
11741186
// add token if necesary?
11751187
//Boolean addToken = (fileName.compareTo(GXDbFile.removeTokenFromFileName(fileName)) == 0);
11761188

1177-
if (fileName.toLowerCase().startsWith("http") && isLocalFile)
1189+
if ( (fileName.toLowerCase().startsWith("http://") || fileName.toLowerCase().startsWith("https://"))
1190+
&& isLocalFile || downloadContent)
11781191
{
11791192
URL fileURL = new URL(fileName);
1180-
1193+
11811194
//fileNameNew = GXDbFile.generateUri(fileName, addToken);
11821195
fileNameNew = blobBasePath + "/" + CommonUtil.getFileName(fileName)+ "." + CommonUtil.getFileType(fileName);
11831196
//fileName = com.genexus.PrivateUtilities.getTempFileName(blobPath, GXutil.getFileName(fileName), GXutil.getFileType(fileName));

common/src/main/java/com/genexus/db/IFieldSetter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ public interface IFieldSetter
2121
public void setLongVarchar(int index, String value, int maxLength) throws SQLException;
2222
public void setString(int index, String value, int length) throws SQLException;
2323
public void setString(int index, String value) throws SQLException;
24-
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException;
2524
public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException;
26-
public void setBytes(int index, byte value[]) throws SQLException;
25+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException;
26+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException;
27+
public void setBytes(int index, byte value[]) throws SQLException;
2728
public void setDateTime(int index, java.util.Date value, boolean onlyTime) throws SQLException;
2829
public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean hasmilliseconds) throws SQLException;
2930
public void setDateTime(int index, java.util.Date value, boolean onlyTime, boolean onlyDate, boolean hasmilliseconds) throws SQLException;
@@ -33,6 +34,7 @@ public interface IFieldSetter
3334
public void setTimestamp(int index, java.sql.Timestamp value) throws SQLException;
3435
public void setBLOBFile(int index, String fileName) throws SQLException;
3536
public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException;
37+
public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException;
3638

3739
public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException;
3840
public void setLongVarchar(int index, String value, boolean allowsNull) throws SQLException;

java/src/main/java/com/genexus/db/ForEachCursor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ public void setString(int index, String value, int length) throws SQLException {
313313
public void setString(int index, String value) throws SQLException {}
314314
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException {}
315315
public void setGXDbFileURI(int index, String fileName, String blobPath, int length) throws SQLException {}
316-
public void setBytes(int index, byte value[]) throws SQLException {}
316+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException {}
317+
public void setBytes(int index, byte value[]) throws SQLException {}
317318

318319
public void setDateTime(int index, java.util.Date value, boolean onlyTime) throws SQLException {}
319320
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 {}
325326
public void setTimestamp(int index, java.sql.Timestamp value) throws SQLException {}
326327
public void setBLOBFile(int index, String fileName) throws SQLException {}
327328
public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException {}
328-
329-
public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {}
329+
public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContet) throws SQLException {}
330+
331+
public void setVarchar(int index, String value, int length, boolean allowsNull) throws SQLException {}
330332
public void setLongVarchar(int index, String value, boolean allowsNull) throws SQLException {}
331333
public void setNLongVarchar(int index, String value, boolean allowsNull) throws SQLException {}
332334
public void setLongVarchar(int index, String value, int maxLength, boolean allowsNull) throws SQLException {}

java/src/main/java/com/genexus/db/driver/GXPreparedStatement.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,12 @@ public void setGXDbFileURI(int index, String fileName, String blobPath, int leng
927927
{
928928
setGXDbFileURI(index, fileName, blobPath, length, null, null);
929929
}
930+
931+
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName, boolean downloadContent) throws SQLException
932+
{
933+
setGXDbFileURI(index, fileName, blobPath, length, tableName, fieldName);
934+
}
935+
930936
public void setGXDbFileURI(int index, String fileName, String blobPath, int length, String tableName, String fieldName) throws SQLException
931937
{
932938

@@ -1349,6 +1355,11 @@ public void setBLOBFile(int index, String fileName) throws SQLException
13491355
setBLOBFile(index, fileName, false);
13501356
}
13511357

1358+
public void setBLOBFile(int index, String fileName, boolean isMultiMedia, boolean downloadContent) throws SQLException
1359+
{
1360+
setBLOBFile(index, fileName, isMultiMedia);
1361+
}
1362+
13521363
public void setBLOBFile(int index, String fileName, boolean isMultiMedia) throws SQLException
13531364
{
13541365
if (isMultiMedia && Application.getGXServices().get(GXServices.STORAGE_SERVICE) != null)

0 commit comments

Comments
 (0)