adam side
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.bayer.edam.migration;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
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;
|
||||
|
||||
import com.bayer.edam.migration.mam.Entry;
|
||||
|
||||
@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", "XXXXXXXXXX");
|
||||
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());
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package com.bayer.edam.migration;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
|
||||
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;
|
||||
@@ -16,10 +16,10 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.bayer.edam.migration.adam.ReadRecord;
|
||||
import com.bayer.edam.migration.adam.Token;
|
||||
import com.bayer.edam.migration.mam.Entry;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MediaAssistantMigrationSimple {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MediaAssistantMigrationSimple.class);
|
||||
@@ -46,14 +46,29 @@ public class MediaAssistantMigrationSimple {
|
||||
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.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());
|
||||
headers.add("Content-Type", "application/json");
|
||||
entity = new HttpEntity<String>("Parameters", headers);
|
||||
ResponseEntity<String> r1 = restTemplate.exchange("https://edam-q.bayer.com:2015/record/28cadf7f5a504a1f9ef5a76300df3681", HttpMethod.GET, entity, String.class);
|
||||
log.info(r1.toString());
|
||||
|
||||
ResponseEntity<String> r1 = restTemplate.exchange("https://edam-q.bayer.com:2015/record/f46147866c6f49f690ffa7900097b861", HttpMethod.GET, entity, String.class);
|
||||
log.info(r1.getBody().toString());
|
||||
|
||||
ResponseEntity<ReadRecord> r2 = restTemplate.exchange("https://edam-q.bayer.com:2015/record/f46147866c6f49f690ffa7900097b861", HttpMethod.GET, entity, ReadRecord.class);
|
||||
log.info(r2.getBody().toString());
|
||||
|
||||
HttpEntity<String> newRecord = new HttpEntity<String>("{\"contentType\": \"Record\"}", headers);
|
||||
URI location = restTemplate.postForLocation("https://edam-q.bayer.com:2015/records", newRecord);
|
||||
log.info("Location: " + location);
|
||||
|
||||
// log.info("Entity: " + entity.getBody());
|
||||
|
||||
// ResponseEntity<String> r3 = restTemplate.exchange("https://edam-q.bayer.com:2015/records", HttpMethod.POST, newRecord)
|
||||
|
||||
|
||||
|
||||
headers = new HttpHeaders();
|
||||
headers.add("Registration", "ADAMBAYER");
|
||||
@@ -69,8 +84,8 @@ public class MediaAssistantMigrationSimple {
|
||||
headers.add("From", "migration@bayer.com");
|
||||
headers.add("Content-Type", "application/json");
|
||||
entity = new HttpEntity<String>("Parameters", headers);
|
||||
ResponseEntity<Entry> r2 = restTemplate.exchange("https://service.media-assistant.animalhealth.bayer.com/rest/migration/entry/71948", HttpMethod.GET, entity, Entry.class);
|
||||
log.info(r2.toString());
|
||||
ResponseEntity<Entry> m1 = restTemplate.exchange("https://service.media-assistant.animalhealth.bayer.com/rest/migration/entry/71948", HttpMethod.GET, entity, Entry.class);
|
||||
log.info(m1.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.bayer.edam.migration.adam;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ReadRecord {
|
||||
|
||||
public String id;
|
||||
public String contentType;
|
||||
public Date modifiedOn;
|
||||
public Date createdOn;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Record{" + "id=" + id + " contentType=" + contentType + ", modifiedOn=" + modifiedOn + ", createdOn=" + createdOn + "}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.bayer.edam.migration.adam;
|
||||
|
||||
public class Record {
|
||||
|
||||
String id;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Entry{" + "id=" + id + '}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.bayer.edam.migration.adam;
|
||||
|
||||
public class WriteRecord {
|
||||
|
||||
|
||||
public static class Classification {
|
||||
public String id;
|
||||
public Integer sortIndex;
|
||||
|
||||
public Classification() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Classifications {
|
||||
public Classification[] addOrUpdate;
|
||||
|
||||
public Classifications() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Field {
|
||||
public String id;
|
||||
|
||||
public Field() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Fields {
|
||||
public Field[] addOrUpdate;
|
||||
|
||||
public Fields() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String contentType = "Record";
|
||||
public Classifications classifications;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bayer.edam.migration.mam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Category {
|
||||
|
||||
public Long id;
|
||||
public Integer parent;
|
||||
public Map<String, String> name;
|
||||
|
||||
public Category() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,11 +6,11 @@ import java.util.Map;
|
||||
|
||||
public class Entry {
|
||||
|
||||
public static class MediaType {
|
||||
public static class Type {
|
||||
public Long id;
|
||||
public Map<String, String> name;
|
||||
|
||||
public MediaType() {
|
||||
public Type() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,15 +98,15 @@ public class Entry {
|
||||
public Map<String, String> comment;
|
||||
public Map<String, String> user;
|
||||
public Map<String, String> uploader;
|
||||
public String indexer;
|
||||
public Map<String, String> indexer;
|
||||
public Double ratingValue;
|
||||
public Map<String, String> release;
|
||||
public String brandingNet;
|
||||
public MediaType mediaType;
|
||||
public Type mediaType;
|
||||
public Copyright copyright;
|
||||
public String master;
|
||||
public Map<String, String> project;
|
||||
public String imageType;
|
||||
public Type imageType;
|
||||
// public String gpc;
|
||||
public String mediaAssistantId;
|
||||
public Map<String, String> metaData;
|
||||
@@ -121,8 +121,8 @@ public class Entry {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Entry{" + "id=" + id + ", fileName=" + fileName + ", creationDate=" + creationDate + ", name="
|
||||
+ name.get("en") + ", user=" + user.get("id") + ", copyright.organization.id=" + copyright.organization.get("id") + '}';
|
||||
return "Entry{" + "id=" + id + ", name=" + name.get("en") + ", creationDate=" + creationDate + ", user="
|
||||
+ user.get("id") + ", copyright.organization.id=" + copyright.organization.get("id") + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.bayer.edam.migration.mam;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class EntrySimple {
|
||||
|
||||
public Long id;
|
||||
public String href;
|
||||
public Long fileSize;
|
||||
public String fileName;
|
||||
public Date creationDate;
|
||||
public Date uploadDate;
|
||||
public Map<String, String> name;
|
||||
public Map<String, String> keyword;
|
||||
public Map<String, String> description;
|
||||
public Map<String, String> comment;
|
||||
public Map<String, String> user;
|
||||
public Map<String, String> uploader;
|
||||
public Map<String, String> indexer;
|
||||
// public Double ratingValue;
|
||||
// public Map<String, String> release;
|
||||
// public String brandingNet;
|
||||
|
||||
public EntrySimple() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Entry{" + "id=" + id + ", href=" + href + '}';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user