Java Code Examples for org.springframework.http.ResponseEntity#getStatusCode()
The following examples show how to use
org.springframework.http.ResponseEntity#getStatusCode() .
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: VaultKvAccessStrategySupport.java From spring-cloud-config with Apache License 2.0 | 6 votes |
/** * @param headers must not be {@literal null}. * @param backend secret backend mount path, must not be {@literal null}. * @param key key within the key-value secret backend, must not be {@literal null}. * @return */ @Override public String getData(HttpHeaders headers, String backend, String key) { try { String urlTemplate = String.format("%s/v1/%s/%s", this.baseUrl, backend, getPath()); ResponseEntity<VaultResponse> response = this.rest.exchange(urlTemplate, HttpMethod.GET, new HttpEntity<>(headers), VaultResponse.class, key); HttpStatus status = response.getStatusCode(); if (status == HttpStatus.OK) { return extractDataFromBody(response.getBody()); } } catch (HttpStatusCodeException e) { if (e.getStatusCode() == HttpStatus.NOT_FOUND) { return null; } throw e; } return null; }
Example 2
Source File: OAuth2TokenEndpointClientAdapter.java From tutorials with MIT License | 6 votes |
/** * Sends a refresh grant to the token endpoint using the current refresh token to obtain new tokens. * * @param refreshTokenValue the refresh token to use to obtain new tokens. * @return the new, refreshed access token. */ @Override public OAuth2AccessToken sendRefreshGrant(String refreshTokenValue) { MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); params.add("grant_type", "refresh_token"); params.add("refresh_token", refreshTokenValue); HttpHeaders headers = new HttpHeaders(); addAuthentication(headers, params); HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(params, headers); log.debug("contacting OAuth2 token endpoint to refresh OAuth2 JWT tokens"); ResponseEntity<OAuth2AccessToken> responseEntity = restTemplate.postForEntity(getTokenEndpoint(), entity, OAuth2AccessToken.class); if (responseEntity.getStatusCode() != HttpStatus.OK) { log.debug("failed to refresh tokens: {}", responseEntity.getStatusCodeValue()); throw new HttpClientErrorException(responseEntity.getStatusCode()); } OAuth2AccessToken accessToken = responseEntity.getBody(); log.info("refreshed OAuth2 JWT cookies using refresh_token grant"); return accessToken; }
Example 3
Source File: AssetImportSMOImpl.java From MicroCommunity with Apache License 2.0 | 6 votes |
/** * 查询存在的房屋信息 * room.queryRooms * * @param pd * @param result * @param fee * @return */ private JSONObject getExistsFee(IPageData pd, ComponentValidateResult result, ImportFee fee) { String apiUrl = ""; ResponseEntity<String> responseEntity = null; apiUrl = ServiceConstant.SERVICE_API_URL + "/api/feeConfig.listFeeConfigs?page=1&row=1&communityId=" + result.getCommunityId() + "&feeName=" + fee.getFeeName(); responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 return null; } JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody()); if (!savedRoomInfoResults.containsKey("feeConfigs") || savedRoomInfoResults.getJSONArray("feeConfigs").size() != 1) { return null; } JSONObject savedFeeConfigInfo = savedRoomInfoResults.getJSONArray("feeConfigs").getJSONObject(0); return savedFeeConfigInfo; }
Example 4
Source File: ThemeServiceImpl.java From halo with GNU General Public License v3.0 | 6 votes |
/** * Downloads zip file and unzip it into specified path. * * @param zipUrl zip url must not be null * @param targetPath target path must not be null * @throws IOException throws when download zip or unzip error */ private void downloadZipAndUnzip(@NonNull String zipUrl, @NonNull Path targetPath) throws IOException { Assert.hasText(zipUrl, "Zip url must not be blank"); log.debug("Downloading [{}]", zipUrl); // Download it ResponseEntity<byte[]> downloadResponse = restTemplate.getForEntity(zipUrl, byte[].class); log.debug("Download response: [{}]", downloadResponse.getStatusCode()); if (downloadResponse.getStatusCode().isError() || downloadResponse.getBody() == null) { throw new ServiceException("下载失败 " + zipUrl + ", 状态码: " + downloadResponse.getStatusCode()); } log.debug("Downloaded [{}]", zipUrl); // Unzip it FileUtils.unzip(downloadResponse.getBody(), targetPath); }
Example 5
Source File: OAuth2TokenEndpointClientAdapter.java From cubeai with Apache License 2.0 | 6 votes |
/** * Sends a password grant to the token endpoint. * * @param username the username to authenticate. * @param password his password. * @return the access token. */ @Override public OAuth2AccessToken sendPasswordGrant(String username, String password) { HttpHeaders reqHeaders = new HttpHeaders(); reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); MultiValueMap<String, String> formParams = new LinkedMultiValueMap<>(); formParams.set("username", username); formParams.set("password", password); formParams.set("grant_type", "password"); addAuthentication(reqHeaders, formParams); HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(formParams, reqHeaders); log.debug("contacting OAuth2 token endpoint to login user: {}", username); ResponseEntity<OAuth2AccessToken> responseEntity = restTemplate.postForEntity(getTokenEndpoint(), entity, OAuth2AccessToken.class); if (responseEntity.getStatusCode() != HttpStatus.OK) { log.debug("failed to authenticate user with OAuth2 token endpoint, status: {}", responseEntity.getStatusCodeValue()); throw new HttpClientErrorException(responseEntity.getStatusCode()); } OAuth2AccessToken accessToken = responseEntity.getBody(); return accessToken; }
Example 6
Source File: FilmCatalogueClientWithHystrix.java From hentai-cloudy-rental with Do What The F*ck You Want To Public License | 6 votes |
@HystrixCommand( fallbackMethod = "getFilmByIdFailure", //all options here: https://github.com/Netflix/Hystrix/wiki/Configuration commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "100") }, threadPoolProperties = { @HystrixProperty(name = "coreSize", value = "5"), // the maximum number of HystrixCommands that can execute concurrently. Default 10 @HystrixProperty(name = "maxQueueSize", value = "101"), //If -1 then SynchronousQueue will be used, otherwise a positive value will be used with LinkedBlockingQueue. @HystrixProperty(name = "metrics.healthSnapshot.intervalInMilliseconds", value = "15") //time to wait, between allowing health snapshots to be taken that calculate success and error percentages and affect circuit breaker status. }) public Optional<Film> getFilmById(final Long filmId) { //this could return Future or ObservableResult, to use it async, not waste resources, and make it explicit that it takes long ResponseEntity<Film> responseEntity = filmCatalogueClient.findOne(filmId); if(responseEntity.getStatusCode() != HttpStatus.OK) { return Optional.empty(); } return Optional.of(responseEntity.getBody()); }
Example 7
Source File: ExceptionTranslator.java From jhipster-online with Apache License 2.0 | 5 votes |
/** * Post-process the Problem payload to add the message key for the front-end if needed. */ @Override public ResponseEntity<Problem> process(@Nullable ResponseEntity<Problem> entity, NativeWebRequest request) { if (entity == null) { return entity; } Problem problem = entity.getBody(); if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) { return entity; } ProblemBuilder builder = Problem.builder() .withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType()) .withStatus(problem.getStatus()) .withTitle(problem.getTitle()) .with(PATH_KEY, request.getNativeRequest(HttpServletRequest.class).getRequestURI()); if (problem instanceof ConstraintViolationProblem) { builder .with(VIOLATIONS_KEY, ((ConstraintViolationProblem) problem).getViolations()) .with(MESSAGE_KEY, ErrorConstants.ERR_VALIDATION); } else { builder .withCause(((DefaultProblem) problem).getCause()) .withDetail(problem.getDetail()) .withInstance(problem.getInstance()); problem.getParameters().forEach(builder::with); if (!problem.getParameters().containsKey(MESSAGE_KEY) && problem.getStatus() != null) { builder.with(MESSAGE_KEY, "error.http." + problem.getStatus().getStatusCode()); } } return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode()); }
Example 8
Source File: ExceptionTranslator.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 5 votes |
/** * Post-process the Problem payload to add the message key for the front-end if needed */ @Override public ResponseEntity<Problem> process(@Nullable ResponseEntity<Problem> entity, NativeWebRequest request) { if (entity == null) { return entity; } Problem problem = entity.getBody(); if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) { return entity; } ProblemBuilder builder = Problem.builder() .withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType()) .withStatus(problem.getStatus()) .withTitle(problem.getTitle()) .with("path", request.getNativeRequest(HttpServletRequest.class).getRequestURI()); if (problem instanceof ConstraintViolationProblem) { builder .with("violations", ((ConstraintViolationProblem) problem).getViolations()) .with("message", ErrorConstants.ERR_VALIDATION); } else { builder .withCause(((DefaultProblem) problem).getCause()) .withDetail(problem.getDetail()) .withInstance(problem.getInstance()); problem.getParameters().forEach(builder::with); if (!problem.getParameters().containsKey("message") && problem.getStatus() != null) { builder.with("message", "error.http." + problem.getStatus().getStatusCode()); } } return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode()); }
Example 9
Source File: UserController.java From api-examples with Apache License 2.0 | 5 votes |
@RequestMapping(method = GET, value = "/products") public ResponseEntity<Product[]> listProducts(@RequestParam("access_token") String accessToken, @RequestParam("page") String page) { ResponseEntity<Product[]> productListResponse = contaAzulService.listProducts(accessToken, page); if (productListResponse.getStatusCode() != HttpStatus.OK) { return new ResponseEntity(productListResponse.getBody().toString(), HttpStatus.INTERNAL_SERVER_ERROR); } return new ResponseEntity<Product[]>(productListResponse.getBody(), HttpStatus.OK); }
Example 10
Source File: FloorServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 编辑小区楼信息 * * @param pd 页面数据封装对象 * @return */ @Override public ResponseEntity<String> editFloor(IPageData pd) { validateEditFloor(pd); //校验员工是否有权限操作 super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_FLOOR); JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); String communityId = paramIn.getString("communityId"); ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); //数据校验是否 商户是否入驻该小区 super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); paramIn.put("userId", pd.getUserId()); paramIn.put("name", paramIn.getString("floorName")); responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/floor.editFloor", HttpMethod.POST); return responseEntity; }
Example 11
Source File: ExceptionTranslator.java From cubeai with Apache License 2.0 | 5 votes |
/** * Post-process Problem payload to add the message key for front-end if needed */ @Override public ResponseEntity<Problem> process(@Nullable ResponseEntity<Problem> entity, NativeWebRequest request) { if (entity == null || entity.getBody() == null) { return entity; } Problem problem = entity.getBody(); if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) { return entity; } ProblemBuilder builder = Problem.builder() .withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType()) .withStatus(problem.getStatus()) .withTitle(problem.getTitle()) .with("path", request.getNativeRequest(HttpServletRequest.class).getRequestURI()); if (problem instanceof ConstraintViolationProblem) { builder .with("violations", ((ConstraintViolationProblem) problem).getViolations()) .with("message", ErrorConstants.ERR_VALIDATION); return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode()); } else { builder .withCause(((DefaultProblem) problem).getCause()) .withDetail(problem.getDetail()) .withInstance(problem.getInstance()); problem.getParameters().forEach(builder::with); if (!problem.getParameters().containsKey("message") && problem.getStatus() != null) { builder.with("message", "error.http." + problem.getStatus().getStatusCode()); } return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode()); } }
Example 12
Source File: CarServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
@Override public ResponseEntity<String> deleteCar(IPageData pd) { validateDeleteCar(pd); //校验员工是否有权限操作 super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_FLOOR); JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); if (paramIn.getString("carId").equals(paramIn.getString("memberId"))) { paramIn.put("carTypeCd", "1001"); } else { paramIn.put("carTypeCd", "1002"); } String communityId = paramIn.getString("communityId"); ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); //数据校验是否 商户是否入驻该小区 super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), ServiceConstant.SERVICE_API_URL + "/api/car.deleteCar", HttpMethod.POST); return responseEntity; }
Example 13
Source File: CheckUserHasPrivilegeListener.java From MicroCommunity with Apache License 2.0 | 5 votes |
@Override public void soService(ServiceDataFlowEvent event) { DataFlowContext dataFlowContext = event.getDataFlowContext(); AppService service = event.getAppService(); JSONObject data = dataFlowContext.getReqJson(); logger.debug("请求信息:{}",JSONObject.toJSONString(dataFlowContext)); Assert.hasKeyAndValue(data,"userId","请求报文中未包含userId节点"); Assert.hasKeyAndValue(data,"pId","请求报文中未包含pId节点"); ResponseEntity<String> responseEntity = null; //根据名称查询用户信息 responseEntity = privilegeBMOImpl.callService(event); if(responseEntity.getStatusCode() != HttpStatus.OK){ dataFlowContext.setResponseEntity(responseEntity); return ; } JSONObject resultInfo = JSONObject.parseObject(responseEntity.getBody().toString()); JSONArray _privileges = resultInfo.getJSONArray("privileges"); if(_privileges.size() == 0 ){ responseEntity = new ResponseEntity<String>("没有权限操作",HttpStatus.UNAUTHORIZED); }else{ responseEntity = new ResponseEntity<String>("成功",HttpStatus.OK); } dataFlowContext.setResponseEntity(responseEntity); }
Example 14
Source File: UnitServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
@Override public ResponseEntity<String> updateUnit(IPageData pd) { //校验入参 validateUpdateUnit(pd); //校验用户是否有权限 super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_UNIT); JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); String communityId = paramIn.getString("communityId"); ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); //数据校验是否 商户是否入驻该小区 super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/unit.updateUnit"; responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); return responseEntity; }
Example 15
Source File: FrontCommunityServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
@Override public ResponseEntity<String> listMyCommunity(IPageData pd) { ResponseEntity<String> responseEntity = null; JSONObject _paramObj = JSONObject.parseObject(pd.getReqData()); //权限校验 checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_ENTER_COMMUNITY); responseEntity = super.getStoreInfo(pd, restTemplate); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); //修改用户信息 /* responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/query.myCommunity.byMember?memberId=" + storeId + "&memberTypeCd=" + MappingCache.getValue(MappingConstant.DOMAIN_STORE_TYPE_2_COMMUNITY_MEMBER_TYPE, storeTypeCd), HttpMethod.GET);*/ Map paramIn = new HashMap(); paramIn.put("memberId", storeId); paramIn.put("memberTypeCd", MappingCache.getValue(MappingConstant.DOMAIN_STORE_TYPE_2_COMMUNITY_MEMBER_TYPE, storeTypeCd)); paramIn.putAll(_paramObj); responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/query.myCommunity.byMember" + mapToUrlParam(paramIn), HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } JSONArray tmpCommunitys = JSONObject.parseObject(responseEntity.getBody().toString()).getJSONArray("communitys"); freshCommunityAttr(tmpCommunitys); responseEntity = new ResponseEntity<String>(tmpCommunitys.toJSONString(), HttpStatus.OK); return responseEntity; }
Example 16
Source File: SaveComplaintSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
@Override protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) throws IOException { //查询用户ID paramIn.put("userId", pd.getUserId()); //查询商户ID Map paramObj = new HashMap(); paramObj.put("communityId", paramIn.getString("communityId")); paramObj.put("auditStatusCd", "1100"); paramObj.put("memberTypeCd", "390001200002"); paramObj.put("page", 1); paramObj.put("row", 1); String url = ServiceConstant.SERVICE_API_URL + "/api/store.listStoresByCommunity" + mapToUrlParam(paramObj); ResponseEntity<String> responseEntity = super.callCenterService(restTemplate, pd, "", url, HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } JSONObject storeObj = JSONObject.parseObject(responseEntity.getBody()); JSONArray stores = storeObj.getJSONArray("stores"); String storeId = stores.getJSONObject(0).getString("storeId"); paramIn.put("storeId", storeId); url = ServiceConstant.SERVICE_API_URL + "/api/complaint.saveComplaint"; responseEntity = super.callCenterService(restTemplate, pd, paramIn.toJSONString(), url, HttpMethod.POST); return responseEntity; }
Example 17
Source File: ExceptionTranslator.java From ehcache3-samples with Apache License 2.0 | 5 votes |
/** * Post-process the Problem payload to add the message key for the front-end if needed */ @Override public ResponseEntity<Problem> process(@Nullable ResponseEntity<Problem> entity, NativeWebRequest request) { if (entity == null) { return entity; } Problem problem = entity.getBody(); if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) { return entity; } ProblemBuilder builder = Problem.builder() .withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType()) .withStatus(problem.getStatus()) .withTitle(problem.getTitle()) .with("path", request.getNativeRequest(HttpServletRequest.class).getRequestURI()); if (problem instanceof ConstraintViolationProblem) { builder .with("violations", ((ConstraintViolationProblem) problem).getViolations()) .with("message", ErrorConstants.ERR_VALIDATION); } else { builder .withCause(((DefaultProblem) problem).getCause()) .withDetail(problem.getDetail()) .withInstance(problem.getInstance()); problem.getParameters().forEach(builder::with); if (!problem.getParameters().containsKey("message") && problem.getStatus() != null) { builder.with("message", "error.http." + problem.getStatus().getStatusCode()); } } return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode()); }
Example 18
Source File: BonusPoller.java From microservice-istio with Apache License 2.0 | 5 votes |
public void pollInternal() { HttpHeaders requestHeaders = new HttpHeaders(); if (lastModified != null) { requestHeaders.set(HttpHeaders.IF_MODIFIED_SINCE, DateUtils.formatDate(lastModified)); } HttpEntity<?> requestEntity = new HttpEntity(requestHeaders); ResponseEntity<OrderFeed> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, OrderFeed.class); if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) { log.trace("data has been modified"); OrderFeed feed = response.getBody(); for (OrderFeedEntry entry : feed.getOrders()) { if ((lastModified == null) || (entry.getUpdated().after(lastModified))) { Bonus bonus = restTemplate .getForEntity(entry.getLink(), Bonus.class).getBody(); log.trace("saving bonus {}", bonus.getId()); bonusService.calculateBonus(bonus); } } if (response.getHeaders().getFirst("Last-Modified") != null) { lastModified = DateUtils.parseDate(response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED)); log.trace("Last-Modified header {}", lastModified); } } else { log.trace("no new data"); } }
Example 19
Source File: OwnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 5 votes |
/** * 查询小区楼 * * @param pd 页面数据封装对象 * @return 返回 ResponseEntity对象包含 http状态 信息 body信息 */ @Override public ResponseEntity<String> listOwnerMember(IPageData pd) { validateListOwnerMember(pd); JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); String communityId = paramIn.getString("communityId"); //校验用户是否有权限 super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_FLOOR); ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); if (responseEntity.getStatusCode() != HttpStatus.OK) { return responseEntity; } Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); //数据校验是否 商户是否入驻该小区 super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/owner.queryOwnerMembers" + mapToUrlParam(paramIn); responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); return responseEntity; }
Example 20
Source File: AssetExportSMOImpl.java From MicroCommunity with Apache License 2.0 | 4 votes |
/** * 查询存在的房屋信息 * room.queryRooms * * @param pd * @param result * @return */ private JSONArray getExistsRoom(IPageData pd, ComponentValidateResult result) { String apiUrl = ""; ResponseEntity<String> responseEntity = null; apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.queryRooms?page=1&row=10000&communityId=" + result.getCommunityId(); responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 return null; } JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody()); if (!savedRoomInfoResults.containsKey("rooms") ) { return null; } return savedRoomInfoResults.getJSONArray("rooms"); }