Java Code Examples for org.springframework.web.bind.annotation.RequestMethod#PUT

The following examples show how to use org.springframework.web.bind.annotation.RequestMethod#PUT . 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: RestNetworkServiceRecord.java    From NFVO with Apache License 2.0 6 votes vote down vote up
/**
 * Edits the PhysicalNetworkFunctionRecord
 *
 * @param pRecord : The PhysicalNetworkFunctionRecord to be edited
 * @param id : The NSD id
 * @return PhysicalNetworkFunctionRecord: The PhysicalNetworkFunctionRecord edited
 */
@ApiOperation(value = "", notes = "", hidden = true)
@RequestMapping(
    value = "{id}/pnfrecords/{id_pnf}",
    method = RequestMethod.PUT,
    consumes = MediaType.APPLICATION_JSON_VALUE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public PhysicalNetworkFunctionRecord updatePNFD(
    @RequestBody @Valid PhysicalNetworkFunctionRecord pRecord,
    @PathVariable("id") String id,
    @PathVariable("id_pnf") String id_pnf,
    @RequestHeader(value = "project-id") String projectId)
    throws NotFoundException {
  NetworkServiceRecord nsd = networkServiceRecordManagement.query(id, projectId);
  nsd.getPnfr().add(pRecord);
  networkServiceRecordManagement.update(nsd, id, projectId);
  return pRecord;
}
 
Example 2
Source File: TicketController.java    From Building-RESTful-Web-Services-with-Spring-5-Second-Edition with MIT License 6 votes vote down vote up
@ResponseBody
@RequestMapping(value = "/{ticketid}", method =  RequestMethod.PUT)
public <T> T updateTicketByCustomer (
		@PathVariable("ticketid") final Integer ticketid,
		
		@RequestParam(value="content") String content,
		
		HttpServletRequest request			
		) {
	
	User user = userSevice.getUserByToken(request.getHeader("token"));
	
	if(user == null){
		return Util.getUserNotAvailableError();
	}
	
	ticketSevice.updateTicket(ticketid, content, 2, 1);
	
	return Util.getSuccessResult(); 
}
 
Example 3
Source File: CacheController.java    From Kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Wipe system cache
 *
 * @param type  {@link Broadcaster.TYPE}
 * @param event {@link Broadcaster.EVENT}
 * @param name
 * @return if the action success
 * @throws IOException
 */
@RequestMapping(value = "/{type}/{name}/{event}", method = { RequestMethod.PUT })
@ResponseBody
public void wipeCache(@PathVariable String type, @PathVariable String event, @PathVariable String name) throws IOException {

    Broadcaster.TYPE wipeType = Broadcaster.TYPE.getType(type);
    EVENT wipeEvent = Broadcaster.EVENT.getEvent(event);

    logger.info("wipe cache type: " + wipeType + " event:" + wipeEvent + " name:" + name);

    switch (wipeEvent) {
    case CREATE:
    case UPDATE:
        cacheService.rebuildCache(wipeType, name);
        break;
    case DROP:
        cacheService.removeCache(wipeType, name);
        break;
    default:
        throw new RuntimeException("invalid type:" + wipeEvent);
    }
}
 
Example 4
Source File: SysDictController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * @功能:编辑
 * @param sysDict
 * @return
 */
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
	Result<SysDict> result = new Result<SysDict>();
	SysDict sysdict = sysDictService.getById(sysDict.getId());
	if(sysdict==null) {
		result.error500("未找到对应实体");
	}else {
		sysDict.setUpdateTime(new Date());
		boolean ok = sysDictService.updateById(sysDict);
		if(ok) {
			result.success("编辑成功!");
		}
	}
	return result;
}
 
Example 5
Source File: TicketController.java    From Building-RESTful-Web-Services-with-Spring-5-Second-Edition with MIT License 6 votes vote down vote up
@ResponseBody
@CSRTokenRequired
@RequestMapping(value = "/by/csr", method =  RequestMethod.PUT)
public <T> T updateTicketByCSR (
		@RequestParam("ticketid") final Integer ticketid,
		
		@RequestParam(value="content") String content,
		@RequestParam(value="severity") Integer severity,
		@RequestParam(value="status") Integer status,
		
		HttpServletRequest request
		) {
	
	ticketSevice.updateTicket(ticketid, content, severity, status);
	
	return Util.getSuccessResult(); 
}
 
Example 6
Source File: InterpretationController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT )
@ResponseStatus( HttpStatus.NO_CONTENT )
public void updateInterpretation( @PathVariable( "uid" ) String uid, @RequestBody String text, HttpServletResponse response )
    throws WebMessageException
{
    Interpretation interpretation = interpretationService.getInterpretation( uid );

    if ( interpretation == null )
    {
        throw new WebMessageException( WebMessageUtils.notFound( "Interpretation does not exist: " + uid ) );
    }

    if ( !currentUserService.getCurrentUser().equals( interpretation.getUser() )
        && !currentUserService.currentUserIsSuper() )
    {
        throw new AccessDeniedException( "You are not allowed to update this interpretation." );
    }

    interpretationService.updateInterpretationText( interpretation, text );
}
 
Example 7
Source File: JobController.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Rollback a job to the given step
 *
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{jobId}/steps/{stepId}/rollback", method = { RequestMethod.PUT }, produces = {
        "application/json" })
@ResponseBody
public JobInstance rollback(@PathVariable String jobId, @PathVariable String stepId) {
    try {
        final JobInstance jobInstance = jobService.getJobInstance(jobId);
        if (jobInstance == null) {
            throw new BadRequestException("Cannot find job: " + jobId);
        }
        jobService.rollbackJob(jobInstance, stepId);
        return jobService.getJobInstance(jobId);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e);
    }
}
 
Example 8
Source File: PetController.java    From activejpa with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public String processUpdateForm(@ModelAttribute("pet") Pet pet, BindingResult result, SessionStatus status) {
    // we're not using @Valid annotation here because it is easier to define such validation rule in Java
    new PetValidator().validate(pet, result);
    if (result.hasErrors()) {
        return "pets/createOrUpdatePetForm";
    } else {
        this.clinicService.savePet(pet);
        status.setComplete();
        return "redirect:/owners/{ownerId}";
    }
}
 
Example 9
Source File: UserController.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@ByPermissionClass(UserMgr.Update.class)
@RequestMapping(value="{id}", method=RequestMethod.PUT)
public ModelAndView update(@PathVariable("id") Long id, @Validated({ValidAnyTime.class, ValidWhenEdit.class}) User adminUser, BindingResult br){
	ValidatorUtils.throwIfHasErrors(br, true);
    adminUser.setId(id);
    adminUserServiceImpl.update(adminUser);
    return messageMv("更新成功!");
}
 
Example 10
Source File: DpmtRestController.java    From oneops with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="/dj/simple/approvals/{approvalId}", method = RequestMethod.PUT)
@ResponseBody
public CmsDpmtApproval dpmtApprove(
		@RequestBody CmsDpmtApproval approval, @PathVariable long approvalId,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope,
		@RequestHeader(value="X-Cms-User", required = true)  String userId,
		@RequestHeader(value="X-Approval-Token", required = false) String approvalToken){
	
	approval.setUpdatedBy(userId);
	
    djManager.updateApprovalList(Arrays.asList(approval), approvalToken);
    return djManager.getDeploymentApproval(approval.getApprovalId());
}
 
Example 11
Source File: RegularExpressionController.java    From JDeSurvey with GNU Affero General Public License v3.0 5 votes vote down vote up
@Secured({"ROLE_ADMIN"})
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@RequestParam(value = "_proceed", required = false) String proceed,
					@Valid RegularExpression regularExpression, 
					BindingResult bindingResult,
					Principal principal,
					Model uiModel, 
					HttpServletRequest httpServletRequest) {
	log.info("update(): handles PUT");
	try{
		User user = userService.user_findByLogin(principal.getName());	
		if(proceed != null){
			if (bindingResult.hasErrors()) {
				populateEditForm(uiModel, regularExpression,user);
				return "admin/masks/update";
			}
		
			if (surveySettingsService.regularExpression_findByName(regularExpression.getName()) != null &&
				!surveySettingsService.regularExpression_findByName(regularExpression.getName()).getId().equals(regularExpression.getId())) {
				bindingResult.rejectValue("name", "field_unique");
				populateEditForm(uiModel, regularExpression,user);
				return "admin/masks/update";
			}
			uiModel.asMap().clear();
			regularExpression =surveySettingsService.regularExpression_merge(regularExpression);
			return "redirect:/admin/masks"; // + encodeUrlPathSegment(regularExpression.getId().toString(), httpServletRequest);
		}else{
			return "redirect:/admin/masks";
		}

	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 12
Source File: CubeController.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * Build/Rebuild a cube segment by source offset
 */
@RequestMapping(value = "/{cubeName}/rebuild2", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public JobInstance rebuild2(@PathVariable String cubeName, @RequestBody JobBuildRequest2 req) {
    return buildInternal(cubeName, null, new SegmentRange(req.getSourceOffsetStart(), req.getSourceOffsetEnd()),
            req.getSourcePartitionOffsetStart(), req.getSourcePartitionOffsetEnd(), req.getBuildType(),
            req.isForce(), req.getPriorityOffset());
}
 
Example 13
Source File: ChartFacadeController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE )
public void putJsonObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
    List<Visualization> objects = (List<Visualization>) getEntity( pvUid );

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

    User user = currentUserService.getCurrentUser();

    if ( !aclService.canUpdate( user, objects.get( 0 ) ) )
    {
        throw new UpdateAccessDeniedException( "You don't have the proper permissions to update this object." );
    }

    Chart parsed = deserializeJsonEntity( request, response );
    parsed.setUid( pvUid );

    final Visualization visualization = convertToVisualization( parsed );

    MetadataImportParams params = importService.getParamsFromMap( contextService.getParameterValuesMap() )
        .setImportReportMode( ImportReportMode.FULL )
        .setUser( user )
        .setImportStrategy( ImportStrategy.UPDATE )
        .addObject( visualization );

    ImportReport importReport = importService.importMetadata( params );
    WebMessage webMessage = WebMessageUtils.objectReport( importReport );

    if ( importReport.getStatus() != Status.OK )
    {
        webMessage.setStatus( Status.ERROR );
    }

    webMessageService.send( webMessage, response, request );
}
 
Example 14
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/{cubeName}/cost", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public CubeInstance updateCubeCost(@PathVariable String cubeName, @RequestParam(value = "cost") int cost) {
    checkCubeExists(cubeName);
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
    try {
        return cubeService.updateCubeCost(cube, cost);
    } catch (Exception e) {
        String message = "Failed to update cube cost: " + cubeName + " : " + cost;
        logger.error(message, e);
        throw new InternalErrorException(message + " Caused by: " + e.getMessage(), e);
    }
}
 
Example 15
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/segment_build_complete/{cubeName}/{segmentName}", method = RequestMethod.PUT, produces = { "application/json" })
@ResponseBody
public void segmentBuildComplete(@PathVariable(value = "cubeName") String cubeName,
        @PathVariable(value = "segmentName") String segmentName) {
    logger.info("receive segment build complete, cube:{}, segment:{}", cubeName, segmentName);
    streamingServer.remoteSegmentBuildComplete(cubeName, segmentName);
}
 
Example 16
Source File: HueMulator.java    From amazon-echo-ha-bridge with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/{userId}/lights/{lightId}/state", method = RequestMethod.PUT)
public ResponseEntity<String> stateChange(@PathVariable(value = "lightId") String lightId, @PathVariable(value = "userId") String userId, HttpServletRequest request, @RequestBody String requestString) {
    /**
     * strangely enough the Echo sends a content type of application/x-www-form-urlencoded even though
     * it sends a json object
     */
    log.info("hue state change requested: " + userId + " from " + request.getRemoteAddr());
    log.info("hue stage change body: " + requestString );

    DeviceState state = null;
    try {
        state = mapper.readValue(requestString, DeviceState.class);
    } catch (IOException e) {
        log.info("object mapper barfed on input", e);
        return new ResponseEntity<>(null, null, HttpStatus.BAD_REQUEST);
    }

    DeviceDescriptor device = repository.findOne(lightId);
    if (device == null) {
        return new ResponseEntity<>(null, null, HttpStatus.NOT_FOUND);
    }

    String responseString;
    String url;
    if (state.isOn()) {
        responseString = "[{\"success\":{\"/lights/" + lightId + "/state/on\":true}}]";
        url = device.getOnUrl();
    } else {
        responseString = "[{\"success\":{\"/lights/" + lightId + "/state/on\":false}}]";
        url = device.getOffUrl();
    }

    //quick template
    url = replaceIntensityValue(url, state.getBri());
    String body = replaceIntensityValue(device.getContentBody(), state.getBri());
    //make call
    if(!doHttpRequest(url, device.getHttpVerb(), device.getContentType(), body)){
        return new ResponseEntity<>(null, null, HttpStatus.SERVICE_UNAVAILABLE);
    }

    HttpHeaders headerMap = new HttpHeaders();

    ResponseEntity<String> entity = new ResponseEntity<>(responseString, headerMap, HttpStatus.OK);
    return entity;
}
 
Example 17
Source File: ApiMethodV31V32Controller.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@RequestMapping( value = "b", method = RequestMethod.PUT )
@ApiVersion( DhisApiVersion.V32 )
public void testPutV32( HttpServletResponse response ) throws IOException
{
    response.getWriter().println( "TEST" );
}
 
Example 18
Source File: SessionController.java    From eb-java-scorekeep with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value="/{sessionId}", method=RequestMethod.PUT)
public Session updateSession(@PathVariable String sessionId, @RequestBody Session session) {
  model.saveSession(session);
  return session;
}
 
Example 19
Source File: UriTemplateServletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@RequestMapping(method = RequestMethod.PUT, value = "{hotelId}")
public void createOrUpdate(@PathVariable long hotelId, Writer writer) {
}
 
Example 20
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 3 votes vote down vote up
/**
 * PUT /fake/test-query-paramters
 * To test the collection format in query parameters
 *
 * @param pipe  (required)
 * @param ioutil  (required)
 * @param http  (required)
 * @param url  (required)
 * @param context  (required)
 * @return Success (status code 200)
 */
@ApiOperation(value = "", nickname = "testQueryParameterCollectionFormat", notes = "To test the collection format in query parameters", tags={ "fake", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "Success") })
@RequestMapping(value = "/fake/test-query-paramters",
    method = RequestMethod.PUT)
default ResponseEntity<Void> testQueryParameterCollectionFormat(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "pipe", required = true) List<String> pipe,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "ioutil", required = true) List<String> ioutil,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "http", required = true) List<String> http,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "url", required = true) List<String> url,@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "context", required = true) List<String> context) {
    return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

}