mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 08:26:10 +00:00
Merge pull request #163 from owncloud/multiple_public_shares
Support in library for multiple public shares per file
This commit is contained in:
commit
bac38d13ef
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
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.
|
* 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 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_PATH = "path";
|
||||||
private static final String PARAM_SHARE_TYPE = "shareType";
|
private static final String PARAM_SHARE_TYPE = "shareType";
|
||||||
private static final String PARAM_SHARE_WITH = "shareWith";
|
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 PARAM_PERMISSIONS = "permissions";
|
||||||
|
private static final String FORMAT_EXPIRATION_DATE = "yyyy-MM-dd";
|
||||||
|
|
||||||
private String mRemoteFilePath;
|
private String mRemoteFilePath;
|
||||||
private ShareType mShareType;
|
private ShareType mShareType;
|
||||||
private String mShareWith;
|
private String mShareWith;
|
||||||
private boolean mPublicUpload;
|
|
||||||
private String mPassword;
|
|
||||||
private int mPermissions;
|
|
||||||
private boolean mGetShareDetails;
|
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 = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access permissions for the file bound to the share
|
||||||
|
*/
|
||||||
|
private int mPermissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload permissions for the public link (only folders)
|
||||||
|
*/
|
||||||
|
private Boolean mPublicUpload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -94,6 +124,59 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
|||||||
mGetShareDetails = false; // defaults to false for backwards compatibility
|
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.
|
||||||
|
* Null or empty string result in no value set for the name.
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.mName = (name == null) ? "" : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set password to create in Share resource.
|
||||||
|
*
|
||||||
|
* @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) {
|
||||||
|
mPassword = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set expiration date to create in Share resource.
|
||||||
|
*
|
||||||
|
* @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) {
|
||||||
|
mExpirationDateInMillis = expirationDateInMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set permissions to create in Share resource.
|
||||||
|
*
|
||||||
|
* @param permissions Permissions to set to the target share.
|
||||||
|
* Values <= 0 result in value set 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() {
|
public boolean isGettingShareDetails() {
|
||||||
return mGetShareDetails;
|
return mGetShareDetails;
|
||||||
}
|
}
|
||||||
@ -119,6 +202,19 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
|||||||
post.addParameter(PARAM_PATH, mRemoteFilePath);
|
post.addParameter(PARAM_PATH, mRemoteFilePath);
|
||||||
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.length() > 0) {
|
||||||
|
post.addParameter(PARAM_NAME, mName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mExpirationDateInMillis > 0) {
|
||||||
|
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) {
|
if (mPublicUpload) {
|
||||||
post.addParameter(PARAM_PUBLIC_UPLOAD, Boolean.toString(true));
|
post.addParameter(PARAM_PUBLIC_UPLOAD, Boolean.toString(true));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2016 ownCloud GmbH.
|
* Copyright (C) 2017 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares;
|
package com.owncloud.android.lib.resources.shares;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@ -37,7 +38,7 @@ import com.owncloud.android.lib.resources.files.FileUtils;
|
|||||||
* Contains the data of a Share from the Share API
|
* Contains the data of a Share from the Share API
|
||||||
*
|
*
|
||||||
* @author masensio
|
* @author masensio
|
||||||
*
|
* @author David A. Velasco
|
||||||
*/
|
*/
|
||||||
public class OCShare implements Parcelable, Serializable {
|
public class OCShare implements Parcelable, Serializable {
|
||||||
|
|
||||||
@ -57,32 +58,26 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
public static final int MAXIMUM_PERMISSIONS_FOR_FILE =
|
public static final int MAXIMUM_PERMISSIONS_FOR_FILE =
|
||||||
READ_PERMISSION_FLAG +
|
READ_PERMISSION_FLAG +
|
||||||
UPDATE_PERMISSION_FLAG +
|
UPDATE_PERMISSION_FLAG +
|
||||||
SHARE_PERMISSION_FLAG
|
SHARE_PERMISSION_FLAG;
|
||||||
;
|
|
||||||
public static final int MAXIMUM_PERMISSIONS_FOR_FOLDER =
|
public static final int MAXIMUM_PERMISSIONS_FOR_FOLDER =
|
||||||
MAXIMUM_PERMISSIONS_FOR_FILE +
|
MAXIMUM_PERMISSIONS_FOR_FILE +
|
||||||
CREATE_PERMISSION_FLAG +
|
CREATE_PERMISSION_FLAG +
|
||||||
DELETE_PERMISSION_FLAG
|
DELETE_PERMISSION_FLAG;
|
||||||
;
|
|
||||||
public static final int FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9 =
|
public static final int FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9 =
|
||||||
READ_PERMISSION_FLAG +
|
READ_PERMISSION_FLAG +
|
||||||
UPDATE_PERMISSION_FLAG
|
UPDATE_PERMISSION_FLAG;
|
||||||
;
|
|
||||||
public static final int FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9 =
|
public static final int FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9 =
|
||||||
READ_PERMISSION_FLAG +
|
READ_PERMISSION_FLAG +
|
||||||
UPDATE_PERMISSION_FLAG +
|
UPDATE_PERMISSION_FLAG +
|
||||||
SHARE_PERMISSION_FLAG
|
SHARE_PERMISSION_FLAG;
|
||||||
;
|
|
||||||
public static final int FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 =
|
public static final int FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 =
|
||||||
READ_PERMISSION_FLAG +
|
READ_PERMISSION_FLAG +
|
||||||
UPDATE_PERMISSION_FLAG +
|
UPDATE_PERMISSION_FLAG +
|
||||||
CREATE_PERMISSION_FLAG +
|
CREATE_PERMISSION_FLAG +
|
||||||
DELETE_PERMISSION_FLAG
|
DELETE_PERMISSION_FLAG;
|
||||||
;
|
|
||||||
public static final int FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 =
|
public static final int FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 =
|
||||||
FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 +
|
FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 +
|
||||||
SHARE_PERMISSION_FLAG
|
SHARE_PERMISSION_FLAG;
|
||||||
;
|
|
||||||
|
|
||||||
private long mId;
|
private long mId;
|
||||||
private long mFileSource;
|
private long mFileSource;
|
||||||
@ -95,6 +90,7 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
private long mExpirationDate;
|
private long mExpirationDate;
|
||||||
private String mToken;
|
private String mToken;
|
||||||
private String mSharedWithDisplayName;
|
private String mSharedWithDisplayName;
|
||||||
|
private String mName;
|
||||||
private boolean mIsFolder;
|
private boolean mIsFolder;
|
||||||
private long mUserId;
|
private long mUserId;
|
||||||
private long mRemoteId;
|
private long mRemoteId;
|
||||||
@ -133,6 +129,7 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
mUserId = -1;
|
mUserId = -1;
|
||||||
mRemoteId = -1;
|
mRemoteId = -1;
|
||||||
mShareLink = "";
|
mShareLink = "";
|
||||||
|
mName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getters and Setters
|
/// Getters and Setters
|
||||||
@ -225,6 +222,14 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
this.mSharedWithDisplayName = (sharedWithDisplayName != null) ? sharedWithDisplayName : "";
|
this.mSharedWithDisplayName = (sharedWithDisplayName != null) ? sharedWithDisplayName : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
mName = (name != null) ? name : "";
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFolder() {
|
public boolean isFolder() {
|
||||||
return mIsFolder;
|
return mIsFolder;
|
||||||
}
|
}
|
||||||
@ -306,6 +311,7 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
mUserId = source.readLong();
|
mUserId = source.readLong();
|
||||||
mRemoteId = source.readLong();
|
mRemoteId = source.readLong();
|
||||||
mShareLink = source.readString();
|
mShareLink = source.readString();
|
||||||
|
mName = source.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -332,6 +338,7 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
dest.writeLong(mUserId);
|
dest.writeLong(mUserId);
|
||||||
dest.writeLong(mRemoteId);
|
dest.writeLong(mRemoteId);
|
||||||
dest.writeString(mShareLink);
|
dest.writeString(mShareLink);
|
||||||
|
dest.writeString(mName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ public class ShareToRemoteOperationResultParser {
|
|||||||
if (shares != null) {
|
if (shares != null) {
|
||||||
for (OCShare share : shares) {
|
for (OCShare share : shares) {
|
||||||
resultData.add(share);
|
resultData.add(share);
|
||||||
// build the share link if not in the response (only received when the share is created)
|
// build the share link if not in the response
|
||||||
|
// (needed for OC servers < 9.0.0, see ShareXMLParser.java#line256)
|
||||||
if (share.getShareType() == ShareType.PUBLIC_LINK &&
|
if (share.getShareType() == ShareType.PUBLIC_LINK &&
|
||||||
(share.getShareLink() == null ||
|
(share.getShareLink() == null ||
|
||||||
share.getShareLink().length() <= 0) &&
|
share.getShareLink().length() <= 0) &&
|
||||||
@ -98,7 +99,7 @@ public class ShareToRemoteOperationResultParser {
|
|||||||
String sharingLinkPath = ShareUtils.getSharingLinkPath(mOwnCloudVersion);
|
String sharingLinkPath = ShareUtils.getSharingLinkPath(mOwnCloudVersion);
|
||||||
share.setShareLink(mServerBaseUri + sharingLinkPath + share.getToken());
|
share.setShareLink(mServerBaseUri + sharingLinkPath + share.getToken());
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Couldn't build link for public share");
|
Log_OC.e(TAG, "Couldn't build link for public share :(");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ public class ShareXMLParser {
|
|||||||
private static final String NODE_STORAGE = "storage";
|
private static final String NODE_STORAGE = "storage";
|
||||||
private static final String NODE_MAIL_SEND = "mail_send";
|
private static final String NODE_MAIL_SEND = "mail_send";
|
||||||
private static final String NODE_SHARE_WITH_DISPLAY_NAME = "share_with_displayname";
|
private static final String NODE_SHARE_WITH_DISPLAY_NAME = "share_with_displayname";
|
||||||
|
private static final String NODE_NAME = "name";
|
||||||
|
|
||||||
private static final String NODE_URL = "url";
|
private static final String NODE_URL = "url";
|
||||||
|
|
||||||
@ -252,6 +253,9 @@ public class ShareXMLParser {
|
|||||||
share.setIdRemoteShared(Integer.parseInt(value));
|
share.setIdRemoteShared(Integer.parseInt(value));
|
||||||
|
|
||||||
} else if (name.equalsIgnoreCase(NODE_URL)) {
|
} else if (name.equalsIgnoreCase(NODE_URL)) {
|
||||||
|
// NOTE: this field is received in all the public shares from OC 9.0.0
|
||||||
|
// in previous versions, it's received in the result of POST requests, but not
|
||||||
|
// in GET requests
|
||||||
share.setShareType(ShareType.PUBLIC_LINK);
|
share.setShareType(ShareType.PUBLIC_LINK);
|
||||||
String value = readNode(parser, NODE_URL);
|
String value = readNode(parser, NODE_URL);
|
||||||
share.setShareLink(value);
|
share.setShareLink(value);
|
||||||
@ -356,6 +360,9 @@ public class ShareXMLParser {
|
|||||||
String value = readNode(parser, NODE_URL);
|
String value = readNode(parser, NODE_URL);
|
||||||
share.setShareLink(value);
|
share.setShareLink(value);
|
||||||
|
|
||||||
|
} else if (name.equalsIgnoreCase(NODE_NAME)) {
|
||||||
|
share.setName(readNode(parser, NODE_NAME));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
skip(parser);
|
skip(parser);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +55,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
|
|
||||||
private static final String TAG = GetRemoteShareOperation.class.getSimpleName();
|
private static final String TAG = GetRemoteShareOperation.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final String PARAM_NAME = "name";
|
||||||
private static final String PARAM_PASSWORD = "password";
|
private static final String PARAM_PASSWORD = "password";
|
||||||
private static final String PARAM_EXPIRATION_DATE = "expireDate";
|
private static final String PARAM_EXPIRATION_DATE = "expireDate";
|
||||||
private static final String PARAM_PERMISSIONS = "permissions";
|
private static final String PARAM_PERMISSIONS = "permissions";
|
||||||
@ -87,6 +89,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
* Upload permissions for the public link (only folders)
|
* Upload permissions for the public link (only folders)
|
||||||
*/
|
*/
|
||||||
private Boolean mPublicUpload;
|
private Boolean mPublicUpload;
|
||||||
|
private String mName;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,6 +105,17 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set name to update in Share resource. Ignored by servers previous to version 10.0.0
|
||||||
|
*
|
||||||
|
* @param name Name to set to the target share.
|
||||||
|
* Empty string clears the current name.
|
||||||
|
* Null results in no update applied to the name.
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
this.mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set password to update in Share resource.
|
* Set password to update in Share resource.
|
||||||
*
|
*
|
||||||
@ -150,38 +164,42 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
@Override
|
@Override
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
int status = -1;
|
int status;
|
||||||
|
|
||||||
/// prepare array of parameters to update
|
/// prepare array of parameters to update
|
||||||
List<Pair<String, String>> parametersToUpdate = new ArrayList<Pair<String, String>>();
|
List<Pair<String, String>> parametersToUpdate = new ArrayList<>();
|
||||||
|
if (mName != null) {
|
||||||
|
parametersToUpdate.add(new Pair<>(PARAM_NAME, mName));
|
||||||
|
}
|
||||||
|
|
||||||
if (mPassword != null) {
|
if (mPassword != null) {
|
||||||
parametersToUpdate.add(new Pair<String, String>(PARAM_PASSWORD, mPassword));
|
parametersToUpdate.add(new Pair<>(PARAM_PASSWORD, mPassword));
|
||||||
}
|
}
|
||||||
if (mExpirationDateInMillis < 0) {
|
if (mExpirationDateInMillis < 0) {
|
||||||
// clear expiration date
|
// clear expiration date
|
||||||
parametersToUpdate.add(new Pair(PARAM_EXPIRATION_DATE, ""));
|
parametersToUpdate.add(new Pair<>(PARAM_EXPIRATION_DATE, ""));
|
||||||
|
|
||||||
} else if (mExpirationDateInMillis > 0) {
|
} else if (mExpirationDateInMillis > 0) {
|
||||||
// set expiration date
|
// set expiration date
|
||||||
DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE);
|
DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE, Locale.GERMAN);
|
||||||
Calendar expirationDate = Calendar.getInstance();
|
Calendar expirationDate = Calendar.getInstance();
|
||||||
expirationDate.setTimeInMillis(mExpirationDateInMillis);
|
expirationDate.setTimeInMillis(mExpirationDateInMillis);
|
||||||
String formattedExpirationDate = dateFormat.format(expirationDate.getTime());
|
String formattedExpirationDate = dateFormat.format(expirationDate.getTime());
|
||||||
parametersToUpdate.add(new Pair(PARAM_EXPIRATION_DATE, formattedExpirationDate));
|
parametersToUpdate.add(new Pair<>(PARAM_EXPIRATION_DATE, formattedExpirationDate));
|
||||||
|
|
||||||
} // else, ignore - no update
|
} // else, ignore - no update
|
||||||
if (mPermissions > 0) {
|
if (mPermissions > 0) {
|
||||||
// set permissions
|
// set permissions
|
||||||
parametersToUpdate.add(new Pair(PARAM_PERMISSIONS, Integer.toString(mPermissions)));
|
parametersToUpdate.add(new Pair<>(PARAM_PERMISSIONS, Integer.toString(mPermissions)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPublicUpload != null) {
|
if (mPublicUpload != null) {
|
||||||
parametersToUpdate.add(new Pair(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload)));
|
parametersToUpdate.add(new Pair<>(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// perform required PUT requests
|
/// perform required PUT requests
|
||||||
PutMethod put = null;
|
PutMethod put = null;
|
||||||
String uriString = null;
|
String uriString;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Uri requestUri = client.getBaseUri();
|
Uri requestUri = client.getBaseUri();
|
||||||
@ -218,7 +236,11 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
} else {
|
} else {
|
||||||
result = new RemoteOperationResult(false, put);
|
result = new RemoteOperationResult(false, put);
|
||||||
}
|
}
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess() &&
|
||||||
|
!PARAM_NAME.equals(parameter.first)
|
||||||
|
// fail in "name" parameter will be ignored; requires OCX, will fail
|
||||||
|
// fails in previous versions
|
||||||
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,5 +259,4 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
|
|||||||
private static final String PROPERTY_DAYS = "days";
|
private static final String PROPERTY_DAYS = "days";
|
||||||
private static final String PROPERTY_SEND_MAIL = "send_mail";
|
private static final String PROPERTY_SEND_MAIL = "send_mail";
|
||||||
private static final String PROPERTY_UPLOAD = "upload";
|
private static final String PROPERTY_UPLOAD = "upload";
|
||||||
|
private static final String PROPERTY_MULTIPLE = "multiple";
|
||||||
private static final String PROPERTY_RESHARING = "resharing";
|
private static final String PROPERTY_RESHARING = "resharing";
|
||||||
private static final String PROPERTY_OUTGOING = "outgoing";
|
private static final String PROPERTY_OUTGOING = "outgoing";
|
||||||
private static final String PROPERTY_INCOMING = "incoming";
|
private static final String PROPERTY_INCOMING = "incoming";
|
||||||
@ -205,6 +206,10 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
|
|||||||
capability.setFilesSharingPublicUpload(CapabilityBooleanType.fromBooleanValue(
|
capability.setFilesSharingPublicUpload(CapabilityBooleanType.fromBooleanValue(
|
||||||
respPublic.getBoolean(PROPERTY_UPLOAD)));
|
respPublic.getBoolean(PROPERTY_UPLOAD)));
|
||||||
}
|
}
|
||||||
|
if (respPublic.has(PROPERTY_MULTIPLE)) {
|
||||||
|
capability.setFilesSharingPublicMultiple(CapabilityBooleanType.fromBooleanValue(
|
||||||
|
respPublic.getBoolean(PROPERTY_MULTIPLE)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (respFilesSharing.has(NODE_USER)) {
|
if (respFilesSharing.has(NODE_USER)) {
|
||||||
|
@ -54,6 +54,7 @@ public class OCCapability {
|
|||||||
private CapabilityBooleanType mFilesSharingPublicExpireDateEnforced;
|
private CapabilityBooleanType mFilesSharingPublicExpireDateEnforced;
|
||||||
private CapabilityBooleanType mFilesSharingPublicSendMail;
|
private CapabilityBooleanType mFilesSharingPublicSendMail;
|
||||||
private CapabilityBooleanType mFilesSharingPublicUpload;
|
private CapabilityBooleanType mFilesSharingPublicUpload;
|
||||||
|
private CapabilityBooleanType mFilesSharingPublicMultiple;
|
||||||
|
|
||||||
private CapabilityBooleanType mFilesSharingUserSendMail;
|
private CapabilityBooleanType mFilesSharingUserSendMail;
|
||||||
|
|
||||||
@ -87,6 +88,7 @@ public class OCCapability {
|
|||||||
mFilesSharingPublicExpireDateEnforced = CapabilityBooleanType.UNKNOWN;
|
mFilesSharingPublicExpireDateEnforced = CapabilityBooleanType.UNKNOWN;
|
||||||
mFilesSharingPublicSendMail = CapabilityBooleanType.UNKNOWN;
|
mFilesSharingPublicSendMail = CapabilityBooleanType.UNKNOWN;
|
||||||
mFilesSharingPublicUpload = CapabilityBooleanType.UNKNOWN;
|
mFilesSharingPublicUpload = CapabilityBooleanType.UNKNOWN;
|
||||||
|
mFilesSharingPublicMultiple = CapabilityBooleanType.UNKNOWN;
|
||||||
mFilesSharingUserSendMail = CapabilityBooleanType.UNKNOWN;
|
mFilesSharingUserSendMail = CapabilityBooleanType.UNKNOWN;
|
||||||
mFilesSharingResharing = CapabilityBooleanType.UNKNOWN;
|
mFilesSharingResharing = CapabilityBooleanType.UNKNOWN;
|
||||||
mFilesSharingFederationOutgoing = CapabilityBooleanType.UNKNOWN;
|
mFilesSharingFederationOutgoing = CapabilityBooleanType.UNKNOWN;
|
||||||
@ -229,6 +231,14 @@ public class OCCapability {
|
|||||||
this.mFilesSharingPublicUpload = filesSharingPublicUpload;
|
this.mFilesSharingPublicUpload = filesSharingPublicUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CapabilityBooleanType getFilesSharingPublicMultiple() {
|
||||||
|
return mFilesSharingPublicMultiple;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilesSharingPublicMultiple(CapabilityBooleanType filesSharingPublicMultiple) {
|
||||||
|
this.mFilesSharingPublicMultiple = filesSharingPublicMultiple;
|
||||||
|
}
|
||||||
|
|
||||||
public CapabilityBooleanType getFilesSharingUserSendMail() {
|
public CapabilityBooleanType getFilesSharingUserSendMail() {
|
||||||
return mFilesSharingUserSendMail;
|
return mFilesSharingUserSendMail;
|
||||||
}
|
}
|
||||||
@ -284,8 +294,4 @@ public class OCCapability {
|
|||||||
public void setFilesVersioning(CapabilityBooleanType filesVersioning) {
|
public void setFilesVersioning(CapabilityBooleanType filesVersioning) {
|
||||||
this.mFilesVersioning = filesVersioning;
|
this.mFilesVersioning = filesVersioning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
private static final int MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301;
|
private static final int MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301;
|
||||||
// 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd
|
// 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd
|
||||||
|
|
||||||
|
private static final int MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000;
|
||||||
|
|
||||||
private static final String INVALID_ZERO_VERSION = "0.0.0";
|
private static final String INVALID_ZERO_VERSION = "0.0.0";
|
||||||
|
|
||||||
private static final int MAX_DOTS = 3;
|
private static final int MAX_DOTS = 3;
|
||||||
@ -193,4 +195,8 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
(mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE)
|
(mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMultiplePublicSharingSupported() {
|
||||||
|
return (mVersion >= MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user