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

Rename OCShare to RemoteShare

This commit is contained in:
davigonz 2019-01-03 14:33:03 +01:00
parent f11cab39bb
commit 54283c0ba9
7 changed files with 335 additions and 354 deletions

View File

@ -214,7 +214,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
if (mPassword != null && mPassword.length() > 0) {
formBodyBuilder.add(PARAM_PASSWORD, mPassword);
}
if (OCShare.DEFAULT_PERMISSION != mPermissions) {
if (RemoteShare.DEFAULT_PERMISSION != mPermissions) {
formBodyBuilder.add(PARAM_PERMISSIONS, Integer.toString(mPermissions));
}
@ -245,7 +245,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
// TODO Use executeHttpMethod
// retrieve more info - POST only returns the index of the new share
OCShare emptyShare = result.getData().getShares().get(0);
RemoteShare emptyShare = result.getData().getShares().get(0);
GetRemoteShareOperation getInfo = new GetRemoteShareOperation(
emptyShare.getRemoteId()
);

View File

@ -34,6 +34,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.FileUtils;
/**
* Contains the data of a Share from the Share API
*
@ -41,7 +42,14 @@ import com.owncloud.android.lib.resources.files.FileUtils;
* @author David A. Velasco
* @author David González Verdugo
*/
public class OCShare implements Parcelable, Serializable {
public class RemoteShare implements Parcelable, Serializable {
/**
* Generated - should be refreshed every time the class changes!!
*/
private static final long serialVersionUID = 4124975224281327921L;
private static final String TAG = RemoteShare.class.getSimpleName();
/**
* Generated - should be refreshed every time the class changes!!
@ -80,7 +88,6 @@ public class OCShare implements Parcelable, Serializable {
FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 +
SHARE_PERMISSION_FLAG;
private long mId;
private long mFileSource;
private long mItemSource;
private ShareType mShareType;
@ -98,16 +105,16 @@ public class OCShare implements Parcelable, Serializable {
private long mRemoteId;
private String mShareLink;
public OCShare() {
public RemoteShare() {
super();
resetData();
}
public OCShare(String path) {
public RemoteShare(String path) {
resetData();
if (path == null || path.length() <= 0 || !path.startsWith(FileUtils.PATH_SEPARATOR)) {
Log_OC.e(TAG, "Trying to create a OCShare with a non valid path");
throw new IllegalArgumentException("Trying to create a OCShare with a non valid path: " + path);
Log_OC.e(TAG, "Trying to create a RemoteShare with a non valid path");
throw new IllegalArgumentException("Trying to create a RemoteShare with a non valid path: " + path);
}
mPath = path;
}
@ -116,7 +123,6 @@ public class OCShare implements Parcelable, Serializable {
* Used internally. Reset all file properties
*/
private void resetData() {
mId = -1;
mFileSource = 0;
mItemSource = 0;
mShareType = ShareType.NO_SHARED;
@ -136,15 +142,6 @@ public class OCShare implements Parcelable, Serializable {
}
/// Getters and Setters
public long getId() {
return mId;
}
public void setId(long id) {
mId = id;
}
public long getFileSource() {
return mFileSource;
}
@ -280,15 +277,15 @@ public class OCShare implements Parcelable, Serializable {
/**
* Parcelable Methods
*/
public static final Parcelable.Creator<OCShare> CREATOR = new Parcelable.Creator<OCShare>() {
public static final Parcelable.Creator<RemoteShare> CREATOR = new Parcelable.Creator<RemoteShare>() {
@Override
public OCShare createFromParcel(Parcel source) {
return new OCShare(source);
public RemoteShare createFromParcel(Parcel source) {
return new RemoteShare(source);
}
@Override
public OCShare[] newArray(int size) {
return new OCShare[size];
public RemoteShare[] newArray(int size) {
return new RemoteShare[size];
}
};
@ -297,13 +294,11 @@ public class OCShare implements Parcelable, Serializable {
*
* @param source The source parcel
*/
protected OCShare(Parcel source) {
protected RemoteShare(Parcel source) {
readFromParcel(source);
}
public void readFromParcel(Parcel source) {
mId = source.readLong();
mFileSource = source.readLong();
mItemSource = source.readLong();
try {
@ -335,7 +330,6 @@ public class OCShare implements Parcelable, Serializable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mId);
dest.writeLong(mFileSource);
dest.writeLong(mItemSource);
dest.writeString((mShareType == null) ? "" : mShareType.name());

View File

@ -28,15 +28,15 @@ package com.owncloud.android.lib.resources.shares;
import java.util.ArrayList;
public class ShareParserResult {
private ArrayList<OCShare> shares;
private ArrayList<RemoteShare> shares;
private String parserMessage;
public ShareParserResult(ArrayList<OCShare> shares, String parserMessage) {
public ShareParserResult(ArrayList<RemoteShare> shares, String parserMessage) {
this.shares = shares;
this.parserMessage = parserMessage;
}
public ArrayList<OCShare> getShares() {
public ArrayList<RemoteShare> getShares() {
return shares;
}

View File

@ -31,10 +31,8 @@ package com.owncloud.android.lib.resources.shares;
*/
public class SharePermissionsBuilder {
/**
* Set of permissions
*/
private int mPermissions = OCShare.READ_PERMISSION_FLAG; // READ is minimum permission
/** Set of permissions */
private int mPermissions = RemoteShare.READ_PERMISSION_FLAG; // READ is minimum permission
/**
* Sets or clears permission to reshare a file or folder.
@ -43,7 +41,7 @@ public class SharePermissionsBuilder {
* @return Instance to builder itself, to allow consecutive calls to setters
*/
public SharePermissionsBuilder setSharePermission(boolean enabled) {
updatePermission(OCShare.SHARE_PERMISSION_FLAG, enabled);
updatePermission(RemoteShare.SHARE_PERMISSION_FLAG, enabled);
return this;
}
@ -54,7 +52,7 @@ public class SharePermissionsBuilder {
* @return Instance to builder itself, to allow consecutive calls to setters
*/
public SharePermissionsBuilder setUpdatePermission(boolean enabled) {
updatePermission(OCShare.UPDATE_PERMISSION_FLAG, enabled);
updatePermission(RemoteShare.UPDATE_PERMISSION_FLAG, enabled);
return this;
}
@ -65,7 +63,7 @@ public class SharePermissionsBuilder {
* @return Instance to builder itself, to allow consecutive calls to setters
*/
public SharePermissionsBuilder setCreatePermission(boolean enabled) {
updatePermission(OCShare.CREATE_PERMISSION_FLAG, enabled);
updatePermission(RemoteShare.CREATE_PERMISSION_FLAG, enabled);
return this;
}
@ -76,7 +74,7 @@ public class SharePermissionsBuilder {
* @return Instance to builder itself, to allow consecutive calls to setters
*/
public SharePermissionsBuilder setDeletePermission(boolean enabled) {
updatePermission(OCShare.DELETE_PERMISSION_FLAG, enabled);
updatePermission(RemoteShare.DELETE_PERMISSION_FLAG, enabled);
return this;
}

View File

@ -71,7 +71,7 @@ public class ShareToRemoteOperationResultParser {
}
RemoteOperationResult<ShareParserResult> result;
final ArrayList<OCShare> resultData = new ArrayList<>();
final ArrayList<RemoteShare> resultData = new ArrayList<>();
try {
// Parse xml response and obtain the list of shares
@ -80,13 +80,13 @@ public class ShareToRemoteOperationResultParser {
Log_OC.w(TAG, "No ShareXmlParser provided, creating new instance ");
mShareXmlParser = new ShareXMLParser();
}
List<OCShare> shares = mShareXmlParser.parseXMLResponse(is);
List<RemoteShare> shares = mShareXmlParser.parseXMLResponse(is);
if (mShareXmlParser.isSuccess()) {
if ((shares != null && shares.size() > 0) || !mOneOrMoreSharesRequired) {
result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.OK);
if (shares != null) {
for (OCShare share : shares) {
for (RemoteShare share : shares) {
resultData.add(share);
// build the share link if not in the response
// (needed for OC servers < 9.0.0, see ShareXMLParser.java#line256)

View File

@ -140,13 +140,12 @@ public class ShareXMLParser {
/**
* Parse is as response of Share API
*
* @param is
* @return List of ShareRemoteFiles
* @throws XmlPullParserException
* @throws IOException
*/
public ArrayList<OCShare> parseXMLResponse(InputStream is) throws XmlPullParserException,
public ArrayList<RemoteShare> parseXMLResponse(InputStream is) throws XmlPullParserException,
IOException {
try {
@ -167,16 +166,15 @@ public class ShareXMLParser {
/**
* Parse OCS node
*
* @param parser
* @return List of ShareRemoteFiles
* @throws XmlPullParserException
* @throws IOException
*/
private ArrayList<OCShare> readOCS(XmlPullParser parser) throws XmlPullParserException,
private ArrayList<RemoteShare> readOCS (XmlPullParser parser) throws XmlPullParserException,
IOException {
ArrayList<OCShare> shares = new ArrayList<>();
parser.require(XmlPullParser.START_TAG, ns, NODE_OCS);
ArrayList<RemoteShare> shares = new ArrayList<>();
parser.require(XmlPullParser.START_TAG, ns , NODE_OCS);
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
@ -197,7 +195,6 @@ public class ShareXMLParser {
/**
* Parse Meta node
*
* @param parser
* @throws XmlPullParserException
* @throws IOException
@ -229,16 +226,15 @@ public class ShareXMLParser {
/**
* Parse Data node
*
* @param parser
* @return
* @throws XmlPullParserException
* @throws IOException
*/
private ArrayList<OCShare> readData(XmlPullParser parser) throws XmlPullParserException,
private ArrayList<RemoteShare> readData(XmlPullParser parser) throws XmlPullParserException,
IOException {
ArrayList<OCShare> shares = new ArrayList<OCShare>();
OCShare share = null;
ArrayList<RemoteShare> shares = new ArrayList<RemoteShare>();
RemoteShare share = null;
parser.require(XmlPullParser.START_TAG, ns, NODE_DATA);
//Log_OC.d(TAG, "---- NODE DATA ---");
@ -251,7 +247,7 @@ public class ShareXMLParser {
readElement(parser, shares);
} else if (name.equalsIgnoreCase(NODE_ID)) {// Parse Create XML Response
share = new OCShare();
share = new RemoteShare();
String value = readNode(parser, NODE_ID);
share.setIdRemoteShared(Integer.parseInt(value));
@ -284,17 +280,16 @@ public class ShareXMLParser {
/**
* Parse Element node
*
* @param parser
* @return
* @throws XmlPullParserException
* @throws IOException
*/
private void readElement(XmlPullParser parser, ArrayList<OCShare> shares)
private void readElement(XmlPullParser parser, ArrayList<RemoteShare> shares)
throws XmlPullParserException, IOException {
parser.require(XmlPullParser.START_TAG, ns, NODE_ELEMENT);
OCShare share = new OCShare();
RemoteShare share = new RemoteShare();
//Log_OC.d(TAG, "---- NODE ELEMENT ---");
while (parser.next() != XmlPullParser.END_TAG) {
@ -360,9 +355,6 @@ public class ShareXMLParser {
} else if (name.equalsIgnoreCase(NODE_SHARE_WITH_DISPLAY_NAME)) {
share.setSharedWithDisplayName(readNode(parser, NODE_SHARE_WITH_DISPLAY_NAME));
} else if (name.equalsIgnoreCase(NODE_SHARE_WITH_ADDITIONAL_INFO)) {
share.setSharedWithAdditionalInfo(readNode(parser, NODE_SHARE_WITH_ADDITIONAL_INFO));
} else if (name.equalsIgnoreCase(NODE_URL)) {
String value = readNode(parser, NODE_URL);
share.setShareLink(value);
@ -380,11 +372,11 @@ public class ShareXMLParser {
}
}
private boolean isValidShare(OCShare share) {
private boolean isValidShare(RemoteShare share) {
return (share.getRemoteId() > -1);
}
private void fixPathForFolder(OCShare share) {
private void fixPathForFolder(RemoteShare share) {
if (share.isFolder() && share.getPath() != null && share.getPath().length() > 0 &&
!share.getPath().endsWith(FileUtils.PATH_SEPARATOR)) {
share.setPath(share.getPath() + FileUtils.PATH_SEPARATOR);
@ -393,15 +385,14 @@ public class ShareXMLParser {
/**
* Parse a node, to obtain its text. Needs readText method
*
* @param parser
* @param node
* @return Text of the node
* @throws XmlPullParserException
* @throws IOException
*/
private String readNode(XmlPullParser parser, String node) throws XmlPullParserException,
IOException {
private String readNode (XmlPullParser parser, String node) throws XmlPullParserException,
IOException{
parser.require(XmlPullParser.START_TAG, ns, node);
String value = readText(parser);
//Log_OC.d(TAG, "node= " + node + ", value= " + value);
@ -411,7 +402,6 @@ public class ShareXMLParser {
/**
* Read the text from a node
*
* @param parser
* @return Text of the node
* @throws IOException
@ -428,7 +418,6 @@ public class ShareXMLParser {
/**
* Skip tags in parser procedure
*
* @param parser
* @throws XmlPullParserException
* @throws IOException

View File

@ -99,7 +99,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation<ShareParserResul
mPassword = null; // no update
mExpirationDateInMillis = 0; // no update
mPublicUpload = null;
mPermissions = OCShare.DEFAULT_PERMISSION;
mPermissions = RemoteShare.DEFAULT_PERMISSION;
}
/**