use of org.springframework.web.bind.annotation.ResponseBody in project Activiti by Activiti.
the class HistoricProcessInstanceVariableDataResource method getVariableData.
@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/variables/{variableName}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("processInstanceId") String processInstanceId, @PathVariable("variableName") String variableName, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
RestVariable variable = getVariableFromRequest(true, processInstanceId, variableName, request);
if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
result = (byte[]) variable.getValue();
response.setContentType("application/octet-stream");
} else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
outputStream.writeObject(variable.getValue());
outputStream.close();
result = buffer.toByteArray();
response.setContentType("application/x-java-serialized-object");
} else {
throw new ActivitiObjectNotFoundException("The variable does not have a binary data stream.", null);
}
return result;
} catch (IOException ioe) {
// Re-throw IOException
throw new ActivitiException("Unexpected exception getting variable data", ioe);
}
}
use of org.springframework.web.bind.annotation.ResponseBody in project Activiti by Activiti.
the class ExecutionVariableDataResource method getVariableData.
@RequestMapping(value = "/runtime/executions/{executionId}/variables/{variableName}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("executionId") String executionId, @PathVariable("variableName") String variableName, @RequestParam(value = "scope", required = false) String scope, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
Execution execution = getExecutionFromRequest(executionId);
RestVariable variable = getVariableFromRequest(execution, variableName, scope, true);
if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
result = (byte[]) variable.getValue();
response.setContentType("application/octet-stream");
} else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
outputStream.writeObject(variable.getValue());
outputStream.close();
result = buffer.toByteArray();
response.setContentType("application/x-java-serialized-object");
} else {
throw new ActivitiObjectNotFoundException("The variable does not have a binary data stream.", null);
}
return result;
} catch (IOException ioe) {
throw new ActivitiException("Error getting variable " + variableName, ioe);
}
}
use of org.springframework.web.bind.annotation.ResponseBody in project aixuexiao by zhiyuncloud.
the class WeixinController method replyMessage.
//接收微信公众号接收的消息,处理后再做相应的回复
@RequestMapping(value = "/weixin", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
@ResponseBody
public String replyMessage(HttpServletRequest request) {
//仅处理微信服务端发的请求
if (checkWeixinReques(request)) {
Map<String, String> requestMap = WeixinUtil.parseXml(request);
Message message = WeixinUtil.mapToMessage(requestMap);
//保存接受消息到数据库
weixinService.addMessage(message);
String replyContent = Reply.WELCOME_CONTENT;
String type = message.getMsgType();
if (type.equals(Message.TEXT)) {
//仅处理文本回复内容
//消息内容
String content = message.getContent();
//消息内容都以下划线_分隔
String[] cs = content.split("_");
if (cs.length == 2) {
//学生编号
int studentid;
//操作
String process = cs[1];
try {
studentid = Integer.parseInt(cs[0]);
if ("考试".equals(process)) {
replyContent = weixinService.getSingleExamMarkStringByStudentId(studentid);
} else if ("考试历史".equals(process)) {
replyContent = weixinService.getExamMarkHistoryStringByStudentId(studentid);
} else if ("留言".equals(process)) {
replyContent = weixinService.getSingleStudentMessageByStudentId(studentid);
} else if ("留言历史".equals(process)) {
replyContent = weixinService.getStudentMessageHistoryByStudentId(studentid);
} else if ("动态".equals(process)) {
replyContent = weixinService.getSingleClassesNewsByStudentId(studentid);
} else if ("动态历史".equals(process)) {
replyContent = weixinService.getClassesNewsHistoryByStudentId(studentid);
}
} catch (NumberFormatException e) {
replyContent = Reply.ERROR_CONTENT;
}
}
}
//拼装回复消息
Reply reply = new Reply();
reply.setToUserName(message.getFromUserName());
reply.setFromUserName(message.getToUserName());
reply.setCreateTime(new Date());
reply.setMsgType(Reply.TEXT);
reply.setContent(replyContent);
//保存回复消息到数据库
weixinService.addReply(reply);
//将回复消息序列化为xml形式
String back = WeixinUtil.replyToXml(reply);
System.out.println(back);
return back;
} else {
return "error";
}
}
use of org.springframework.web.bind.annotation.ResponseBody in project Activiti by Activiti.
the class ProcessEngineMvcEndpoint method processDefinitionDiagram.
/**
* Look up the process definition by key. For example,
* this is <A href="http://localhost:8080/activiti/processes/fulfillmentProcess">process-diagram for</A>
* a process definition named {@code fulfillmentProcess}.
*/
@RequestMapping(value = "/processes/{processDefinitionKey:.*}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public ResponseEntity processDefinitionDiagram(@PathVariable String processDefinitionKey) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).latestVersion().singleResult();
if (processDefinition == null) {
return ResponseEntity.status(NOT_FOUND).body(null);
}
ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
if (bpmnModel.getLocationMap().size() == 0) {
BpmnAutoLayout autoLayout = new BpmnAutoLayout(bpmnModel);
autoLayout.execute();
}
InputStream is = processDiagramGenerator.generateJpgDiagram(bpmnModel);
return ResponseEntity.ok(new InputStreamResource(is));
}
use of org.springframework.web.bind.annotation.ResponseBody in project ORCID-Source by ORCID.
the class AdminController method resendClaimEmail.
@RequestMapping(value = "/resend-claim.json", method = RequestMethod.POST)
@ResponseBody
public Map<String, List<String>> resendClaimEmail(@RequestBody String emailsOrOrcids) {
List<String> emailOrOrcidList = new ArrayList<String>();
if (StringUtils.isNotBlank(emailsOrOrcids)) {
StringTokenizer tokenizer = new StringTokenizer(emailsOrOrcids, INP_STRING_SEPARATOR);
while (tokenizer.hasMoreTokens()) {
emailOrOrcidList.add(tokenizer.nextToken());
}
}
List<String> claimedIds = new ArrayList<String>();
List<String> successIds = new ArrayList<String>();
List<String> notFoundIds = new ArrayList<String>();
for (String emailOrOrcid : emailOrOrcidList) {
String orcidId = getOrcidFromParam(emailOrOrcid);
if (orcidId == null) {
notFoundIds.add(emailOrOrcid);
} else {
if (!profileEntityManager.orcidExists(orcidId)) {
notFoundIds.add(orcidId);
} else {
ProfileEntity entity = profileEntityCacheManager.retrieve(orcidId);
if (entity.getClaimed()) {
claimedIds.add(emailOrOrcid);
} else {
notificationManager.sendApiRecordCreationEmail(emailOrOrcid, orcidId);
successIds.add(emailOrOrcid);
}
}
}
}
Map<String, List<String>> resendIdMap = new HashMap<String, List<String>>();
resendIdMap.put("notFoundList", notFoundIds);
resendIdMap.put("claimResendSuccessfulList", successIds);
resendIdMap.put("alreadyClaimedList", claimedIds);
return resendIdMap;
}
Aggregations