public UserInfo getUserInfo(String username, String appId, String repoCode) { Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("username", username); parameterMap.put("appId", appId); parameterMap.put("repoCode", repoCode); try { String content = httpHandler.readText(url, parameterMap); logger.info(content); JsonMapper jsonMapper = new JsonMapper(); Map map = jsonMapper.fromJson(content, Map.class); logger.debug("{}", map); long userId = ((Number) map.get("userId")).longValue(); List<String> authorities = (List<String>) map.get("authorities"); List<String> attributes = (List<String>) map.get("attributes"); UserInfoImpl userInfo = new UserInfoImpl(); userInfo.setUsername(username); userInfo.setPassword((String) map.get("password")); userInfo.setAuthorities(authorities); userInfo.setAttributes(attributes); userInfo.getExtra().put("userId", userId); userInfo.getExtra().put("appId", appId); return userInfo; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new UsernameNotFoundException(username, ex); } }
public Map<String, String> getSource(String type) { Map<String, Object> parameterMap = new HashMap<String, Object>(); if (appId != null) { parameterMap.put("appId", appId); } try { String content = httpHandler.readText(url, parameterMap); logger.info(content); JsonMapper jsonMapper = new JsonMapper(); List<Map> list = jsonMapper.fromJson(content, List.class); Map<String, String> resourceMap = new LinkedHashMap<String, String>(); for (Map map : list) { String access = (String) map.get("access"); String permission = (String) map.get("permission"); if (resourceMap.containsKey(access)) { String value = resourceMap.get(access); resourceMap.put(access, value + "," + permission); } else { resourceMap.put(access, permission); } } return resourceMap; } catch (Exception ex) { logger.error("", ex); throw new RuntimeException(ex); } }
public void handleMessage(String message) { try { ScopeDTO scopeDto = jsonMapper.fromJson(message, ScopeDTO.class); if (scopeDto.getName() == null) { scopeCache.removeScope(scopeDto); logger.info("remove scopeDto : {}", message); } else { scopeCache.updateScope(scopeDto); logger.info("update scopeDto : {}", message); } } catch (IOException ex) { logger.error(ex.getMessage(), ex); } }
public void handleMessage(String message) { try { UserDTO userDto = jsonMapper.fromJson(message, UserDTO.class); Long typeId = 1L; Long entityId = this.getPartyEntityId(userDto.getId(), typeId); if (entityId == null) { return; } Long structTypeId = 1L; jdbcTemplate.update(removePartyStructSql, structTypeId, entityId, entityId); jdbcTemplate.update(removePartyEntitySql, entityId); logger.info("update user : {}", message); } catch (IOException ex) { logger.error(ex.getMessage(), ex); } }
@POST @Path("completeTask") @Produces(MediaType.APPLICATION_JSON) public BaseDTO completeTask( @HeaderParam("sessionId") String sessionId, @FormParam("taskId") String taskId, @FormParam("data") String data) throws Exception { logger.info("start : {} {}", taskId, data); String humanTaskId = taskId; PimDevice pimDevice = pimDeviceManager.findUniqueBy("sessionId", sessionId); if (pimDevice == null) { BaseDTO result = new BaseDTO(); result.setCode(401); result.setMessage("auth fail"); return result; } String userId = pimDevice.getUserId(); String tenantId = "1"; Map<String, Object> map = jsonMapper.fromJson(data, Map.class); map.put("taskId", humanTaskId); Record record = null; FormParameter formParameter = null; HumanTaskDTO humanTaskDto = null; FormDTO formDto = null; formParameter = doSaveRecord(map, userId, tenantId); humanTaskId = formParameter.getHumanTaskId(); operationService.saveDraft(userId, tenantId, formParameter); formDto = humanTaskConnector.findTaskForm(humanTaskId); humanTaskDto = humanTaskConnector.findHumanTask(humanTaskId); String processInstanceId = humanTaskDto.getProcessInstanceId(); record = keyValueConnector.findByRef(processInstanceId); record = new RecordBuilder().build(record, formParameter.getMultiValueMap(), tenantId); keyValueConnector.save(record); Xform xform = new XformBuilder() .setStoreConnector(storeConnector) .setContent(formDto.getContent()) .setRecord(record) .build(); Map<String, Object> taskParameters = xform.getMapData(); logger.info("taskParameters : {}", taskParameters); String comment = ""; String action = ""; try { humanTaskConnector.completeTask(humanTaskId, userId, action, comment, taskParameters); } catch (IllegalStateException ex) { logger.error(ex.getMessage(), ex); return null; } if (record == null) { record = new Record(); } record = new RecordBuilder().build(record, STATUS_RUNNING, humanTaskDto.getProcessInstanceId()); keyValueConnector.save(record); BaseDTO result = new BaseDTO(); result.setCode(200); result.setData(data); logger.info("end"); return result; }