Skip to content

Commit

Permalink
[ExternalStorage] add WebDAV external storage implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 committed Aug 23, 2021
1 parent 0ce7f90 commit 96eb75a
Show file tree
Hide file tree
Showing 23 changed files with 619 additions and 22 deletions.
10 changes: 9 additions & 1 deletion .docker/docker-compose-testing.yml
Expand Up @@ -11,12 +11,20 @@ services:
httpbin:
image: kennethreitz/httpbin:latest

webdav:
image: nginx
volumes:
- ${GH_WORKSPACE}/.docker/webdav/nginx.conf:/etc/nginx/conf.d/default.conf
- ${GH_WORKSPACE}/.docker/webdav/passwords.list:/etc/nginx/.passwords.list
- /tmp/webdav_tests:/tmp/webdav_tests_root/webdav_tests

qgis-deps:
tty: true
image: qgis3-build-deps-binary-image
volumes:
- ${GH_WORKSPACE}:/root/QGIS
# links:
links:
- webdav
# - mssql
links:
- httpbin
Expand Down
3 changes: 3 additions & 0 deletions .docker/docker-variables.env
Expand Up @@ -20,3 +20,6 @@ QGIS_CONTINUOUS_INTEGRATION_RUN=true
PUSH_TO_CDASH=false

XDG_RUNTIME_DIR=/tmp

QGIS_WEBDAV_HOST=webdav
QGIS_WEBDAV_PORT=80
21 changes: 21 additions & 0 deletions .docker/webdav/nginx.conf
@@ -0,0 +1,21 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

location /webdav_tests {

auth_basic realm_name;
auth_basic_user_file /etc/nginx/.passwords.list;

dav_methods PUT DELETE MKCOL COPY MOVE;
#dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:r;

autoindex on;

client_max_body_size 0;
create_full_put_path on;
root /tmp/webdav_tests_root;
}
}
1 change: 1 addition & 0 deletions .docker/webdav/passwords.list
@@ -0,0 +1 @@
qgis:$apr1$cxID/nB1$3tG4J0FkYvEHyWAB.yqjo.
1 change: 1 addition & 0 deletions .github/workflows/run-tests.yml
Expand Up @@ -386,4 +386,5 @@ jobs:
[[ ${{ matrix.test-batch }} == "ORACLE" ]] && sudo rm -rf /usr/share/dotnet/sdk
echo "TEST_BATCH=$TEST_BATCH"
echo "DOCKERFILE=$DOCKERFILE"
mkdir -p /tmp/webdav_tests && chmod 777 /tmp/webdav_tests
docker-compose -f .docker/$DOCKERFILE run qgis-deps /root/QGIS/.docker/docker-qgis-test.sh $TEST_BATCH
Expand Up @@ -69,7 +69,7 @@ can be retrieved by calling :py:func:`~QgsBlockingNetworkRequest.errorMessage`.
.. seealso:: :py:func:`post`
%End

ErrorCode post( QNetworkRequest &request, const QByteArray &data, bool forceRefresh = false, QgsFeedback *feedback = 0 );
ErrorCode post( QNetworkRequest &request, QIODevice *data, bool forceRefresh = false, QgsFeedback *feedback = 0 );
%Docstring
Performs a "post" operation on the specified ``request``, using the given ``data``.

Expand All @@ -89,6 +89,15 @@ If an error was encountered then a specific ErrorCode will be returned, and a de
can be retrieved by calling :py:func:`~QgsBlockingNetworkRequest.errorMessage`.

.. seealso:: :py:func:`get`

.. versionadded:: 3.22
%End

ErrorCode post( QNetworkRequest &request, const QByteArray &data, bool forceRefresh = false, QgsFeedback *feedback = 0 );
%Docstring
This is an overloaded function.

Performs a "post" operation on the specified ``request``, using the given ``data``.
%End

ErrorCode head( QNetworkRequest &request, bool forceRefresh = false, QgsFeedback *feedback = 0 );
Expand All @@ -113,7 +122,7 @@ can be retrieved by calling :py:func:`~QgsBlockingNetworkRequest.errorMessage`.
.. versionadded:: 3.18
%End

ErrorCode put( QNetworkRequest &request, const QByteArray &data, QgsFeedback *feedback = 0 );
ErrorCode put( QNetworkRequest &request, QIODevice *data, QgsFeedback *feedback = 0 );
%Docstring
Performs a "put" operation on the specified ``request``, using the given ``data``.

Expand All @@ -129,6 +138,15 @@ by calling :py:func:`~QgsBlockingNetworkRequest.reply`.
If an error was encountered then a specific ErrorCode will be returned, and a detailed error message
can be retrieved by calling :py:func:`~QgsBlockingNetworkRequest.errorMessage`.

.. versionadded:: 3.22
%End

ErrorCode put( QNetworkRequest &request, const QByteArray &data, QgsFeedback *feedback = 0 );
%Docstring
This is an overloaded function.

Performs a "put" operation on the specified ``request``, using the given ``data``.

.. versionadded:: 3.18
%End

Expand Down Expand Up @@ -192,6 +210,13 @@ Emitted when when data arrives during a request.
void downloadFinished();
%Docstring
Emitted once a request has finished downloading.
%End

void uploadProgress( qint64, qint64 );
%Docstring
Emitted when when data are sent during a request.

.. versionadded:: 3.22
%End

};
Expand Down
Expand Up @@ -95,6 +95,14 @@ Emitted when content has loaded
Emitted when data is received.

.. versionadded:: 3.2
%End

void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
%Docstring
Emitted when an error with ``code`` error occured while processing the request
``errorMsg`` is a textual description of the error

.. versionadded:: 3.22
%End

};
Expand Down
Expand Up @@ -32,7 +32,8 @@ FetchedContent holds useful information about a network content being fetched
Failed
};

explicit QgsFetchedContent( const QString &url, QTemporaryFile *file = 0, ContentStatus status = NotStarted );
explicit QgsFetchedContent( const QString &url, QTemporaryFile *file = 0, ContentStatus status = NotStarted,
const QString &authConfig = QString() );
%Docstring
Constructs a FetchedContent with pointer to the downloaded file and status of the download
%End
Expand All @@ -54,6 +55,11 @@ Returns the status of the download
QNetworkReply::NetworkError error() const;
%Docstring
Returns the potential error of the download
%End

QString authConfig() const;
%Docstring
Returns the authentication configuration id use for this fetched content
%End

public slots:
Expand All @@ -74,6 +80,14 @@ Cancel the download operation.
void fetched();
%Docstring
Emitted when the file is fetched and accessible
%End

void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
%Docstring
Emitted when an error with ``code`` error occured while processing the request
``errorMsg`` is a textual description of the error

.. versionadded:: 3.22
%End

};
Expand Down Expand Up @@ -103,12 +117,13 @@ Create the registry for temporary downloaded files

~QgsNetworkContentFetcherRegistry();

const QgsFetchedContent *fetch( const QString &url, Qgis::ActionStart fetchingMode = Qgis::ActionStart::Deferred );
QgsFetchedContent *fetch( const QString &url, Qgis::ActionStart fetchingMode = Qgis::ActionStart::Deferred, const QString &authConfig = QString() );
%Docstring
Initialize a download for the given URL

:param url: the URL to be fetched
:param fetchingMode: defines if the download will start immediately or shall be manually triggered
:param authConfig: authentication configuration id to be used while fetching

.. note::

Expand Down
Expand Up @@ -91,6 +91,14 @@ of whether the fetch was successful or not.
Users of QgsNetworkContentFetcherTask should connect to this signal,
and from the associated slot they can then safely access the network :py:func:`~QgsNetworkContentFetcherTask.reply`
without danger of the task being first removed by the :py:class:`QgsTaskManager`.
%End

void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
%Docstring
Emitted when an error with ``code`` error occured while processing the request
``errorMsg`` is a textual description of the error

.. versionadded:: 3.22
%End

};
Expand Down
3 changes: 2 additions & 1 deletion src/core/CMakeLists.txt
Expand Up @@ -133,6 +133,7 @@ set(QGIS_CORE_SRCS
externalstorage/qgsexternalstorage.cpp
externalstorage/qgsexternalstorageregistry.cpp
externalstorage/qgssimplecopyexternalstorage.cpp
externalstorage/qgswebdavexternalstorage.cpp

layertree/qgscolorramplegendnode.cpp
layertree/qgscolorramplegendnodesettings.cpp
Expand Down Expand Up @@ -1750,8 +1751,8 @@ set(QGIS_CORE_PRIVATE_HDRS
qgsspatialindexkdbush_p.h

editform/qgseditformconfig_p.h

externalstorage/qgssimplecopyexternalstorage_p.h
externalstorage/qgswebdavexternalstorage_p.h

proj/qgscoordinatereferencesystem_p.h
proj/qgscoordinatetransformcontext_p.h
Expand Down
2 changes: 2 additions & 0 deletions src/core/externalstorage/qgsexternalstorageregistry.cpp
Expand Up @@ -17,10 +17,12 @@

#include "qgsexternalstorage.h"
#include "qgssimplecopyexternalstorage_p.h"
#include "qgswebdavexternalstorage_p.h"

QgsExternalStorageRegistry::QgsExternalStorageRegistry()
{
registerExternalStorage( new QgsSimpleCopyExternalStorage() );
registerExternalStorage( new QgsWebDAVExternalStorage() );
}

QgsExternalStorageRegistry::~QgsExternalStorageRegistry()
Expand Down

0 comments on commit 96eb75a

Please sign in to comment.