@GET("/sessions/current") public Optional<Session> currentSession() { return currentSessionResolver.resolveCurrentSession(); }
methodAnnotations.add(new ResourceMethodAnnotation("GET", elem, get.value()));
@GET("/sessions/current") public Optional<Session> currentSession() { return currentSessionResolver.resolveCurrentSession(); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/i18n/locales") public Iterable<String> locales() { Collection<String> locales = new ArrayList<>(); for (SupportedLocale supportedLocale : supportedLocales) { String tag = supportedLocale.getLocale().toLanguageTag(); locales.add(Locale.ROOT.toLanguageTag().equals(tag) ? "/" : tag); } return locales; }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/i18n/locales") public Iterable<String> locales() { Collection<String> locales = new ArrayList<>(); for (SupportedLocale supportedLocale : supportedLocales) { String tag = supportedLocale.getLocale().toLanguageTag(); locales.add(Locale.ROOT.toLanguageTag().equals(tag) ? "/" : tag); } return locales; }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/thread-dump") public String threadDump() { ByteArrayOutputStream out = new ByteArrayOutputStream(); threadDump.dump(out); return new String(out.toByteArray()); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/thread-dump") public String threadDump() { ByteArrayOutputStream out = new ByteArrayOutputStream(); threadDump.dump(out); return new String(out.toByteArray()); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/specs/{id}") public Optional<RestxSpec> getSpecById(String id) { try { // to decode the spec id we first URL decode it, and then we replace triple underscores by forward slashes // This let the client address the spec id without having to URI encode the forward slash as %2F, which is // not allowed on some servers (especially tomcat) // see https://github.com/restx/restx/issues/90 String specId = URLDecoder.decode(id, Charsets.UTF_8.name()).replace("___", "/"); return repository.findSpecById(specId); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/sessionStats") public Iterable<Sessions.SessionData> metrics() { return sessions.getAll().values(); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/sessionStats") public Iterable<Sessions.SessionData> metrics() { return sessions.getAll().values(); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/specs/{id}") public Optional<RestxSpec> getSpecById(String id) { try { // to decode the spec id we first URL decode it, and then we replace triple underscores by forward slashes // This let the client address the spec id without having to URI encode the forward slash as %2F, which is // not allowed on some servers (especially tomcat) // see https://github.com/restx/restx/issues/90 String specId = URLDecoder.decode(id, Charsets.UTF_8.name()).replace("___", "/"); return repository.findSpecById(specId); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/logs") public String getLogs() { // quick and dirty basic implementation to get logs from the default log file. // this doesn't scale at all, and is very limited try { File appLog = new File(System.getProperty("logs.base", "logs"), "app.log"); String logs = Files.toString( appLog, Charsets.UTF_8); // limit to around 30k int limit = 30000; if (logs.length() > limit) { int length = logs.length(); logs = logs.substring(logs.length() - limit); logs = logs.substring(logs.indexOf('\n') + 1); logs = "[... " + ((length - logs.length()) / 1024) + " kB truncated ...]\n" + logs; } logs = "LOGS FROM: " + appLog.getAbsolutePath() + "\n" + "------------------------------------------------------------------------------------------------\n" + logs; return logs; } catch (IOException e) { return e.getMessage(); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/tests/results/{key}") public Optional<TestResult> getTestResultByKey(String key) { return server.getResultByKey(key); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/restx-stats") public RestxStats getRestxStats() { return collector.getStats(); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/i18n/keys") public Iterable<String> keys() { return messages.keys(); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/health-checks") public Map healthChecks() { return healthChecks.runHealthChecks(); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/config/elements") public Iterable<ConfigElement> findConfigElements() { return config.elements(); } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/pages") public Iterable<AdminPage> findPages(@Param(kind = Param.Kind.CONTEXT, value = "baseUri") String baseUri) { List<AdminPage> rootedPages = Lists.newArrayList(); for (AdminPage page : pages) { rootedPages.add(page.rootOn(baseUri)); } return rootedPages; } }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/tests/requests/{key}") public Optional<TestRequest> getTestRequestByKey(String key) { return server.getRequestByKey(key); }
@RolesAllowed(AdminModule.RESTX_ADMIN_ROLE) @GET("/@/specs") public Iterable<String> findSpecsForOperation(String httpMethod, String path) { return repository.findSpecsByOperation(httpMethod, path); }