Example usage for org.springframework.http HttpHeaders HttpHeaders

List of usage examples for org.springframework.http HttpHeaders HttpHeaders

Introduction

In this page you can find the example usage for org.springframework.http HttpHeaders HttpHeaders.

Prototype

public HttpHeaders() 

Source Link

Document

Construct a new, empty instance of the HttpHeaders object.

Usage

From source file:org.dawnsci.marketplace.controllers.ExtendedRestApiController.java

/**
 * Used by the client software to obtain a CSRF token to use in further
 * communication with the server./*from   www  .j a v a2s.co m*/
 */
@ResponseBody
@RequestMapping(value = "/token")
public ResponseEntity<String> login(HttpServletRequest request) {
    CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
    HttpHeaders headers = new HttpHeaders();
    headers.add(token.getHeaderName(), token.getToken());
    return new ResponseEntity<>("you got your token", headers, HttpStatus.OK);
}

From source file:org.jrb.commons.web.ResponseUtils.java

public <R extends Response> ResponseEntity<R> finalize(final R response) {
    return finalize(response, HttpStatus.OK, new HttpHeaders());
}

From source file:edu.wisc.cypress.dao.advrpt.RestAdvisorReportDao.java

@Override
public void getAdvisorReport(String pvi, String docId, ProxyResponse proxyResponse) {
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set("PVI", pvi);

    this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId);
}

From source file:cn.cdwx.jpa.web.account.TaskRestController.java

@RequestMapping(method = RequestMethod.POST, consumes = MediaTypes.JSON)
public ResponseEntity<?> create(@RequestBody Task task, UriComponentsBuilder uriBuilder) {
    // JSR303 Bean Validator, RestExceptionHandler?.
    BeanValidators.validateWithException(validator, task);

    // ?//from   ww w . j a  v  a 2  s . c  o  m
    taskService.saveTask(task);

    // Restful?url, ?id.
    String id = task.getId();
    URI uri = uriBuilder.path("/api/v1/task/" + id).build().toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);

    return new ResponseEntity(headers, HttpStatus.CREATED);
}

From source file:edu.wisc.cypress.dao.ernstmt.RestEarningStatementDao.java

@Override
public void getEarningStatement(String emplid, String docId, ProxyResponse proxyResponse) {
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set("HRID", emplid);
    this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId);
}

From source file:com.gopivotal.cla.github.GitHubConditionalTest.java

@Test
public void withNextLink() {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Link", "<" + URL + ">; rel=\"first\"");
    headers.add("Link", "<" + LINK_URL + ">; rel=\"next\"");
    ResponseEntity<Set> response1 = new ResponseEntity<Set>(Sets.asSet(), headers, HttpStatus.OK);
    when(this.restOperations.exchange(URL, HttpMethod.GET, REQUEST_ENTITY, Set.class)).thenReturn(response1);

    ResponseEntity<Set> response2 = new ResponseEntity<Set>(Sets.asSet(), HttpStatus.OK);
    when(this.restOperations.exchange(LINK_URL, HttpMethod.GET, REQUEST_ENTITY, Set.class))
            .thenReturn(response2);/*from  ww w .  j  av  a2  s .c o m*/

    this.gitHubType.getTrigger();

    assertTrue(this.gitHubType.initializedCalled);
}

From source file:com.gazbert.bxbot.rest.api.MarketConfigController.java

@RequestMapping(value = "/market/{marketId}", method = RequestMethod.PUT)
ResponseEntity<?> updateMarket(@AuthenticationPrincipal User user, @PathVariable String marketId,
        @RequestBody MarketConfig config) {

    final MarketConfig updatedMarketConfig = marketConfigService.updateMarket(config);
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setLocation(ServletUriComponentsBuilder.fromCurrentRequest().path("/{marketId}")
            .buildAndExpand(updatedMarketConfig.getId()).toUri());
    return new ResponseEntity<>(updatedMarketConfig, httpHeaders, HttpStatus.NO_CONTENT);
}

From source file:io.github.howiefh.jeews.modules.sys.controller.OrganizationController.java

@RequiresPermissions("organization:create")
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseEntity<OrganizationResource> create(HttpEntity<Organization> entity, HttpServletRequest request)
        throws URISyntaxException {
    Organization organization = entity.getBody();
    organizationService.save(organization);
    HttpHeaders headers = new HttpHeaders();
    OrganizationResource organizationResource = new OrganizationResourceAssembler().toResource(organization);
    headers.setLocation(entityLinks.linkForSingleResource(Organization.class, organization.getId()).toUri());
    ResponseEntity<OrganizationResource> responseEntity = new ResponseEntity<OrganizationResource>(
            organizationResource, headers, HttpStatus.CREATED);
    return responseEntity;
}

From source file:fi.helsinki.opintoni.integration.unisport.UnisportRestClient.java

private HttpEntity<String> getAuthorizationHeader(final Long unisportUserId) {
    HttpHeaders headers = new HttpHeaders();
    headers.add(AUTHORIZATION_HEADER, unisportJWTService.generateToken(unisportUserId));
    return new HttpEntity<>("parameters", headers);
}

From source file:com.ge.predix.acceptance.test.policy.admin.PolicyCreationStepsDefinitions.java

@Before
public void setup() throws JsonParseException, JsonMappingException, IOException {
    this.zone1Headers = new HttpHeaders();
    this.zone1Headers.set(PolicyHelper.PREDIX_ZONE_ID, this.zoneHelper.getZone1Name());
    if (Arrays.asList(this.env.getActiveProfiles()).contains("public")) {
        setupPublicACS();// w  w  w . ja v a2  s . c om
    } else {
        setupPredixACS();
    }
}