Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SelectReviewService.cs
1using Paiwise;
2using System;
3using System.Collections.Generic;
4using System.Threading.Tasks;
5using System.Xml;
6using Waher.Content;
11using Waher.Script;
15
17{
22 {
27 : base("Legal/SelectReviewService",
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(SelectReviewService).Namespace + ".JSON.SelectReviewService.req");
34 private static readonly string xmlPattern = Resources.LoadResourceAsText(typeof(SelectReviewService).Namespace + ".XML.SelectReviewService.req");
35
44 public override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters)
45 {
47
48 string ServiceId = (string)Parameters["PServiceId"].AssociatedObjectValue;
49 string ServiceProvider = (string)Parameters["PServiceProvider"].AssociatedObjectValue;
50
52 ?? throw new NotFoundException("Service provider not found.");
53
54 if (!typeof(IPeerReviewServiceProvider).IsAssignableFrom(T))
55 throw new BadRequestException("Invalid service provider.");
56
57 LegalIdentity IdentityApplication = await Database.FindFirstIgnoreRest<LegalIdentity>(new FilterAnd(
58 new FilterFieldEqualTo("Account", User.UserName),
59 new FilterFieldEqualTo("State", IdentityState.Created)), "-Created")
60 ?? throw new ForbiddenException("No Identity Application found.");
61
62 KeyValuePair<string, object>[] Tags = IdentityApplication.GetTags();
64 IPeerReviewService Service = await Provider.GetServiceForPeerReview(ServiceId, Tags)
65 ?? throw new NotFoundException("Peer-review service not found.");
66
67 XmppServerModule.Legal?.SelectServiceProvider(User.UserName, Service);
68
69 await Response.Return(new NamedDictionary<string, object>("AckResponse", AgentNamespace));
70 }
71 }
72}
Contains information about a service provider.
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:15
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Definition: Resources.cs:96
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Represents an HTTP request.
Definition: HttpRequest.cs:18
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
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 that dynamically manages types and interfaces available in the runtime environment.
Definition: Types.cs:14
static Type GetType(string FullName)
Gets a type, given its full name.
Definition: Types.cs:41
static object Instantiate(Type Type, params object[] Arguments)
Returns an instance of the type Type . If one needs to be created, it is. If the constructor requires...
Definition: Types.cs:1353
Class managing a script expression.
Definition: Expression.cs:39
Abstract base class for agent resources supporting the POST method.
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
Service Module hosting the XMPP broker and its components.
Interface for currency converter service providers
Interface for peer-review service providers.
Task< IPeerReviewService > GetServiceForPeerReview(string ServiceId, KeyValuePair< string, object >[] Identity)
Gets a peer-review service.