List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.omertron.themoviedbapi.methods.TmdbCertifications.java
/** * Get a list of movies certification./* w w w .j a v a2 s.c om*/ * * @return * @throws MovieDbException */ public ResultsMap<String, List<Certification>> getMoviesCertification() throws MovieDbException { URL url = new ApiUrl(apiKey, MethodBase.CERTIFICATION).subMethod(MethodSub.MOVIE_LIST).buildUrl(); String webpage = httpTools.getRequest(url); try { JsonNode node = MAPPER.readTree(webpage); Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() { }); return new ResultsMap<String, List<Certification>>(results); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie certifications", url, ex); } }
From source file:retsys.client.controller.UserController.java
/** * Initializes the controller class./*from w ww. ja va2 s . c om*/ */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO AutoCompletionBinding<User> txt_name = TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<User>>() { @Override public Collection<User> call(AutoCompletionBinding.ISuggestionRequest param) { List<User> list = null; HttpHelper helper = new HttpHelper(); try { LovHandler lovHandler = new LovHandler("users", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<User>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<User>>() { }); } catch (IOException ex) { Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<User>() { @Override public String toString(User object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public User fromString(String string) { throw new UnsupportedOperationException("Not supported yet."); } }); //event handler for setting other Client fields with values from selected Client object //fires after autocompletion txt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<User>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<User> event) { User user = event.getCompletion(); //fill other item related fields id.setText(splitId(name.getText()) + ""); name.setText(user.getName()); password.setText(user.getPassword()); if ("N".equals(user.getUsertype())) usertype.getSelectionModel().select(1); else if ("A".equals(user.getUsertype())) usertype.getSelectionModel().select(2); else usertype.getSelectionModel().clearSelection(); populateAuditValues(user); } }); }
From source file:edu.slu.tpen.servlet.LoginServlet.java
/** * Handles the HTTP <code>POST</code> method by logging in using the given credentials. Credentials * should be specified as a JSON object in the request body. There is also a deprecated way of passing * the credentials as query parameters./*from w ww . j av a2 s . com*/ * * @param req servlet request * @param resp servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { String mail = null, password = null; if (req.getContentLength() > 0) { String contentType = getBaseContentType(req); if (contentType.equals("application/json")) { ObjectMapper mapper = new ObjectMapper(); Map<String, String> creds = mapper.readValue(req.getInputStream(), new TypeReference<Map<String, String>>() { }); mail = creds.get("mail"); password = creds.get("password"); } } else { // Deprecated approach where user-name and password are passed on the query string. mail = req.getParameter("uname"); password = req.getParameter("password"); } if (mail != null && password != null) { User u = new User(mail, password); if (u.getUID() > 0) { HttpSession sess = req.getSession(true); sess.setAttribute("UID", u.getUID()); } else { resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); } } else if (mail == null && password == null) { // Passing null data indicates a logout. HttpSession sess = req.getSession(true); sess.removeAttribute("UID"); resp.setStatus(HttpServletResponse.SC_NO_CONTENT); } else { // Only supplied one of user-id and password. resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); } } catch (NoSuchAlgorithmException ex) { reportInternalError(resp, ex); } }
From source file:com.auth0.api.internal.SimpleRequest.java
public SimpleRequest(Handler handler, HttpUrl url, OkHttpClient client, ObjectMapper mapper, String httpMethod, Class<T> clazz) {/*from w w w.j av a2 s . c om*/ super(handler, url, client, mapper.reader(clazz), mapper.writer()); this.errorReader = mapper.reader(new TypeReference<Map<String, Object>>() { }); this.method = httpMethod; }
From source file:com.okta.sdk.clients.AuthApiClient.java
public OrgAnonymousInfo getAnonymousInfo() throws IOException { return get(getEncodedPath("/info"), new TypeReference<OrgAnonymousInfo>() { });// www .ja v a 2 s.co m }
From source file:net.nikore.gozer.marathon.MarathonHost.java
public App getApp(String id) throws Exception { HttpClientRequest<ByteBuf> request = HttpClientRequest .createGet("http://" + marathonHost + "/v2/apps/" + id); SimpleRibbonResponse response = utils.simpleRequest(request); Map<String, App> apps = mapper.readValue(response.getContent(), new TypeReference<Map<String, App>>() { });/*from w w w . j ava 2 s. c o m*/ return apps.get("app"); }
From source file:org.ocsoft.olivia.models.contents.config.JsonObject.java
public Map<String, Object> getAsMap() throws IOException { return JsonUtils.readJsonParser(root.traverse(), new TypeReference<Map<String, Object>>() { });/* w w w . j a va 2 s. c o m*/ }
From source file:info.losd.galenweb.client.GalenClient.java
@Override public List<GalenHealthCheck> getHealthChecks() { try {//from www . j a v a2 s.com HttpResponse response = Request.Get(String.format("%s/tasks", url)).execute().returnResponse(); ReadContext ctx = JsonPath.parse(response.getEntity().getContent()); JSONArray tasks = ctx.read("$._embedded.tasks"); return new ObjectMapper().readValue(tasks.toJSONString(), new TypeReference<List<GalenHealthCheck>>() { }); } catch (IOException e) { LOG.error("Problem getting health check list", e); } catch (PathNotFoundException e) { LOG.debug("There are no healthchecks"); } return Collections.emptyList(); }
From source file:com.okta.sdk.clients.FactorsApiClient.java
public List<Factor> getUserLifecycleFactors(String userId) throws IOException { return get(getEncodedPath("/%s/factors", userId), new TypeReference<List<Factor>>() { });/*from w ww. ja v a 2 s. co m*/ }