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
;
35 * Contains the data of a Share Remote File from the Share API
40 public class ShareRemoteFile
extends RemoteFile
{
43 * Generated - should be refreshed every time the class changes!!
45 private static final long serialVersionUID
= -5916376011588784325L;
47 private static final String TAG
= ShareRemoteFile
.class.getSimpleName();
49 private long mFileSource
;
50 private long mItemSource
;
51 private ShareType mShareType
;
52 private String mShareWith
;
54 private int mPermissions
;
55 private long mSharedDate
;
56 private long mExpirationDate
;
57 private String mToken
;
58 private String mSharedWithDisplayName
;
59 private boolean mIsDirectory
;
61 private long mIdRemoteShared
;
64 public ShareRemoteFile(String path
) {
67 if (path
== null
|| path
.length() <= 0 || !path
.startsWith(FileUtils
.PATH_SEPARATOR
)) {
68 Log
.e(TAG
, "Trying to create a OCShare with a non valid path");
69 throw new IllegalArgumentException("Trying to create a OCShare with a non valid path: " + path
);
74 public ShareRemoteFile(WebdavEntry we
) {
76 // TODO Auto-generated constructor stub
80 * Used internally. Reset all file properties
82 private void resetData() {
85 mShareType
= ShareType
.NO_SHARED
;
92 mSharedWithDisplayName
= null
;
98 /// Getters and Setters
99 public long getFileSource() {
103 public void setFileSource(long fileSource
) {
104 this.mFileSource
= fileSource
;
107 public long getItemSource() {
111 public void setItemSource(long itemSource
) {
112 this.mItemSource
= itemSource
;
115 public ShareType
getShareType() {
119 public void setShareType(ShareType shareType
) {
120 this.mShareType
= shareType
;
123 public String
getShareWith() {
127 public void setShareWith(String shareWith
) {
128 this.mShareWith
= shareWith
;
131 public String
getPath() {
135 public void setPath(String path
) {
139 public int getPermissions() {
143 public void setPermissions(int permissions
) {
144 this.mPermissions
= permissions
;
147 public long getSharedDate() {
151 public void setSharedDate(long sharedDate
) {
152 this.mSharedDate
= sharedDate
;
155 public long getExpirationDate() {
156 return mExpirationDate
;
159 public void setExpirationDate(long expirationDate
) {
160 this.mExpirationDate
= expirationDate
;
163 public String
getToken() {
167 public void setToken(String token
) {
171 public String
getSharedWithDisplayName() {
172 return mSharedWithDisplayName
;
175 public void setSharedWithDisplayName(String sharedWithDisplayName
) {
176 this.mSharedWithDisplayName
= sharedWithDisplayName
;
179 public boolean isDirectory() {
183 public void setIsDirectory(boolean isDirectory
) {
184 this.mIsDirectory
= isDirectory
;
187 public long getUserId() {
191 public void setUserId(long userId
) {
192 this.mUserId
= userId
;
195 public long getIdRemoteShared() {
196 return mIdRemoteShared
;
199 public void setIdRemoteShared(long idRemoteShared
) {
200 this.mIdRemoteShared
= idRemoteShared
;
206 public static final Parcelable
.Creator
<ShareRemoteFile
> CREATOR
= new Parcelable
.Creator
<ShareRemoteFile
>() {
208 public ShareRemoteFile
createFromParcel(Parcel source
) {
209 return new ShareRemoteFile(source
);
213 public ShareRemoteFile
[] newArray(int size
) {
214 return new ShareRemoteFile
[size
];
219 * Reconstruct from parcel
221 * @param source The source parcel
223 protected ShareRemoteFile(Parcel source
) {
227 public void readFromParcel(Parcel source
) {
228 super.readFromParcel(source
);
230 mFileSource
= source
.readLong();
231 mItemSource
= source
.readLong();
233 mShareType
= ShareType
.valueOf(source
.readString());
234 } catch (IllegalArgumentException x
) {
235 mShareType
= ShareType
.NO_SHARED
;
237 mShareWith
= source
.readString();
238 mPath
= source
.readString();
239 mPermissions
= source
.readInt();
240 mSharedDate
= source
.readLong();
241 mExpirationDate
= source
.readLong();
242 mToken
= source
.readString();
243 mSharedWithDisplayName
= source
.readString();
244 mIsDirectory
= source
.readInt() == 0;
245 mUserId
= source
.readLong();
246 mIdRemoteShared
= source
.readLong();
251 public void writeToParcel(Parcel dest
, int flags
) {
252 super.writeToParcel(dest
, flags
);
254 dest
.writeLong(mFileSource
);
255 dest
.writeLong(mItemSource
);
256 dest
.writeString((mShareType
== null
) ?
"" : mShareType
.name());
257 dest
.writeString(mShareWith
);
258 dest
.writeString(mPath
);
259 dest
.writeInt(mPermissions
);
260 dest
.writeLong(mSharedDate
);
261 dest
.writeLong(mExpirationDate
);
262 dest
.writeString(mToken
);
263 dest
.writeString(mSharedWithDisplayName
);
264 dest
.writeInt(mIsDirectory ?
1 : 0);
265 dest
.writeLong(mUserId
);
266 dest
.writeLong(mIdRemoteShared
);