Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DeletePackage.cs
1using System;
2using System.IO;
3using System.Threading.Tasks;
8
10{
12 {
13 public DeletePackage()
14 : base("/DeletePackage")
15 {
16 }
17
18 public override bool HandlesSubPaths => false;
19 public override bool UserSessions => true;
20 public bool AllowsPOST => true;
21
22 public async Task POST(HttpRequest Request, HttpResponse Response)
23 {
24 Gateway.AssertUserAuthenticated(Request, "Admin.Software.Upload");
25
26 if (!Request.HasData || !(await Request.DecodeDataAsync() is string FileName))
27 throw new BadRequestException();
28
29 string FullFileName = Path.Combine(XmppServerModule.PackagesFolder, FileName);
30 if (File.Exists(FullFileName))
31 File.Delete(FullFileName);
32
33 Package Package = await Provisioning.ProvisioningComponent.GetPackage(FileName);
34 if (!(Package is null))
35 {
37 {
38 FullFileName = Path.Combine(XmppServerModule.DownloadsFolder, FileName);
39 if (File.Exists(FullFileName))
40 File.Delete(FullFileName);
41 }
42
43 await Database.Delete(Package);
44 await XmppServerModule.Provisioning.PackageDeleted(Package);
45 }
46 }
47 }
48}
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
Definition: Gateway.cs:3041
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
Definition: HttpRequest.cs:18
bool HasData
If the request has data.
Definition: HttpRequest.cs:74
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Definition: HttpRequest.cs:95
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
static async Task Delete(object Object)
Deletes an object in the database.
Definition: Database.cs:717
Contains information about a software package.
Definition: Package.cs:18
bool Downloadable
If package should be made downloadable via web interface.
Definition: Package.cs:106
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
Service Module hosting the XMPP broker and its components.
POST Interface for HTTP resources.