Skip to content

Commit 5229d3a

Browse files
committed
minor changes
1 parent e38989b commit 5229d3a

File tree

14 files changed

+39
-152
lines changed

14 files changed

+39
-152
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencies {
5252
implementation 'javax.validation:validation-api:2.0.1.Final'
5353
implementation 'edu.kit.datamanager:service-base:1.0.4'
5454

55-
testImplementation(platform('org.junit:junit-bom:5.9.0'))
55+
testImplementation platform('org.junit:junit-bom:5.9.0')
5656
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
5757
testImplementation 'org.junit.jupiter:junit-jupiter-migrationsupport:5.9.0'
5858
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.3'

src/main/java/edu/kit/datamanager/mappingservice/MappingServiceApplication.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,24 @@
11
package edu.kit.datamanager.mappingservice;
22

3-
import com.fasterxml.jackson.annotation.JsonInclude;
4-
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import com.fasterxml.jackson.databind.SerializationFeature;
6-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
73
import edu.kit.datamanager.mappingservice.configuration.ApplicationProperties;
84
import edu.kit.datamanager.mappingservice.plugins.PluginManager;
95
import edu.kit.datamanager.mappingservice.util.PythonRunnerUtil;
106
import org.slf4j.Logger;
117
import org.slf4j.LoggerFactory;
12-
import org.springframework.beans.factory.InjectionPoint;
138
import org.springframework.boot.SpringApplication;
149
import org.springframework.boot.autoconfigure.SpringBootApplication;
1510
import org.springframework.boot.autoconfigure.domain.EntityScan;
1611
import org.springframework.boot.context.properties.ConfigurationProperties;
1712
import org.springframework.context.annotation.Bean;
18-
import org.springframework.context.annotation.ComponentScan;
1913
import org.springframework.context.annotation.Configuration;
20-
import org.springframework.context.annotation.Scope;
21-
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
22-
import org.springframework.scheduling.annotation.EnableScheduling;
2314

2415
@SpringBootApplication
25-
@EnableScheduling
26-
@ComponentScan({"edu.kit.datamanager.mappingservice", "edu.kit.datamanager.configuration"})
2716
@EntityScan("edu.kit.datamanager")
28-
@ComponentScan
2917
@Configuration
3018
public class MappingServiceApplication {
3119

3220
private static final Logger LOG = LoggerFactory.getLogger(MappingServiceApplication.class);
3321

34-
// @Bean
35-
// @Scope("prototype")
36-
// public Logger logger(InjectionPoint injectionPoint) {
37-
// Class<?> targetClass = injectionPoint.getMember().getDeclaringClass();
38-
// return LoggerFactory.getLogger(targetClass.getCanonicalName());
39-
// }
40-
41-
// @Bean(name = "OBJECT_MAPPER_BEAN")
42-
// public ObjectMapper jsonObjectMapper() {
43-
// return Jackson2ObjectMapperBuilder.json()
44-
// .serializationInclusion(JsonInclude.Include.NON_EMPTY) // Don’t include null values
45-
// .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) //ISODate
46-
// .modules(new JavaTimeModule())
47-
// .build();
48-
// }
49-
5022
@Bean
5123
@ConfigurationProperties("repo")
5224
public ApplicationProperties applicationProperties() {

src/main/java/edu/kit/datamanager/mappingservice/configuration/JPAPersistenceConfig.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/java/edu/kit/datamanager/mappingservice/dao/IAclEntryDao.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/edu/kit/datamanager/mappingservice/impl/MappingService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public class MappingService {
5151
/**
5252
* Repo holding all MappingRecords.
5353
*/
54-
@Autowired
55-
private IMappingRecordDao mappingRepo;
54+
private final IMappingRecordDao mappingRepo;
5655
/**
5756
* Path to directory holding all mapping files.
5857
*/
@@ -64,8 +63,9 @@ public class MappingService {
6463
private final static Logger LOGGER = LoggerFactory.getLogger(MappingService.class);
6564

6665
@Autowired
67-
public MappingService(ApplicationProperties applicationProperties) {
66+
public MappingService(ApplicationProperties applicationProperties, IMappingRecordDao mappingRepo) {
6867
init(applicationProperties);
68+
this.mappingRepo = mappingRepo;
6969
}
7070

7171
/**

src/main/java/edu/kit/datamanager/mappingservice/plugins/PluginLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public static Map<String, IMappingPlugin> loadPlugins(File plugDir) throws IOExc
6464
List<IMappingPlugin> IMappingPluginList = PluginLoader.createPluggableObjects(plugClasses);
6565
Map<String, IMappingPlugin> result = new HashMap<>();
6666
for (IMappingPlugin i : IMappingPluginList) {
67-
System.out.println("Found Plugin: " + i.id());
6867
i.setup();
6968
result.put(i.id(), i);
7069
}

src/main/java/edu/kit/datamanager/mappingservice/plugins/PluginManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package edu.kit.datamanager.mappingservice.plugins;
1717

18-
import edu.kit.datamanager.mappingservice.util.ShellRunnerUtil;
1918
import org.slf4j.Logger;
2019
import org.slf4j.LoggerFactory;
2120

@@ -119,7 +118,6 @@ public List<String> getListOfAvailableValidators() {
119118
public MappingPluginState mapFile(String pluginId, Path mappingFile, Path inputFile, Path outputFile) throws MappingPluginException {
120119
for (var entry : plugins.entrySet()) {
121120
if (entry.getKey().equals(pluginId)) {
122-
ShellRunnerUtil.run("cat", inputFile.toString());
123121
return entry.getValue().mapFile(mappingFile, inputFile, outputFile);
124122
}
125123
}

src/main/java/edu/kit/datamanager/mappingservice/rest/impl/MappingAdministrationController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public ResponseEntity createMapping(@RequestPart(name = "record") final Multipar
163163
locationUri = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(this.getClass()).getMappingById(recordDocument.getMappingId())).toUri();
164164

165165
LOG.trace("Schema record successfully persisted. Returning result.");
166+
LOG.info("Successfully created mapping record with id '{}' and type '{}'.", recordDocument.getMappingId(), recordDocument.getMappingType());
166167
return ResponseEntity.created(locationUri).eTag("\"" + etag + "\"").body(recordDocument);
167168
}
168169

@@ -243,6 +244,7 @@ public ResponseEntity deleteMapping(@PathVariable(value = "mappingId") String ma
243244
throw new MappingException("Unknown error removing map!");
244245
}
245246

247+
LOG.info("Successfully deleted mapping record with id '{}'.", mappingId);
246248
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
247249
}
248250

@@ -298,6 +300,7 @@ public ResponseEntity updateMapping(@PathVariable(value = "mappingId") String ma
298300
URI locationUri;
299301
locationUri = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(this.getClass()).getMappingById(recordDocument.getMappingId())).toUri();
300302

303+
LOG.info("Successfully updated mapping record with id '{}' and type '{}'.", recordDocument.getMappingId(), recordDocument.getMappingType());
301304
return ResponseEntity.ok().location(locationUri).eTag("\"" + etag + "\"").body(recordDocument);
302305
}
303306

@@ -339,6 +342,13 @@ public MappingRecord getMappingById(String mappingId) throws ResourceNotFoundExc
339342
return record.get();
340343
}
341344

345+
/**
346+
* This method merges two MappingRecords.
347+
*
348+
* @param managed The existing MappingRecord.
349+
* @param provided The MappingRecord to merge.
350+
* @return The merged MappingRecord.
351+
*/
342352
public MappingRecord mergeRecords(MappingRecord managed, MappingRecord provided) {
343353
if (provided != null) {
344354
if (provided.getTitle() != null) {

src/main/java/edu/kit/datamanager/mappingservice/rest/impl/MappingExecutionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import edu.kit.datamanager.mappingservice.impl.MappingService;
2121
import edu.kit.datamanager.mappingservice.rest.IMappingExecutionController;
2222
import edu.kit.datamanager.mappingservice.util.FileUtil;
23-
import edu.kit.datamanager.mappingservice.util.ShellRunnerUtil;
2423
import org.slf4j.Logger;
2524
import org.slf4j.LoggerFactory;
2625
import org.springframework.core.io.FileSystemResource;
@@ -104,6 +103,7 @@ public ResponseEntity mapDocument(MultipartFile document, String mappingID, Http
104103
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Internal error while accessing result");
105104
}
106105

106+
LOG.info("Successfully mapped document with mapping {}.", mappingID);
107107
return ResponseEntity.ok().header(HttpHeaders.CONTENT_LENGTH, String.valueOf(resultPath.toFile().length())).body(new FileSystemResource(resultPath.toFile()));
108108
}
109109
}

src/main/java/edu/kit/datamanager/mappingservice/util/FileUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static void removeFile(Path tempFile) {
165165

166166
private static String guessFileExtension(byte[] schema) {
167167
// Cut schema to a maximum of MAX_LENGTH_OF_HEADER characters.
168-
int length = schema.length > MAX_LENGTH_OF_HEADER ? MAX_LENGTH_OF_HEADER : schema.length;
168+
int length = Math.min(schema.length, MAX_LENGTH_OF_HEADER);
169169
String schemaAsString = new String(schema, 0, length);
170170
LOGGER.trace("Guess type for '{}'", schemaAsString);
171171

@@ -189,7 +189,7 @@ private static String guessFileExtension(byte[] schema) {
189189
* @return the path to the cloned repository
190190
*/
191191
public static Path cloneGitRepository(String repositoryUrl, String branch) {
192-
File target = new File("lib/" + repositoryUrl.trim().substring(repositoryUrl.length() - 7, repositoryUrl.length() - 1) + "_" + branch);
192+
File target = new File("lib/" + repositoryUrl.trim().replace("https://", "").replace(".git", "") + "_" + branch);
193193
target.mkdirs();
194194

195195
LOGGER.info("Cloning branch '{}' of repository '{}' to '{}'", branch, repositoryUrl, target.getPath());

0 commit comments

Comments
 (0)