mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Create public link [WIP]
This commit is contained in:
parent
188ce07155
commit
dda1429581
@ -34,6 +34,11 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Creates a new share. This allows sharing with a user or group or as a link.
|
||||
*/
|
||||
@ -41,21 +46,46 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
|
||||
private static final String TAG = CreateRemoteShareOperation.class.getSimpleName();
|
||||
|
||||
private static final String PARAM_NAME = "name";
|
||||
private static final String PARAM_PASSWORD = "password";
|
||||
private static final String PARAM_EXPIRATION_DATE = "expireDate";
|
||||
private static final String PARAM_PUBLIC_UPLOAD = "publicUpload";
|
||||
private static final String PARAM_PATH = "path";
|
||||
private static final String PARAM_SHARE_TYPE = "shareType";
|
||||
private static final String PARAM_SHARE_WITH = "shareWith";
|
||||
private static final String PARAM_PUBLIC_UPLOAD = "publicUpload";
|
||||
private static final String PARAM_PASSWORD = "password";
|
||||
private static final String PARAM_PERMISSIONS = "permissions";
|
||||
private static final String FORMAT_EXPIRATION_DATE = "yyyy-MM-dd";
|
||||
|
||||
private String mRemoteFilePath;
|
||||
private ShareType mShareType;
|
||||
private String mShareWith;
|
||||
private boolean mPublicUpload;
|
||||
private String mPassword;
|
||||
private int mPermissions;
|
||||
private boolean mGetShareDetails;
|
||||
|
||||
/**
|
||||
* Name to set for the public link
|
||||
*/
|
||||
private String mName;
|
||||
|
||||
/**
|
||||
* Password to set for the public link
|
||||
*/
|
||||
private String mPassword;
|
||||
|
||||
/**
|
||||
* Expiration date to set for the public link
|
||||
*/
|
||||
private long mExpirationDateInMillis;
|
||||
|
||||
/**
|
||||
* Access permissions for the file bound to the share
|
||||
*/
|
||||
private int mPermissions;
|
||||
|
||||
/**
|
||||
* Upload permissions for the public link (only folders)
|
||||
*/
|
||||
private Boolean mPublicUpload;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -94,6 +124,56 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
mGetShareDetails = false; // defaults to false for backwards compatibility
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.mName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set password to create in Share resource.
|
||||
*
|
||||
* @param password Password to set to the target share.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
mPassword = password;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set expiration date to create in Share resource.
|
||||
*
|
||||
* @param expirationDateInMillis Expiration date to set to the target share.
|
||||
*/
|
||||
public void setExpirationDate(long expirationDateInMillis) {
|
||||
mExpirationDateInMillis = expirationDateInMillis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set permissions to create in Share resource.
|
||||
*
|
||||
* @param permissions Permissions to set to the target share.
|
||||
* Values <= 0 result in no update applied to the permissions.
|
||||
*/
|
||||
public void setPermissions(int permissions) {
|
||||
mPermissions = permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* * Enable upload permissions to create in Share resource.
|
||||
* *
|
||||
* * @param publicUpload Upload permission to set to the target share.
|
||||
* * Null results in no update applied to the upload permission.
|
||||
*/
|
||||
public void setPublicUpload(Boolean publicUpload) {
|
||||
mPublicUpload = publicUpload;
|
||||
}
|
||||
|
||||
public boolean isGettingShareDetails() {
|
||||
return mGetShareDetails;
|
||||
}
|
||||
@ -119,6 +199,24 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
post.addParameter(PARAM_PATH, mRemoteFilePath);
|
||||
post.addParameter(PARAM_SHARE_TYPE, Integer.toString(mShareType.getValue()));
|
||||
post.addParameter(PARAM_SHARE_WITH, mShareWith);
|
||||
|
||||
if (mName != null) {
|
||||
post.addParameter(PARAM_NAME, mName);
|
||||
}
|
||||
|
||||
if (mExpirationDateInMillis < 0) {
|
||||
// empty expiration date
|
||||
post.addParameter(PARAM_EXPIRATION_DATE, "");
|
||||
|
||||
} else {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE, Locale.getDefault());
|
||||
Calendar expirationDate = Calendar.getInstance();
|
||||
expirationDate.setTimeInMillis(mExpirationDateInMillis);
|
||||
String formattedExpirationDate = dateFormat.format(expirationDate.getTime());
|
||||
post.addParameter(PARAM_EXPIRATION_DATE, formattedExpirationDate);
|
||||
}
|
||||
|
||||
if (mPublicUpload) {
|
||||
post.addParameter(PARAM_PUBLIC_UPLOAD, Boolean.toString(true));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user