1 /* ownCloud Android Library is available under MIT license
2 * Copyright (C) 2014 ownCloud (http://www.owncloud.org/)
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 package com
.owncloud
.android
.oc_framework
.operations
;
27 import android
.os
.Parcel
;
28 import android
.os
.Parcelable
;
29 import android
.util
.Log
;
31 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavEntry
;
32 import com
.owncloud
.android
.oc_framework
.utils
.FileUtils
;
34 public class ShareRemoteFile
extends RemoteFile
{
37 * Generated - should be refreshed every time the class changes!!
39 private static final long serialVersionUID
= -5916376011588784325L;
41 private static final String TAG
= ShareRemoteFile
.class.getSimpleName();
43 private long mFileSource
;
44 private long mItemSource
;
45 private ShareType mShareType
;
46 private String mShareWith
;
48 private int mPermissions
;
49 private long mSharedDate
;
50 private long mExpirationDate
;
51 private String mToken
;
52 private String mSharedWithDisplayName
;
53 private boolean mIsDirectory
;
55 private long mIdRemoteShared
;
58 public ShareRemoteFile(String path
) {
61 if (path
== null
|| path
.length() <= 0 || !path
.startsWith(FileUtils
.PATH_SEPARATOR
)) {
62 Log
.e(TAG
, "Trying to create a OCShare with a non valid path");
63 throw new IllegalArgumentException("Trying to create a OCShare with a non valid path: " + path
);
68 public ShareRemoteFile(WebdavEntry we
) {
70 // TODO Auto-generated constructor stub
74 * Used internally. Reset all file properties
76 private void resetData() {
79 mShareType
= ShareType
.NO_SHARED
;
86 mSharedWithDisplayName
= null
;
92 /// Getters and Setters
93 public long getFileSource() {
97 public void setFileSource(long fileSource
) {
98 this.mFileSource
= fileSource
;
101 public long getItemSource() {
105 public void setItemSource(long itemSource
) {
106 this.mItemSource
= itemSource
;
109 public ShareType
getShareType() {
113 public void setShareType(ShareType shareType
) {
114 this.mShareType
= shareType
;
117 public String
getShareWith() {
121 public void setShareWith(String shareWith
) {
122 this.mShareWith
= shareWith
;
125 public String
getPath() {
129 public void setPath(String path
) {
133 public int getPermissions() {
137 public void setPermissions(int permissions
) {
138 this.mPermissions
= permissions
;
141 public long getSharedDate() {
145 public void setSharedDate(long sharedDate
) {
146 this.mSharedDate
= sharedDate
;
149 public long getExpirationDate() {
150 return mExpirationDate
;
153 public void setExpirationDate(long expirationDate
) {
154 this.mExpirationDate
= expirationDate
;
157 public String
getToken() {
161 public void setToken(String token
) {
165 public String
getSharedWithDisplayName() {
166 return mSharedWithDisplayName
;
169 public void setSharedWithDisplayName(String sharedWithDisplayName
) {
170 this.mSharedWithDisplayName
= sharedWithDisplayName
;
173 public boolean isDirectory() {
177 public void setIsDirectory(boolean isDirectory
) {
178 this.mIsDirectory
= isDirectory
;
181 public long getUserId() {
185 public void setUserId(long userId
) {
186 this.mUserId
= userId
;
189 public long getIdRemoteShared() {
190 return mIdRemoteShared
;
193 public void setIdRemoteShared(long idRemoteShared
) {
194 this.mIdRemoteShared
= idRemoteShared
;
200 public static final Parcelable
.Creator
<ShareRemoteFile
> CREATOR
= new Parcelable
.Creator
<ShareRemoteFile
>() {
202 public ShareRemoteFile
createFromParcel(Parcel source
) {
203 return new ShareRemoteFile(source
);
207 public ShareRemoteFile
[] newArray(int size
) {
208 return new ShareRemoteFile
[size
];
213 * Reconstruct from parcel
215 * @param source The source parcel
217 protected ShareRemoteFile(Parcel source
) {
221 public void readFromParcel(Parcel source
) {
222 super.readFromParcel(source
);
224 mFileSource
= source
.readLong();
225 mItemSource
= source
.readLong();
227 mShareType
= ShareType
.valueOf(source
.readString());
228 } catch (IllegalArgumentException x
) {
229 mShareType
= ShareType
.NO_SHARED
;
231 mShareWith
= source
.readString();
232 mPath
= source
.readString();
233 mPermissions
= source
.readInt();
234 mSharedDate
= source
.readLong();
235 mExpirationDate
= source
.readLong();
236 mToken
= source
.readString();
237 mSharedWithDisplayName
= source
.readString();
238 mIsDirectory
= source
.readInt() == 0;
239 mUserId
= source
.readLong();
240 mIdRemoteShared
= source
.readLong();
245 public void writeToParcel(Parcel dest
, int flags
) {
246 super.writeToParcel(dest
, flags
);
248 dest
.writeLong(mFileSource
);
249 dest
.writeLong(mItemSource
);
250 dest
.writeString((mShareType
== null
) ?
"" : mShareType
.name());
251 dest
.writeString(mShareWith
);
252 dest
.writeString(mPath
);
253 dest
.writeInt(mPermissions
);
254 dest
.writeLong(mSharedDate
);
255 dest
.writeLong(mExpirationDate
);
256 dest
.writeString(mToken
);
257 dest
.writeString(mSharedWithDisplayName
);
258 dest
.writeInt(mIsDirectory ?
1 : 0);
259 dest
.writeLong(mUserId
);
260 dest
.writeLong(mIdRemoteShared
);