protected Map callContextApi(Map context, String command, String[] publicIds, Map options) throws IOException { return callContextApi(Util.encodeContext(context), command, publicIds, options); }
protected Map callContextApi(Map context, String command, String[] publicIds, Map options) throws IOException { return callContextApi(Util.encodeContext(context), command, publicIds, options); }
@SuppressWarnings("unchecked") public static final void processWriteParameters(Map<String, Object> options, Map<String, Object> params) { if (options.get("headers") != null) params.put("headers", buildCustomHeaders(options.get("headers"))); if (options.get("tags") != null) params.put("tags", StringUtils.join(ObjectUtils.asArray(options.get("tags")), ",")); if (options.get("face_coordinates") != null) params.put("face_coordinates", Coordinates.parseCoordinates(options.get("face_coordinates")).toString()); if (options.get("custom_coordinates") != null) params.put("custom_coordinates", Coordinates.parseCoordinates(options.get("custom_coordinates")).toString()); if (options.get("context") != null) params.put("context", encodeContext(options.get("context"))); if (options.get("access_control") != null) { params.put("access_control", encodeAccessControl(options.get("access_control"))); } putObject("ocr", options, params); putObject("raw_convert", options, params); putObject("categorization", options, params); putObject("detection", options, params); putObject("similarity_search", options, params); putObject("background_removal", options, params); if (options.get("auto_tagging") != null) params.put("auto_tagging", ObjectUtils.asFloat(options.get("auto_tagging"))); }
@SuppressWarnings("unchecked") public static final void processWriteParameters(Map<String, Object> options, Map<String, Object> params) { if (options.get("headers") != null) params.put("headers", buildCustomHeaders(options.get("headers"))); if (options.get("tags") != null) params.put("tags", StringUtils.join(ObjectUtils.asArray(options.get("tags")), ",")); if (options.get("face_coordinates") != null) params.put("face_coordinates", Coordinates.parseCoordinates(options.get("face_coordinates")).toString()); if (options.get("custom_coordinates") != null) params.put("custom_coordinates", Coordinates.parseCoordinates(options.get("custom_coordinates")).toString()); if (options.get("context") != null) params.put("context", encodeContext(options.get("context"))); if (options.get("access_control") != null) { params.put("access_control", encodeAccessControl(options.get("access_control"))); } putObject("ocr", options, params); putObject("raw_convert", options, params); putObject("categorization", options, params); putObject("detection", options, params); putObject("similarity_search", options, params); putObject("background_removal", options, params); if (options.get("auto_tagging") != null) params.put("auto_tagging", ObjectUtils.asFloat(options.get("auto_tagging"))); }
@Test public void encodeContext() throws Exception { Map context = ObjectUtils.asMap("caption", "different = caption", "alt2", "alt|alternative"); String result = Util.encodeContext(context); assertTrue("caption=different \\= caption|alt2=alt\\|alternative".equals(result) || "alt2=alt\\|alternative|caption=different \\= caption".equals(result)); }