package com.owncloud.android.datamodel;
+import com.owncloud.android.oc_framework.operations.ShareRemoteFile;
+import com.owncloud.android.oc_framework.operations.ShareType;
import com.owncloud.android.utils.Log_OC;
import android.os.Parcel;
private static final String TAG = OCShare.class.getSimpleName();
- // Enum for ShareType
- public enum ShareType {
- NO_SHARED (-1),
- USER (0),
- GROUP (1),
- PUBLIC_LINK (3),
- EMAIL (4),
- CONTACT (5);
-
- private int value;
-
- private ShareType(int value)
- {
- this.value = value;
- }
-
- public int getValue() {
- return value;
- }
-
- public static ShareType fromValue(int value)
- {
- switch (value)
- {
- case -1:
- return NO_SHARED;
- case 0:
- return USER;
- case 1:
- return GROUP;
- case 3:
- return PUBLIC_LINK;
- case 4:
- return EMAIL;
- case 5:
- return CONTACT;
- }
- return null;
- }
- };
-
private long mId;
private long mFileSource;
private long mItemSource;
mPath = path;
}
+ public OCShare(ShareRemoteFile remoteFile) {
+ mId = -1;
+
+ String path = remoteFile.getPath();
+ if (path == null || path.length() <= 0 || !path.startsWith(OCFile.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);
+ }
+ mPath = path;
+
+ mFileSource = remoteFile.getFileSource();
+ mItemSource = remoteFile.getItemSource();
+ mShareType = remoteFile.getShareType();
+ mShareWith = remoteFile.getShareWith();
+ mPermissions = remoteFile.getPermissions();
+ mSharedDate = remoteFile.getSharedDate();
+ mExpirationDate = remoteFile.getExpirationDate();
+ mToken = remoteFile.getToken();
+ mSharedWithDisplayName = remoteFile.getSharedWithDisplayName();
+ mIsDirectory = remoteFile.isDirectory();
+ mUserId = remoteFile.getUserId();
+ mIdRemoteShared = remoteFile.getIdRemoteShared();
+ }
+
/**
* Used internally. Reset all file properties
*/
public long getId() {
return mId;
}
+
+ public void setId(long id){
+ mId = id;
+ }
- /// Parcelable methods
+ /**
+ * Parcelable Methods
+ */
public static final Parcelable.Creator<OCShare> CREATOR = new Parcelable.Creator<OCShare>() {
@Override
public OCShare createFromParcel(Parcel source) {
dest.writeLong(mUserId);
dest.writeLong(mIdRemoteShared);
}
-
}