List of usage examples for org.springframework.http HttpStatus FOUND
HttpStatus FOUND
To view the source code for org.springframework.http HttpStatus FOUND.
Click Source Link
From source file:org.springframework.social.facebook.api.impl.FacebookTemplate.java
public byte[] fetchImage(String objectId, String connectionType, ImageType type) { URI uri = URIBuilder/*from w ww.j av a2 s .c o m*/ .fromUri(GRAPH_API_URL + objectId + "/" + connectionType + "?type=" + type.toString().toLowerCase()) .build(); ResponseEntity<byte[]> response = getRestTemplate().getForEntity(uri, byte[].class); if (response.getStatusCode() == HttpStatus.FOUND) { throw new UnsupportedOperationException( "Attempt to fetch image resulted in a redirect which could not be followed. Add Apache HttpComponents HttpClient to the classpath " + "to be able to follow redirects."); } return response.getBody(); }
From source file:org.talend.dataprep.api.service.command.dataset.DataSetPreview.java
public DataSetPreview(String dataSetId, boolean metadata, String sheetName) { super(GenericCommand.TRANSFORM_GROUP); execute(() -> onExecute(dataSetId, metadata, sheetName)); onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_RETRIEVE_DATASET_CONTENT, e, ExceptionContext.build().put("id", dataSetId))); on(HttpStatus.ACCEPTED, HttpStatus.NO_CONTENT).then(emptyStream()); on(HttpStatus.OK).then(pipeStream()); // Move permanently/temporarily behaviors BiFunction<HttpRequestBase, HttpResponse, InputStream> move = (req, res) -> { Exception cause = new Exception(res.getStatusLine().getStatusCode() + ":" // + res.getStatusLine().getReasonPhrase()); throw new TDPException(APIErrorCodes.DATASET_REDIRECT, cause, ExceptionContext.build().put("id", dataSetId)); };//from ww w. j a v a 2s.c o m on(HttpStatus.MOVED_PERMANENTLY, HttpStatus.FOUND).then(move); }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.ExecuteServiceHandlerTest.java
@Test public void testHandleWithMapInputsPost() { ExecuteServiceData edata = new ExecuteServiceData(); String serviceId = "8"; edata.setServiceId(serviceId);//www . ja v a 2 s .c o m HashMap<String, DataType> dataInputs = new HashMap<String, DataType>(); TextDataType tdt = new TextDataType(); tdt.content = "Marge"; dataInputs.put("name", tdt); edata.setDataInputs(dataInputs); URI uri = URI.create("http://localhost:8082/string/toUpper"); Mockito.when(serviceMock.getUrl()).thenReturn(uri.toString()); Mockito.when(accessorMock.getServiceById(serviceId)).thenReturn(service); Mockito.doNothing().when(loggerMock).log(Mockito.anyString(), Mockito.anyString()); when(restTemplateMock.postForEntity(Mockito.eq(uri), Mockito.any(Object.class), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<String>("testExecuteService", HttpStatus.FOUND)); MongoAccessor mockMongo = mock(MongoAccessor.class); when(mockMongo.getServiceById("8")).thenReturn(service); ResponseEntity<String> retVal = executeServiceHandler.handle(edata); assertTrue(retVal.getBody().contains("testExecuteService")); }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.ExecuteServiceHandlerTest.java
/** * Tests executing web service with GET method *///ww w.ja v a2 s . com @Test public void testHandleWithMapInputsGet() { ExecuteServiceData edata = new ExecuteServiceData(); String serviceId = "a842aae2-bd74-4c4b-9a65-c45e8cd9060f"; edata.setServiceId(serviceId); HashMap<String, DataType> dataInputs = new HashMap<String, DataType>(); URLParameterDataType tdt = new URLParameterDataType(); tdt.content = "Marge"; dataInputs.put("name", tdt); edata.setDataInputs(dataInputs); ObjectMapper mapper = new ObjectMapper(); try { String tsvc = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(edata); System.out.println(tsvc); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); } URI uri = URI.create("http://localhost:8087/jumpstart/moviequotewelcome?name=Marge"); Mockito.when(serviceMock.getUrl()).thenReturn(uri.toString()); Mockito.when(accessorMock.getServiceById(serviceId)).thenReturn(movieService); Mockito.doNothing().when(loggerMock).log(Mockito.anyString(), Mockito.anyString()); Mockito.when(restTemplateMock.getForEntity(Mockito.eq(uri), Mockito.eq(String.class))) .thenReturn(new ResponseEntity<String>("testExecuteService", HttpStatus.FOUND)); when(accessorMock.getServiceById(serviceId)).thenReturn(movieService); ResponseEntity<String> retVal = executeServiceHandler.handle(edata); assertTrue(retVal.getBody().contains("testExecuteService")); }