Ejemplo n.º 1
0
        private void ValidatePath(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var key   = string.Format("{0}/validate", Library.Utility.Uri.UrlPathEncode(input["path"].Value));

            RESTHandler.DoProcess(request, response, session, "GET", typeof(RESTMethods.Filesystem).Name.ToLowerInvariant(), key);
        }
Ejemplo n.º 2
0
        private void ExportBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var key   = string.Format("{0}/export", Library.Utility.Uri.UrlPathEncode(input["id"].Value));

            RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
        }
Ejemplo n.º 3
0
        private void CreateRemoteFolder(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var key   = string.Format("{0}/create", Library.Utility.Uri.UrlPathEncode(input["url"].Value));

            RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.RemoteOperation).Name.ToLowerInvariant(), key);
        }
Ejemplo n.º 4
0
        private void ListBackupSets(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var key   = string.Format("{0}/filesets", input["id"].Value);

            RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
        }
Ejemplo n.º 5
0
        private void SearchBackupFiles(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var input = request.Method.Equals("POST", StringComparison.InvariantCultureIgnoreCase) ? request.Form : request.QueryString;
            var key   = string.Format("{0}/files/{1}", input["id"].Value, input["filter"].Value);

            RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
        }
Ejemplo n.º 6
0
        private void ReadLogData(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;

            if (string.IsNullOrEmpty(input["id"].Value))
            {
                RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.LogData));
            }
            else
            {
                var key = string.Format("{0}/{1}", input["id"].Value, Duplicati.Library.Utility.Utility.ParseBool(input["remotelog"].Value, false) ? "remotelog" : "log");
                RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
        }
Ejemplo n.º 7
0
        private void SendCommand(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;

            string command = input["command"].Value ?? "";

            switch (command.ToLowerInvariant())
            {
            case "check-update":
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Updates).Name.ToLowerInvariant(), "check");
                return;

            case "install-update":
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Updates).Name.ToLowerInvariant(), "install");
                return;

            case "activate-update":
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Updates).Name.ToLowerInvariant(), "activate");
                return;

            case "pause":
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.ServerState).Name.ToLowerInvariant(), "pause");
                return;

            case "resume":
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.ServerState).Name.ToLowerInvariant(), "resume");
                return;

            case "stop":
            case "abort":
            {
                var key = string.Format("{0}/{1}", input["taskid"].Value, command);
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Task).Name.ToLowerInvariant(), key);
            }
                return;

            case "is-backup-active":
            {
                var key = string.Format("{0}/isactive", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                RESTHandler.DoProcess(request, response, session, "GET", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
                return;

            case "run":
            case "run-backup":
            {
                var key = string.Format("{0}/start", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
                return;

            case "run-verify":
            {
                var key = string.Format("{0}/verify", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
                return;

            case "run-repair-update":
            {
                var key = string.Format("{0}/repairupdate", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
                return;

            case "run-repair":
            {
                var key = string.Format("{0}/repair", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
                return;

            case "create-report":
            {
                var key = string.Format("{0}/createreport", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
            }
                return;

            default:
            {
                var key = string.Format("{0}", Library.Utility.Uri.UrlPathEncode(input["command"].Value));
                RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.WebModule).Name.ToLowerInvariant(), key);
                return;
            }
            }
        }
Ejemplo n.º 8
0
 private void PollLogMessages(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.DoProcess(request, response, session, "GET", typeof(RESTMethods.LogData).Name.ToLowerInvariant(), "poll");
 }
Ejemplo n.º 9
0
 private void ImportBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backups).Name.ToLowerInvariant(), "import");
 }
Ejemplo n.º 10
0
 private void GetFolderContents(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Filesystem).Name.ToLowerInvariant(), Library.Utility.Uri.UrlPathEncode(request.QueryString["path"].Value));
 }