Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LoadPrivateXml.cs
1using System;
3using System.Threading.Tasks;
4using System.Xml;
5using Waher.Content;
12using Waher.Script;
15
17{
22 {
27 : base("Storage/LoadPrivateXml",
28 new KeyValuePair<Type, Expression>(typeof(Dictionary<string, object>), new Expression(jsonPattern)),
29 new KeyValuePair<Type, Expression>(typeof(XmlDocument), new Expression(xmlPattern)))
30 {
31 }
32
33 private static readonly string jsonPattern = Resources.LoadResourceAsText(typeof(LoadPrivateXml).Namespace + ".JSON.LoadPrivateXml.req");
34 private static readonly string xmlPattern = Resources.LoadResourceAsText(typeof(LoadPrivateXml).Namespace + ".XML.LoadPrivateXml.req");
35
44 public override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters)
45 {
47
48 string LocalName = (string)Parameters["PLocalName"].AssociatedObjectValue;
49 string Namespace = (string)Parameters["PNamespace"].AssociatedObjectValue;
50
51 PersistedElement Element = await Database.FindFirstDeleteRest<PersistedElement>(new FilterAnd(
52 new FilterFieldEqualTo("Account", User.UserName),
53 new FilterFieldEqualTo("Namespace", Namespace),
54 new FilterFieldEqualTo("LocalName", LocalName)))
55 ?? throw new NotFoundException("Private XML not found.");
56
57 XmlDocument Doc = XML.ParseXml(Element.Xml, true);
58
60 {
61 { "created", Element.Created },
62 { "updated", Element.Updated },
63 { "Xml", Doc }
64 });
65 }
66 }
67}
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Helps with common XML-related tasks.
Definition: XML.cs:21
static XmlDocument ParseXml(string Xml)
Parses an XML Document from its string representation.
Definition: XML.cs:713
Represents an HTTP request.
Definition: HttpRequest.cs:22
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
Task Return(Exception ex)
Returns an error to the client.
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Contains information about one persisted XML element.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
This filter selects objects that conform to all child-filters provided.
Definition: FilterAnd.cs:10
This filter selects objects that have a named field equal to a given value.
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:13
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Definition: Resources.cs:55
Base class for all types of elements.
Definition: Element.cs:14
Class managing a script expression.
Definition: Expression.cs:41
Abstract base class for agent resources supporting the POST method.
Abstract base class for agent resources
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
const string AgentNamespace
https://waher.se/Schema/BrokerAgent.xsd
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.