Java 类org.springframework.web.bind.annotation.ResponseStatus 实例源码

项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:klask-io    文件:ExceptionTranslator.java   
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorDTO> processRuntimeException(Exception ex) throws Exception {
    BodyBuilder builder;
    ErrorDTO errorDTO;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        builder = ResponseEntity.status(responseStatus.value());
        errorDTO = new ErrorDTO("error." + responseStatus.value().value(), responseStatus.reason());
    } else {
        builder = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR);
        errorDTO = new ErrorDTO(ErrorConstants.ERR_INTERNAL_SERVER_ERROR, "Internal server error");
    }
    log.error("Exception in rest call", ex);
    errorDTO.add("error", "error", ex.getMessage());
    return builder.body(errorDTO);
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:plumdo-work    文件:FormModelCollectionResource.java   
@ApiOperation(value = "分页查询表单模型", notes = "根据传进来的查询参数,获取表单模型信息")
@ApiImplicitParams({ 
    @ApiImplicitParam(name = "id", value = "主键ID", required = false, dataType = "int", paramType = "query"), 
    @ApiImplicitParam(name = "category", value = "模型分类,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "key", value = "模型键,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "name", value = "模型名称,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "tenantId", value = "租户ID,模糊匹配", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "pageNum", value = "分页查询开始查询的页码", defaultValue = "1", required = false, dataType = "int", paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页查询每页显示的记录数", defaultValue = "10", required = false, dataType = "int", paramType = "query"), 
    @ApiImplicitParam(name = "sortName", value = "排序的字段,可以多值以逗号分割", required = false, dataType = "string", paramType = "query"), 
    @ApiImplicitParam(name = "sortOrder", value = "排序的方式,可以为asc或desc,可以多值以逗号分割", required = false, dataType = "string", paramType = "query") 
})
@RequestMapping(value = "/form-models", method = RequestMethod.GET, produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public PageResponse<FormModelResponse> getFormModels(@ApiIgnore @RequestParam Map<String, String> requestParams) {
    Criteria<FormModel> criteria = new Criteria<FormModel>();
    criteria.add(Restrictions.eq("id", requestParams.get("id"), true));
    criteria.add(Restrictions.like("category", requestParams.get("category"), true));
    criteria.add(Restrictions.like("key", requestParams.get("key"), true));
    criteria.add(Restrictions.like("name", requestParams.get("name"), true));
    criteria.add(Restrictions.like("tenantId", requestParams.get("tenantId"), true));
    return responseFactory.createFormModelPageResponse(formModelRepository.findAll(criteria, getPageable(requestParams)));
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:tokamak    文件:RolesEndpoint.java   
@Authorize(scopes = "roles:create")
@ResponseStatus(value = HttpStatus.CREATED)
@RequestMapping(value = "/v1/roles", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
public RoleRepresentation create(@RequestBody RoleRepresentation representation) {
    Role role = roleConversionService.convert(representation);
    Role created = roleService.create(role).orThrow();
    return roleConversionService.convert(roleService.findById(created.getId()).orThrow());
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    sb.append(", root cause: ").append((throwable != null && throwable.getCause() != null ? throwable.getCause() : "Unknown cause"));
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Blockchain-Academic-Verification-Service    文件:UnilogResource.java   
@PostMapping(value = "/complete/registration", headers = "Accept=application/json", params = "action=Submit")
@ResponseStatus(value = HttpStatus.ACCEPTED)
public String completeRegistration(@ModelAttribute final RegistrationRequest request, final Map<String, Object> model)
        throws UserExistsException, IOException, InterruptedException {
    LOGGER.info("Completing registration for transcript owner");
    if (userService.isRegistered(request.getRecipientEmailAddress())) {
        model.put("alreadyRegistered", true);
    } else if (userService.completeRegistration(request)) {
        LOGGER.info("Adding qualifications");
        model.put("success", true);
        RegistrationRequest registrationRequest = new RegistrationRequest();
        model.put("registrationRequest", registrationRequest);
    } else {
        model.put("error", true);
    }
    return "registration";
}
项目:iotplatform    文件:AuthController.java   
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/auth/changePassword", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void changePassword (
        @RequestParam(value = "currentPassword") String currentPassword,
        @RequestParam(value = "newPassword") String newPassword) throws IoTPException {
    try {
        SecurityUser securityUser = getCurrentUser();
        UserCredentials userCredentials = userService.findUserCredentialsByUserId(securityUser.getId());
        if (!passwordEncoder.matches(currentPassword, userCredentials.getPassword())) {
            throw new IoTPException("Current password doesn't match!", IoTPErrorCode.BAD_REQUEST_PARAMS);
        }
        userCredentials.setPassword(passwordEncoder.encode(newPassword));
        userService.saveUserCredentials(userCredentials);
    } catch (Exception e) {
        throw handleException(e);
    }
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:plumdo-work    文件:ProcessDefinitionActivateResource.java   
@RequestMapping(value = "/process-definition/{processDefinitionId}/activate", method = RequestMethod.PUT, produces = "application/json", name = "流程定义激活")
@ResponseStatus(value = HttpStatus.OK)
public void activateProcessDefinition(@PathVariable String processDefinitionId,@RequestBody(required=false) ProcessDefinitionActionRequest actionRequest) {

    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);

    if (!processDefinition.isSuspended()) {
        throw new FlowableConflictException("Process definition with id '" + processDefinition.getId() + " ' is already active");
    }

    if (actionRequest == null) {
        repositoryService.activateProcessDefinitionById(processDefinitionId);
    }else{
        repositoryService.activateProcessDefinitionById(processDefinition.getId(), actionRequest.isIncludeProcessInstances(),actionRequest.getDate());
    }
}
项目:iotplatform    文件:PluginController.java   
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/plugin/{pluginId}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.OK)
public void deletePlugin(@PathVariable("pluginId") String strPluginId) throws IoTPException {
    checkParameter("pluginId", strPluginId);
    try {
        PluginId pluginId = new PluginId(toUUID(strPluginId));
        PluginMetaData plugin = checkPlugin(pluginService.findPluginById(pluginId));
        pluginService.deletePluginById(pluginId);
        //actorService.onPluginStateChange(plugin.getTenantId(), plugin.getId(), ComponentLifecycleEvent.DELETED);
        JsonObject json = new JsonObject();
        json.addProperty(ThingsMetaKafkaTopics.TENANT_ID, plugin.getTenantId().toString());
        json.addProperty(ThingsMetaKafkaTopics.PLUGIN_ID, plugin.getId().toString());
        json.addProperty(ThingsMetaKafkaTopics.EVENT, ComponentLifecycleEvent.DELETED.name());
        msgProducer.send(ThingsMetaKafkaTopics.METADATA_PLUGIN_TOPIC, plugin.getId().toString(), json.toString());
    } catch (Exception e) {
        throw handleException(e);
    }
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    sb.append(", root cause: ").append((throwable != null && throwable.getCause() != null ? throwable.getCause() : "Unknown cause"));
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:iotplatform    文件:EntityRelationController.java   
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/relation", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void saveRelation(@RequestBody EntityRelation relation) throws IoTPException {
  try {
    checkNotNull(relation);
    checkEntityId(relation.getFrom());
    checkEntityId(relation.getTo());
    if (relation.getTypeGroup() == null) {
      relation.setTypeGroup(RelationTypeGroup.COMMON);
    }
    relationService.saveRelation(relation).get();
  } catch (Exception e) {
    throw handleException(e);
  }
}
项目:loc-framework    文件:LocAdviceErrorAutoConfiguration.java   
@ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
//对于接口方法不匹配的异常处理
public BasicResult handleHttpRequestMethodNotSupportedException(
    HttpRequestMethodNotSupportedException e) {
  logError("httpRequestMethodNotSupportedException", e.getMessage(), e);
  return BasicResult
      .fail(BasicResultCode.METHOD_NOT_ALLOW_ERROR.getCode(),
          BasicResultCode.METHOD_NOT_ALLOW_ERROR.getMsg(),
          e.getMessage());
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:spring-boot-aop    文件:ExceptionHandlers.java   
@ExceptionHandler(ServletRequestBindingException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorResponse handle(final ServletRequestBindingException ex) {
    log.error("Missing parameter", ex);
    return new ErrorResponse("MISSING_PARAMETER", ex.getMessage());
}
项目:plumdo-work    文件:TaskReturnResource.java   
@RequestMapping(value="/task/{taskId}/return", method = RequestMethod.PUT, name="任务回退")
@ResponseStatus(value = HttpStatus.OK)
@Transactional(propagation = Propagation.REQUIRED)
public List<TaskResponse> returnTask(@PathVariable("taskId") String taskId,@RequestBody(required=false) TaskActionRequest actionRequest) {
    List<TaskResponse> responses = new ArrayList<TaskResponse>();

    Task task = getTaskFromRequest(taskId);

    if(task.getAssignee()==null){
        taskService.setAssignee(taskId, Authentication.getAuthenticatedUserId());
    }

   /* List<Task> tasks = taskExtService.returnTask(task.getId());
    for(Task nextTask : tasks){
        TaskExt taskExt = taskExtService.getTaskExtById(nextTask.getId());
        responses.add(restResponseFactory.createTaskResponse(taskExt));
    }*/
    return responses;
}
项目:iotplatform    文件:UserController.java   
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/user/sendActivationMail", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void sendActivationEmail(
        @RequestParam(value = "email") String email,
        HttpServletRequest request) throws IoTPException {
    try {
        User user = checkNotNull(userService.findUserByEmail(email));
        UserCredentials userCredentials = userService.findUserCredentialsByUserId(user.getId());
        if (!userCredentials.isEnabled()) {
            String baseUrl = constructBaseUrl(request);
            String activateUrl = String.format("%s/api/noauth/activate?activateToken=%s", baseUrl,
                    userCredentials.getActivateToken());
            mailService.sendActivationEmail(activateUrl, email);
        } else {
            throw new IoTPException("User is already active!", IoTPErrorCode.BAD_REQUEST_PARAMS);
        }
    } catch (Exception e) {
        throw handleException(e);
    }
}
项目:spring-cloud-dashboard    文件:AppRegistryController.java   
/**
 * Retrieve detailed information about a particular application.
 * @param type application type
 * @param name application name
 * @return detailed application information
 */
@RequestMapping(value = "/{type}/{name}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public DetailedAppRegistrationResource info(
        @PathVariable("type") String type,
        @PathVariable("name") String name) {
    AppRegistration registration = appRegistry.find(name, type);
    if (registration == null) {
        throw new NoSuchAppRegistrationException(name, type);
    }
    DetailedAppRegistrationResource result = new DetailedAppRegistrationResource(assembler.toResource(registration));
    Resource resource = registration.getResource();

    List<ConfigurationMetadataProperty> properties = metadataResolver.listProperties(resource);
    for (ConfigurationMetadataProperty property : properties) {
        result.addOption(property);
    }
    return result;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:spring-boot-aop    文件:ExceptionHandlers.java   
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Throwable.class)
@ResponseBody
public ErrorResponse handle(final Throwable ex) {
    log.error("Unexpected error", ex);
    return new ErrorResponse("INTERNAL_SERVER_ERROR", "An unexpected internal server error occured");
}
项目:Spring-Security-Third-Edition    文件:ErrorController.java   
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
项目:plumdo-work    文件:GlobalExceptionHandler.java   
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ObjectNotFoundException.class)
@ResponseBody
public ErrorInfo handleNotFound(ObjectNotFoundException e) {
    LOGGER.error("not found object", e);
    return new ErrorInfo("not found object", e);
}
项目:product-management-system    文件:ProductController.java   
/**
 * Delete {@link Product} from database by identifier.
 */
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteProduct(@PathVariable final String id) {
    log.info("Start deleteProduct: {}", id);
    productService.delete(id);
}
项目:OperatieBRP    文件:LeveringsautorisatieController.java   
/**
 * Slaat een gewijzigd item op.
 * @param leveringsautorisatieId Id van de leveringsautorisatie
 * @param dienstbundelGroepId groep ID
 * @param item item
 * @return item
 * @throws NotFoundException wanneer het item niet gevonden kan worden om te updaten
 */
@RequestMapping(value = "/{id2}/dienstbundels/{did8}/dienstbundelgroepen/{gid2}/attributen", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public final Page<DienstbundelGroepAttribuutView> saveDienstbundelGroepAttribuut(
        @PathVariable("id2") final Integer leveringsautorisatieId,
        @PathVariable("gid2") final Integer dienstbundelGroepId,
        @RequestBody final DienstbundelGroepAttribuutView item) throws NotFoundException {
    return new SaveTransaction<Page<DienstbundelGroepAttribuutView>>(getTransactionTemplate()).execute(() -> {
        final Leveringsautorisatie leveringsautorisatie = get(leveringsautorisatieId);
        if (!Stelsel.BRP.equals(leveringsautorisatie.getStelsel())) {
            throw new IllegalArgumentException("Groepen kunnen niet worden toegevoegd op een GBA autorisatie.");
        }

        final DienstbundelGroep dienstbundelGroep = dienstbundelGroepController.get(dienstbundelGroepId);

        if (item.getId() != null && !item.isActief()) {
            // Verwijderen attribuut uit dienstbundelgroep.
            dienstbundelGroep.getDienstbundelGroepAttribuutSet().removeIf(attribuut -> attribuut.getId().equals(item.getId()));
        } else if (item.isActief()) {
            // Toevoegen attribuut aan dienstbundelgroep.
            dienstbundelGroep.getDienstbundelGroepAttribuutSet().add(new DienstbundelGroepAttribuut(dienstbundelGroep, item.getAttribuut()));
        }

        dienstbundelGroepController.save(dienstbundelGroep);
        return new PageImpl<>(bepaalActiefStatusAttributenVoorGroep(dienstbundelGroep));
    });
}
项目:loc-framework    文件:LocAdviceErrorAutoConfiguration.java   
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class)
//验证requestbody失败异常的处理
public BasicResult handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
  logError("methodArgumentNotValidException", e.getMessage(), e);
  return BasicResult.fail(BasicResultCode.METHOD_ARGUMENT_MISS_ERROR.getCode(),
      BasicResultCode.METHOD_ARGUMENT_MISS_ERROR.getMsg(),
      MethodArgumentNotValidExceptionHelper.firstErrorMessage(e.getBindingResult()));
}
项目:plumdo-stock    文件:StockReportResource.java   
@GetMapping("/stock-reports/stock-details")
@ResponseStatus(HttpStatus.OK)
public PageResponse<StockDetail> getStockDetails(@RequestParam Map<String, String> allRequestParams) {
    Criteria<StockDetail> criteria = new Criteria<StockDetail>();
    criteria.add(Restrictions.like("stockCode", allRequestParams.get("stockCode"), true));
    criteria.add(Restrictions.like("stockName", allRequestParams.get("stockName"), true));
    criteria.add(Restrictions.gte("stockDate", ObjectUtils.convertToDate(allRequestParams.get("stockDateBegin")), true));
    criteria.add(Restrictions.lte("stockDate", ObjectUtils.convertToDate(allRequestParams.get("stockDateEnd")), true));
    return createPageResponse(stockDetailRepository.findAll(criteria, getPageable(allRequestParams)));
}
项目:corporate-game-share    文件:LibraryController.java   
@ResponseStatus(value = HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST, value = "/{userId}/games")
@ApiOperation(value = "Add a game to your library",
              notes = "Example Minimum Payload: {\"attributes\": {\"game\": {\"id\": \"123\"}}}")
public void addGameToLibrary(Authentication user, @PathVariable Long userId, @RequestBody LibraryGameData data) {
    libraryService.addGameToLibrary(user, userId, data);
}
项目:spring-cloud-skipper    文件:AboutController.java   
/**
 * Return meta information about the Skipper server.
 *
 * @return Detailed information about the enabled features, versions of implementation
 * libraries, and security configuration
 */
@RequestMapping(method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public AboutResource getAboutResource() {
    final AboutResource aboutResource = new AboutResource();
    final VersionInfo versionInfo = getVersionInfo();
    aboutResource.setVersionInfo(versionInfo);
    return aboutResource;
}
项目:iotplatform    文件:AssetController.java   
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/asset/{assetId}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.OK)
public void deleteAsset(@PathVariable("assetId") String strAssetId) throws IoTPException {
  checkParameter("assetId", strAssetId);
  try {
    AssetId assetId = new AssetId(toUUID(strAssetId));
    checkAssetId(assetId);
    assetService.deleteAsset(assetId);
  } catch (Exception e) {
    throw handleException(e);
  }
}
项目:spring-boot-jwt-jpa    文件:GlobalHandler.java   
/**
 * 400 - Bad Request
 */
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity handleServiceException(ConstraintViolationException e) {
    LOGGER.error("参数验证失败", e);
    Set<ConstraintViolation<?>> violations = e.getConstraintViolations();
    ConstraintViolation<?> violation = violations.iterator().next();
    String message = violation.getMessage();
    return ResponseEntity.badRequest().body("parameter:" + message);
}
项目:plumdo-work    文件:FormDefinitionJsonResource.java   
@ApiOperation(value = "获取表单定义设计内容", notes = "根据表单定义的id来获取表单定义设计内容")
@ApiImplicitParam(name = "id", value = "表单定义ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-definitions/{id}/json", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public String getEditorJson(@PathVariable Long id) throws UnsupportedEncodingException {
    FormDefinition formDefinition = getFormDefinitionFromRequest(id);
    String editorJson = null;
    if (formDefinition.getEditorSourceBytes() == null) {
        editorJson = objectMapper.createArrayNode().toString();
    } else {
        editorJson = new String(formDefinition.getEditorSourceBytes(), "utf-8");
    }
    return editorJson;
}
项目:java-spring-web    文件:TestController.java   
@ResponseStatus(value = HttpStatus.CONFLICT, reason = "Data integrity violation")
@ExceptionHandler(MappedException.class)
public void mappedExceptionHandler(MappedException ex) {
    verifyActiveSpan();

    // Nothing to do
}