1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +00:00

Prevent send of empty value for expiration date and link name when public share is created

This commit is contained in:
David A. Velasco 2017-05-05 12:57:55 +02:00
parent 6d0773cf34
commit 8f5ac456ab
2 changed files with 11 additions and 13 deletions

View File

@ -255,7 +255,7 @@ public class RemoteOperationResult implements Serializable {
ErrorMessageParser xmlParser = new ErrorMessageParser(); ErrorMessageParser xmlParser = new ErrorMessageParser();
try { try {
String errorMessage = xmlParser.parseXMLResponse(is); String errorMessage = xmlParser.parseXMLResponse(is);
if (errorMessage != null && errorMessage != "") { if (errorMessage != null && errorMessage.length() > 0) {
mCode = ResultCode.SPECIFIC_FORBIDDEN; mCode = ResultCode.SPECIFIC_FORBIDDEN;
mHttpPhrase = errorMessage; mHttpPhrase = errorMessage;
} }

View File

@ -64,7 +64,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
/** /**
* Name to set for the public link * Name to set for the public link
*/ */
private String mName; private String mName = "";
/** /**
* Password to set for the public link * Password to set for the public link
@ -74,7 +74,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
/** /**
* Expiration date to set for the public link * Expiration date to set for the public link
*/ */
private long mExpirationDateInMillis; private long mExpirationDateInMillis = 0;
/** /**
* Access permissions for the file bound to the share * Access permissions for the file bound to the share
@ -128,16 +128,18 @@ public class CreateRemoteShareOperation extends RemoteOperation {
/** /**
* Set name to create in Share resource. Ignored by servers previous to version 10.0.0 * Set name to create in Share resource. Ignored by servers previous to version 10.0.0
* *
* @param name Name to set to the target share. * @param name Name to set to the target share.
* Null or empty string result in no value set for the name.
*/ */
public void setName(String name) { public void setName(String name) {
this.mName = name; this.mName = (name == null) ? "" : name;
} }
/** /**
* Set password to create in Share resource. * Set password to create in Share resource.
* *
* @param password Password to set to the target share. * @param password Password to set to the target share.
* Null or empty string result in no value set for the password.
*/ */
public void setPassword(String password) { public void setPassword(String password) {
mPassword = password; mPassword = password;
@ -148,6 +150,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
* Set expiration date to create in Share resource. * Set expiration date to create in Share resource.
* *
* @param expirationDateInMillis Expiration date to set to the target share. * @param expirationDateInMillis Expiration date to set to the target share.
* Zero or negative value results in no value sent for expiration date.
*/ */
public void setExpirationDate(long expirationDateInMillis) { public void setExpirationDate(long expirationDateInMillis) {
mExpirationDateInMillis = expirationDateInMillis; mExpirationDateInMillis = expirationDateInMillis;
@ -158,7 +161,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
* Set permissions to create in Share resource. * Set permissions to create in Share resource.
* *
* @param permissions Permissions to set to the target share. * @param permissions Permissions to set to the target share.
* Values <= 0 result in no update applied to the permissions. * Values <= 0 result in value set to the permissions.
*/ */
public void setPermissions(int permissions) { public void setPermissions(int permissions) {
mPermissions = permissions; mPermissions = permissions;
@ -200,16 +203,11 @@ public class CreateRemoteShareOperation extends RemoteOperation {
post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue())); post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue()));
post.addParameter(PARAM_SHARE_WITH, mShareWith); post.addParameter(PARAM_SHARE_WITH, mShareWith);
if (mName != null) { if (mName.length() > 0) {
post.addParameter(PARAM_NAME, mName); post.addParameter(PARAM_NAME, mName);
} }
if (mExpirationDateInMillis < 0) { if (mExpirationDateInMillis > 0) {
// empty expiration date
post.addParameter(PARAM_EXPIRATION_DATE, "");
} else {
DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE, Locale.getDefault()); DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE, Locale.getDefault());
Calendar expirationDate = Calendar.getInstance(); Calendar expirationDate = Calendar.getInstance();
expirationDate.setTimeInMillis(mExpirationDateInMillis); expirationDate.setTimeInMillis(mExpirationDateInMillis);