//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @POST @Path("/{username}/password") public javax.ws.rs.core.Response setPassword(@PathParam("username") String username, @Context HttpServletRequest req, String payload) public virtual Response SetPassword(string username, HttpServletRequest req, string payload) { Principal principal = req.UserPrincipal; if (principal == null || !principal.Name.Equals(username)) { return(_output.notFound()); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String, Object> deserialized; IDictionary <string, object> deserialized; try { deserialized = _input.readMap(payload); } catch (BadInputException e) { return(_output.response(BAD_REQUEST, new ExceptionRepresentation(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, e.Message)))); } object o = deserialized[PASSWORD]; if (o == null) { return(_output.response(UNPROCESSABLE, new ExceptionRepresentation(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Required parameter '{0}' is missing.", PASSWORD))))); } if (!(o is string)) { return(_output.response(UNPROCESSABLE, new ExceptionRepresentation(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Expected '{0}' to be a string.", PASSWORD))))); } string newPassword = ( string )o; try { LoginContext loginContext = getLoginContextFromUserPrincipal(principal); if (loginContext == null) { return(_output.notFound()); } else { UserManager userManager = _userManagerSupplier.getUserManager(loginContext.Subject(), false); userManager.SetUserPassword(username, UTF8.encode(newPassword), false); } } catch (IOException e) { return(_output.serverErrorWithoutLegacyStacktrace(e)); } catch (InvalidArgumentsException e) { return(_output.response(UNPROCESSABLE, new ExceptionRepresentation(new Neo4jError(e.Status(), e.Message)))); } return(_output.ok()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @POST public javax.ws.rs.core.Response exec(@Context InputFormat input, String data) public virtual Response Exec(InputFormat input, string data) { IDictionary <string, object> args; try { args = input.readMap(data); } catch (BadInputException e) { return(_output.badRequest(e)); } if (!args.ContainsKey("command")) { return(Response.status(Response.Status.BAD_REQUEST).entity("Expected command argument not present.").build()); } ScriptSession scriptSession; try { scriptSession = GetSession(args); } catch (System.ArgumentException e) { return(_output.badRequest(e)); } _log.debug(scriptSession.ToString()); try { Pair <string, string> result = scriptSession.Evaluate(( string )args["command"]); IList <Representation> list = new IList <Representation> { ValueRepresentation.@string(result.First()), ValueRepresentation.@string(result.Other()) }; return(_output.ok(new ListRepresentation(RepresentationType.STRING, list))); } catch (Exception e) { IList <Representation> list = new IList <Representation> { ValueRepresentation.@string(e.GetType() + " : " + e.Message + "\n"), ValueRepresentation.@string(null) }; return(_output.ok(new ListRepresentation(RepresentationType.STRING, list))); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public java.util.Map<String, Object> readMap(String input, String... requiredKeys) throws org.neo4j.server.rest.repr.BadInputException public override IDictionary <string, object> ReadMap(string input, params string[] requiredKeys) { return(InputFormat.readMap(input, requiredKeys)); }