/** * converts a String (for example the url paramter) into a Version object * * @param urlElement * String that should * @return the generated version */ public static Version getVersionFromString(String urlElement) { if (urlElement != null) { for (Version v : Version.values()) { if (urlElement.equals(v.getUrlElement())) { return v; } } } return UNVERSIONED; } }
/** * Returns the base endpoint URL for the Graph API. * * @return The base endpoint URL for the Graph API. */ protected String getFacebookGraphEndpointUrl() { if (apiVersion.isUrlElementRequired()) { return getFacebookEndpointUrls().getGraphEndpoint() + '/' + apiVersion.getUrlElement(); } else { return getFacebookEndpointUrls().getGraphEndpoint(); } }
static Version byUrlElement(String urlElement) { for (Version version : Version.values()) { if (version.getUrlElement().equals(urlElement)) { return version; } } return null; }
@JsonMapper.JsonMappingCompleted public void convertVersion() { version = Version.getVersionFromString(versionAsString); }
/** * Returns the base endpoint URL for the Graph API's video upload functionality. * * @return The base endpoint URL for the Graph API's video upload functionality. * @since 1.6.5 */ protected String getFacebookGraphVideoEndpointUrl() { if (apiVersion.isUrlElementRequired()) { return getFacebookEndpointUrls().getGraphVideoEndpoint() + '/' + apiVersion.getUrlElement(); } else { return getFacebookEndpointUrls().getGraphVideoEndpoint(); } }
private static final Map<String, Version> VERSION_INDEX = new HashMap<>(); static { for (Version version : Version.values()) { VERSION_INDEX.put(version.getUrlElement(), version); } }
protected void fillHeaderAndDebugInfo(HttpURLConnection httpUrlConnection) { currentHeaders = Collections.unmodifiableMap(httpUrlConnection.getHeaderFields()); String usedApiVersion = StringUtils.trimToEmpty(httpUrlConnection.getHeaderField("facebook-api-version")); HTTP_LOGGER.debug("Facebook used the API {} to answer your request", usedApiVersion); String fbTraceId = StringUtils.trimToEmpty(httpUrlConnection.getHeaderField("x-fb-trace-id")); String fbRev = StringUtils.trimToEmpty(httpUrlConnection.getHeaderField("x-fb-rev")); String fbDebug = StringUtils.trimToEmpty(httpUrlConnection.getHeaderField("x-fb-debug")); String fbAppUsage = StringUtils.trimToEmpty(httpUrlConnection.getHeaderField("x-app-usage")); String fbPageUsage = StringUtils.trimToEmpty(httpUrlConnection.getHeaderField("x-page-usage")); Version usedVersion = Version.getVersionFromString(usedApiVersion); debugHeaderInfo = new DebugHeaderInfo(fbDebug, fbRev, fbTraceId, usedVersion, fbAppUsage, fbPageUsage); }