Java tutorial
package it.reply.orchestrator.service; /* * Copyright 2015-2017 Santer Reply S.p.A. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import it.reply.orchestrator.dto.slam.SlamPreferences; import it.reply.orchestrator.exception.service.DeploymentException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @Service @PropertySource("classpath:slam/slam.properties") public class SlamServiceImpl implements SlamService { @Autowired private RestTemplate restTemplate; @Value("${slam.url}") private String url; @Value("${preferences}") private String preferences; @Override public String getUrl() { return url; } @Override public SlamPreferences getCustomerPreferences() { ResponseEntity<SlamPreferences> response = restTemplate .getForEntity(url.concat(preferences).concat("/indigo-dc"), SlamPreferences.class); if (response.getStatusCode().is2xxSuccessful()) { return response.getBody(); } throw new DeploymentException("Unable to find SLAM preferences. " + response.getStatusCode().toString() + " " + response.getStatusCode().getReasonPhrase()); } }