2c7f378b0133433effb3a46c86ff2cb861b2a473
1 package eu
.alefzero
.webdav
;
5 import org
.apache
.jackrabbit
.webdav
.MultiStatusResponse
;
6 import org
.apache
.jackrabbit
.webdav
.property.DavProperty
;
7 import org
.apache
.jackrabbit
.webdav
.property.DavPropertyName
;
8 import org
.apache
.jackrabbit
.webdav
.property.DavPropertySet
;
10 import android
.util
.Log
;
12 public class WebdavEntry
{
13 private String mName
, mPath
, mUri
, mContentType
;
14 private long mContentLength
, mCreateTimestamp
, mModifiedTimestamp
;
16 public WebdavEntry(MultiStatusResponse ms
) {
18 if (ms
.getStatus().length
!= 0) {
21 mPath
= mUri
.split("webdav.php", 2)[1];
23 int status
= ms
.getStatus()[0].getStatusCode();
24 DavPropertySet propSet
= ms
.getProperties(status
);
25 @SuppressWarnings("rawtypes")
26 DavProperty prop
= propSet
.get(DavPropertyName
.DISPLAYNAME
);
27 if (prop
!= null
) mName
= (String
) prop
.getName().toString();
29 String
[] tmp
= mPath
.split("/");
31 mName
= tmp
[tmp
.length
-1];
34 prop
= propSet
.get(DavPropertyName
.GETCONTENTTYPE
);
36 mContentType
= (String
) prop
.getValue();
39 /*prop = propSet.get(DavPropertyName.ISCOLLECTION);
40 if (prop != null && Boolean.parseBoolean((String) prop.getValue()))
41 mContentType = "DIR";*/
44 prop
= propSet
.get(DavPropertyName
.GETCONTENTLENGTH
);
46 mContentLength
= Long
.parseLong((String
) prop
.getValue());
48 prop
= propSet
.get(DavPropertyName
.GETLASTMODIFIED
);
50 Date d
= WebdavUtils
.parseResponseDate((String
)prop
.getValue());
51 mModifiedTimestamp
= (d
!= null
) ? d
.getTime() : 0;
54 prop
= propSet
.get(DavPropertyName
.CREATIONDATE
);
56 Date d
= WebdavUtils
.parseResponseDate((String
)prop
.getValue());
57 mCreateTimestamp
= (d
!= null
) ? d
.getTime() : 0;
61 Log
.e("WebdavEntry", "General fuckup, no status for webdav response");
65 public String
path() {
69 public String
name() {
73 public boolean isDirectory() {
74 return mContentType
.equals("DIR");
77 public String
contentType() {
85 public long contentLength() {
86 return mContentLength
;
89 public long createTimestamp() {
90 return mCreateTimestamp
;
93 public long modifiedTimesamp() {
94 return mModifiedTimestamp
;
97 private void resetData() {
98 mName
= mUri
= mContentType
= null
;
99 mContentLength
= mCreateTimestamp
= mModifiedTimestamp
= 0;