mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Add privatelink property support to webdav reponses
This commit is contained in:
		
							parent
							
								
									c18329efd6
								
							
						
					
					
						commit
						9fe3e11c52
					
				| @ -41,21 +41,22 @@ public class WebdavEntry { | |||||||
| 
 | 
 | ||||||
|     private static final String TAG = WebdavEntry.class.getSimpleName(); |     private static final String TAG = WebdavEntry.class.getSimpleName(); | ||||||
| 
 | 
 | ||||||
| 	public static final String NAMESPACE_OC = "http://owncloud.org/ns"; |     public static final String NAMESPACE_OC = "http://owncloud.org/ns"; | ||||||
| 	public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions"; |     public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions"; | ||||||
| 	public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id"; |     public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id"; | ||||||
|     public static final String EXTENDED_PROPERTY_NAME_SIZE = "size"; |     public static final String EXTENDED_PROPERTY_NAME_SIZE = "size"; | ||||||
|  |     public static final String EXTENDED_PROPERTY_NAME_PRIVATE_LINK = "privatelink"; | ||||||
| 
 | 
 | ||||||
|     public static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes"; |     public static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes"; | ||||||
|     public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes"; |     public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes"; | ||||||
| 
 | 
 | ||||||
|     private static final int CODE_PROP_NOT_FOUND = 404; |     private static final int CODE_PROP_NOT_FOUND = 404; | ||||||
| 
 | 
 | ||||||
| 	private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId; |     private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId, mPrivateLink; | ||||||
| 	private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize; |     private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize; | ||||||
|     private BigDecimal mQuotaUsedBytes, mQuotaAvailableBytes; |     private BigDecimal mQuotaUsedBytes, mQuotaAvailableBytes; | ||||||
| 
 | 
 | ||||||
| 	public WebdavEntry(MultiStatusResponse ms, String splitElement) { |     public WebdavEntry(MultiStatusResponse ms, String splitElement) { | ||||||
|         resetData(); |         resetData(); | ||||||
|         if (ms.getStatus().length != 0) { |         if (ms.getStatus().length != 0) { | ||||||
|             mUri = ms.getHref(); |             mUri = ms.getHref(); | ||||||
| @ -63,7 +64,7 @@ public class WebdavEntry { | |||||||
|             mPath = mUri.split(splitElement, 2)[1]; |             mPath = mUri.split(splitElement, 2)[1]; | ||||||
| 
 | 
 | ||||||
|             int status = ms.getStatus()[0].getStatusCode(); |             int status = ms.getStatus()[0].getStatusCode(); | ||||||
|             if ( status == CODE_PROP_NOT_FOUND ) { |             if (status == CODE_PROP_NOT_FOUND) { | ||||||
|                 status = ms.getStatus()[1].getStatusCode(); |                 status = ms.getStatus()[1].getStatusCode(); | ||||||
|             } |             } | ||||||
|             DavPropertySet propSet = ms.getProperties(status); |             DavPropertySet propSet = ms.getProperties(status); | ||||||
| @ -71,9 +72,8 @@ public class WebdavEntry { | |||||||
|             DavProperty prop = propSet.get(DavPropertyName.DISPLAYNAME); |             DavProperty prop = propSet.get(DavPropertyName.DISPLAYNAME); | ||||||
|             if (prop != null) { |             if (prop != null) { | ||||||
|                 mName = (String) prop.getName().toString(); |                 mName = (String) prop.getName().toString(); | ||||||
|                 mName = mName.substring(1, mName.length()-1); |                 mName = mName.substring(1, mName.length() - 1); | ||||||
|             } |             } else { | ||||||
|             else { |  | ||||||
|                 String[] tmp = mPath.split("/"); |                 String[] tmp = mPath.split("/"); | ||||||
|                 if (tmp.length > 0) |                 if (tmp.length > 0) | ||||||
|                     mName = tmp[tmp.length - 1]; |                     mName = tmp[tmp.length - 1]; | ||||||
| @ -95,13 +95,13 @@ public class WebdavEntry { | |||||||
|             // check if it's a folder in the standard way: see RFC2518 12.2 . RFC4918 14.3 |             // check if it's a folder in the standard way: see RFC2518 12.2 . RFC4918 14.3 | ||||||
|             // {DAV:}resourcetype |             // {DAV:}resourcetype | ||||||
|             prop = propSet.get(DavPropertyName.RESOURCETYPE); |             prop = propSet.get(DavPropertyName.RESOURCETYPE); | ||||||
|             if (prop!= null) { |             if (prop != null) { | ||||||
|                 Object value = prop.getValue(); |                 Object value = prop.getValue(); | ||||||
|                 if (value != null) { |                 if (value != null) { | ||||||
|                     mContentType = "DIR";   // a specific attribute would be better, |                     mContentType = "DIR";   // a specific attribute would be better, | ||||||
|                                             // but this is enough; |                     // but this is enough; | ||||||
|                                             // unless while we have no reason to distinguish |                     // unless while we have no reason to distinguish | ||||||
|                                             // MIME types for folders |                     // MIME types for folders | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -114,14 +114,14 @@ public class WebdavEntry { | |||||||
|             prop = propSet.get(DavPropertyName.GETLASTMODIFIED); |             prop = propSet.get(DavPropertyName.GETLASTMODIFIED); | ||||||
|             if (prop != null) { |             if (prop != null) { | ||||||
|                 Date d = WebdavUtils |                 Date d = WebdavUtils | ||||||
|                         .parseResponseDate((String) prop.getValue()); |                     .parseResponseDate((String) prop.getValue()); | ||||||
|                 mModifiedTimestamp = (d != null) ? d.getTime() : 0; |                 mModifiedTimestamp = (d != null) ? d.getTime() : 0; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             prop = propSet.get(DavPropertyName.CREATIONDATE); |             prop = propSet.get(DavPropertyName.CREATIONDATE); | ||||||
|             if (prop != null) { |             if (prop != null) { | ||||||
|                 Date d = WebdavUtils |                 Date d = WebdavUtils | ||||||
|                         .parseResponseDate((String) prop.getValue()); |                     .parseResponseDate((String) prop.getValue()); | ||||||
|                 mCreateTimestamp = (d != null) ? d.getTime() : 0; |                 mCreateTimestamp = (d != null) ? d.getTime() : 0; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -140,10 +140,10 @@ public class WebdavEntry { | |||||||
|                     mQuotaUsedBytes = new BigDecimal(quotaUsedBytesSt); |                     mQuotaUsedBytes = new BigDecimal(quotaUsedBytesSt); | ||||||
|                 } catch (NumberFormatException e) { |                 } catch (NumberFormatException e) { | ||||||
|                     Log_OC.w(TAG, "No value for QuotaUsedBytes - NumberFormatException"); |                     Log_OC.w(TAG, "No value for QuotaUsedBytes - NumberFormatException"); | ||||||
|                 } catch (NullPointerException e ){ |                 } catch (NullPointerException e) { | ||||||
|                     Log_OC.w(TAG, "No value for QuotaUsedBytes - NullPointerException"); |                     Log_OC.w(TAG, "No value for QuotaUsedBytes - NullPointerException"); | ||||||
|                 } |                 } | ||||||
|                 Log_OC.d(TAG , "QUOTA_USED_BYTES " + quotaUsedBytesSt ); |                 Log_OC.d(TAG, "QUOTA_USED_BYTES " + quotaUsedBytesSt); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // {DAV:}quota-available-bytes |             // {DAV:}quota-available-bytes | ||||||
| @ -154,40 +154,47 @@ public class WebdavEntry { | |||||||
|                     mQuotaAvailableBytes = new BigDecimal(quotaAvailableBytesSt); |                     mQuotaAvailableBytes = new BigDecimal(quotaAvailableBytesSt); | ||||||
|                 } catch (NumberFormatException e) { |                 } catch (NumberFormatException e) { | ||||||
|                     Log_OC.w(TAG, "No value for QuotaAvailableBytes - NumberFormatException"); |                     Log_OC.w(TAG, "No value for QuotaAvailableBytes - NumberFormatException"); | ||||||
|                 } catch (NullPointerException e ){ |                 } catch (NullPointerException e) { | ||||||
|                     Log_OC.w(TAG, "No value for QuotaAvailableBytes"); |                     Log_OC.w(TAG, "No value for QuotaAvailableBytes"); | ||||||
|                 } |                 } | ||||||
|                 Log_OC.d(TAG , "QUOTA_AVAILABLE_BYTES " + quotaAvailableBytesSt ); |                 Log_OC.d(TAG, "QUOTA_AVAILABLE_BYTES " + quotaAvailableBytesSt); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // OC permissions property <oc:permissions> |             // OC permissions property <oc:permissions> | ||||||
|             prop = propSet.get( |             prop = propSet.get( | ||||||
|             		EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC) |                 EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC) | ||||||
|     		); |             ); | ||||||
|             if (prop != null) { |             if (prop != null) { | ||||||
|                 mPermissions = prop.getValue().toString(); |                 mPermissions = prop.getValue().toString(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // OC remote id property <oc:id> |             // OC remote id property <oc:id> | ||||||
|             prop = propSet.get( |             prop = propSet.get( | ||||||
|             		EXTENDED_PROPERTY_NAME_REMOTE_ID, Namespace.getNamespace(NAMESPACE_OC) |                 EXTENDED_PROPERTY_NAME_REMOTE_ID, Namespace.getNamespace(NAMESPACE_OC) | ||||||
|     		); |             ); | ||||||
|             if (prop != null) { |             if (prop != null) { | ||||||
|                 mRemoteId = prop.getValue().toString(); |                 mRemoteId = prop.getValue().toString(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // TODO: is it necessary? |  | ||||||
|             // OC size property <oc:size> |             // OC size property <oc:size> | ||||||
|             prop = propSet.get( |             prop = propSet.get( | ||||||
|             		EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(NAMESPACE_OC) |                 EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(NAMESPACE_OC) | ||||||
|     		); |             ); | ||||||
|             if (prop != null) { |             if (prop != null) { | ||||||
|                 mSize = Long.parseLong((String) prop.getValue()); |                 mSize = Long.parseLong((String) prop.getValue()); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             // OC privatelink property <oc:privatelink> | ||||||
|  |             prop = propSet.get( | ||||||
|  |                 EXTENDED_PROPERTY_NAME_PRIVATE_LINK, Namespace.getNamespace(NAMESPACE_OC) | ||||||
|  |             ); | ||||||
|  |             if (prop != null) { | ||||||
|  |                 mPrivateLink = prop.getValue().toString(); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|         } else { |         } else { | ||||||
|             Log_OC.e("WebdavEntry", |             Log_OC.e("WebdavEntry", | ||||||
|                     "General fuckup, no status for webdav response"); |                 "General fuckup, no status for webdav response"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -239,7 +246,7 @@ public class WebdavEntry { | |||||||
|         return mRemoteId; |         return mRemoteId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public long size(){ |     public long size() { | ||||||
|         return mSize; |         return mSize; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -251,11 +258,17 @@ public class WebdavEntry { | |||||||
|         return mQuotaAvailableBytes; |         return mQuotaAvailableBytes; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public String privateLink() { | ||||||
|  |         return mPrivateLink; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private void resetData() { |     private void resetData() { | ||||||
|         mName = mUri = mContentType = mPermissions = null; mRemoteId = null; |         mName = mUri = mContentType = mPermissions = null; | ||||||
|  |         mRemoteId = null; | ||||||
|         mContentLength = mCreateTimestamp = mModifiedTimestamp = 0; |         mContentLength = mCreateTimestamp = mModifiedTimestamp = 0; | ||||||
|         mSize = 0; |         mSize = 0; | ||||||
|         mQuotaUsedBytes = null; |         mQuotaUsedBytes = null; | ||||||
|         mQuotaAvailableBytes = null; |         mQuotaAvailableBytes = null; | ||||||
|  |         mPrivateLink = null; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -107,6 +107,8 @@ public class WebdavUtils { | |||||||
|                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); |                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
|         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, |         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, | ||||||
|                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); |                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
|  |         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PRIVATE_LINK, | ||||||
|  |             Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
| 
 | 
 | ||||||
|         return propSet; |         return propSet; | ||||||
|     } |     } | ||||||
| @ -130,6 +132,10 @@ public class WebdavUtils { | |||||||
|                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); |                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
|         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, |         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, | ||||||
|                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); |                 Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
|  |         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, | ||||||
|  |             Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
|  |         propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PRIVATE_LINK, | ||||||
|  |             Namespace.getNamespace(WebdavEntry.NAMESPACE_OC)); | ||||||
| 
 | 
 | ||||||
|         return propSet; |         return propSet; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -171,6 +171,7 @@ public class ReadRemoteFolderOperation extends RemoteOperation { | |||||||
|         file.setSize(we.size()); |         file.setSize(we.size()); | ||||||
|         file.setQuotaUsedBytes(we.quotaUsedBytes()); |         file.setQuotaUsedBytes(we.quotaUsedBytes()); | ||||||
|         file.setQuotaAvailableBytes(we.quotaAvailableBytes()); |         file.setQuotaAvailableBytes(we.quotaAvailableBytes()); | ||||||
|  |         file.setPrivateLink(we.privateLink()); | ||||||
|         return file; |         return file; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -33,132 +33,143 @@ import android.os.Parcelable; | |||||||
| import com.owncloud.android.lib.common.network.WebdavEntry; | import com.owncloud.android.lib.common.network.WebdavEntry; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  *  Contains the data of a Remote File from a WebDavEntry |  * Contains the data of a Remote File from a WebDavEntry | ||||||
|  * |  * | ||||||
|  *  @author masensio |  * @author masensio | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| public class RemoteFile implements Parcelable, Serializable { | public class RemoteFile implements Parcelable, Serializable { | ||||||
| 
 | 
 | ||||||
|     /** Generated - should be refreshed every time the class changes!! */ |     /** | ||||||
|  |      * Generated - should be refreshed every time the class changes!! | ||||||
|  |      */ | ||||||
|     private static final long serialVersionUID = 3130865437811248451L; |     private static final long serialVersionUID = 3130865437811248451L; | ||||||
| 
 | 
 | ||||||
| 	private String mRemotePath; |     private String mRemotePath; | ||||||
| 	private String mMimeType; |     private String mMimeType; | ||||||
| 	private long mLength; |     private long mLength; | ||||||
| 	private long mCreationTimestamp; |     private long mCreationTimestamp; | ||||||
| 	private long mModifiedTimestamp; |     private long mModifiedTimestamp; | ||||||
| 	private String mEtag; |     private String mEtag; | ||||||
| 	private String mPermissions; |     private String mPermissions; | ||||||
| 	private String mRemoteId; |     private String mRemoteId; | ||||||
|     private long mSize; |     private long mSize; | ||||||
|     private BigDecimal mQuotaUsedBytes; |     private BigDecimal mQuotaUsedBytes; | ||||||
|     private BigDecimal mQuotaAvailableBytes; |     private BigDecimal mQuotaAvailableBytes; | ||||||
|  |     private String mPrivateLink; | ||||||
| 
 | 
 | ||||||
| 	/**  |     /** | ||||||
| 	 * Getters and Setters |      * Getters and Setters | ||||||
| 	 */ |      */ | ||||||
| 
 | 
 | ||||||
|     public String getRemotePath() { |     public String getRemotePath() { | ||||||
| 		return mRemotePath; |         return mRemotePath; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setRemotePath(String remotePath) { |     public void setRemotePath(String remotePath) { | ||||||
| 		this.mRemotePath = remotePath; |         this.mRemotePath = remotePath; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public String getMimeType() { |     public String getMimeType() { | ||||||
| 		return mMimeType; |         return mMimeType; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setMimeType(String mimeType) { |     public void setMimeType(String mimeType) { | ||||||
| 		this.mMimeType = mimeType; |         this.mMimeType = mimeType; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public long getLength() { |     public long getLength() { | ||||||
| 		return mLength; |         return mLength; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setLength(long length) { |     public void setLength(long length) { | ||||||
| 		this.mLength = length; |         this.mLength = length; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public long getCreationTimestamp() { |     public long getCreationTimestamp() { | ||||||
| 		return mCreationTimestamp; |         return mCreationTimestamp; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setCreationTimestamp(long creationTimestamp) { |     public void setCreationTimestamp(long creationTimestamp) { | ||||||
| 		this.mCreationTimestamp = creationTimestamp; |         this.mCreationTimestamp = creationTimestamp; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public long getModifiedTimestamp() { |     public long getModifiedTimestamp() { | ||||||
| 		return mModifiedTimestamp; |         return mModifiedTimestamp; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setModifiedTimestamp(long modifiedTimestamp) { |     public void setModifiedTimestamp(long modifiedTimestamp) { | ||||||
| 		this.mModifiedTimestamp = modifiedTimestamp; |         this.mModifiedTimestamp = modifiedTimestamp; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public String getEtag() { |     public String getEtag() { | ||||||
| 		return mEtag; |         return mEtag; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setEtag(String etag) { |     public void setEtag(String etag) { | ||||||
| 		this.mEtag = etag; |         this.mEtag = etag; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public String getPermissions() { |     public String getPermissions() { | ||||||
| 		return mPermissions; |         return mPermissions; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setPermissions(String permissions) { |     public void setPermissions(String permissions) { | ||||||
| 		this.mPermissions = permissions; |         this.mPermissions = permissions; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public String getRemoteId() { |     public String getRemoteId() { | ||||||
| 		return mRemoteId; |         return mRemoteId; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public void setRemoteId(String remoteId) { |     public void setRemoteId(String remoteId) { | ||||||
| 		this.mRemoteId = remoteId; |         this.mRemoteId = remoteId; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
|     public long getSize() { |     public long getSize() { | ||||||
|         return mSize; |         return mSize; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setSize (long size){ |     public void setSize(long size) { | ||||||
|         mSize = size; |         mSize = size; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setQuotaUsedBytes (BigDecimal quotaUsedBytes) { |     public void setQuotaUsedBytes(BigDecimal quotaUsedBytes) { | ||||||
|         mQuotaUsedBytes = quotaUsedBytes; |         mQuotaUsedBytes = quotaUsedBytes; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setQuotaAvailableBytes (BigDecimal quotaAvailableBytes) { |     public void setQuotaAvailableBytes(BigDecimal quotaAvailableBytes) { | ||||||
|         mQuotaAvailableBytes = quotaAvailableBytes; |         mQuotaAvailableBytes = quotaAvailableBytes; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 	public RemoteFile() { |     public String getPrivateLink() { | ||||||
| 		resetData(); |         return mPrivateLink; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	/** |     public void setPrivateLink(String privateLink) { | ||||||
|  |         mPrivateLink = privateLink; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public RemoteFile() { | ||||||
|  |         resetData(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|      * Create new {@link RemoteFile} with given path. |      * Create new {@link RemoteFile} with given path. | ||||||
|      *  |      * <p> | ||||||
|      * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'. |      * The path received must be URL-decoded. Path separator must be OCFile.PATH_SEPARATOR, and it must be the first character in 'path'. | ||||||
|      * |      * | ||||||
|      * @param path The remote path of the file. |      * @param path The remote path of the file. | ||||||
|      */ |      */ | ||||||
| 	public RemoteFile(String path) { |     public RemoteFile(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)) { | ||||||
|             throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path); |             throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path); | ||||||
|         } |         } | ||||||
|         mRemotePath = path; |         mRemotePath = path; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	public RemoteFile(WebdavEntry we) { |     public RemoteFile(WebdavEntry we) { | ||||||
|         this(we.decodedPath()); |         this(we.decodedPath()); | ||||||
|         this.setCreationTimestamp(we.createTimestamp()); |         this.setCreationTimestamp(we.createTimestamp()); | ||||||
|         this.setLength(we.contentLength()); |         this.setLength(we.contentLength()); | ||||||
| @ -170,9 +181,10 @@ public class RemoteFile implements Parcelable, Serializable { | |||||||
|         this.setSize(we.size()); |         this.setSize(we.size()); | ||||||
|         this.setQuotaUsedBytes(we.quotaUsedBytes()); |         this.setQuotaUsedBytes(we.quotaUsedBytes()); | ||||||
|         this.setQuotaAvailableBytes(we.quotaAvailableBytes()); |         this.setQuotaAvailableBytes(we.quotaAvailableBytes()); | ||||||
| 	} |         this.setPrivateLink(we.privateLink()); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| 	/** |     /** | ||||||
|      * Used internally. Reset all file properties |      * Used internally. Reset all file properties | ||||||
|      */ |      */ | ||||||
|     private void resetData() { |     private void resetData() { | ||||||
| @ -187,6 +199,7 @@ public class RemoteFile implements Parcelable, Serializable { | |||||||
|         mSize = 0; |         mSize = 0; | ||||||
|         mQuotaUsedBytes = null; |         mQuotaUsedBytes = null; | ||||||
|         mQuotaAvailableBytes = null; |         mQuotaAvailableBytes = null; | ||||||
|  |         mPrivateLink = null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -211,41 +224,43 @@ public class RemoteFile implements Parcelable, Serializable { | |||||||
|      * @param source The source parcel |      * @param source The source parcel | ||||||
|      */ |      */ | ||||||
|     protected RemoteFile(Parcel source) { |     protected RemoteFile(Parcel source) { | ||||||
|     	readFromParcel(source); |         readFromParcel(source); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void readFromParcel (Parcel source) { |     public void readFromParcel(Parcel source) { | ||||||
|         mRemotePath = source.readString(); |         mRemotePath = source.readString(); | ||||||
|         mMimeType = source.readString(); |         mMimeType = source.readString(); | ||||||
|         mLength = source.readLong(); |         mLength = source.readLong(); | ||||||
|         mCreationTimestamp = source.readLong(); |         mCreationTimestamp = source.readLong(); | ||||||
|         mModifiedTimestamp = source.readLong(); |         mModifiedTimestamp = source.readLong(); | ||||||
|         mEtag = source.readString(); |         mEtag = source.readString(); | ||||||
|         mPermissions= source.readString(); |         mPermissions = source.readString(); | ||||||
|         mRemoteId = source.readString(); |         mRemoteId = source.readString(); | ||||||
|         mSize = source.readLong(); |         mSize = source.readLong(); | ||||||
|         mQuotaUsedBytes = (BigDecimal) source.readSerializable(); |         mQuotaUsedBytes = (BigDecimal) source.readSerializable(); | ||||||
|         mQuotaAvailableBytes = (BigDecimal) source.readSerializable(); |         mQuotaAvailableBytes = (BigDecimal) source.readSerializable(); | ||||||
|  |         mPrivateLink = source.readString(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 	@Override |     @Override | ||||||
| 	public int describeContents() { |     public int describeContents() { | ||||||
| 		return this.hashCode(); |         return this.hashCode(); | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	@Override |     @Override | ||||||
| 	public void writeToParcel(Parcel dest, int flags) { |     public void writeToParcel(Parcel dest, int flags) { | ||||||
| 		dest.writeString(mRemotePath); |         dest.writeString(mRemotePath); | ||||||
| 		dest.writeString(mMimeType);     |         dest.writeString(mMimeType); | ||||||
| 		dest.writeLong(mLength); |         dest.writeLong(mLength); | ||||||
| 		dest.writeLong(mCreationTimestamp); |         dest.writeLong(mCreationTimestamp); | ||||||
| 		dest.writeLong(mModifiedTimestamp); |         dest.writeLong(mModifiedTimestamp); | ||||||
| 		dest.writeString(mEtag); |         dest.writeString(mEtag); | ||||||
| 		dest.writeString(mPermissions); |         dest.writeString(mPermissions); | ||||||
| 		dest.writeString(mRemoteId); |         dest.writeString(mRemoteId); | ||||||
|         dest.writeLong(mSize); |         dest.writeLong(mSize); | ||||||
|         dest.writeSerializable(mQuotaUsedBytes); |         dest.writeSerializable(mQuotaUsedBytes); | ||||||
|         dest.writeSerializable(mQuotaAvailableBytes); |         dest.writeSerializable(mQuotaAvailableBytes); | ||||||
| 	} |         dest.writeString(mPrivateLink); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user