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) { if (mPassword != null && mPassword.length() > 0) {
formBodyBuilder.add(PARAM_PASSWORD, mPassword); formBodyBuilder.add(PARAM_PASSWORD, mPassword);
} }
if (OCShare.DEFAULT_PERMISSION != mPermissions) { if (RemoteShare.DEFAULT_PERMISSION != mPermissions) {
formBodyBuilder.add(PARAM_PERMISSIONS, Integer.toString(mPermissions)); formBodyBuilder.add(PARAM_PERMISSIONS, Integer.toString(mPermissions));
} }
@ -245,7 +245,7 @@ public class CreateRemoteShareOperation extends RemoteOperation {
// TODO Use executeHttpMethod // TODO Use executeHttpMethod
// retrieve more info - POST only returns the index of the new share // 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( GetRemoteShareOperation getInfo = new GetRemoteShareOperation(
emptyShare.getRemoteId() 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; 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
* *
@ -41,7 +42,14 @@ import com.owncloud.android.lib.resources.files.FileUtils;
* @author David A. Velasco * @author David A. Velasco
* @author David González Verdugo * @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!! * 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 + FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 +
SHARE_PERMISSION_FLAG; SHARE_PERMISSION_FLAG;
private long mId;
private long mFileSource; private long mFileSource;
private long mItemSource; private long mItemSource;
private ShareType mShareType; private ShareType mShareType;
@ -98,16 +105,16 @@ public class OCShare implements Parcelable, Serializable {
private long mRemoteId; private long mRemoteId;
private String mShareLink; private String mShareLink;
public OCShare() { public RemoteShare() {
super(); super();
resetData(); resetData();
} }
public OCShare(String path) { public RemoteShare(String path) {
resetData(); resetData();
if (path == null || path.length() <= 0 || !path.startsWith(FileUtils.PATH_SEPARATOR)) { 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"); Log_OC.e(TAG, "Trying to create a RemoteShare with a non valid path");
throw new IllegalArgumentException("Trying to create a OCShare with a non valid path: " + path); throw new IllegalArgumentException("Trying to create a RemoteShare with a non valid path: " + path);
} }
mPath = path; mPath = path;
} }
@ -116,7 +123,6 @@ public class OCShare implements Parcelable, Serializable {
* Used internally. Reset all file properties * Used internally. Reset all file properties
*/ */
private void resetData() { private void resetData() {
mId = -1;
mFileSource = 0; mFileSource = 0;
mItemSource = 0; mItemSource = 0;
mShareType = ShareType.NO_SHARED; mShareType = ShareType.NO_SHARED;
@ -136,15 +142,6 @@ public class OCShare implements Parcelable, Serializable {
} }
/// Getters and Setters /// Getters and Setters
public long getId() {
return mId;
}
public void setId(long id) {
mId = id;
}
public long getFileSource() { public long getFileSource() {
return mFileSource; return mFileSource;
} }
@ -280,15 +277,15 @@ public class OCShare implements Parcelable, Serializable {
/** /**
* Parcelable Methods * 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 @Override
public OCShare createFromParcel(Parcel source) { public RemoteShare createFromParcel(Parcel source) {
return new OCShare(source); return new RemoteShare(source);
} }
@Override @Override
public OCShare[] newArray(int size) { public RemoteShare[] newArray(int size) {
return new OCShare[size]; return new RemoteShare[size];
} }
}; };
@ -297,13 +294,11 @@ public class OCShare implements Parcelable, Serializable {
* *
* @param source The source parcel * @param source The source parcel
*/ */
protected OCShare(Parcel source) { protected RemoteShare(Parcel source) {
readFromParcel(source); readFromParcel(source);
} }
public void readFromParcel(Parcel source) { public void readFromParcel(Parcel source) {
mId = source.readLong();
mFileSource = source.readLong(); mFileSource = source.readLong();
mItemSource = source.readLong(); mItemSource = source.readLong();
try { try {
@ -335,7 +330,6 @@ public class OCShare implements Parcelable, Serializable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mId);
dest.writeLong(mFileSource); dest.writeLong(mFileSource);
dest.writeLong(mItemSource); dest.writeLong(mItemSource);
dest.writeString((mShareType == null) ? "" : mShareType.name()); dest.writeString((mShareType == null) ? "" : mShareType.name());

View File

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

View File

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

View File

@ -71,7 +71,7 @@ public class ShareToRemoteOperationResultParser {
} }
RemoteOperationResult<ShareParserResult> result; RemoteOperationResult<ShareParserResult> result;
final ArrayList<OCShare> resultData = new ArrayList<>(); final ArrayList<RemoteShare> resultData = new ArrayList<>();
try { try {
// Parse xml response and obtain the list of shares // 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 "); Log_OC.w(TAG, "No ShareXmlParser provided, creating new instance ");
mShareXmlParser = new ShareXMLParser(); mShareXmlParser = new ShareXMLParser();
} }
List<OCShare> shares = mShareXmlParser.parseXMLResponse(is); List<RemoteShare> shares = mShareXmlParser.parseXMLResponse(is);
if (mShareXmlParser.isSuccess()) { if (mShareXmlParser.isSuccess()) {
if ((shares != null && shares.size() > 0) || !mOneOrMoreSharesRequired) { if ((shares != null && shares.size() > 0) || !mOneOrMoreSharesRequired) {
result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.OK); result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.OK);
if (shares != null) { if (shares != null) {
for (OCShare share : shares) { for (RemoteShare share : shares) {
resultData.add(share); resultData.add(share);
// build the share link if not in the response // build the share link if not in the response
// (needed for OC servers < 9.0.0, see ShareXMLParser.java#line256) // (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 * Parse is as response of Share API
*
* @param is * @param is
* @return List of ShareRemoteFiles * @return List of ShareRemoteFiles
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
*/ */
public ArrayList<OCShare> parseXMLResponse(InputStream is) throws XmlPullParserException, public ArrayList<RemoteShare> parseXMLResponse(InputStream is) throws XmlPullParserException,
IOException { IOException {
try { try {
@ -167,16 +166,15 @@ public class ShareXMLParser {
/** /**
* Parse OCS node * Parse OCS node
*
* @param parser * @param parser
* @return List of ShareRemoteFiles * @return List of ShareRemoteFiles
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
*/ */
private ArrayList<OCShare> readOCS(XmlPullParser parser) throws XmlPullParserException, private ArrayList<RemoteShare> readOCS (XmlPullParser parser) throws XmlPullParserException,
IOException { IOException {
ArrayList<OCShare> shares = new ArrayList<>(); ArrayList<RemoteShare> shares = new ArrayList<>();
parser.require(XmlPullParser.START_TAG, ns, NODE_OCS); parser.require(XmlPullParser.START_TAG, ns , NODE_OCS);
while (parser.next() != XmlPullParser.END_TAG) { while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) {
continue; continue;
@ -197,7 +195,6 @@ public class ShareXMLParser {
/** /**
* Parse Meta node * Parse Meta node
*
* @param parser * @param parser
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
@ -229,16 +226,15 @@ public class ShareXMLParser {
/** /**
* Parse Data node * Parse Data node
*
* @param parser * @param parser
* @return * @return
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
*/ */
private ArrayList<OCShare> readData(XmlPullParser parser) throws XmlPullParserException, private ArrayList<RemoteShare> readData(XmlPullParser parser) throws XmlPullParserException,
IOException { IOException {
ArrayList<OCShare> shares = new ArrayList<OCShare>(); ArrayList<RemoteShare> shares = new ArrayList<RemoteShare>();
OCShare share = null; RemoteShare share = null;
parser.require(XmlPullParser.START_TAG, ns, NODE_DATA); parser.require(XmlPullParser.START_TAG, ns, NODE_DATA);
//Log_OC.d(TAG, "---- NODE DATA ---"); //Log_OC.d(TAG, "---- NODE DATA ---");
@ -251,7 +247,7 @@ public class ShareXMLParser {
readElement(parser, shares); readElement(parser, shares);
} else if (name.equalsIgnoreCase(NODE_ID)) {// Parse Create XML Response } else if (name.equalsIgnoreCase(NODE_ID)) {// Parse Create XML Response
share = new OCShare(); share = new RemoteShare();
String value = readNode(parser, NODE_ID); String value = readNode(parser, NODE_ID);
share.setIdRemoteShared(Integer.parseInt(value)); share.setIdRemoteShared(Integer.parseInt(value));
@ -284,17 +280,16 @@ public class ShareXMLParser {
/** /**
* Parse Element node * Parse Element node
*
* @param parser * @param parser
* @return * @return
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
*/ */
private void readElement(XmlPullParser parser, ArrayList<OCShare> shares) private void readElement(XmlPullParser parser, ArrayList<RemoteShare> shares)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
parser.require(XmlPullParser.START_TAG, ns, NODE_ELEMENT); parser.require(XmlPullParser.START_TAG, ns, NODE_ELEMENT);
OCShare share = new OCShare(); RemoteShare share = new RemoteShare();
//Log_OC.d(TAG, "---- NODE ELEMENT ---"); //Log_OC.d(TAG, "---- NODE ELEMENT ---");
while (parser.next() != XmlPullParser.END_TAG) { while (parser.next() != XmlPullParser.END_TAG) {
@ -360,9 +355,6 @@ public class ShareXMLParser {
} else if (name.equalsIgnoreCase(NODE_SHARE_WITH_DISPLAY_NAME)) { } else if (name.equalsIgnoreCase(NODE_SHARE_WITH_DISPLAY_NAME)) {
share.setSharedWithDisplayName(readNode(parser, 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)) { } else if (name.equalsIgnoreCase(NODE_URL)) {
String value = readNode(parser, NODE_URL); String value = readNode(parser, NODE_URL);
share.setShareLink(value); share.setShareLink(value);
@ -380,11 +372,11 @@ public class ShareXMLParser {
} }
} }
private boolean isValidShare(OCShare share) { private boolean isValidShare(RemoteShare share) {
return (share.getRemoteId() > -1); return (share.getRemoteId() > -1);
} }
private void fixPathForFolder(OCShare share) { private void fixPathForFolder(RemoteShare share) {
if (share.isFolder() && share.getPath() != null && share.getPath().length() > 0 && if (share.isFolder() && share.getPath() != null && share.getPath().length() > 0 &&
!share.getPath().endsWith(FileUtils.PATH_SEPARATOR)) { !share.getPath().endsWith(FileUtils.PATH_SEPARATOR)) {
share.setPath(share.getPath() + 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 * Parse a node, to obtain its text. Needs readText method
*
* @param parser * @param parser
* @param node * @param node
* @return Text of the node * @return Text of the node
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
*/ */
private String readNode(XmlPullParser parser, String node) throws XmlPullParserException, private String readNode (XmlPullParser parser, String node) throws XmlPullParserException,
IOException { IOException{
parser.require(XmlPullParser.START_TAG, ns, node); parser.require(XmlPullParser.START_TAG, ns, node);
String value = readText(parser); String value = readText(parser);
//Log_OC.d(TAG, "node= " + node + ", value= " + value); //Log_OC.d(TAG, "node= " + node + ", value= " + value);
@ -411,7 +402,6 @@ public class ShareXMLParser {
/** /**
* Read the text from a node * Read the text from a node
*
* @param parser * @param parser
* @return Text of the node * @return Text of the node
* @throws IOException * @throws IOException
@ -428,7 +418,6 @@ public class ShareXMLParser {
/** /**
* Skip tags in parser procedure * Skip tags in parser procedure
*
* @param parser * @param parser
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException

View File

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