adam side

This commit is contained in:
gezvf
2017-09-13 17:27:41 +02:00
parent fd2b29260c
commit 9d7d3b6776
16 changed files with 306 additions and 74 deletions
@@ -0,0 +1,61 @@
package com.bayer.edam.migration;
import java.util.Collections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import com.bayer.edam.migration.mam.Entry;
@SpringBootApplication
@PropertySource("file:secret.properties")
public class MamMigrationSelective implements CommandLineRunner {
private static final Logger log = LoggerFactory.getLogger(MamMigrationSelective.class);
@Value("${mam.auth}")
private String mamAuth;
static int[] selection = {71048,70778,70746/*,70142,70361,63924,71263,63201,56942,57641,70745,70440,70340,70288,71725*/};
@Override
public void run(String... strings) throws Exception {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.add("Authorization", "Basic " + mamAuth);
headers.add("From", "migration@bayer.com");
headers.add("Content-Type", "application/json");
HttpEntity<String> entity = new HttpEntity<String>("Parameters", headers);
for (int id : selection) {
Entry entry = restTemplate
.exchange("https://service.media-assistant.animalhealth.bayer.com/rest/migration/entry/{id}",
HttpMethod.GET, entity, Entry.class, id)
.getBody();
migrate(entry);
}
}
void migrate(Entry entry) {
log.info("Migrating entry " + entry.id);
}
public static void main(String args[]) {
SpringApplication.run(MamMigrationSelective.class, args);
}
}