thinkgem / jeesite

Java rapid development platform, based (Spring Boot, Spring MVC, Apache Shiro, MyBatis, Beetl, Bootstrap, AdminLTE), online code generation, including modules: Organization, role users, menu and button authorization, data permissions, system parameters, content management, workflow, etc. Loose coupling design is adopted; one key skin switch; account security Settings, password policies; Online scheduled task configuration; Support cluster, support SAAS; Support for multiple data sources

Home Page:http://jeesite.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

流程保存报错

ouyangzhiming opened this issue · comments

提示错误:Unexpected error: could not save model

点击保存并关闭:400 Bad request
http://localhost:8181/jeesite/act/service/model/ff4cdbb2c3c94dfd819601bab24349d7/save

image
qq 20180717142222

解决办法:

@RequiresPermissions("act:model:edit")
@RequestMapping(value = "/act/service/model/{modelId}/save", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)
public void saveModel(@PathVariable String modelId, HttpServletRequest request) {
//public void saveModel(@PathVariable String modelId, @requestbody MultiValueMap<String, String> values) {
try {

		Map<String, String[]> values = request.getParameterMap();

		Model model = repositoryService.getModel(modelId);

		ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());

		//modelJson.put(MODEL_NAME, values.getFirst("name"));
		modelJson.put(MODEL_NAME, values.get("name")[0]);
		//modelJson.put(MODEL_DESCRIPTION, values.getFirst("description"));
		modelJson.put(MODEL_DESCRIPTION, values.get("description")[0]);
		model.setMetaInfo(modelJson.toString());
		//model.setName(values.getFirst("name"));
		model.setName(values.get("name")[0]);

		repositoryService.saveModel(model);

		//repositoryService.addModelEditorSource(model.getId(), values.getFirst("json_xml").getBytes("utf-8"));
		repositoryService.addModelEditorSource(model.getId(), new String(values.get("json_xml")[0]).getBytes("utf-8"));

		//InputStream svgStream = new ByteArrayInputStream(values.getFirst("svg_xml").getBytes("utf-8"));
		InputStream svgStream = new ByteArrayInputStream(new String(values.get("svg_xml")[0]).getBytes("utf-8"));
		TranscoderInput input = new TranscoderInput(svgStream);

		PNGTranscoder transcoder = new PNGTranscoder();
		// Setup output
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		TranscoderOutput output = new TranscoderOutput(outStream);

		// Do the transformation
		transcoder.transcode(input, output);
		final byte[] result = outStream.toByteArray();
		repositoryService.addModelEditorSourceExtra(model.getId(), result);
		outStream.close();

	} catch (Exception e) {
		LOGGER.error("Error saving model", e);
		throw new ActivitiException("Error saving model", e);
	}
}