예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @POST @Consumes(javax.ws.rs.core.MediaType.APPLICATION_JSON) @Path(QUERY_PATH) @SuppressWarnings("unchecked") public javax.ws.rs.core.Response queryBeans(String query)
        public virtual Response QueryBeans(string query)
        {
            try
            {
                MBeanServer server = ManagementFactory.PlatformMBeanServer;

                string json = DodgeStartingUnicodeMarker(query);
                ICollection <object> queries = (ICollection <object>)JsonHelper.readJson(json);

                List <JmxMBeanRepresentation> beans = new List <JmxMBeanRepresentation>();
                foreach (object queryObj in queries)
                {
                    Debug.Assert(queryObj is string);
                    foreach (object objName in server.queryNames(new ObjectName(( string )queryObj), null))
                    {
                        beans.Add(new JmxMBeanRepresentation(( ObjectName )objName));
                    }
                }

                return(_output.ok(new ListRepresentation("jmxBean", beans)));
            }
            catch (Exception e) when(e is JsonParseException || e is MalformedObjectNameException)
            {
                return(_output.badRequest(e));
            }
        }
예제 #2
0
//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)));
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @POST @Path(PATH_GRAPHDB_EXTENSION_METHOD) public javax.ws.rs.core.Response invokeGraphDatabaseExtension(@PathParam("name") String name, @PathParam("method") String method, String data)
        public virtual Response InvokeGraphDatabaseExtension(string name, string method, string data)
        {
            try
            {
                return(_output.ok(this.InvokeGraphDatabaseExtension(name, method, _input.readParameterList(data))));
            }
            catch (BadInputException e)
            {
                return(_output.badRequest(e));
            }
            catch (PluginLookupException e)
            {
                return(_output.notFound(e));
            }
            catch (BadPluginInvocationException e)
            {
                return(_output.badRequest(e.InnerException));
            }
            catch (SyntaxException e)
            {
                return(_output.badRequest(e.InnerException));
            }
            catch (PluginInvocationFailureException e)
            {
                return(_output.serverError(e.InnerException));
            }
            catch (Exception e)
            {
                return(_output.serverError(e));
            }
        }