org.springframework.web.bind.annotation.ResponseStatus Java Examples

The following examples show how to use org.springframework.web.bind.annotation.ResponseStatus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * PUT  /rest/users/:login/change_password -> changes the user's password
 */
@RequestMapping(value = "/rest/users/{login}/change-password", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)
public void changePassword(@PathVariable String login, @RequestBody ObjectNode actionBody) {
    if (actionBody.get("oldPassword") == null || actionBody.get("oldPassword").isNull()) {
        throw new BadRequestException("oldPassword should not be empty");

    } else if (actionBody.get("newPassword") == null || actionBody.get("newPassword").isNull()) {
        throw new BadRequestException("newPassword should not be empty");

    } else {
    	try {
    		userService.changePassword(login, actionBody.get("oldPassword").asText(), actionBody.get("newPassword").asText());
    	} catch(ActivitiServiceException ase) {
    		throw new BadRequestException(ase.getMessage());
    	}
    }
}
 
Example #2
Source File: ChartFacadeController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@RequestMapping( value = "/{uid}/favorite", method = RequestMethod.DELETE )
@ResponseStatus( HttpStatus.OK )
public void removeAsFavorite( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
    if ( !getSchema().isFavoritable() )
    {
        throw new WebMessageException( WebMessageUtils.conflict( "Objects of this class cannot be set as favorite" ) );
    }

    List<Visualization> entity = (List<Visualization>) getEntity( pvUid );

    if ( entity.isEmpty() )
    {
        throw new WebMessageException( WebMessageUtils.notFound( Chart.class, pvUid ) );
    }

    Visualization object = entity.get( 0 );
    User user = currentUserService.getCurrentUser();

    object.removeAsFavorite( user );
    manager.updateNoAcl( object );

    String message = String.format( "Object '%s' removed as favorite for user '%s'", pvUid, user.getUsername() );
    webMessageService.send( WebMessageUtils.ok( message ), response, request );
}
 
Example #3
Source File: AuditRecordController.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
/**
 * Return a page-able list of {@link AuditRecordResource}s.
 *
 * @param pageable Pagination information
 * @param assembler assembler for {@link AuditRecord}
 * @param actions Optional. For which {@link AuditActionType}s do you want to retrieve
 *     {@link AuditRecord}s
 * @param fromDate Optional. The fromDate must be {@link DateTimeFormatter}.ISO_DATE_TIME
 *     formatted. eg.: 2019-02-03T00:00:30
 * @param toDate Optional. The toDate must be {@link DateTimeFormatter}.ISO_DATE_TIME
 *     formatted. eg.: 2019-02-05T23:59:30
 * @param operations Optional. For which {@link AuditOperationType}s do you want to
 *     retrieve {@link AuditRecord}s
 * @return list of audit records
 */
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public PagedModel<AuditRecordResource> list(Pageable pageable,
		@RequestParam(required = false) AuditActionType[] actions,
		@RequestParam(required = false) AuditOperationType[] operations,
		@RequestParam(required = false) String fromDate,
		@RequestParam(required = false) String toDate,
		PagedResourcesAssembler<AuditRecord> assembler) {

	final Instant fromDateAsInstant = paresStringToInstant(fromDate);
	final Instant toDateAsInstant = paresStringToInstant(toDate);

	if (fromDate != null && toDate != null && fromDate.compareTo(toDate) > 0) {
		throw new InvalidDateRangeException("The fromDate cannot be after the toDate.");
	}

	final Page<AuditRecord> auditRecords = this.auditRecordService
			.findAuditRecordByAuditOperationTypeAndAuditActionTypeAndDate(pageable, actions, operations,
					fromDateAsInstant,
					toDateAsInstant);
	return assembler.toModel(auditRecords, new Assembler(auditRecords));
}
 
Example #4
Source File: TranslationCollectKeyAPI.java    From singleton with Eclipse Public License 2.0 6 votes vote down vote up
/**
 *Post a string key's source to l10n server.
 *
 */
@ApiIgnore
@ApiOperation(value = APIOperation.KEY_SOURCE_POST_VALUE, notes = APIOperation.KEY_SOURCE_POST_NOTES)
@RequestMapping(value = L10nI18nAPI.TRANSLATION_PRODUCT_NOCOMOPONENT_KEY_APIV1, method = RequestMethod.POST, produces = { API.API_CHARSET })
@ResponseStatus(HttpStatus.OK)
public SourceAPIResponseDTO collectV1KeyTranslationNoComponent(
		@ApiParam(name = APIParamName.PRODUCT_NAME, required = true, value = APIParamValue.PRODUCT_NAME) @PathVariable(APIParamName.PRODUCT_NAME) String productName,
		@ApiParam(name = APIParamName.VERSION, required = true, value = APIParamValue.VERSION) @RequestParam(value = APIParamName.VERSION, required = true) String version,
		@ApiParam(name = APIParamName.KEY, required = true, value = APIParamValue.KEY) @PathVariable(APIParamName.KEY) String key,
		@ApiParam(name = APIParamName.SOURCE, required = false, value = APIParamValue.SOURCE) @RequestParam(value = APIParamName.SOURCE, required = false) String source,
		@ApiParam(name = APIParamName.COMMENT_SOURCE, value = APIParamValue.COMMENT_SOURCE) @RequestParam(value = APIParamName.COMMENT_SOURCE, required = false) String commentForSource,
		@ApiParam(name = APIParamName.LOCALE, value = APIParamValue.LOCALE) @RequestParam(value = APIParamName.LOCALE, required = false) String locale,
		@ApiParam(name = APIParamName.SOURCE_FORMAT, value = APIParamValue.SOURCE_FORMAT) @RequestParam(value = APIParamName.SOURCE_FORMAT, required = false) String sourceFormat,
		@ApiParam(name = APIParamName.COLLECT_SOURCE, value = APIParamValue.COLLECT_SOURCE) @RequestParam(value = APIParamName.COLLECT_SOURCE, required = true, defaultValue = "true") String collectSource,
	//	@ApiParam(name = APIParamName.PSEUDO, value = APIParamValue.PSEUDO) @RequestParam(value = APIParamName.PSEUDO, required = false, defaultValue = ConstantsKeys.FALSE) String pseudo,
		HttpServletRequest request) throws L10nAPIException {
	String newLocale = locale == null ? ConstantsUnicode.EN : locale;
	String newKey = StringUtils.isEmpty(sourceFormat) ? key
			: (key + ConstantsChar.DOT + ConstantsChar.POUND + sourceFormat.toUpperCase());
	String newSource = source == null ? "" : source;
	StringSourceDTO sourceObj = SourceUtils.createSourceDTO(productName, version, ConstantsFile.DEFAULT_COMPONENT, newLocale, newKey,
			newSource, commentForSource, sourceFormat);
	boolean isSourceCached = sourceService.cacheSource(sourceObj);
	return SourceUtils.handleSourceResponse(isSourceCached);
	
}
 
Example #5
Source File: RestProject.java    From NFVO with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a new Project to the Projects repository
 *
 * @param project
 * @return project
 */
@ApiOperation(
    value = "Adding a Project",
    notes = "Project data has to be passed as JSON in the Request Body.")
@RequestMapping(
    method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_JSON_VALUE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public Project create(@RequestBody @Valid Project project)
    throws NotAllowedException, NotFoundException {
  log.info("Adding Project: " + project.getName());
  if (utils.isAdmin()) {
    return projectManagement.add(project);
  } else {
    throw new NotAllowedException("Forbidden to create project " + project.getName());
  }
}
 
Example #6
Source File: GlobalExceptionHandler.java    From spring-boot-plus with Apache License 2.0 6 votes vote down vote up
/**
 * 自定义业务/数据异常处理
 *
 * @param exception
 * @return
 */
@ExceptionHandler(value = {SpringBootPlusException.class})
@ResponseStatus(HttpStatus.OK)
public ApiResult<Boolean> springBootPlusExceptionHandler(SpringBootPlusException exception) {
    printRequestDetail();
    log.error("springBootPlusException:", exception);
    int errorCode;
    if (exception instanceof BusinessException) {
        errorCode = ApiCode.BUSINESS_EXCEPTION.getCode();
    } else if (exception instanceof DaoException) {
        errorCode = ApiCode.DAO_EXCEPTION.getCode();
    } else if (exception instanceof VerificationCodeException) {
        errorCode = ApiCode.VERIFICATION_CODE_EXCEPTION.getCode();
    } else {
        errorCode = ApiCode.SPRING_BOOT_PLUS_EXCEPTION.getCode();
    }
    return new ApiResult<Boolean>()
            .setCode(errorCode)
            .setMessage(exception.getMessage());
}
 
Example #7
Source File: CartRestController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value = "/add/{productId}", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void addItem(@PathVariable String productId, HttpServletRequest request) {
	
	String sessionId = request.getSession(true).getId();
	Cart cart = cartService.read(sessionId);
	if(cart== null) {
		cart = cartService.create(new Cart(sessionId));
	}
	
	Product product = productService.getProductById(productId);
	if(product == null) {
		throw new IllegalArgumentException(new ProductNotFoundException(productId));
	}
	
	cart.addCartItem(new CartItem(product));
	
	cartService.update(sessionId, cart);
}
 
Example #8
Source File: JobExecutionController.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve all task job executions with the task name specified
 *
 * @param jobName name of the job. SQL server specific wildcards are enabled (eg.: myJob%,
 *     m_Job, ...)
 * @param pageable page-able collection of {@code TaskJobExecution}s.
 * @param assembler for the {@link TaskJobExecution}s
 * @return list task/job executions with the specified jobName.
 * @throws NoSuchJobException if the job with the given name does not exist.
 */
@RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json")
@ResponseStatus(HttpStatus.OK)
public PagedModel<JobExecutionResource> retrieveJobsByParameters(
		@RequestParam(value = "name", required = false) String jobName,
		@RequestParam(value = "status", required = false) BatchStatus status,
		Pageable pageable, PagedResourcesAssembler<TaskJobExecution> assembler) throws NoSuchJobException, NoSuchJobExecutionException {
	List<TaskJobExecution> jobExecutions;
	Page<TaskJobExecution> page;

	if (jobName == null && status == null) {
		jobExecutions = taskJobService.listJobExecutions(pageable);
		page = new PageImpl<>(jobExecutions, pageable, taskJobService.countJobExecutions());
	} else {
		jobExecutions = taskJobService.listJobExecutionsForJob(pageable, jobName, status);
		page = new PageImpl<>(jobExecutions, pageable,
				taskJobService.countJobExecutionsForJob(jobName, status));
	}

	return assembler.toModel(page, jobAssembler);
}
 
Example #9
Source File: UserController.java    From QuizZz with MIT License 5 votes vote down vote up
@RequestMapping(value = "/forgotPassword")
@PreAuthorize("permitAll")
@ResponseStatus(HttpStatus.OK)
public User forgotPassword(String email) {
	User user = userService.findByEmail(email);
	userManagementService.resendPassword(user);
	
	return user;
}
 
Example #10
Source File: TranslationProductAPI.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
/**
    * Provide translation based on multiple component.
    *
    */
@ApiOperation(value = APIOperation.PRODUCT_TRANSLATION_VALUE, notes = APIOperation.PRODUCT_TRANSLATION_NOTES)
   @RequestMapping(value = APIV2.PRODUCT_TRANSLATION_GET, method = RequestMethod.GET, produces = { API.API_CHARSET })
   @ResponseStatus(HttpStatus.OK)
   public APIResponseDTO getMultipleComponentsTranslation(
		@ApiParam(name = APIParamName.PRODUCT_NAME, required = true, value = APIParamValue.PRODUCT_NAME) @PathVariable(APIParamName.PRODUCT_NAME) String productName,
		@ApiParam(name = APIParamName.VERSION, required = true, value = APIParamValue.VERSION) @PathVariable(value = APIParamName.VERSION) String version,
    	@ApiParam(name = APIParamName.COMPONENTS, required = false, value = APIParamValue.COMPONENTS) @RequestParam(value = APIParamName.COMPONENTS, required = false, defaultValue = "") String components,
		@ApiParam(name = APIParamName.LOCALES, required = false, value = APIParamValue.LOCALES) @RequestParam(value = APIParamName.LOCALES, required = false, defaultValue = "") String locales,
		@ApiParam(name = APIParamName.PSEUDO, value = APIParamValue.PSEUDO) @RequestParam(value = APIParamName.PSEUDO, required = false, defaultValue = "false") String pseudo,
           HttpServletRequest req)  throws Exception {
       return super.getMultTrans(productName, version, components, locales, pseudo, req);
   }
 
Example #11
Source File: RestNetworkServiceRecord.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
    value = "Add a VNFC instance to a VDU of a VNFR",
    notes = "Specifies and adds a VNFC instance in the VDU inside a VNFR that is inside the NSR")
@RequestMapping(
    value = "{id}/vnfrecords/{idVnf}/vdunits/{idVdu}/vnfcinstances",
    method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
@SuppressWarnings("unchecked")
public void postVNFCInstance(
    @RequestBody @Valid JsonObject body,
    @PathVariable("id") String id,
    @PathVariable("idVnf") String idVnf,
    @PathVariable("idVdu") String idVdu,
    @RequestHeader(value = "project-id") String projectId)
    throws NotFoundException, BadFormatException, WrongStatusException, BadRequestException {
  if (!body.has("vnfComponent"))
    throw new BadRequestException(
        "The passed request body is not correct. It should include a field named: vnfComponent");

  VNFComponent component = retrieveVNFComponentFromRequest(body);
  List<String> vimInstanceNames = retrieveVimInstanceNamesFromRequest(body);

  log.trace("Received: " + component + "\nand\n" + vimInstanceNames);
  networkServiceRecordManagement.addVNFCInstance(
      id, idVnf, idVdu, component, "", projectId, vimInstanceNames);
}
 
Example #12
Source File: ExceptionHandlers.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@ExceptionHandler(PasswordDoesNotMatchException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public ResponseBody handlePasswordDoesNotMatchException(HttpServletRequest request,
                                                        PasswordDoesNotMatchException e) {
    ApiResponse response = new ApiResponse(ApiResponse.USER_PASSWORD_DOES_NOT_MATCH);
    return handleExceptionInternal(request, e, response);
}
 
Example #13
Source File: OperationsTransformer.java    From spring-openapi with MIT License 5 votes vote down vote up
private String resolveResponseStatus(Method method) {
	ResponseStatus responseStatusAnnotation = method.getAnnotation(ResponseStatus.class);
	if (responseStatusAnnotation == null) {
		return DEFAULT_RESPONSE_STATUS;
	}
	return String.valueOf(defaultIfUnexpectedServerError(responseStatusAnnotation.code(), responseStatusAnnotation.value()).value());
}
 
Example #14
Source File: UserAccountController.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@ExceptionHandler(AccessDeniedException.class)
@ResponseStatus(value = HttpStatus.FORBIDDEN)
@ResponseBody
private ErrorMessageResponse handleAccessDeniedException(AccessDeniedException e) {
  LOG.warn("Access denied", e);
  return new ErrorMessageResponse(Collections.singletonList(new ErrorMessage(e.getMessage())));
}
 
Example #15
Source File: AbstractRestExceptionHandler.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
/**
 * {@link HttpRequestMethodNotSupportedException}をハンドリングします。
 * @param e {@link HttpRequestMethodNotSupportedException}
 * @return {@link ErrorMessage}
 *         HTTPステータス 405 でレスポンスを返却します。
 */
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseBody
@ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED)
@Override
public ErrorMessage handle(HttpRequestMethodNotSupportedException e) {
    if (L.isDebugEnabled()) {
        L.debug(R.getString("D-SPRINGMVC-REST-HANDLER#0002"), e);
    }
    ErrorMessage error = createClientErrorMessage(HttpStatus.METHOD_NOT_ALLOWED);
    warn(error, e);
    return error;
}
 
Example #16
Source File: MeController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@PostMapping( value = "/dashboard/interpretations/read" )
@ResponseStatus( value = HttpStatus.NO_CONTENT )
@ApiVersion( include = { DhisApiVersion.ALL, DhisApiVersion.DEFAULT } )
public void updateInterpretationsLastRead()
{
    interpretationService.updateCurrentUserLastChecked();
}
 
Example #17
Source File: TodoApiController.java    From onboard with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/attach", method = RequestMethod.DELETE)
@Interceptors({ ProjectNotArchivedRequired.class })
@ResponseStatus(HttpStatus.OK)
public void deleteAttachTodos(@RequestParam(value = "attachType", required = true) String attachType,
        @RequestParam(value = "attachId", required = true) Integer attachId,
        @RequestParam(value = "todoId", required = true) Integer todoId) {
    todoService.removeAttachToTodo(attachType, attachId, todoId);
}
 
Example #18
Source File: GlobalExceptionHandler.java    From MeetingFilm with Apache License 2.0 5 votes vote down vote up
/**
 * 用户未登录异常
 */
@ExceptionHandler(AuthenticationException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public String unAuth(AuthenticationException e) {
    log.error("用户未登陆:", e);
    return "/login.html";
}
 
Example #19
Source File: MaintenanceController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping( value = "/softDeletedProgramInstanceRemoval", method = { RequestMethod.PUT, RequestMethod.POST } )
@PreAuthorize( "hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')" )
@ResponseStatus( HttpStatus.NO_CONTENT )
public void deleteSoftDeletedProgramInstances()
{
    maintenanceService.deleteSoftDeletedProgramInstances();
}
 
Example #20
Source File: ExceptionAdvice.java    From EasyReport with Apache License 2.0 5 votes vote down vote up
/**
 * 400 - Bad Request
 */
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseResult handleMethodArgumentNotValidException(final MethodArgumentNotValidException e) {
    log.error("MethodArgumentNotValidException", e);
    return ResponseResult.failure(SystemErrorCode.DATA_BIND_VALIDATION_FAILURE, e);
}
 
Example #21
Source File: SniffersResourceController.java    From logsniffer with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/sniffers/{snifferId}/start", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
void start(@PathVariable("snifferId") final long snifferId)
		throws ResourceNotFoundException, SchedulerException, ParseException {
	logger.info("Starting sniffer: {}", snifferId);
	snifferScheduler.startSniffing(snifferId);
	logger.info("Started sniffer: {}", snifferId);
}
 
Example #22
Source File: SnifferEventsResourceController.java    From logsniffer with GNU Lesser General Public License v3.0 5 votes vote down vote up
@RequestMapping(value = "/sniffers/{snifferId}/events/{eventId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
Event showEvent(@PathVariable("snifferId") final long snifferId, @PathVariable("eventId") final String eventId)
		throws ResourceNotFoundException {
	final Event event = eventPersistence.getEvent(snifferId, eventId);
	if (event == null) {
		throw new ResourceNotFoundException(Event.class, eventId, "Event not found for id: " + eventId);
	}
	return event;
}
 
Example #23
Source File: ControllerHandler.java    From spring-boot-examples with Apache License 2.0 5 votes vote down vote up
/**
 * 处理UserNotExistException异常
 * @param ex
 * @return
 */
@ExceptionHandler({UserNotExistException.class})
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public JsonResult handleUserNotExistException(UserNotExistException ex) {
    System.out.println("请求用户数据异常:" + ex.toString());
    return new JsonResult(false, "请求用户数据失败");
}
 
Example #24
Source File: RestController.java    From proctor with Apache License 2.0 5 votes vote down vote up
@ExceptionHandler(InternalServerException.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView handleInternalServerException(final InternalServerException e) {
    ModelAndView mav = new ModelAndView(new JsonResponseView());
    mav.addObject(new JsonEmptyDataResponse(new JsonMeta(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage())));
    return mav;
}
 
Example #25
Source File: AppManagerController.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@ResponseStatus(HttpStatus.OK)
@PostMapping("/activate/{id}")
public void activateApp(@PathVariable(value = "id") String id) {
  App app = getApp(id);
  app.setActive(true);
  dataService.update(AppMetadata.APP, app);
}
 
Example #26
Source File: TaskSchedulerController.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Unschedule the schedule from the Scheduler.
 *
 * @param scheduleName name of the schedule to be deleted
 * @param platform name of the platform from which the schedule is deleted.
 */
@RequestMapping(value = "/{scheduleName}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
public void unschedule(@PathVariable("scheduleName") String scheduleName,
		@RequestParam(value = "platform", required = false) String platform) {
	schedulerService.unschedule(scheduleName, platform);
}
 
Example #27
Source File: CommandRestController.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Delete all applications from database.
 *
 * @throws PreconditionFailedException When deleting one of the commands would violated a consistency issue
 */
@DeleteMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteAllCommands() throws PreconditionFailedException {
    log.warn("Called to delete all commands.");
    this.persistenceService.deleteAllCommands();
}
 
Example #28
Source File: UserResource.java    From plumdo-work with Apache License 2.0 5 votes vote down vote up
@GetMapping(value = "/users")
@ResponseStatus(value = HttpStatus.OK)
public PageResponse getUsers(@RequestParam Map<String, String> requestParams) {
    Criteria<User> criteria = new Criteria<>();
    criteria.add(Restrictions.eq("id", requestParams.get("id")));
    criteria.add(Restrictions.like("phone", requestParams.get("phone")));
    criteria.add(Restrictions.eq("status", requestParams.get("status")));
    criteria.add(Restrictions.like("name", requestParams.get("name")));
    criteria.add(Restrictions.like("tenantId", requestParams.get("tenantId")));
    return createPageResponse(userRepository.findAll(criteria, getPageable(requestParams)));
}
 
Example #29
Source File: QuizController.java    From QuizZz with MIT License 5 votes vote down vote up
@RequestMapping(value = "/{quiz_id}", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@ResponseStatus(HttpStatus.OK)
public Quiz update(@PathVariable Long quiz_id, @Valid Quiz quiz, BindingResult result) {

	RestVerifier.verifyModelResult(result);

	quiz.setId(quiz_id);
	return quizService.update(quiz);
}
 
Example #30
Source File: RestCaseController.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/create/", method = RequestMethod.POST)
@ResponseBody
@ResponseStatus(HttpStatus.CREATED)
public void createUser(@RequestBody User user, HttpServletResponse response,
    UriComponentsBuilder ucBuilder) throws InterruptedException {
    users.put(user.getId(), user);
    response.setHeader("Location", ucBuilder.path("/get/{id}")
                                            .buildAndExpand(user.getId())
                                            .toUri()
                                            .toASCIIString());
}