1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +00:00

remove jackrabit

This commit is contained in:
theScrabi 2018-06-27 17:44:47 +02:00 committed by davigonz
parent 0d0b711556
commit b99723205b
5 changed files with 1 additions and 371 deletions

View File

@ -18,7 +18,6 @@ allprojects {
} }
dependencies { dependencies {
api 'org.apache.jackrabbit:jackrabbit-webdav:2.12.4'
api 'com.squareup.okhttp3:okhttp:3.10.0' api 'com.squareup.okhttp3:okhttp:3.10.0'
api project(':dav4android') api project(':dav4android')

View File

@ -1,276 +0,0 @@
/** ownCloud Android Library is available under MIT license
*
* @author Christian Schabesberger
* Copyright (C) 2018 ownCloud GmbH.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
package com.owncloud.android.lib.common.network;
import java.math.BigDecimal;
import java.util.Date;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.property.DavProperty;
import org.apache.jackrabbit.webdav.property.DavPropertyName;
import org.apache.jackrabbit.webdav.property.DavPropertySet;
import org.apache.jackrabbit.webdav.xml.Namespace;
import android.net.Uri;
import com.owncloud.android.lib.common.utils.Log_OC;
public class WebdavEntry {
private static final String TAG = WebdavEntry.class.getSimpleName();
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_REMOTE_ID = "id";
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_AVAILABLE_BYTES = "quota-available-bytes";
private static final int CODE_PROP_NOT_FOUND = 404;
private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId, mPrivateLink;
private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize;
private BigDecimal mQuotaUsedBytes, mQuotaAvailableBytes;
public WebdavEntry(MultiStatusResponse ms, String splitElement) {
resetData();
if (ms.getStatus().length != 0) {
mUri = ms.getHref();
mPath = mUri.split(splitElement, 2)[1];
int status = ms.getStatus()[0].getStatusCode();
if (status == CODE_PROP_NOT_FOUND) {
status = ms.getStatus()[1].getStatusCode();
}
DavPropertySet propSet = ms.getProperties(status);
@SuppressWarnings("rawtypes")
DavProperty prop = propSet.get(DavPropertyName.DISPLAYNAME);
if (prop != null) {
mName = (String) prop.getName().toString();
mName = mName.substring(1, mName.length() - 1);
} else {
String[] tmp = mPath.split("/");
if (tmp.length > 0)
mName = tmp[tmp.length - 1];
}
// use unknown mimetype as default behavior
// {DAV:}getcontenttype
mContentType = "application/octet-stream";
prop = propSet.get(DavPropertyName.GETCONTENTTYPE);
if (prop != null) {
mContentType = (String) prop.getValue();
// dvelasco: some builds of ownCloud server 4.0.x added a trailing ';'
// to the MIME type ; if looks fixed, but let's be cautious
if (mContentType.indexOf(";") >= 0) {
mContentType = mContentType.substring(0, mContentType.indexOf(";"));
}
}
// check if it's a folder in the standard way: see RFC2518 12.2 . RFC4918 14.3
// {DAV:}resourcetype
prop = propSet.get(DavPropertyName.RESOURCETYPE);
if (prop != null) {
Object value = prop.getValue();
if (value != null) {
mContentType = "DIR"; // a specific attribute would be better,
// but this is enough;
// unless while we have no reason to distinguish
// MIME types for folders
}
}
// {DAV:}getcontentlength
prop = propSet.get(DavPropertyName.GETCONTENTLENGTH);
if (prop != null)
mContentLength = Long.parseLong((String) prop.getValue());
// {DAV:}getlastmodified
prop = propSet.get(DavPropertyName.GETLASTMODIFIED);
if (prop != null) {
Date d = WebdavUtils
.parseResponseDate((String) prop.getValue());
mModifiedTimestamp = (d != null) ? d.getTime() : 0;
}
prop = propSet.get(DavPropertyName.CREATIONDATE);
if (prop != null) {
Date d = WebdavUtils
.parseResponseDate((String) prop.getValue());
mCreateTimestamp = (d != null) ? d.getTime() : 0;
}
// {DAV:}getetag
prop = propSet.get(DavPropertyName.GETETAG);
if (prop != null) {
mEtag = (String) prop.getValue();
mEtag = WebdavUtils.parseEtag(mEtag);
}
// {DAV:}quota-used-bytes
prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_USED_BYTES));
if (prop != null) {
String quotaUsedBytesSt = (String) prop.getValue();
try {
mQuotaUsedBytes = new BigDecimal(quotaUsedBytesSt);
} catch (NumberFormatException e) {
Log_OC.w(TAG, "No value for QuotaUsedBytes - NumberFormatException");
} catch (NullPointerException e) {
Log_OC.w(TAG, "No value for QuotaUsedBytes - NullPointerException");
}
Log_OC.d(TAG, "QUOTA_USED_BYTES " + quotaUsedBytesSt);
}
// {DAV:}quota-available-bytes
prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_AVAILABLE_BYTES));
if (prop != null) {
String quotaAvailableBytesSt = (String) prop.getValue();
try {
mQuotaAvailableBytes = new BigDecimal(quotaAvailableBytesSt);
} catch (NumberFormatException e) {
Log_OC.w(TAG, "No value for QuotaAvailableBytes - NumberFormatException");
} catch (NullPointerException e) {
Log_OC.w(TAG, "No value for QuotaAvailableBytes");
}
Log_OC.d(TAG, "QUOTA_AVAILABLE_BYTES " + quotaAvailableBytesSt);
}
// OC permissions property <oc:permissions>
prop = propSet.get(
EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC)
);
if (prop != null && prop.getValue() != null) {
mPermissions = prop.getValue().toString();
}
// OC remote id property <oc:id>
prop = propSet.get(
EXTENDED_PROPERTY_NAME_REMOTE_ID, Namespace.getNamespace(NAMESPACE_OC)
);
if (prop != null) {
mRemoteId = prop.getValue().toString();
}
// OC size property <oc:size>
prop = propSet.get(
EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(NAMESPACE_OC)
);
if (prop != null) {
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 {
Log_OC.e("WebdavEntry",
"General fuckup, no status for webdav response");
}
}
public String path() {
return mPath;
}
public String decodedPath() {
return Uri.decode(mPath);
}
public String name() {
return mName;
}
public boolean isDirectory() {
return mContentType.equals("DIR");
}
public String contentType() {
return mContentType;
}
public String uri() {
return mUri;
}
public long contentLength() {
return mContentLength;
}
public long createTimestamp() {
return mCreateTimestamp;
}
public long modifiedTimestamp() {
return mModifiedTimestamp;
}
public String etag() {
return mEtag;
}
public String permissions() {
return mPermissions;
}
public String remoteId() {
return mRemoteId;
}
public long size() {
return mSize;
}
public BigDecimal quotaUsedBytes() {
return mQuotaUsedBytes;
}
public BigDecimal quotaAvailableBytes() {
return mQuotaAvailableBytes;
}
public String privateLink() {
return mPrivateLink;
}
private void resetData() {
mName = mUri = mContentType = mPermissions = null;
mRemoteId = null;
mContentLength = mCreateTimestamp = mModifiedTimestamp = 0;
mSize = 0;
mQuotaUsedBytes = null;
mQuotaAvailableBytes = null;
mPrivateLink = null;
}
}

View File

@ -34,10 +34,6 @@ import android.net.Uri;
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod; import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyName;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
import org.apache.jackrabbit.webdav.xml.Namespace;
public class WebdavUtils { public class WebdavUtils {
public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat( public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat(
"dd.MM.yyyy hh:mm"); "dd.MM.yyyy hh:mm");
@ -85,72 +81,6 @@ public class WebdavUtils {
return encodedPath; return encodedPath;
} }
/**
* Builds a DavPropertyNameSet with all prop
* For using instead of DavConstants.PROPFIND_ALL_PROP
* @return
*/
public static DavPropertyNameSet getAllPropSet(){
DavPropertyNameSet propSet = new DavPropertyNameSet();
propSet.add(DavPropertyName.DISPLAYNAME);
propSet.add(DavPropertyName.GETCONTENTTYPE);
propSet.add(DavPropertyName.RESOURCETYPE);
propSet.add(DavPropertyName.GETCONTENTLENGTH);
propSet.add(DavPropertyName.GETLASTMODIFIED);
propSet.add(DavPropertyName.CREATIONDATE);
propSet.add(DavPropertyName.GETETAG);
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES));
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES));
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS,
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID,
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;
}
/**
* Builds a DavPropertyNameSet with properties for files
* @return
*/
public static DavPropertyNameSet getFilePropSet(){
DavPropertyNameSet propSet = new DavPropertyNameSet();
propSet.add(DavPropertyName.DISPLAYNAME);
propSet.add(DavPropertyName.GETCONTENTTYPE);
propSet.add(DavPropertyName.RESOURCETYPE);
propSet.add(DavPropertyName.GETCONTENTLENGTH);
propSet.add(DavPropertyName.GETLASTMODIFIED);
propSet.add(DavPropertyName.CREATIONDATE);
propSet.add(DavPropertyName.GETETAG);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS,
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID,
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE,
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;
}
/**
* Builds a DavPropertyNameSet with properties for user quotas
* @return set of quota properties
*/
public static DavPropertyNameSet getQuotaPropSet() {
DavPropertyNameSet propSet = new DavPropertyNameSet();
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES));
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES));
return propSet;
}
/** /**
* *
* @param rawEtag * @param rawEtag

View File

@ -33,11 +33,6 @@ import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import com.owncloud.android.lib.common.network.CertificateCombinedException; import com.owncloud.android.lib.common.network.CertificateCombinedException;
import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.common.utils.Log_OC;
import org.apache.jackrabbit.webdav.DavException;
import org.json.JSONException; import org.json.JSONException;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -56,6 +51,7 @@ import java.util.Map;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLPeerUnverifiedException;
import at.bitfire.dav4android.exception.DavException;
import at.bitfire.dav4android.exception.HttpException; import at.bitfire.dav4android.exception.HttpException;
import okhttp3.Headers; import okhttp3.Headers;

View File

@ -27,10 +27,6 @@ package com.owncloud.android.lib.resources.files;
import android.net.Uri; import android.net.Uri;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.Log;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.utils.Log_OC;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -189,21 +185,6 @@ public class RemoteFile implements Parcelable, Serializable {
mRemotePath = path; mRemotePath = path;
} }
public RemoteFile(WebdavEntry webdavEntry) {
this(webdavEntry.decodedPath());
this.setCreationTimestamp(webdavEntry.createTimestamp());
this.setLength(webdavEntry.contentLength());
this.setMimeType(webdavEntry.contentType());
this.setModifiedTimestamp(webdavEntry.modifiedTimestamp());
this.setEtag(webdavEntry.etag());
this.setPermissions(webdavEntry.permissions());
this.setRemoteId(webdavEntry.remoteId());
this.setSize(webdavEntry.size());
this.setQuotaUsedBytes(webdavEntry.quotaUsedBytes());
this.setQuotaAvailableBytes(webdavEntry.quotaAvailableBytes());
this.setPrivateLink(webdavEntry.privateLink());
}
public RemoteFile(final DavResource davResource, String displayName) { public RemoteFile(final DavResource davResource, String displayName) {
this(getRemotePathFromUrl(davResource.getLocation(), displayName)); this(getRemotePathFromUrl(davResource.getLocation(), displayName));
final PropertyCollection properties = davResource.getProperties(); final PropertyCollection properties = davResource.getProperties();