c2e9712fff5f1bd338d8946d96025124f81d88af
1 /* ownCloud Android client application
2 * Copyright (C) 2012 ownCloud
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package eu
.alefzero
.webdav
;
20 import java
.util
.Date
;
22 import org
.apache
.jackrabbit
.webdav
.MultiStatusResponse
;
23 import org
.apache
.jackrabbit
.webdav
.property.DavProperty
;
24 import org
.apache
.jackrabbit
.webdav
.property.DavPropertyName
;
25 import org
.apache
.jackrabbit
.webdav
.property.DavPropertySet
;
27 import android
.util
.Log
;
29 public class WebdavEntry
{
30 private String mName
, mPath
, mUri
, mContentType
;
31 private long mContentLength
, mCreateTimestamp
, mModifiedTimestamp
;
33 public WebdavEntry(MultiStatusResponse ms
) {
35 if (ms
.getStatus().length
!= 0) {
38 mPath
= mUri
.split("webdav.php", 2)[1];
40 int status
= ms
.getStatus()[0].getStatusCode();
41 DavPropertySet propSet
= ms
.getProperties(status
);
42 @SuppressWarnings("rawtypes")
43 DavProperty prop
= propSet
.get(DavPropertyName
.DISPLAYNAME
);
44 if (prop
!= null
) mName
= (String
) prop
.getName().toString();
46 String
[] tmp
= mPath
.split("/");
48 mName
= tmp
[tmp
.length
-1];
51 prop
= propSet
.get(DavPropertyName
.GETCONTENTTYPE
);
53 mContentType
= (String
) prop
.getValue();
56 /*prop = propSet.get(DavPropertyName.ISCOLLECTION);
57 if (prop != null && Boolean.parseBoolean((String) prop.getValue()))
58 mContentType = "DIR";*/
61 prop
= propSet
.get(DavPropertyName
.GETCONTENTLENGTH
);
63 mContentLength
= Long
.parseLong((String
) prop
.getValue());
65 prop
= propSet
.get(DavPropertyName
.GETLASTMODIFIED
);
67 Date d
= WebdavUtils
.parseResponseDate((String
)prop
.getValue());
68 mModifiedTimestamp
= (d
!= null
) ? d
.getTime() : 0;
71 prop
= propSet
.get(DavPropertyName
.CREATIONDATE
);
73 Date d
= WebdavUtils
.parseResponseDate((String
)prop
.getValue());
74 mCreateTimestamp
= (d
!= null
) ? d
.getTime() : 0;
78 Log
.e("WebdavEntry", "General fuckup, no status for webdav response");
82 public String
path() {
86 public String
name() {
90 public boolean isDirectory() {
91 return mContentType
.equals("DIR");
94 public String
contentType() {
102 public long contentLength() {
103 return mContentLength
;
106 public long createTimestamp() {
107 return mCreateTimestamp
;
110 public long modifiedTimesamp() {
111 return mModifiedTimestamp
;
114 private void resetData() {
115 mName
= mUri
= mContentType
= null
;
116 mContentLength
= mCreateTimestamp
= mModifiedTimestamp
= 0;