com.fasterxml.jackson.databind.util.JSONPObject Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.util.JSONPObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NakadiMetricsServlet.java From nakadi with MIT License | 6 votes |
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { resp.setContentType(CONTENT_TYPE); if (allowedOrigin != null) { resp.setHeader("Access-Control-Allow-Origin", allowedOrigin); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); final OutputStream output = resp.getOutputStream(); try { if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } finally { output.close(); } }
Example #2
Source File: PartyJsonpResource.java From lemon with Apache License 2.0 | 6 votes |
/** * TODO: replace JSONWithPadding to JSONPObject. * * @param callback String * @param typeId long * @param q String * @return JSONPObject */ @GET @Path("search") @Produces(MediaType.APPLICATION_JSON) public JSONPObject getPartyEntitiesByType( @QueryParam("callback") String callback, @QueryParam("typeId") long typeId, @QueryParam("q") String q) { String hql = "from PartyEntity where partyType.id=? and name like ? order by name"; Page page = partyEntityManager.pagedQuery(hql, 1, DFAULT_PAGE_SIZE, typeId, q.replace("_", "\\_") + "%"); List<PartyEntity> partyEntities = (List<PartyEntity>) page.getResult(); List<PartyEntityDTO> partyEntityDtos = new ArrayList<PartyEntityDTO>(); for (PartyEntity partyEntity : partyEntities) { PartyEntityDTO partyEntityDto = new PartyEntityDTO(); partyEntityDto.setId(partyEntity.getId()); partyEntityDto.setName(partyEntity.getName()); partyEntityDtos.add(partyEntityDto); } return new JSONPObject(callback, partyEntityDtos); }
Example #3
Source File: DefaultRenderService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void toJsonP( OutputStream output, Object value, String callback ) throws IOException { if ( StringUtils.isEmpty( callback ) ) { callback = "callback"; } jsonMapper.writeValue( output, new JSONPObject( callback, value ) ); }
Example #4
Source File: JVMMetricsServlet.java From hermes with Apache License 2.0 | 6 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType(CONTENT_TYPE); if (allowedOrigin != null) { resp.setHeader("Access-Control-Allow-Origin", allowedOrigin); } resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store"); resp.setStatus(HttpServletResponse.SC_OK); final OutputStream output = resp.getOutputStream(); try { if (jsonpParamName != null && req.getParameter(jsonpParamName) != null) { getWriter(req).writeValue(output, new JSONPObject(req.getParameter(jsonpParamName), registry)); } else { getWriter(req).writeValue(output, registry); } } finally { output.close(); } }
Example #5
Source File: JavascriptScopeInterceptor.java From seldon-server with Apache License 2.0 | 5 votes |
@Override protected void exceptionResponse(HttpServletRequest request, HttpServletResponse response, APIException e) throws IOException { ErrorBean bean = new ErrorBean(e); String jsonpCallback = request.getParameter("jsonpCallback"); final ObjectMapper objectMapper = new ObjectMapper(); response.setContentType("application/json"); if (StringUtils.isBlank(jsonpCallback)) { objectMapper.writeValue(response.getOutputStream(), bean); } else { JSONPObject jsonp = new JSONPObject(jsonpCallback, bean); objectMapper.writeValue(response.getOutputStream(), jsonp); } }
Example #6
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 5 votes |
@ExceptionHandler(value = APIException.class) public @ResponseBody JSONPObject handleException(APIException ex, HttpServletRequest request) { String jsonpCallback = request.getParameter("jsonpCallback"); if (StringUtils.isBlank(jsonpCallback)) { jsonpCallback = "jsonpCallback"; } return asCallback(jsonpCallback, new ErrorBean(ex)); }
Example #7
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 5 votes |
@RequestMapping("/predict") public @ResponseBody JSONPObject predict(HttpSession session, HttpServletRequest request, @RequestParam(value = "json", required = false) String json, @RequestParam("jsonpCallback") String callback) { final ConsumerBean consumerBean = retrieveConsumer(session); @SuppressWarnings("unchecked") Map<String,String[]> parameters = request.getParameterMap(); return asCallback(callback, predictionBusinessService.predict(consumerBean, parameters)); }
Example #8
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 5 votes |
@RequestMapping("/event/new") public @ResponseBody JSONPObject registerEvent(HttpSession session, HttpServletRequest request, @RequestParam("jsonpCallback") String callback) { final ConsumerBean consumerBean = retrieveConsumer(session); @SuppressWarnings("unchecked") Map<String,String[]> parameters = request.getParameterMap(); return asCallback(callback, predictionBusinessService.addEvent(consumerBean, parameters)); }
Example #9
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 5 votes |
@RequestMapping("/action/new") public @ResponseBody JSONPObject registerAction(HttpSession session, @RequestParam("user") String userId, @RequestParam("item") String itemId, @RequestParam("type") Integer type, @RequestParam("jsonpCallback") String callback, @RequestParam(value = "source", required = false) String referrer, @RequestParam(value = "rectag", required = false) String recTag, @RequestParam(value = "pos", required = false) Integer pos, @RequestParam(value = "rlabs", required = false) String rlabs, @RequestParam(value = "extra_data", required = false) String extraData, @RequestParam(value = "click_only", required = false) Boolean click_only, @RequestParam(value = "zehtg", required = false) String req) { final ConsumerBean consumerBean = retrieveConsumer(session); MDCKeys.addKeys(consumerBean, userId, itemId,recTag); //added zehtg parameter as additional option for rlabs if(StringUtils.isNotBlank(req)) { rlabs=req; } if (logger.isDebugEnabled()) logger.debug("Creating action for consumer: " + consumerBean.getShort_name()); ActionBean actionBean = createAction(userId, itemId, type, referrer,recTag,extraData); boolean isCTR = StringUtils.isNotBlank(rlabs); boolean clickOnly = (isCTR && (click_only != null) && (click_only == true)) ? true : false; int clickPos = -1; if (pos != null) clickPos = pos.intValue(); return asCallback(callback, actionBusinessService.addAction(consumerBean, actionBean, isCTR, rlabs,recTag,clickPos, clickOnly)); }
Example #10
Source File: IndexController.java From cjs_ssms with GNU General Public License v2.0 | 5 votes |
@RequestMapping(value = "/jsonpInfo", method = {RequestMethod.GET}) @ResponseBody public Object jsonpInfo(String callback, String userId) throws IOException { UUser user = userFService.getUserById(userId); JSONPObject jsonpObject = new JSONPObject(callback, user); return jsonpObject; }
Example #11
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 5 votes |
@RequestMapping("/user/profile") public @ResponseBody JSONPObject userProfile(HttpSession session, @RequestParam("user") String userId, @RequestParam(value = "models", required = false) String models, @RequestParam("jsonpCallback") String callback) { final ConsumerBean consumerBean = retrieveConsumer(session); if (logger.isDebugEnabled()) logger.debug("get user profile: " + userId + " for consumer: " + consumerBean.getShort_name()); ResourceBean responseBean = userProfileService.getProfile(consumerBean, userId, models); return asCallback(callback, responseBean); }
Example #12
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 5 votes |
@RequestMapping("/user/new") public @ResponseBody JSONPObject registerUser(HttpSession session, @RequestParam("user") String userId, @RequestParam(value = "username", required = false) String username, @RequestParam("jsonpCallback") String callback) { username = (username != null) ? username : userId; final ConsumerBean consumerBean = retrieveConsumer(session); UserBean user = new UserBean(userId, username); user.setType(1); logger.debug("Creating user: " + userId + " for consumer: " + consumerBean.getShort_name()); ResourceBean responseBean = userBusinessService.updateUser((ConsumerBean) consumerBean, user, null, false, false); return asCallback(callback, responseBean); }
Example #13
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 4 votes |
@RequestMapping("/recommendations") public @ResponseBody JSONPObject userRecommendations(HttpSession session, @RequestParam(value = "attributes", required = false) String attributes, @RequestParam(value = "item", required = false) String itemId, @RequestParam(value = "rlabs", required = false) String lastRecommendationListUuid, @RequestParam(value = "zehtg", required = false) String lastRecommendationListUuid2, @RequestParam(value = "dimension", defaultValue = "0") Integer dimensionId, @RequestParam(value = "dimensions", required = false) String dimensionIds, @RequestParam(value = "limit", defaultValue = "10") Integer recommendationsLimit, @RequestParam(value = "algorithms", required = false) String algorithms, @RequestParam(value = "source", required = false) String referrer, @RequestParam(value = "rectag", required = false) String recTag, @RequestParam(value = "cohort", required = false, defaultValue = "false") Boolean includeCohort, @RequestParam(value = "sort", required = false) String scoreItems, @RequestParam(value = "rec_locale", required = false) String locale, @RequestParam("user") String userId, @RequestParam("jsonpCallback") String callback) { final ConsumerBean consumerBean = retrieveConsumer(session); MDCKeys.addKeys(consumerBean, userId, itemId,recTag); //added zehtg parameter as additional option for rlabs if(StringUtils.isNotBlank(lastRecommendationListUuid2)) { lastRecommendationListUuid=lastRecommendationListUuid2;} if (logger.isDebugEnabled()) logger.debug("Retrieving recommendations for user " + userId + ", consumer: " + consumerBean.getShort_name() + " with tag " + recTag); Set<Integer> dimensions; if (dimensionIds != null) { String[] parts = dimensionIds.split(","); dimensions = new HashSet<Integer>(parts.length); for(int i=0;i<parts.length;i++) dimensions.add(Integer.parseInt(parts[i])); } else { dimensions = new HashSet<Integer>(1); dimensions.add(dimensionId); } { // Map dimensions if necessary // map dimensions based on user String client_user_id = userId; dimensions = userDimensionMappingModelManager.getMappedDimensionsByUser(consumerBean.getShort_name(), dimensions, client_user_id); if (locale != null) { // map dimensions based on locale dimensions = dimensionsMappingManager.getMappedDimensionsByLocale(consumerBean.getShort_name(), dimensions, locale); } } final ResourceBean recommendations = getRecommendations(consumerBean, userId, itemId, dimensions, lastRecommendationListUuid, recommendationsLimit, attributes,algorithms,referrer,recTag,includeCohort,scoreItems,locale); //tracking recommendations impression StatsdPeer.logImpression(consumerBean.getShort_name(),recTag); CtrFullLogger.log(false, consumerBean.getShort_name(), userId, itemId,recTag); return asCallback(callback, recommendations); }
Example #14
Source File: ItemController.java From seldon-server with Apache License 2.0 | 4 votes |
private JSONPObject asCallback(String callbackName, Object valueObject) { return new JSONPObject(callbackName, valueObject); }
Example #15
Source File: JsonMapper.java From spring-cloud-yes with Apache License 2.0 | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #16
Source File: JsClientController.java From seldon-server with Apache License 2.0 | 4 votes |
private JSONPObject asCallback(String callbackName, Object valueObject) { return new JSONPObject(callbackName, valueObject); }
Example #17
Source File: ActionsController.java From seldon-server with Apache License 2.0 | 4 votes |
private JSONPObject asCallback(String callbackName, Object valueObject) { return new JSONPObject(callbackName, valueObject); }
Example #18
Source File: TokenController.java From seldon-server with Apache License 2.0 | 4 votes |
private JSONPObject asCallback(String callbackName, Object valueObject) { return new JSONPObject(callbackName, valueObject); }
Example #19
Source File: JsonMapper.java From dubai with MIT License | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #20
Source File: JsonMapper.java From lemon with Apache License 2.0 | 4 votes |
public String toJsonP(String functionName, Object object) throws IOException { return toJson(new JSONPObject(functionName, object)); }
Example #21
Source File: JsonMapper.java From onetwo with Apache License 2.0 | 4 votes |
public String toJsonPadding(String function, Object object){ return toJson(new JSONPObject(function, object)); }
Example #22
Source File: JsonMapper.java From frpMgr with MIT License | 4 votes |
/** * 输出JSONP格式数据. */ public String toJsonpString(String functionName, Object object) { return toJsonString(new JSONPObject(functionName, object)); }
Example #23
Source File: JsonMapper.java From vjtools with Apache License 2.0 | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #24
Source File: JsonTools.java From pampas with Apache License 2.0 | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #25
Source File: JsonMapper.java From distributed-transaction-process with MIT License | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #26
Source File: JsonMapper.java From lightconf with GNU General Public License v3.0 | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #27
Source File: JsonMapper.java From mini-platform with MIT License | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonp(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #28
Source File: JsonMapper.java From azeroth with Apache License 2.0 | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #29
Source File: JsonMapper.java From springcloud-idempotent-starter with GNU General Public License v3.0 | 4 votes |
/** * 輸出JSONP格式數據. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }
Example #30
Source File: JsonMapper.java From wish-pay with Apache License 2.0 | 4 votes |
/** * 输出JSONP格式数据. */ public String toJsonP(String functionName, Object object) { return toJson(new JSONPObject(functionName, object)); }