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
);
45 mName
= (String
) prop
.getName().toString();
47 String
[] tmp
= mPath
.split("/");
49 mName
= tmp
[tmp
.length
- 1];
52 prop
= propSet
.get(DavPropertyName
.GETCONTENTTYPE
);
54 mContentType
= (String
) prop
.getValue();
58 * prop = propSet.get(DavPropertyName.ISCOLLECTION); if (prop !=
59 * null && Boolean.parseBoolean((String) prop.getValue()))
60 * mContentType = "DIR";
64 prop
= propSet
.get(DavPropertyName
.GETCONTENTLENGTH
);
66 mContentLength
= Long
.parseLong((String
) prop
.getValue());
68 prop
= propSet
.get(DavPropertyName
.GETLASTMODIFIED
);
71 .parseResponseDate((String
) prop
.getValue());
72 mModifiedTimestamp
= (d
!= null
) ? d
.getTime() : 0;
75 prop
= propSet
.get(DavPropertyName
.CREATIONDATE
);
78 .parseResponseDate((String
) prop
.getValue());
79 mCreateTimestamp
= (d
!= null
) ? d
.getTime() : 0;
84 "General fuckup, no status for webdav response");
88 public String
path() {
92 public String
name() {
96 public boolean isDirectory() {
97 return mContentType
.equals("DIR");
100 public String
contentType() {
104 public String
uri() {
108 public long contentLength() {
109 return mContentLength
;
112 public long createTimestamp() {
113 return mCreateTimestamp
;
116 public long modifiedTimesamp() {
117 return mModifiedTimestamp
;
120 private void resetData() {
121 mName
= mUri
= mContentType
= null
;
122 mContentLength
= mCreateTimestamp
= mModifiedTimestamp
= 0;