Search in sources :

Example 41 with ResponseBody

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);
    }
}
Also used : RestVariable(org.activiti.rest.service.api.engine.variable.RestVariable) ActivitiException(org.activiti.engine.ActivitiException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 42 with ResponseBody

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);
    }
}
Also used : RestVariable(org.activiti.rest.service.api.engine.variable.RestVariable) ActivitiException(org.activiti.engine.ActivitiException) Execution(org.activiti.engine.runtime.Execution) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 43 with ResponseBody

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";
    }
}
Also used : Message(com.aixuexiao.model.Message) Reply(com.aixuexiao.model.Reply) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 44 with ResponseBody

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));
}
Also used : DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) ProcessDiagramGenerator(org.activiti.image.ProcessDiagramGenerator) InputStream(java.io.InputStream) BpmnAutoLayout(org.activiti.bpmn.BpmnAutoLayout) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) DefaultProcessDiagramGenerator(org.activiti.image.impl.DefaultProcessDiagramGenerator) BpmnModel(org.activiti.bpmn.model.BpmnModel) InputStreamResource(org.springframework.core.io.InputStreamResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 45 with ResponseBody

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ResponseBody (org.springframework.web.bind.annotation.ResponseBody)491 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)454 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)84 ApiOperation (io.swagger.annotations.ApiOperation)64 ArrayList (java.util.ArrayList)55 HashMap (java.util.HashMap)50 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)47 ResponseEntity (org.springframework.http.ResponseEntity)39 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)37 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)36 RootNode (org.hisp.dhis.node.types.RootNode)33 IOException (java.io.IOException)22 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)22 CollectionNode (org.hisp.dhis.node.types.CollectionNode)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)19 Date (java.util.Date)18 User (org.hisp.dhis.user.User)17 Range (com.navercorp.pinpoint.web.vo.Range)15 Text (org.orcid.pojo.ajaxForm.Text)15 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)14