Skip to content

Commit

Permalink
RW-598: Fixed response markup parsing for file sizes greater than Int…
Browse files Browse the repository at this point in the history
…eger.MAX_VALUE.

Modifed the size property on the following classes to support file sizes greater than Integer.MAX_VALUE returned on API response markup:

- RProjectFileDetails
- RProjectResultDetails
- RRepositoryFileDetails

The size property in each case is now of type Long supporting max files sizes of Long.MAX_VALUE.

Relevant unit tests have also been updated to reflect these changes.
  • Loading branch information
david-russell committed Jan 30, 2015
1 parent abfc64d commit 1145c26
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class RProjectFileDetails {

public RProjectFileDetails(String filename, String descr, String type, int size, URL url) {
public RProjectFileDetails(String filename, String descr, String type, long size, URL url) {
this.filename = filename;
this.descr = descr;
this.type = type;
Expand All @@ -44,6 +44,6 @@ public RProjectFileDetails(String filename, String descr, String type, int size,
/**
* Project directory file size.
*/
public final int size;
public final long size;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class RProjectResultDetails {

public RProjectResultDetails(String execution, String filename, String type, int size, URL url) {
public RProjectResultDetails(String execution, String filename, String type, long size, URL url) {
this.execution = execution;
this.filename = filename;
this.type = type;
Expand All @@ -40,7 +40,7 @@ public RProjectResultDetails(String execution, String filename, String type, int
/**
* Project execution result file size.
*/
public final int size;
public final long size;

/**
* Project execution result file url.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class RRepositoryFileDetails {
public RRepositoryFileDetails(String filename, String directory,
String author, String version,
String latestby, String descr, String type,
int size, URL url, String access,
long size, URL url, String access,
String restricted, boolean shared, boolean published,
List<String> authors, String inputs, String outputs,
String tags, RRepositoryFile.Category category,
Expand Down Expand Up @@ -90,7 +90,7 @@ public RRepositoryFileDetails(String filename, String directory,
/**
* Repository file size.
*/
public final int size;
public final long size;

/**
* Repository file access level display-friendly description:
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/com/revo/deployr/client/util/REntityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public static RRepositoryFileDetails getRepositoryFileDetails(Map repoFile) {
url = new URL(urlString);
} catch (Exception ex) {
}
int size = (Integer) repoFile.get("length");
long size = 0L;
Object sizeObj = repoFile.get("length");
if(sizeObj instanceof Long)
size = (Long) sizeObj;
else
if(sizeObj instanceof Integer)
size = ((Integer) sizeObj).longValue();
String restricted = (String) repoFile.get("restricted");
boolean shared = false;
if (repoFile.get("shared") != null) {
Expand Down Expand Up @@ -289,7 +295,13 @@ public static RProjectFileDetails getProjectFileDetails(Map fileMap) {
String filename = (String) fileMap.get("filename");
String descr = (String) fileMap.get("descr");
String type = (String) fileMap.get("type");
int size = (Integer) fileMap.get("length");
long size = 0L;
Object sizeObj = fileMap.get("length");
if(sizeObj instanceof Long)
size = (Long) sizeObj;
else
if(sizeObj instanceof Integer)
size = ((Integer) sizeObj).longValue();
String urlString = (String) fileMap.get("url");
URL url = null;
try {
Expand All @@ -308,7 +320,13 @@ public static RProjectResultDetails getProjectResultDetails(Map resultMap) {
String execution = (String) resultMap.get("execution");
String filename = (String) resultMap.get("filename");
String type = (String) resultMap.get("type");
int size = (Integer) resultMap.get("length");
long size = 0L;
Object sizeObj = resultMap.get("length");
if(sizeObj instanceof Long)
size = (Long) sizeObj;
else
if(sizeObj instanceof Integer)
size = ((Integer) sizeObj).longValue();
String urlString = (String) resultMap.get("url");
URL url = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ public void testProjectDirectoryLoadFile() {
RProjectFile actualProjectFile = null;
URL url = null;
String urlData = "";
int actualSize = 0;
int expSize = 0;
long actualSize = 0;
long expSize = 0;

// Test error handling.
Exception exception = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,8 @@ public void testUserRepositoryTransferFile() {
URL repoURL = null;
URL repoTransURL = null;
RRepositoryFile repoTransFile = null;
int repoFileSize = 0;
int repoTransFileSize = 0;
long repoFileSize = 0;
long repoTransFileSize = 0;

// Test error handling.
Exception exception = null;
Expand Down

0 comments on commit 1145c26

Please sign in to comment.