diff --git a/AH MAM Migration/.gitignore b/AH MAM Migration/.gitignore
index 09e3bc9..5ad78b1 100644
--- a/AH MAM Migration/.gitignore
+++ b/AH MAM Migration/.gitignore
@@ -1,2 +1,3 @@
/bin/
/target/
+/secret.properties
diff --git a/AH MAM Migration/pom.xml b/AH MAM Migration/pom.xml
index 64cfc7c..753b6bc 100644
--- a/AH MAM Migration/pom.xml
+++ b/AH MAM Migration/pom.xml
@@ -27,21 +27,12 @@
org.springframework.hateoas
spring-hateoas
- 0.23.0.RELEASE
src
-
- maven-compiler-plugin
- 3.6.1
-
- 1.8
- 1.8
-
-
org.springframework.boot
spring-boot-maven-plugin
diff --git a/AH MAM Migration/src/com/bayer/edam/migration/Application.java b/AH MAM Migration/src/com/bayer/edam/migration/Application.java
deleted file mode 100644
index cf8b218..0000000
--- a/AH MAM Migration/src/com/bayer/edam/migration/Application.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bayer.edam.migration;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.hateoas.MediaTypes;
-import org.springframework.hateoas.client.Traverson;
-
-public class Application {
-
- private static final Logger log = LoggerFactory.getLogger(Application.class);
-
- public static void main(String args[]) {
- Map parameters = new HashMap<>();
- parameters.put("user", 27);
-
- Traverson traverson;
- try {
- traverson = new Traverson(new URI("http://localhost:8080/api/"), MediaTypes.HAL_JSON);
- String name = traverson.follow("movies", "movie", "actor").withTemplateParameters(parameters).toObject("$.name");
-
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- }
-
-}
\ No newline at end of file
diff --git a/AH MAM Migration/src/com/bayer/edam/migration/Entry.java b/AH MAM Migration/src/com/bayer/edam/migration/Entry.java
new file mode 100644
index 0000000..9b0a556
--- /dev/null
+++ b/AH MAM Migration/src/com/bayer/edam/migration/Entry.java
@@ -0,0 +1,50 @@
+package com.bayer.edam.migration;
+
+public class Entry {
+
+ private Long id;
+ private String href;
+ private Long fileSize;
+ private String fileName;
+
+ public Entry() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public Long getFileSize() {
+ return fileSize;
+ }
+
+ public void setFileSize(Long fileSize) {
+ this.fileSize = fileSize;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public String toString() {
+ return "Entry{" + "id=" + id + ", fileName=" + fileName + '}';
+ }
+
+}
diff --git a/AH MAM Migration/src/com/bayer/edam/migration/MediaAssistantMigration.java b/AH MAM Migration/src/com/bayer/edam/migration/MediaAssistantMigration.java
new file mode 100644
index 0000000..9c3724d
--- /dev/null
+++ b/AH MAM Migration/src/com/bayer/edam/migration/MediaAssistantMigration.java
@@ -0,0 +1,35 @@
+package com.bayer.edam.migration;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+public class MediaAssistantMigration {
+
+ private static final Logger log = LoggerFactory.getLogger(MediaAssistantMigration.class);
+
+ public static void main(String args[]) {
+ SpringApplication.run(MediaAssistantMigration.class);
+ }
+
+ @Bean
+ public RestTemplate restTemplate(RestTemplateBuilder builder) {
+ builder.basicAuthorization("mam2adam", "B8LzciT.`12YxrJIZ72~X/V'");
+ return builder.build();
+ }
+
+ @Bean
+ public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
+ return args -> {
+ Entry entry = restTemplate.getForObject("https://qa.service.media-assistant.animalhealth.bayer.com/rest/migration/entry/204", Entry.class);
+ log.info(entry.toString());
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/AH MAM Migration/src/com/bayer/edam/migration/MediaAssistantMigrationSimple.java b/AH MAM Migration/src/com/bayer/edam/migration/MediaAssistantMigrationSimple.java
new file mode 100644
index 0000000..c89409f
--- /dev/null
+++ b/AH MAM Migration/src/com/bayer/edam/migration/MediaAssistantMigrationSimple.java
@@ -0,0 +1,80 @@
+package com.bayer.edam.migration;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Properties;
+
+import org.apache.log4j.Level;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import com.bayer.edam.migration.adam.Token;
+
+public class MediaAssistantMigrationSimple {
+
+ private static final Logger log = LoggerFactory.getLogger(MediaAssistantMigrationSimple.class);
+
+ public MediaAssistantMigrationSimple() {
+ Properties prop = new Properties();
+ InputStream input = null;
+ try {
+ input = new FileInputStream("secret.properties");
+ prop.load(input);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+
+ RestTemplate restTemplate = new RestTemplate();
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.add("Registration", "ADAMBAYER");
+ headers.add("API-VERSION", "1");
+ headers.add("Authorization", "Basic " + prop.getProperty("adam.auth"));
+ HttpEntity entity = new HttpEntity("Parameters", headers);
+ Token token = restTemplate.exchange("https://edam-q.bayer.com:2015/auth", HttpMethod.GET, entity, Token.class).getBody();
+
+ headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+// headers.add("Accept", "application/hal+json");
+ headers.add("Registration", "ADAMBAYER");
+ headers.add("API-VERSION", "1");
+ headers.add("Authorization", "Token " + token.getToken());
+ entity = new HttpEntity("Parameters", headers);
+ ResponseEntity r1 = restTemplate.exchange("https://edam-q.bayer.com:2015/record/28cadf7f5a504a1f9ef5a76300df3681", HttpMethod.GET, entity, String.class);
+ log.info(r1.toString());
+
+ headers = new HttpHeaders();
+ headers.add("Registration", "ADAMBAYER");
+ headers.add("API-VERSION", "1");
+ headers.add("Authorization", "Token " + token.getToken());
+ entity = new HttpEntity("Parameters", headers);
+ ResponseEntity rz = restTemplate.exchange("https://edam-q.bayer.com:2015/auth", HttpMethod.DELETE, entity, String.class);
+ log.info(rz.toString());
+
+ headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.add("Authorization", "Basic " + prop.getProperty("mam.auth"));
+ headers.add("From", "migration@bayer.com");
+ headers.add("Content-Type", "application/json");
+ entity = new HttpEntity("Parameters", headers);
+ ResponseEntity r2 = restTemplate.exchange("https://qa.service.media-assistant.animalhealth.bayer.com/rest/migration/entry/204", HttpMethod.GET, entity, Entry.class);
+ log.info(r2.getBody().toString());
+
+ }
+
+ public static void main(String args[]) {
+ new MediaAssistantMigrationSimple();
+ }
+
+}
diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/Record.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/Record.java
new file mode 100644
index 0000000..0ce2733
--- /dev/null
+++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/Record.java
@@ -0,0 +1,12 @@
+package com.bayer.edam.migration.adam;
+
+public class Record {
+
+ String id;
+
+ @Override
+ public String toString() {
+ return "Entry{" + "id=" + id + '}';
+ }
+
+}
diff --git a/AH MAM Migration/src/com/bayer/edam/migration/adam/Token.java b/AH MAM Migration/src/com/bayer/edam/migration/adam/Token.java
new file mode 100644
index 0000000..dd037e3
--- /dev/null
+++ b/AH MAM Migration/src/com/bayer/edam/migration/adam/Token.java
@@ -0,0 +1,32 @@
+package com.bayer.edam.migration.adam;
+
+public class Token {
+
+ private String message;
+ private String token;
+
+ public Token() {
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ @Override
+ public String toString() {
+ return "Token{" + "message=" + message + ", token=" + token + '}';
+ }
+
+}
diff --git a/AH MAM Migration/src/hello/Application.java b/AH MAM Migration/src/hello/Application.java
index 3a7f3af..e1d1448 100644
--- a/AH MAM Migration/src/hello/Application.java
+++ b/AH MAM Migration/src/hello/Application.java
@@ -2,17 +2,34 @@ package hello;
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.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
+@SpringBootApplication
public class Application {
- private static final Logger log = LoggerFactory.getLogger(Application.class);
+ private static final Logger log = LoggerFactory.getLogger(Application.class);
+
+ public static void main(String args[]) {
+ SpringApplication.run(Application.class);
+ }
- public static void main(String args[]) {
- RestTemplate restTemplate = new RestTemplate();
- Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
- restTemplate.
- log.info(quote.toString());
- }
+ @Bean
+ public RestTemplate restTemplate(RestTemplateBuilder builder) {
+ return builder.build();
+ }
+
+ @Bean
+ public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
+ return args -> {
+ Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
+ log.info(quote.toString());
+ };
+ }
}
\ No newline at end of file
diff --git a/AH MAM Migration/src/hello/ApplicationSimple.java b/AH MAM Migration/src/hello/ApplicationSimple.java
new file mode 100644
index 0000000..ef60367
--- /dev/null
+++ b/AH MAM Migration/src/hello/ApplicationSimple.java
@@ -0,0 +1,17 @@
+package hello;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.client.RestTemplate;
+
+public class ApplicationSimple {
+
+ private static final Logger log = LoggerFactory.getLogger(ApplicationSimple.class);
+
+ public static void main(String args[]) {
+ RestTemplate restTemplate = new RestTemplate();
+ Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
+ log.info(quote.toString());
+ }
+
+}