/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package br.com.developer.redu.util; import br.com.developer.redu.models.Link; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.scribe.model.Token; /** * * @author Rafael */ public class ReduUtil { /** * * @param links * @return */ public static Map<String, String> converterListLink(List<Link> links) { Map map = new TreeMap(); for (Link link : links) { StringBuilder path = new StringBuilder(link.href); for (int i = link.href.length() - 1; i > 0; i--) { if (link.href.charAt(i) == '/') { path.delete(0, i + 1); break; } } map.put(link.rel, path.toString()); } return map; } /** * * @param httpToken * @return */ public static Token parseToken(String httpToken) { String rawResponse = "{\"access_token\":\"" + httpToken + "\",\"token_type\":\"bearer\"}"; return new Token(httpToken, null, rawResponse); } }