Java Code Examples for org.springframework.http.HttpMethod#GET

The following examples show how to use org.springframework.http.HttpMethod#GET . 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: AbstractSockJsService.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public void handle(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
	if (request.getMethod() == HttpMethod.GET) {
		addNoCacheHeaders(response);
		if (checkOrigin(request, response)) {
			response.getHeaders().setContentType(new MediaType("application", "json", StandardCharsets.UTF_8));
			String content = String.format(
					INFO_CONTENT, random.nextInt(), isSessionCookieNeeded(), isWebSocketEnabled());
			response.getBody().write(content.getBytes());
		}

	}
	else if (request.getMethod() == HttpMethod.OPTIONS) {
		if (checkOrigin(request, response)) {
			addCacheHeaders(response);
			response.setStatusCode(HttpStatus.NO_CONTENT);
		}
	}
	else {
		sendMethodNotAllowed(response, HttpMethod.GET, HttpMethod.OPTIONS);
	}
}
 
Example 2
Source File: PrivilegeServiceSMOImpl.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
/**
 * 查询权限
 *
 * @param pd
 * @return
 */
@Override
public ResponseEntity<String> loadListPrivilege(IPageData pd) {
    JSONObject privilegeInfoObj = JSONObject.parseObject(pd.getReqData());
    Assert.jsonObjectHaveKey(privilegeInfoObj, "pgId", "请求报文中未包含pgId 节点");

    String pgId = privilegeInfoObj.getString("pgId");
    String name = privilegeInfoObj.getString("name");

    ResponseEntity<String> privilegeGroup = super.callCenterService(restTemplate, pd, "",
            ServiceConstant.SERVICE_API_URL + "/api/query.privilege.byPgId?pgId=" + pgId + "&name=" + name, HttpMethod.GET);
    if (privilegeGroup.getStatusCode() != HttpStatus.OK) {
        return privilegeGroup;
    }

    JSONObject privilegeObj = JSONObject.parseObject(privilegeGroup.getBody().toString());

    Assert.jsonObjectHaveKey(privilegeObj, "privileges", "查询菜单未返回privileges节点");

    JSONArray privileges = privilegeObj.getJSONArray("privileges");

    return new ResponseEntity<String>(privileges.toJSONString(), HttpStatus.OK);

}
 
Example 3
Source File: MockHttpServletRequestBuilderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void requestParameterFromQueryList() {
	this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/?foo[0]=bar&foo[1]=baz");

	MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

	assertEquals("foo%5B0%5D=bar&foo%5B1%5D=baz", request.getQueryString());
	assertEquals("bar", request.getParameter("foo[0]"));
	assertEquals("baz", request.getParameter("foo[1]"));
}
 
Example 4
Source File: MockMultipartHttpServletRequestBuilderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
	MockHttpServletRequestBuilder parent = new MockHttpServletRequestBuilder(HttpMethod.GET, "/");
	parent.characterEncoding("UTF-8");
	Object result = new MockMultipartHttpServletRequestBuilder("/fileUpload").merge(parent);

	assertNotNull(result);
	assertEquals(MockMultipartHttpServletRequestBuilder.class, result.getClass());

	MockMultipartHttpServletRequestBuilder builder = (MockMultipartHttpServletRequestBuilder) result;
	MockHttpServletRequest request = builder.buildRequest(new MockServletContext());
	assertEquals("UTF-8", request.getCharacterEncoding());
}
 
Example 5
Source File: SaveComplaintSMOImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
@Override
protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) throws IOException {

    //查询用户ID
    paramIn.put("userId", pd.getUserId());
    //查询商户ID
    Map paramObj = new HashMap();
    paramObj.put("communityId", paramIn.getString("communityId"));
    paramObj.put("auditStatusCd", "1100");
    paramObj.put("memberTypeCd", "390001200002");
    paramObj.put("page", 1);
    paramObj.put("row", 1);
    String url = ServiceConstant.SERVICE_API_URL + "/api/store.listStoresByCommunity" + mapToUrlParam(paramObj);
    ResponseEntity<String> responseEntity = super.callCenterService(restTemplate, pd, "", url, HttpMethod.GET);
    if (responseEntity.getStatusCode() != HttpStatus.OK) {
        return responseEntity;
    }

    JSONObject storeObj = JSONObject.parseObject(responseEntity.getBody());
    JSONArray stores = storeObj.getJSONArray("stores");
    String storeId = stores.getJSONObject(0).getString("storeId");
    paramIn.put("storeId", storeId);
    url = ServiceConstant.SERVICE_API_URL + "/api/complaint.saveComplaint";
    responseEntity = super.callCenterService(restTemplate, pd, paramIn.toJSONString(), url, HttpMethod.POST);

    return responseEntity;
}
 
Example 6
Source File: BodyInsertersTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void fromMultipartData() {
	MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
	map.set("name 3", "value 3");

	BodyInserters.FormInserter<Object> inserter =
			BodyInserters.fromMultipartData("name 1", "value 1")
					.withPublisher("name 2", Flux.just("foo", "bar", "baz"), String.class)
					.with(map);

	MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("https://example.com"));
	Mono<Void> result = inserter.insert(request, this.context);
	StepVerifier.create(result).expectComplete().verify();

}
 
Example 7
Source File: BodyInsertersTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test  // SPR-16350
public void fromMultipartDataWithMultipleValues() {
	MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
	map.put("name", Arrays.asList("value1", "value2"));
	BodyInserters.FormInserter<Object> inserter = BodyInserters.fromMultipartData(map);

	MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("http://example.com"));
	Mono<Void> result = inserter.insert(request, this.context);
	StepVerifier.create(result).expectComplete().verify();

	StepVerifier.create(DataBufferUtils.join(request.getBody()))
			.consumeNextWith(dataBuffer -> {
				byte[] resultBytes = new byte[dataBuffer.readableByteCount()];
				dataBuffer.read(resultBytes);
				DataBufferUtils.release(dataBuffer);
				String content = new String(resultBytes, StandardCharsets.UTF_8);
				assertThat(content, containsString("Content-Disposition: form-data; name=\"name\"\r\n" +
						"Content-Type: text/plain;charset=UTF-8\r\n" +
						"Content-Length: 6\r\n" +
						"\r\n" +
						"value1"));
				assertThat(content, containsString("Content-Disposition: form-data; name=\"name\"\r\n" +
						"Content-Type: text/plain;charset=UTF-8\r\n" +
						"Content-Length: 6\r\n" +
						"\r\n" +
						"value2"));
			})
			.expectComplete()
			.verify();
}
 
Example 8
Source File: MockWebscript.java    From alfresco-mvc with Apache License 2.0 5 votes vote down vote up
private void initialize() {
	method = HttpMethod.GET;
	parameters = null;
	body = null;
	webscriptUrl = "/service/mvc/";
	contentType = "application/json";
	controllerMapping = null;
	cookies = null;
	headers = null;
}
 
Example 9
Source File: MockMultipartHttpServletRequestBuilderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void test() {
	MockHttpServletRequestBuilder parent = new MockHttpServletRequestBuilder(HttpMethod.GET, "/");
	parent.characterEncoding("UTF-8");
	Object result = new MockMultipartHttpServletRequestBuilder("/fileUpload").merge(parent);

	assertNotNull(result);
	assertEquals(MockMultipartHttpServletRequestBuilder.class, result.getClass());

	MockMultipartHttpServletRequestBuilder builder = (MockMultipartHttpServletRequestBuilder) result;
	MockHttpServletRequest request = builder.buildRequest(new MockServletContext());
	assertEquals("UTF-8", request.getCharacterEncoding());
}
 
Example 10
Source File: MockHttpServletRequestBuilderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void contextPathServletPathEmpty() {
	this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/travel/hotels/42");
	this.builder.contextPath("/travel");
	MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

	assertEquals("/travel", request.getContextPath());
	assertEquals("", request.getServletPath());
	assertEquals("/hotels/42", request.getPathInfo());
}
 
Example 11
Source File: MockHttpServletRequestBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void contextPathServletPathInfoEmpty() {
	this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/travel/hotels/42");
	this.builder.contextPath("/travel");
	this.builder.servletPath("/hotels/42");
	MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

	assertEquals("/travel", request.getContextPath());
	assertEquals("/hotels/42", request.getServletPath());
	assertNull(request.getPathInfo());
}
 
Example 12
Source File: MockHttpServletRequestBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void requestParameterFromQueryList() {
	this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/?foo[0]=bar&foo[1]=baz");

	MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);

	assertEquals("foo%5B0%5D=bar&foo%5B1%5D=baz", request.getQueryString());
	assertEquals("bar", request.getParameter("foo[0]"));
	assertEquals("baz", request.getParameter("foo[1]"));
}
 
Example 13
Source File: QueryFeeByParkingSpaceListener.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
@Override
public HttpMethod getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 14
Source File: QueryParkingSpaceCarsListener.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
@Override
public HttpMethod getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 15
Source File: ListMyEnteredCommunitysListener.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
@Override
public HttpMethod getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 16
Source File: ListFeeConfigsListener.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
@Override
public HttpMethod getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 17
Source File: ListCordersListener.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
@Override
public HttpMethod getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 18
Source File: ListPurchaseApplyDetailsListener.java    From MicroCommunity with Apache License 2.0 4 votes vote down vote up
@Override
public HttpMethod getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 19
Source File: OAuth1Shim.java    From shimmer with Apache License 2.0 2 votes vote down vote up
protected HttpMethod getRequestTokenMethod() {

        return HttpMethod.GET;
    }
 
Example 20
Source File: AuthenticationSteps.java    From spring-vault with Apache License 2.0 2 votes vote down vote up
/**
 * Builder entry point to {@code GET} from {@code uri}.
 * @param uri must not be {@literal null}.
 * @return a new {@link HttpRequestBuilder}.
 */
public static HttpRequestBuilder get(URI uri) {
	return new HttpRequestBuilder(HttpMethod.GET, uri);
}