Replaced System.out.println, System.err.println and printStackTrace with a logger (ref #223)

This commit is contained in:
George Kalampokis 2020-01-16 17:46:24 +02:00
parent 476915b23c
commit ae84be5844
39 changed files with 228 additions and 128 deletions

View File

@ -1,5 +1,7 @@
package eu.eudat.data.converters; package eu.eudat.data.converters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.format.datetime.DateFormatter; import org.springframework.format.datetime.DateFormatter;
import javax.persistence.AttributeConverter; import javax.persistence.AttributeConverter;
@ -15,6 +17,7 @@ import java.util.TimeZone;
*/ */
@Converter @Converter
public class DateToUTCConverter implements AttributeConverter<Date, Date> { public class DateToUTCConverter implements AttributeConverter<Date, Date> {
private static final Logger logger = LoggerFactory.getLogger(DateToUTCConverter.class);
@Override @Override
public Date convertToDatabaseColumn(Date attribute) { public Date convertToDatabaseColumn(Date attribute) {
@ -25,7 +28,7 @@ public class DateToUTCConverter implements AttributeConverter<Date, Date> {
String date = formatterIST.format(attribute); String date = formatterIST.format(attribute);
return formatterIST.parse(date); return formatterIST.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return null; return null;
} }
@ -39,7 +42,7 @@ public class DateToUTCConverter implements AttributeConverter<Date, Date> {
String date = formatterIST.format(dbData); String date = formatterIST.format(dbData);
return formatterIST.parse(date); return formatterIST.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return null; return null;
} }

View File

@ -3,8 +3,11 @@ package eu.eudat.data.query.definition;
import eu.eudat.data.dao.criteria.Criteria; import eu.eudat.data.dao.criteria.Criteria;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class Query<C extends Criteria<T>, T extends DataEntity> implements CriteriaQuery<C, T> { public abstract class Query<C extends Criteria<T>, T extends DataEntity> implements CriteriaQuery<C, T> {
private static final Logger logger = LoggerFactory.getLogger(Query.class);
private C criteria; private C criteria;
private QueryableList<T> query; private QueryableList<T> query;
@ -33,10 +36,8 @@ public abstract class Query<C extends Criteria<T>, T extends DataEntity> impleme
q.setCriteria(criteria); q.setCriteria(criteria);
q.setQuery(query); q.setQuery(query);
return q; return q;
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace(); logger.error (e.getMessage(), e);
} catch (IllegalAccessException e) {
e.printStackTrace();
} }
return null; return null;
} }

View File

@ -1,6 +1,8 @@
package eu.eudat.elastic.entities; package eu.eudat.elastic.entities;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
@ -11,6 +13,7 @@ import java.util.Map;
* Created by ikalyvas on 7/5/2018. * Created by ikalyvas on 7/5/2018.
*/ */
public class Dataset implements ElasticEntity<Dataset> { public class Dataset implements ElasticEntity<Dataset> {
private static final Logger logger = LoggerFactory.getLogger(Dataset.class);
private String id; private String id;
private List<Tag> tags = new LinkedList<>(); private List<Tag> tags = new LinkedList<>();
@ -40,7 +43,7 @@ public class Dataset implements ElasticEntity<Dataset> {
try { try {
x.toElasticEntity(builder); x.toElasticEntity(builder);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
}); });
builder.endArray(); builder.endArray();

View File

@ -6,6 +6,8 @@ import eu.eudat.elastic.entities.ElasticEntity;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
@ -13,6 +15,7 @@ import java.io.IOException;
* Created by ikalyvas on 7/5/2018. * Created by ikalyvas on 7/5/2018.
*/ */
public abstract class ElasticRepository<T extends ElasticEntity,C extends Criteria> implements Repository<T,C> { public abstract class ElasticRepository<T extends ElasticEntity,C extends Criteria> implements Repository<T,C> {
private static final Logger logger = LoggerFactory.getLogger(ElasticRepository.class);
private RestHighLevelClient client; private RestHighLevelClient client;
public RestHighLevelClient getClient() { public RestHighLevelClient getClient() {
@ -29,7 +32,7 @@ public abstract class ElasticRepository<T extends ElasticEntity,C extends Criter
try { try {
item = mapper.readValue(value, tClass); item = mapper.readValue(value, tClass);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return item; return item;
} }

View File

@ -7,6 +7,8 @@ import eu.eudat.queryable.jpa.predicates.*;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -18,6 +20,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class QueryableHibernateList<T extends DataEntity> implements QueryableList<T> { public class QueryableHibernateList<T extends DataEntity> implements QueryableList<T> {
private static final Logger logger = LoggerFactory.getLogger(QueryableHibernateList.class);
private Collector collector = new Collector(); private Collector collector = new Collector();
private EntityManager manager; private EntityManager manager;
@ -264,7 +267,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
try { try {
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), this.fields, ""); return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), this.fields, "");
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return null; return null;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));

View File

@ -2,6 +2,8 @@ package eu.eudat.cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache; import org.springframework.cache.guava.GuavaCache;
@ -17,6 +19,7 @@ import java.util.concurrent.TimeUnit;
@Component @Component
@EnableCaching @EnableCaching
public class ResponsesCache { public class ResponsesCache {
private static final Logger logger = LoggerFactory.getLogger(ResponsesCache.class);
public static long HOW_MANY = 30; public static long HOW_MANY = 30;
public static TimeUnit TIME_UNIT = TimeUnit.MINUTES; public static TimeUnit TIME_UNIT = TimeUnit.MINUTES;
@ -24,7 +27,7 @@ public class ResponsesCache {
@Bean @Bean
public CacheManager cacheManager() { public CacheManager cacheManager() {
System.out.print("Loading ResponsesCache..."); logger.info("Loading ResponsesCache...");
SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
List<GuavaCache> caches = new ArrayList<GuavaCache>(); List<GuavaCache> caches = new ArrayList<GuavaCache>();
caches.add(new GuavaCache("repositories", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build())); caches.add(new GuavaCache("repositories", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
@ -38,7 +41,7 @@ public class ResponsesCache {
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build())); caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build())); caches.add(new GuavaCache("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
simpleCacheManager.setCaches(caches); simpleCacheManager.setCaches(caches);
System.out.println("OK"); logger.info("OK");
return simpleCacheManager; return simpleCacheManager;
} }

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicfunder.entities.Configuration;
import eu.eudat.configurations.dynamicfunder.entities.Property; import eu.eudat.configurations.dynamicfunder.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency; import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField; import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,6 +21,7 @@ import java.util.List;
@Service("dynamicFunderConfiguration") @Service("dynamicFunderConfiguration")
@Profile("devel") @Profile("devel")
public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfiguration { public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationDevelImpl.class);
private Configuration configuration; private Configuration configuration;
private List<DynamicField> fields; private List<DynamicField> fields;
@ -32,7 +35,7 @@ public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfigu
public Configuration getConfiguration() { public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration; if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl"); String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -43,13 +46,12 @@ public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfigu
is = new URL("file:///"+ current + "/web/src/main/resources/FunderConfiguration.xml").openStream(); is = new URL("file:///"+ current + "/web/src/main/resources/FunderConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
return this.configuration; return this.configuration;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicfunder.entities.Configuration;
import eu.eudat.configurations.dynamicfunder.entities.Property; import eu.eudat.configurations.dynamicfunder.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency; import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField; import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -20,6 +22,7 @@ import java.util.List;
@Service("dynamicFunderConfiguration") @Service("dynamicFunderConfiguration")
@Profile({ "production", "staging" }) @Profile({ "production", "staging" })
public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration { public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationProdImpl.class);
private Configuration configuration; private Configuration configuration;
private List<DynamicField> fields; private List<DynamicField> fields;
@ -33,7 +36,7 @@ public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfigur
public Configuration getConfiguration() { public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration; if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl"); String fileUrl = this.environment.getProperty("configuration.dynamicFunderUrl");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -44,13 +47,12 @@ public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfigur
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
return this.configuration; return this.configuration;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicgrant.entities.Configuration;
import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.configurations.dynamicgrant.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency; import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField; import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -24,6 +26,7 @@ import java.util.List;
@Service("dynamicGrantConfiguration") @Service("dynamicGrantConfiguration")
@Profile("devel") @Profile("devel")
public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfiguration { public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationDevelImpl.class);
private Configuration configuration; private Configuration configuration;
@ -40,7 +43,7 @@ public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfigura
public Configuration getConfiguration() { public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration; if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl"); String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -51,13 +54,12 @@ public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfigura
is = new URL("file:///"+ current + "/web/src/main/resources/GrantConfiguration.xml").openStream(); is = new URL("file:///"+ current + "/web/src/main/resources/GrantConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
return this.configuration; return this.configuration;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicgrant.entities.Configuration;
import eu.eudat.configurations.dynamicgrant.entities.Property; import eu.eudat.configurations.dynamicgrant.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency; import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField; import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -24,6 +26,7 @@ import java.util.List;
@Service("dynamicGrantConfiguration") @Service("dynamicGrantConfiguration")
@Profile({ "production", "staging" }) @Profile({ "production", "staging" })
public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration { public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationProdImpl.class);
private Configuration configuration; private Configuration configuration;
@ -40,7 +43,7 @@ public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfigurat
public Configuration getConfiguration() { public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration; if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl"); String fileUrl = this.environment.getProperty("configuration.dynamicGrantUrl");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -51,13 +54,12 @@ public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfigurat
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
return this.configuration; return this.configuration;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicproject.entities.Configuration;
import eu.eudat.configurations.dynamicproject.entities.Property; import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency; import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField; import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -20,6 +22,7 @@ import java.util.List;
@Service("dynamicProjectConfiguration") @Service("dynamicProjectConfiguration")
@Profile("devel") @Profile("devel")
public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfiguration{ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfiguration{
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationDevelImpl.class);
private Configuration configuration; private Configuration configuration;
private List<DynamicField> fields; private List<DynamicField> fields;
@ -34,7 +37,7 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
public Configuration getConfiguration() { public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration; if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl"); String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -45,13 +48,12 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
is = new URL("file:///"+ current + "/web/src/main/resources/ProjectConfiguration.xml").openStream(); is = new URL("file:///"+ current + "/web/src/main/resources/ProjectConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
return this.configuration; return this.configuration;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicproject.entities.Configuration;
import eu.eudat.configurations.dynamicproject.entities.Property; import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency; import eu.eudat.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField; import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -21,6 +23,7 @@ import java.util.List;
@Service("dynamicProjectConfiguration") @Service("dynamicProjectConfiguration")
@Profile({ "production", "staging" }) @Profile({ "production", "staging" })
public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationProdImpl.class);
private Configuration configuration; private Configuration configuration;
@ -37,7 +40,7 @@ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfig
public Configuration getConfiguration() { public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration; if (this.configuration != null) return this.configuration;
String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl"); String fileUrl = this.environment.getProperty("configuration.dynamicProjectUrl");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -48,13 +51,12 @@ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfig
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is); this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
return this.configuration; return this.configuration;

View File

@ -5,6 +5,8 @@ import eu.eudat.models.data.ContactEmail.ContactEmailModel;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -15,6 +17,7 @@ import javax.transaction.Transactional;
@CrossOrigin @CrossOrigin
@RequestMapping(value = "api/contactEmail") @RequestMapping(value = "api/contactEmail")
public class ContactEmail { public class ContactEmail {
private static final Logger logger = LoggerFactory.getLogger(ContactEmail.class);
private ContactEmailManager contactEmailManager; private ContactEmailManager contactEmailManager;
@ -31,7 +34,7 @@ public class ContactEmail {
this.contactEmailManager.sendContactEmail(contactEmailModel, principal); this.contactEmailManager.sendContactEmail(contactEmailModel, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error(ex.getMessage(), ex);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
} }
} }

View File

@ -29,6 +29,8 @@ import eu.eudat.models.data.security.Principal;
import eu.eudat.query.DMPQuery; import eu.eudat.query.DMPQuery;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities; import eu.eudat.types.Authorities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -55,6 +57,7 @@ import java.util.UUID;
@CrossOrigin @CrossOrigin
@RequestMapping(value = {"/api/dmps/"}) @RequestMapping(value = {"/api/dmps/"})
public class DMPs extends BaseController { public class DMPs extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DMPs.class);
private DynamicGrantConfiguration dynamicGrantConfiguration; private DynamicGrantConfiguration dynamicGrantConfiguration;
private Environment environment; private Environment environment;
@ -195,7 +198,7 @@ public class DMPs extends BaseController {
String name = file.getName().substring(0, file.getName().length() - 5); String name = file.getName().substring(0, file.getName().length() - 5);
File pdffile = datasetManager.convertToPDF(file, environment, name); File pdffile = datasetManager.convertToPDF(file, environment, name);
InputStream resource = new FileInputStream(pdffile); InputStream resource = new FileInputStream(pdffile);
System.out.println("Mime Type of " + file.getName() + " is " + logger.info("Mime Type of " + file.getName() + " is " +
new MimetypesFileTypeMap().getContentType(file)); new MimetypesFileTypeMap().getContentType(file));
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length()); responseHeaders.setContentLength(pdffile.length());
@ -269,7 +272,7 @@ public class DMPs extends BaseController {
String zenodoDOI = this.dataManagementPlanManager.createZenodoDoi(UUID.fromString(id), principal, configLoader); String zenodoDOI = this.dataManagementPlanManager.createZenodoDoi(UUID.fromString(id), principal, configLoader);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(zenodoDOI)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(zenodoDOI));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
} }
} }

View File

@ -19,6 +19,8 @@ import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -44,6 +46,7 @@ import static eu.eudat.types.Authorities.ANONYMOUS;
@CrossOrigin @CrossOrigin
@RequestMapping(value = {"api/datasetwizard"}) @RequestMapping(value = {"api/datasetwizard"})
public class DatasetWizardController extends BaseController { public class DatasetWizardController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DatasetWizardController.class);
private Environment environment; private Environment environment;
private DatasetManager datasetManager; private DatasetManager datasetManager;
@ -191,7 +194,7 @@ public class DatasetWizardController extends BaseController {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful."));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful.")); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).message("Import was unsuccessful."));
} }
} }

View File

@ -4,11 +4,12 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import eu.eudat.core.logger.Logger;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel; import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
@ -27,13 +28,14 @@ import java.util.Map;
@ControllerAdvice @ControllerAdvice
@Priority(5) @Priority(5)
public class ControllerErrorHandler { public class ControllerErrorHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerErrorHandler.class);
private Logger logger; // private Logger logger;
@Autowired /*@Autowired
public ControllerErrorHandler(Logger logger) { public ControllerErrorHandler(Logger logger) {
this.logger = logger; this.logger = logger;
} }*/
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
@ -49,12 +51,11 @@ public class ControllerErrorHandler {
exceptionMap.put("exception", json); exceptionMap.put("exception", json);
apiExceptionLoggingModel.setData(ow.writeValueAsString(exceptionMap)); apiExceptionLoggingModel.setData(ow.writeValueAsString(exceptionMap));
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
apiExceptionLoggingModel.setMessage(ex.getMessage()); apiExceptionLoggingModel.setMessage(ex.getMessage());
apiExceptionLoggingModel.setType(LoggingType.ERROR); apiExceptionLoggingModel.setType(LoggingType.ERROR);
ex.printStackTrace(); logger.error(ex.getMessage(), ex);
this.logger.error(apiExceptionLoggingModel);
return new ResponseItem<Exception>().message(ex.getMessage()).status(ApiMessageCode.DEFAULT_ERROR_MESSAGE); return new ResponseItem<Exception>().message(ex.getMessage()).status(ApiMessageCode.DEFAULT_ERROR_MESSAGE);
} }
} }

View File

@ -50,6 +50,8 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
@ -76,6 +78,7 @@ import java.util.stream.Collectors;
@Component @Component
public class DataManagementPlanManager { public class DataManagementPlanManager {
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanManager.class);
private ApiContext apiContext; private ApiContext apiContext;
private DatasetManager datasetManager; private DatasetManager datasetManager;
@ -309,7 +312,7 @@ public class DataManagementPlanManager {
try { try {
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService); wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
// Page break at the end of the Dataset. // Page break at the end of the Dataset.
XWPFParagraph parBreakDataset = document.createParagraph(); XWPFParagraph parBreakDataset = document.createParagraph();
@ -975,7 +978,7 @@ public class DataManagementPlanManager {
try { try {
mapper.writeValue(file, rdaExportModel); mapper.writeValue(file, rdaExportModel);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
InputStream resource = new FileInputStream(file); InputStream resource = new FileInputStream(file);
@ -1033,7 +1036,7 @@ public class DataManagementPlanManager {
DmpImportModel dmpImportModel = (DmpImportModel) jaxbUnmarshaller.unmarshal(in); DmpImportModel dmpImportModel = (DmpImportModel) jaxbUnmarshaller.unmarshal(in);
dataManagementPlans.add(dmpImportModel); dataManagementPlans.add(dmpImportModel);
} catch (IOException | JAXBException ex) { } catch (IOException | JAXBException ex) {
ex.printStackTrace(); logger.error(ex.getMessage(), ex);
} }
// TODO Iterate through the list of dataManagementPlans. // TODO Iterate through the list of dataManagementPlans.
// Creates new dataManagementPlan to fill it with the data model that was parsed from the xml. // Creates new dataManagementPlan to fill it with the data model that was parsed from the xml.
@ -1096,7 +1099,7 @@ public class DataManagementPlanManager {
//createOrUpdate(apiContext, dm, principal); //createOrUpdate(apiContext, dm, principal);
System.out.println(dm); logger.info(dm.toString());
} }
return dataManagementPlans; return dataManagementPlans;

View File

@ -21,6 +21,8 @@ import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -43,6 +45,7 @@ import org.w3c.dom.Element;
*/ */
@Component @Component
public class DataManagementProfileManager { public class DataManagementProfileManager {
private static final Logger logger = LoggerFactory.getLogger(DataManagementProfileManager.class);
private ApiContext apiContext; private ApiContext apiContext;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
@ -93,7 +96,7 @@ public class DataManagementProfileManager {
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException { public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(dmpProfile, label); FileEnvelope envelope = getXmlDocument(dmpProfile, label);
InputStream resource = new FileInputStream(envelope.getFile()); InputStream resource = new FileInputStream(envelope.getFile());
System.out.println("Mime Type of " + envelope.getFilename() + " is " + logger.info("Mime Type of " + envelope.getFilename() + " is " +
new MimetypesFileTypeMap().getContentType(envelope.getFile())); new MimetypesFileTypeMap().getContentType(envelope.getFile()));
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(envelope.getFile().length()); responseHeaders.setContentLength(envelope.getFile().length());
@ -124,7 +127,7 @@ public class DataManagementProfileManager {
try { try {
return xmlBuilder.build(convert(multiPartFile)); return xmlBuilder.build(convert(multiPartFile));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return null; return null;
} }

View File

@ -36,6 +36,8 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
@ -73,6 +75,7 @@ import java.util.zip.ZipInputStream;
@Component @Component
public class DatasetManager { public class DatasetManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetManager.class);
private ApiContext apiContext; private ApiContext apiContext;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
@ -544,7 +547,7 @@ public class DatasetManager {
public ResponseEntity<byte[]> getDocument(String id, VisibilityRuleService visibilityRuleService, String contentType) throws IllegalAccessException, IOException, InstantiationException { public ResponseEntity<byte[]> getDocument(String id, VisibilityRuleService visibilityRuleService, String contentType) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(id, visibilityRuleService); FileEnvelope envelope = getXmlDocument(id, visibilityRuleService);
InputStream resource = new FileInputStream(envelope.getFile()); InputStream resource = new FileInputStream(envelope.getFile());
System.out.println("Mime Type of " + envelope.getFilename() + " is " + logger.info("Mime Type of " + envelope.getFilename() + " is " +
new MimetypesFileTypeMap().getContentType(envelope.getFile())); new MimetypesFileTypeMap().getContentType(envelope.getFile()));
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(envelope.getFile().length()); responseHeaders.setContentLength(envelope.getFile().length());
@ -574,7 +577,7 @@ public class DatasetManager {
DatasetImportPagedDatasetProfile datasetImport = (DatasetImportPagedDatasetProfile) jaxbUnmarshaller.unmarshal(in); DatasetImportPagedDatasetProfile datasetImport = (DatasetImportPagedDatasetProfile) jaxbUnmarshaller.unmarshal(in);
importModel = datasetImport; importModel = datasetImport;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
// Checks if XML datasetProfileId GroupId matches the one selected. // Checks if XML datasetProfileId GroupId matches the one selected.
@ -585,7 +588,7 @@ public class DatasetManager {
throw new Exception(); throw new Exception();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} }

View File

@ -22,6 +22,8 @@ import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -41,6 +43,7 @@ import java.io.*;
@Component @Component
public class DatasetProfileManager { public class DatasetProfileManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
private ApiContext apiContext; private ApiContext apiContext;
private DatabaseRepository databaseRepository; private DatabaseRepository databaseRepository;
@ -119,7 +122,7 @@ public class DatasetProfileManager {
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException { public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(datasetProfile, label); FileEnvelope envelope = getXmlDocument(datasetProfile, label);
InputStream resource = new FileInputStream(envelope.getFile()); InputStream resource = new FileInputStream(envelope.getFile());
System.out.println("Mime Type of " + envelope.getFilename() + " is " + logger.info("Mime Type of " + envelope.getFilename() + " is " +
new MimetypesFileTypeMap().getContentType(envelope.getFile())); new MimetypesFileTypeMap().getContentType(envelope.getFile()));
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(envelope.getFile().length()); responseHeaders.setContentLength(envelope.getFile().length());
@ -151,7 +154,7 @@ public class DatasetProfileManager {
try { try {
return xmlBuilder.build(convert(multiPartFile)); return xmlBuilder.build(convert(multiPartFile));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return null; return null;
} }

View File

@ -13,6 +13,8 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*; import org.springframework.http.*;
@ -36,6 +38,7 @@ import java.util.zip.ZipInputStream;
*/ */
@Service @Service
public class DocumentManager { public class DocumentManager {
private static final Logger logger = LoggerFactory.getLogger(DocumentManager.class);
private ApiContext context; private ApiContext context;
private DatasetManager datasetManager; private DatasetManager datasetManager;
@ -104,12 +107,12 @@ public class DocumentManager {
Map mediaResult = new RestTemplate().getForObject(environment.getProperty("pdf.converter.url") + Map mediaResult = new RestTemplate().getForObject(environment.getProperty("pdf.converter.url") +
"/api/v1/" + queueResult.get("id"), Map.class); "/api/v1/" + queueResult.get("id"), Map.class);
System.out.println("Status: " + mediaResult.get("status")); logger.info("Status: " + mediaResult.get("status"));
while (!mediaResult.get("status").equals("finished")) { while (!mediaResult.get("status").equals("finished")) {
Thread.sleep(500); Thread.sleep(500);
mediaResult = new RestTemplate().getForObject(environment.getProperty("pdf.converter.url") + mediaResult = new RestTemplate().getForObject(environment.getProperty("pdf.converter.url") +
"api/v1/" + queueResult.get("id"), Map.class); "api/v1/" + queueResult.get("id"), Map.class);
System.out.println("Polling"); logger.info("Polling");
} }
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter()); restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());

View File

@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.proxy.config.ExternalUrls; import eu.eudat.logic.proxy.config.ExternalUrls;
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders; import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -33,6 +35,7 @@ import java.util.stream.Collectors;
@Service("configLoader") @Service("configLoader")
@Profile("devel") @Profile("devel")
public class DevelConfigLoader implements ConfigLoader { public class DevelConfigLoader implements ConfigLoader {
private static final Logger logger = LoggerFactory.getLogger(DevelConfigLoader.class);
private ExternalUrls externalUrls; private ExternalUrls externalUrls;
private List<String> rdaProperties; private List<String> rdaProperties;
@ -45,7 +48,7 @@ public class DevelConfigLoader implements ConfigLoader {
private void setExternalUrls() { private void setExternalUrls() {
String fileUrl = this.environment.getProperty("configuration.externalUrls"); String fileUrl = this.environment.getProperty("configuration.externalUrls");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
InputStream is = null; InputStream is = null;
try { try {
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class); JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
@ -53,13 +56,12 @@ public class DevelConfigLoader implements ConfigLoader {
is = getClass().getClassLoader().getResource(fileUrl).openStream(); is = getClass().getClassLoader().getResource(fileUrl).openStream();
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is); externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find resource in classpath", ex);
System.err.println("Cannot find resource in classpath");
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
System.err.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
} }
@ -77,7 +79,7 @@ public class DevelConfigLoader implements ConfigLoader {
} }
reader.close(); reader.close();
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
rdaProperties = rdaList; rdaProperties = rdaList;
@ -90,12 +92,12 @@ public class DevelConfigLoader implements ConfigLoader {
is = getClass().getClassLoader().getResource(filePath).openStream(); is = getClass().getClassLoader().getResource(filePath).openStream();
this.document = new XWPFDocument(is); this.document = new XWPFDocument(is);
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.err.println("Warning: Could not close a stream after reading from file: " + filePath); logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
} }
} }
} }
@ -108,19 +110,19 @@ public class DevelConfigLoader implements ConfigLoader {
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.configurableProviders = mapper.readValue(is, ConfigurableProviders.class); this.configurableProviders = mapper.readValue(is, ConfigurableProviders.class);
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.err.println("Warning: Could not close a stream after reading from file: " + filePath); logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
} }
} }
} }
private void setKeyToSourceMap() { private void setKeyToSourceMap() {
String filePath = this.environment.getProperty("configuration.externalUrls"); String filePath = this.environment.getProperty("configuration.externalUrls");
System.out.println("Loaded also config file: " + filePath); logger.info("Loaded also config file: " + filePath);
Document doc = getXmlDocumentFromFilePath(filePath); Document doc = getXmlDocumentFromFilePath(filePath);
if (doc == null) { if (doc == null) {
this.keyToSourceMap = null; this.keyToSourceMap = null;
@ -177,14 +179,14 @@ public class DevelConfigLoader implements ConfigLoader {
doc = documentBuilder.parse(is); doc = documentBuilder.parse(is);
return doc; return doc;
} catch (IOException | ParserConfigurationException | SAXException | NullPointerException e) { } catch (IOException | ParserConfigurationException | SAXException | NullPointerException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} finally { } finally {
try { try {
if (is != null) { if (is != null) {
is.close(); is.close();
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + filePath); logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
} }
} }
return null; return null;
@ -197,7 +199,7 @@ public class DevelConfigLoader implements ConfigLoader {
try { try {
nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET); nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
} catch (XPathExpressionException e) { } catch (XPathExpressionException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
if (nodeList != null) { if (nodeList != null) {
for (int i = 0; i < nodeList.getLength(); i++) { for (int i = 0; i < nodeList.getLength(); i++) {

View File

@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.proxy.config.ExternalUrls; import eu.eudat.logic.proxy.config.ExternalUrls;
import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders; import eu.eudat.logic.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -34,6 +36,7 @@ import java.util.stream.Collectors;
@Service("configLoader") @Service("configLoader")
@Profile({ "production", "staging" }) @Profile({ "production", "staging" })
public class ProductionConfigLoader implements ConfigLoader { public class ProductionConfigLoader implements ConfigLoader {
private static final Logger logger = LoggerFactory.getLogger(ProductionConfigLoader.class);
private ExternalUrls externalUrls; private ExternalUrls externalUrls;
private List<String> rdaProperties; private List<String> rdaProperties;
@ -46,7 +49,7 @@ public class ProductionConfigLoader implements ConfigLoader {
private void setExternalUrls() { private void setExternalUrls() {
String fileUrl = this.environment.getProperty("configuration.externalUrls"); String fileUrl = this.environment.getProperty("configuration.externalUrls");
System.out.println("Loaded also config file: " + fileUrl); logger.info("Loaded also config file: " + fileUrl);
String current = null; String current = null;
InputStream is = null; InputStream is = null;
try { try {
@ -57,13 +60,12 @@ public class ProductionConfigLoader implements ConfigLoader {
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is); externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error("Cannot find in folder" + current, ex);
System.out.println("Cannot find in folder" + current);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + fileUrl); logger.warn("Warning: Could not close a stream after reading from file: " + fileUrl, e);
} }
} }
} }
@ -81,7 +83,7 @@ public class ProductionConfigLoader implements ConfigLoader {
} }
reader.close(); reader.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
rdaProperties = rdaList; rdaProperties = rdaList;
@ -94,12 +96,12 @@ public class ProductionConfigLoader implements ConfigLoader {
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream(); is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
this.document = new XWPFDocument(is); this.document = new XWPFDocument(is);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + filePath); logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
} }
} }
} }
@ -117,18 +119,18 @@ public class ProductionConfigLoader implements ConfigLoader {
this.configurableProviders = new ConfigurableProviders(); this.configurableProviders = new ConfigurableProviders();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} finally { } finally {
try { try {
if (is != null) is.close(); if (is != null) is.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + filePath); logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
} }
} }
} }
private void setKeyToSourceMap() { private void setKeyToSourceMap() {
String filePath = this.environment.getProperty("configuration.externalUrls"); String filePath = this.environment.getProperty("configuration.externalUrls");
System.out.println("Loaded also config file: " + filePath); logger.info("Loaded also config file: " + filePath);
Document doc = getXmlDocumentFromFilePath(filePath); Document doc = getXmlDocumentFromFilePath(filePath);
if (doc == null) { if (doc == null) {
this.keyToSourceMap = null; this.keyToSourceMap = null;
@ -183,14 +185,14 @@ public class ProductionConfigLoader implements ConfigLoader {
doc = documentBuilder.parse(is); doc = documentBuilder.parse(is);
return doc; return doc;
} catch (IOException | ParserConfigurationException | SAXException e) { } catch (IOException | ParserConfigurationException | SAXException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} finally { } finally {
try { try {
if (is != null) { if (is != null) {
is.close(); is.close();
} }
} catch (IOException e) { } catch (IOException e) {
System.out.println("Warning: Could not close a stream after reading from file: " + filePath); logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
} }
} }
return null; return null;
@ -203,7 +205,7 @@ public class ProductionConfigLoader implements ConfigLoader {
try { try {
nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET); nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
} catch (XPathExpressionException e) { } catch (XPathExpressionException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
if (nodeList != null) { if (nodeList != null) {
for (int i = 0; i < nodeList.getLength(); i++) { for (int i = 0; i < nodeList.getLength(); i++) {

View File

@ -8,6 +8,8 @@ import eu.eudat.logic.proxy.config.*;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader; import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -25,6 +27,7 @@ import java.util.stream.Collectors;
@Service @Service
public class RemoteFetcher { public class RemoteFetcher {
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
private ConfigLoader configLoader; private ConfigLoader configLoader;
@ -163,7 +166,7 @@ public class RemoteFetcher {
try { try {
funderId = URLEncoder.encode(externalUrlCriteria.getFunderId(), "UTF-8"); funderId = URLEncoder.encode(externalUrlCriteria.getFunderId(), "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
completedPath = completedPath.replace("{funderId}", funderId); completedPath = completedPath.replace("{funderId}", funderId);
} }
@ -251,13 +254,13 @@ public class RemoteFetcher {
return results; return results;
} }
} catch (MalformedURLException e1) { } catch (MalformedURLException e1) {
e1.printStackTrace(); logger.error(e1.getMessage(), e1);
} //maybe print smth... } //maybe print smth...
catch (IOException e2) { catch (IOException e2) {
e2.printStackTrace(); logger.error(e2.getMessage(), e2);
} //maybe print smth... } //maybe print smth...
catch (Exception exception) { catch (Exception exception) {
exception.printStackTrace(); logger.error(exception.getMessage(), exception);
} //maybe print smth... } //maybe print smth...
finally { finally {
} }
@ -273,7 +276,7 @@ public class RemoteFetcher {
internalResults = mapper.readValue(new File(filePath), new TypeReference<List<Map<String, Object>>>(){}); internalResults = mapper.readValue(new File(filePath), new TypeReference<List<Map<String, Object>>>(){});
return searchListMap(internalResults, query); return searchListMap(internalResults, query);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return new LinkedList<>(); return new LinkedList<>();
} }
} }

View File

@ -6,6 +6,8 @@ import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.models.data.login.LoginInfo; import eu.eudat.models.data.login.LoginInfo;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.logic.security.validators.TokenValidatorFactory; import eu.eudat.logic.security.validators.TokenValidatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -14,6 +16,7 @@ import java.security.GeneralSecurityException;
@Component @Component
public class CustomAuthenticationProvider { public class CustomAuthenticationProvider {
private static final Logger logger = LoggerFactory.getLogger(CustomAuthenticationProvider.class);
@Autowired @Autowired
@ -25,14 +28,13 @@ public class CustomAuthenticationProvider {
Principal principal = this.tokenValidatorFactory.getProvider(credentials.getProvider()).validateToken(credentials); Principal principal = this.tokenValidatorFactory.getProvider(credentials.getProvider()).validateToken(credentials);
return principal; return principal;
} catch (NonValidTokenException e) { } catch (NonValidTokenException e) {
e.printStackTrace(); logger.error("Could not validate a user by his token! Reason: " + e.getMessage(), e);
System.out.println("Could not validate a user by his token! Reason: " + e.getMessage());
throw new UnauthorisedException("Token validation failed - Not a valid token"); throw new UnauthorisedException("Token validation failed - Not a valid token");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
throw new UnauthorisedException("IO Exeption"); throw new UnauthorisedException("IO Exeption");
} catch (NullEmailException e) { } catch (NullEmailException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
throw new NullEmailException(); throw new NullEmailException();
} }
} }

View File

@ -2,6 +2,8 @@ package eu.eudat.logic.services.helpers;
import eu.eudat.exceptions.files.TempFileNotFoundException; import eu.eudat.exceptions.files.TempFileNotFoundException;
import eu.eudat.models.data.files.ContentFile; import eu.eudat.models.data.files.ContentFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
@ -22,6 +24,7 @@ import java.util.UUID;
*/ */
@Service("fileStorageService") @Service("fileStorageService")
public class FileStorageServiceImpl implements FileStorageService { public class FileStorageServiceImpl implements FileStorageService {
private static final Logger logger = LoggerFactory.getLogger(FileStorageServiceImpl.class);
private Environment environment; private Environment environment;
@ -68,7 +71,7 @@ public class FileStorageServiceImpl implements FileStorageService {
Files.createDirectory(Paths.get(environment.getProperty("files.storage.final"))); Files.createDirectory(Paths.get(environment.getProperty("files.storage.final")));
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }

View File

@ -15,12 +15,15 @@ import eu.eudat.models.data.loginprovider.LoginProviderUser;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.types.Authorities; import eu.eudat.types.Authorities;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
public abstract class AbstractAuthenticationService implements AuthenticationService { public abstract class AbstractAuthenticationService implements AuthenticationService {
private static final Logger logger = LoggerFactory.getLogger(AbstractAuthenticationService.class);
protected ApiContext apiContext; protected ApiContext apiContext;
protected Environment environment; protected Environment environment;
@ -86,7 +89,7 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
try { try {
credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret()); credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} }
} }

View File

@ -1,9 +1,10 @@
package eu.eudat.logic.services.utilities; package eu.eudat.logic.services.utilities;
import eu.eudat.core.logger.Logger;
import eu.eudat.data.dao.entities.LoginConfirmationEmailDao; import eu.eudat.data.dao.entities.LoginConfirmationEmailDao;
import eu.eudat.data.entities.LoginConfirmationEmail; import eu.eudat.data.entities.LoginConfirmationEmail;
import eu.eudat.models.data.mail.SimpleMail; import eu.eudat.models.data.mail.SimpleMail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,11 +14,12 @@ import java.util.concurrent.CompletableFuture;
@Service("ConfirmationEmailService") @Service("ConfirmationEmailService")
public class ConfirmationEmailServiceImpl implements ConfirmationEmailService { public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
private Logger logger; private static final Logger logger = LoggerFactory.getLogger(ConfirmationEmailServiceImpl.class);
//private Logger logger;
private Environment environment; private Environment environment;
public ConfirmationEmailServiceImpl(Logger logger, Environment environment) { public ConfirmationEmailServiceImpl(/*Logger logger,*/ Environment environment) {
this.logger = logger; // this.logger = logger;
this.environment = environment; this.environment = environment;
} }
@ -48,8 +50,7 @@ public class ConfirmationEmailServiceImpl implements ConfirmationEmailService {
try { try {
mailService.sendSimpleMail(mail); mailService.sendSimpleMail(mail);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error(ex.getMessage(), ex);
this.logger.error(ex, ex.getMessage());
} }
}); });
} }

View File

@ -1,6 +1,5 @@
package eu.eudat.logic.services.utilities; package eu.eudat.logic.services.utilities;
import eu.eudat.core.logger.Logger;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel; import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
import eu.eudat.data.dao.entities.DMPDao; import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.dao.entities.InvitationDao; import eu.eudat.data.dao.entities.InvitationDao;
@ -8,6 +7,8 @@ import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Invitation; import eu.eudat.data.entities.Invitation;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.models.data.mail.SimpleMail; import eu.eudat.models.data.mail.SimpleMail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -25,13 +26,13 @@ import java.util.stream.Collectors;
@Service("invitationService") @Service("invitationService")
public class InvitationServiceImpl implements InvitationService { public class InvitationServiceImpl implements InvitationService {
private static final Logger logger = LoggerFactory.getLogger(InvitationServiceImpl.class);
private Logger logger; // private Logger logger;
private Environment environment; private Environment environment;
@Autowired @Autowired
public InvitationServiceImpl(Logger logger, Environment environment) { public InvitationServiceImpl(/*Logger logger,*/ Environment environment) {
this.logger = logger; // this.logger = logger;
this.environment = environment; this.environment = environment;
} }
@ -75,8 +76,7 @@ public class InvitationServiceImpl implements InvitationService {
try { try {
mailService.sendSimpleMail(mail); mailService.sendSimpleMail(mail);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); logger.error(ex.getMessage(), ex);
this.logger.error(ex, ex.getMessage());
} }
}); });
} }

View File

@ -2,6 +2,8 @@ package eu.eudat.logic.services.utilities;
import eu.eudat.models.data.mail.SimpleMail; import eu.eudat.models.data.mail.SimpleMail;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -17,6 +19,7 @@ import java.io.*;
@Service("mailService") @Service("mailService")
public class MailServiceImpl implements MailService { public class MailServiceImpl implements MailService {
private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class);
private Environment env; private Environment env;
@ -54,7 +57,7 @@ public class MailServiceImpl implements MailService {
IOUtils.copy(inputStream, writer, "UTF-8"); IOUtils.copy(inputStream, writer, "UTF-8");
return writer.toString(); return writer.toString();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return ""; return "";
} }

View File

@ -5,6 +5,8 @@ import eu.eudat.models.data.components.commons.datafield.*;
import eu.eudat.models.data.entities.xmlmodels.modeldefinition.DatabaseModelDefinition; import eu.eudat.models.data.entities.xmlmodels.modeldefinition.DatabaseModelDefinition;
import eu.eudat.logic.utilities.interfaces.ModelDefinition; import eu.eudat.logic.utilities.interfaces.ModelDefinition;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition; import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.LinkedList; import java.util.LinkedList;
@ -12,15 +14,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class ModelBuilder { public class ModelBuilder {
private static final Logger logger = LoggerFactory.getLogger(ModelBuilder.class);
public <U extends ModelDefinition<T>, T extends DatabaseModelDefinition> List<T> toModelDefinition(List<U> items, Class<T> clazz) { public <U extends ModelDefinition<T>, T extends DatabaseModelDefinition> List<T> toModelDefinition(List<U> items, Class<T> clazz) {
List<T> list = new LinkedList<T>(); List<T> list = new LinkedList<T>();
for (U item : items) { for (U item : items) {
try { try {
list.add(item.toDatabaseDefinition(clazz.newInstance())); list.add(item.toDatabaseDefinition(clazz.newInstance()));
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }
return list; return list;
@ -32,9 +35,9 @@ public class ModelBuilder {
try { try {
list.add(item.toDatabaseDefinition(clazz.newInstance())); list.add(item.toDatabaseDefinition(clazz.newInstance()));
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }
return list; return list;
@ -48,9 +51,9 @@ public class ModelBuilder {
modelItem.fromDatabaseDefinition(item); modelItem.fromDatabaseDefinition(item);
list.add(modelItem); list.add(modelItem);
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }
return list; return list;

View File

@ -1,5 +1,7 @@
package eu.eudat.logic.utilities.builders; package eu.eudat.logic.utilities.builders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -21,6 +23,7 @@ import java.io.StringWriter;
public class XmlBuilder { public class XmlBuilder {
private static final Logger logger = LoggerFactory.getLogger(XmlBuilder.class);
public static Document getDocument() { public static Document getDocument() {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
@ -31,7 +34,7 @@ public class XmlBuilder {
return doc; return doc;
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} }
} }
@ -48,7 +51,7 @@ public class XmlBuilder {
return writer.toString(); return writer.toString();
} catch (TransformerException e) { } catch (TransformerException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} }
} }
@ -63,7 +66,7 @@ public class XmlBuilder {
return doc; return doc;
} catch (ParserConfigurationException | SAXException | IOException e) { } catch (ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} }
} }

View File

@ -19,6 +19,8 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLvl; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLvl;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STNumberFormat; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STNumberFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
@ -27,6 +29,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class WordBuilder { public class WordBuilder {
private static final Logger logger = LoggerFactory.getLogger(WordBuilder.class);
private Map<ParagraphStyle, ApplierWithValue<XWPFDocument, String, XWPFParagraph>> options = new HashMap<>(); private Map<ParagraphStyle, ApplierWithValue<XWPFDocument, String, XWPFParagraph>> options = new HashMap<>();
private CTAbstractNum cTAbstractNum; private CTAbstractNum cTAbstractNum;
@ -186,7 +189,7 @@ public class WordBuilder {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent)); number.setVal(BigInteger.valueOf(indent));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }
} }

View File

@ -1,5 +1,7 @@
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml; package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile; import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
@ -7,6 +9,7 @@ import javax.xml.bind.Unmarshaller;
import java.io.*; import java.io.*;
public class ImportXmlBuilderDatasetProfile { public class ImportXmlBuilderDatasetProfile {
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDatasetProfile.class);
public DatasetProfile build(File xmlFile) throws IOException { public DatasetProfile build(File xmlFile) throws IOException {
DatasetProfile datasetProfile = new DatasetProfile(); DatasetProfile datasetProfile = new DatasetProfile();
@ -16,7 +19,7 @@ public class ImportXmlBuilderDatasetProfile {
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
datasetProfile = (DatasetProfile) unmarshaller.unmarshal(xmlFile); datasetProfile = (DatasetProfile) unmarshaller.unmarshal(xmlFile);
} catch (JAXBException e) { } catch (JAXBException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return datasetProfile; return datasetProfile;

View File

@ -1,6 +1,8 @@
package eu.eudat.logic.utilities.documents.xml.dmpXml; package eu.eudat.logic.utilities.documents.xml.dmpXml;
import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile; import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
@ -9,6 +11,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
public class ImportXmlBuilderDmpProfile { public class ImportXmlBuilderDmpProfile {
private static final Logger logger = LoggerFactory.getLogger(ImportXmlBuilderDmpProfile.class);
public DmpProfile build(File xmlFile) throws IOException { public DmpProfile build(File xmlFile) throws IOException {
DmpProfile dmpProfile = new DmpProfile(); DmpProfile dmpProfile = new DmpProfile();
@ -18,7 +21,7 @@ public class ImportXmlBuilderDmpProfile {
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
dmpProfile = (DmpProfile) unmarshaller.unmarshal(xmlFile); dmpProfile = (DmpProfile) unmarshaller.unmarshal(xmlFile);
} catch (JAXBException e) { } catch (JAXBException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return dmpProfile; return dmpProfile;

View File

@ -1,16 +1,20 @@
package eu.eudat.models; package eu.eudat.models;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HintedModelFactory { public class HintedModelFactory {
private static final Logger logger = LoggerFactory.getLogger(HintedModelFactory.class);
public static <T extends DataModel> String getHint(Class<T> clazz) { public static <T extends DataModel> String getHint(Class<T> clazz) {
try { try {
return clazz.newInstance().getHint(); return clazz.newInstance().getHint();
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
return null; return null;
} }
} }

View File

@ -2,11 +2,14 @@ package eu.eudat.models.data.dmp;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.logic.utilities.helpers.LabelGenerator; import eu.eudat.logic.utilities.helpers.LabelGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
public class Researcher implements DataModel<eu.eudat.data.entities.Researcher, Researcher>, LabelGenerator { public class Researcher implements DataModel<eu.eudat.data.entities.Researcher, Researcher>, LabelGenerator {
private static final Logger logger = LoggerFactory.getLogger(Researcher.class);
private String label; private String label;
private String name; private String name;
private String id; private String id;
@ -104,7 +107,7 @@ public class Researcher implements DataModel<eu.eudat.data.entities.Researcher,
try { try {
throw new Exception("Researcher has no key value"); throw new Exception("Researcher has no key value");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }

View File

@ -2,12 +2,15 @@ package eu.eudat.models.data.external;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsExternalSourcesModel> { public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsExternalSourcesModel> {
private static final Logger logger = LoggerFactory.getLogger(ProjectsExternalSourcesModel.class);
private static final ObjectMapper mapper = new ObjectMapper(); private static final ObjectMapper mapper = new ObjectMapper();
@Override @Override
@ -61,7 +64,7 @@ public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsEx
this.add(model); this.add(model);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
} }
return this; return this;

View File

@ -9,6 +9,8 @@ import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.utilities.builders.XmlBuilder; import eu.eudat.logic.utilities.builders.XmlBuilder;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@ -20,6 +22,7 @@ import java.util.*;
import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.groupingBy;
public class DatasetRDAExportModel { public class DatasetRDAExportModel {
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAExportModel.class);
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
private Map<String, String> multiplicityIdToFieldSetId = new HashMap<>(); private Map<String, String> multiplicityIdToFieldSetId = new HashMap<>();
@ -165,7 +168,7 @@ public class DatasetRDAExportModel {
String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(dataset.getId().toString()).getDatasetProfileDefinition()); String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(dataset.getId().toString()).getDatasetProfileDefinition());
datasetDescriptionJson = new JSONObject(jsonResult); datasetDescriptionJson = new JSONObject(jsonResult);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
setMultiplicityIdToFieldSetId(datasetDescriptionJson); setMultiplicityIdToFieldSetId(datasetDescriptionJson);
@ -461,7 +464,7 @@ public class DatasetRDAExportModel {
valuesList.add(node.getNodeValue()); valuesList.add(node.getNodeValue());
} }
} catch (XPathExpressionException e) { } catch (XPathExpressionException e) {
e.printStackTrace(); logger.error(e.getMessage(), e);
} }
return valuesList; return valuesList;