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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,8 @@ package eu.eudat.cache;
import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache;
@ -17,6 +19,7 @@ import java.util.concurrent.TimeUnit;
@Component
@EnableCaching
public class ResponsesCache {
private static final Logger logger = LoggerFactory.getLogger(ResponsesCache.class);
public static long HOW_MANY = 30;
public static TimeUnit TIME_UNIT = TimeUnit.MINUTES;
@ -24,7 +27,7 @@ public class ResponsesCache {
@Bean
public CacheManager cacheManager() {
System.out.print("Loading ResponsesCache...");
logger.info("Loading ResponsesCache...");
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
List<GuavaCache> caches = new ArrayList<GuavaCache>();
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("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
simpleCacheManager.setCaches(caches);
System.out.println("OK");
logger.info("OK");
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.models.data.dynamicfields.Dependency;
import eu.eudat.models.data.dynamicfields.DynamicField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
@ -19,6 +21,7 @@ import java.util.List;
@Service("dynamicFunderConfiguration")
@Profile("devel")
public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationDevelImpl.class);
private Configuration configuration;
private List<DynamicField> fields;
@ -32,7 +35,7 @@ public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfigu
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
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;
InputStream is = null;
try {
@ -43,13 +46,12 @@ public class DynamicFunderConfigurationDevelImpl implements DynamicFunderConfigu
is = new URL("file:///"+ current + "/web/src/main/resources/FunderConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
logger.error("Cannot find in folder" + current, ex);
} finally {
try {
if (is != null) is.close();
} 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;

View File

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

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicgrant.entities.Configuration;
import eu.eudat.configurations.dynamicgrant.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency;
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.context.annotation.Profile;
import org.springframework.core.env.Environment;
@ -24,6 +26,7 @@ import java.util.List;
@Service("dynamicGrantConfiguration")
@Profile("devel")
public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationDevelImpl.class);
private Configuration configuration;
@ -40,7 +43,7 @@ public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfigura
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
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;
InputStream is = null;
try {
@ -51,13 +54,12 @@ public class DynamicGrantConfigurationDevelImpl implements DynamicGrantConfigura
is = new URL("file:///"+ current + "/web/src/main/resources/GrantConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
logger.error("Cannot find in folder" + current, ex);
} finally {
try {
if (is != null) is.close();
} 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;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicgrant.entities.Configuration;
import eu.eudat.configurations.dynamicgrant.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency;
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.context.annotation.Profile;
import org.springframework.core.env.Environment;
@ -24,6 +26,7 @@ import java.util.List;
@Service("dynamicGrantConfiguration")
@Profile({ "production", "staging" })
public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationProdImpl.class);
private Configuration configuration;
@ -40,7 +43,7 @@ public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfigurat
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
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;
InputStream is = null;
try {
@ -51,13 +54,12 @@ public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfigurat
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
logger.error("Cannot find in folder" + current, ex);
} finally {
try {
if (is != null) is.close();
} 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;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicproject.entities.Configuration;
import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency;
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.context.annotation.Profile;
import org.springframework.core.env.Environment;
@ -20,6 +22,7 @@ import java.util.List;
@Service("dynamicProjectConfiguration")
@Profile("devel")
public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfiguration{
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationDevelImpl.class);
private Configuration configuration;
private List<DynamicField> fields;
@ -34,7 +37,7 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
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;
InputStream is = null;
try {
@ -45,13 +48,12 @@ public class DynamicProjectConfigurationDevelImpl implements DynamicProjectConfi
is = new URL("file:///"+ current + "/web/src/main/resources/ProjectConfiguration.xml").openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
logger.error("Cannot find in folder" + current, ex);
} finally {
try {
if (is != null) is.close();
} 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;

View File

@ -4,6 +4,8 @@ import eu.eudat.configurations.dynamicproject.entities.Configuration;
import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.models.data.dynamicfields.Dependency;
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.context.annotation.Profile;
import org.springframework.core.env.Environment;
@ -21,6 +23,7 @@ import java.util.List;
@Service("dynamicProjectConfiguration")
@Profile({ "production", "staging" })
public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationProdImpl.class);
private Configuration configuration;
@ -37,7 +40,7 @@ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfig
public Configuration getConfiguration() {
if (this.configuration != null) return this.configuration;
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;
InputStream is = null;
try {
@ -48,13 +51,12 @@ public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfig
is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
this.configuration = (Configuration) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
logger.error("Cannot find in folder" + current, ex);
} finally {
try {
if (is != null) is.close();
} 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;

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.security.Principal;
import eu.eudat.types.ApiMessageCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@ -15,6 +17,7 @@ import javax.transaction.Transactional;
@CrossOrigin
@RequestMapping(value = "api/contactEmail")
public class ContactEmail {
private static final Logger logger = LoggerFactory.getLogger(ContactEmail.class);
private ContactEmailManager contactEmailManager;
@ -31,7 +34,7 @@ public class ContactEmail {
this.contactEmailManager.sendContactEmail(contactEmailModel, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
} 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()));
}
}

View File

@ -29,6 +29,8 @@ import eu.eudat.models.data.security.Principal;
import eu.eudat.query.DMPQuery;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
@ -55,6 +57,7 @@ import java.util.UUID;
@CrossOrigin
@RequestMapping(value = {"/api/dmps/"})
public class DMPs extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DMPs.class);
private DynamicGrantConfiguration dynamicGrantConfiguration;
private Environment environment;
@ -195,7 +198,7 @@ public class DMPs extends BaseController {
String name = file.getName().substring(0, file.getName().length() - 5);
File pdffile = datasetManager.convertToPDF(file, environment, name);
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));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
@ -269,7 +272,7 @@ public class DMPs extends BaseController {
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));
} 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()));
}
}

View File

@ -19,6 +19,8 @@ import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.types.ApiMessageCode;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
@ -44,6 +46,7 @@ import static eu.eudat.types.Authorities.ANONYMOUS;
@CrossOrigin
@RequestMapping(value = {"api/datasetwizard"})
public class DatasetWizardController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(DatasetWizardController.class);
private Environment environment;
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."));
}
} 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."));
}
}

View File

@ -4,11 +4,12 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import eu.eudat.core.logger.Logger;
import eu.eudat.core.models.exception.ApiExceptionLoggingModel;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
@ -27,13 +28,14 @@ import java.util.Map;
@ControllerAdvice
@Priority(5)
public class ControllerErrorHandler {
private static final Logger logger = LoggerFactory.getLogger(ControllerErrorHandler.class);
private Logger logger;
// private Logger logger;
@Autowired
/*@Autowired
public ControllerErrorHandler(Logger logger) {
this.logger = logger;
}
}*/
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ -49,12 +51,11 @@ public class ControllerErrorHandler {
exceptionMap.put("exception", json);
apiExceptionLoggingModel.setData(ow.writeValueAsString(exceptionMap));
} catch (JsonProcessingException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
apiExceptionLoggingModel.setMessage(ex.getMessage());
apiExceptionLoggingModel.setType(LoggingType.ERROR);
ex.printStackTrace();
this.logger.error(apiExceptionLoggingModel);
logger.error(ex.getMessage(), ex);
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.XWPFRun;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
@ -76,6 +78,7 @@ import java.util.stream.Collectors;
@Component
public class DataManagementPlanManager {
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanManager.class);
private ApiContext apiContext;
private DatasetManager datasetManager;
@ -309,7 +312,7 @@ public class DataManagementPlanManager {
try {
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
// Page break at the end of the Dataset.
XWPFParagraph parBreakDataset = document.createParagraph();
@ -975,7 +978,7 @@ public class DataManagementPlanManager {
try {
mapper.writeValue(file, rdaExportModel);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
InputStream resource = new FileInputStream(file);
@ -1033,7 +1036,7 @@ public class DataManagementPlanManager {
DmpImportModel dmpImportModel = (DmpImportModel) jaxbUnmarshaller.unmarshal(in);
dataManagementPlans.add(dmpImportModel);
} catch (IOException | JAXBException ex) {
ex.printStackTrace();
logger.error(ex.getMessage(), ex);
}
// TODO Iterate through the list of dataManagementPlans.
// 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);
System.out.println(dm);
logger.info(dm.toString());
}
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.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@ -43,6 +45,7 @@ import org.w3c.dom.Element;
*/
@Component
public class DataManagementProfileManager {
private static final Logger logger = LoggerFactory.getLogger(DataManagementProfileManager.class);
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
@ -93,7 +96,7 @@ public class DataManagementProfileManager {
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(dmpProfile, label);
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()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(envelope.getFile().length());
@ -124,7 +127,7 @@ public class DataManagementProfileManager {
try {
return xmlBuilder.build(convert(multiPartFile));
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
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.XWPFRun;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
@ -73,6 +75,7 @@ import java.util.zip.ZipInputStream;
@Component
public class DatasetManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetManager.class);
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
@ -544,7 +547,7 @@ public class DatasetManager {
public ResponseEntity<byte[]> getDocument(String id, VisibilityRuleService visibilityRuleService, String contentType) throws IllegalAccessException, IOException, InstantiationException {
FileEnvelope envelope = getXmlDocument(id, visibilityRuleService);
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()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(envelope.getFile().length());
@ -574,7 +577,7 @@ public class DatasetManager {
DatasetImportPagedDatasetProfile datasetImport = (DatasetImportPagedDatasetProfile) jaxbUnmarshaller.unmarshal(in);
importModel = datasetImport;
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
// Checks if XML datasetProfileId GroupId matches the one selected.
@ -585,7 +588,7 @@ public class DatasetManager {
throw new Exception();
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
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.queryable.QueryableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
@ -41,6 +43,7 @@ import java.io.*;
@Component
public class DatasetProfileManager {
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
private ApiContext apiContext;
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 {
FileEnvelope envelope = getXmlDocument(datasetProfile, label);
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()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(envelope.getFile().length());
@ -151,7 +154,7 @@ public class DatasetProfileManager {
try {
return xmlBuilder.build(convert(multiPartFile));
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
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.poi.xwpf.usermodel.XWPFDocument;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
@ -36,6 +38,7 @@ import java.util.zip.ZipInputStream;
*/
@Service
public class DocumentManager {
private static final Logger logger = LoggerFactory.getLogger(DocumentManager.class);
private ApiContext context;
private DatasetManager datasetManager;
@ -104,12 +107,12 @@ public class DocumentManager {
Map mediaResult = new RestTemplate().getForObject(environment.getProperty("pdf.converter.url") +
"/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")) {
Thread.sleep(500);
mediaResult = new RestTemplate().getForObject(environment.getProperty("pdf.converter.url") +
"api/v1/" + queueResult.get("id"), Map.class);
System.out.println("Polling");
logger.info("Polling");
}
RestTemplate restTemplate = new RestTemplate();
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.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
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.context.annotation.Profile;
import org.springframework.core.env.Environment;
@ -33,6 +35,7 @@ import java.util.stream.Collectors;
@Service("configLoader")
@Profile("devel")
public class DevelConfigLoader implements ConfigLoader {
private static final Logger logger = LoggerFactory.getLogger(DevelConfigLoader.class);
private ExternalUrls externalUrls;
private List<String> rdaProperties;
@ -45,7 +48,7 @@ public class DevelConfigLoader implements ConfigLoader {
private void setExternalUrls() {
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;
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ExternalUrls.class);
@ -53,13 +56,12 @@ public class DevelConfigLoader implements ConfigLoader {
is = getClass().getClassLoader().getResource(fileUrl).openStream();
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.err.println("Cannot find resource in classpath");
logger.error("Cannot find resource in classpath", ex);
} finally {
try {
if (is != null) is.close();
} 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();
} catch (IOException | NullPointerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
rdaProperties = rdaList;
@ -90,12 +92,12 @@ public class DevelConfigLoader implements ConfigLoader {
is = getClass().getClassLoader().getResource(filePath).openStream();
this.document = new XWPFDocument(is);
} catch (IOException | NullPointerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
try {
if (is != null) is.close();
} 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);
this.configurableProviders = mapper.readValue(is, ConfigurableProviders.class);
} catch (IOException | NullPointerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
try {
if (is != null) is.close();
} 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() {
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);
if (doc == null) {
this.keyToSourceMap = null;
@ -177,14 +179,14 @@ public class DevelConfigLoader implements ConfigLoader {
doc = documentBuilder.parse(is);
return doc;
} catch (IOException | ParserConfigurationException | SAXException | NullPointerException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
try {
if (is != null) {
is.close();
}
} 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;
@ -197,7 +199,7 @@ public class DevelConfigLoader implements ConfigLoader {
try {
nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
if (nodeList != null) {
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.security.customproviders.ConfigurableProvider.entities.ConfigurableProviders;
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.context.annotation.Profile;
import org.springframework.core.env.Environment;
@ -34,6 +36,7 @@ import java.util.stream.Collectors;
@Service("configLoader")
@Profile({ "production", "staging" })
public class ProductionConfigLoader implements ConfigLoader {
private static final Logger logger = LoggerFactory.getLogger(ProductionConfigLoader.class);
private ExternalUrls externalUrls;
private List<String> rdaProperties;
@ -46,7 +49,7 @@ public class ProductionConfigLoader implements ConfigLoader {
private void setExternalUrls() {
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;
InputStream is = null;
try {
@ -57,13 +60,12 @@ public class ProductionConfigLoader implements ConfigLoader {
externalUrls = (ExternalUrls) jaxbUnmarshaller.unmarshal(is);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find in folder" + current);
logger.error("Cannot find in folder" + current, ex);
} finally {
try {
if (is != null) is.close();
} 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();
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
rdaProperties = rdaList;
@ -94,12 +96,12 @@ public class ProductionConfigLoader implements ConfigLoader {
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
this.document = new XWPFDocument(is);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
try {
if (is != null) is.close();
} 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();
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
try {
if (is != null) is.close();
} 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() {
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);
if (doc == null) {
this.keyToSourceMap = null;
@ -183,14 +185,14 @@ public class ProductionConfigLoader implements ConfigLoader {
doc = documentBuilder.parse(is);
return doc;
} catch (IOException | ParserConfigurationException | SAXException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} finally {
try {
if (is != null) {
is.close();
}
} 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;
@ -203,7 +205,7 @@ public class ProductionConfigLoader implements ConfigLoader {
try {
nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
if (nodeList != null) {
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.exceptions.HugeResultSet;
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.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@ -25,6 +27,7 @@ import java.util.stream.Collectors;
@Service
public class RemoteFetcher {
private static final Logger logger = LoggerFactory.getLogger(RemoteFetcher.class);
private ConfigLoader configLoader;
@ -163,7 +166,7 @@ public class RemoteFetcher {
try {
funderId = URLEncoder.encode(externalUrlCriteria.getFunderId(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
completedPath = completedPath.replace("{funderId}", funderId);
}
@ -251,13 +254,13 @@ public class RemoteFetcher {
return results;
}
} catch (MalformedURLException e1) {
e1.printStackTrace();
logger.error(e1.getMessage(), e1);
} //maybe print smth...
catch (IOException e2) {
e2.printStackTrace();
logger.error(e2.getMessage(), e2);
} //maybe print smth...
catch (Exception exception) {
exception.printStackTrace();
logger.error(exception.getMessage(), exception);
} //maybe print smth...
finally {
}
@ -273,7 +276,7 @@ public class RemoteFetcher {
internalResults = mapper.readValue(new File(filePath), new TypeReference<List<Map<String, Object>>>(){});
return searchListMap(internalResults, query);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
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.security.Principal;
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.stereotype.Component;
@ -14,6 +16,7 @@ import java.security.GeneralSecurityException;
@Component
public class CustomAuthenticationProvider {
private static final Logger logger = LoggerFactory.getLogger(CustomAuthenticationProvider.class);
@Autowired
@ -25,14 +28,13 @@ public class CustomAuthenticationProvider {
Principal principal = this.tokenValidatorFactory.getProvider(credentials.getProvider()).validateToken(credentials);
return principal;
} catch (NonValidTokenException e) {
e.printStackTrace();
System.out.println("Could not validate a user by his token! Reason: " + e.getMessage());
logger.error("Could not validate a user by his token! Reason: " + e.getMessage(), e);
throw new UnauthorisedException("Token validation failed - Not a valid token");
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
throw new UnauthorisedException("IO Exeption");
} catch (NullEmailException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
throw new NullEmailException();
}
}

View File

@ -2,6 +2,8 @@ package eu.eudat.logic.services.helpers;
import eu.eudat.exceptions.files.TempFileNotFoundException;
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.core.env.Environment;
import org.springframework.core.io.Resource;
@ -22,6 +24,7 @@ import java.util.UUID;
*/
@Service("fileStorageService")
public class FileStorageServiceImpl implements FileStorageService {
private static final Logger logger = LoggerFactory.getLogger(FileStorageServiceImpl.class);
private Environment environment;
@ -68,7 +71,7 @@ public class FileStorageServiceImpl implements FileStorageService {
Files.createDirectory(Paths.get(environment.getProperty("files.storage.final")));
}
} 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.types.Authorities;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
public abstract class AbstractAuthenticationService implements AuthenticationService {
private static final Logger logger = LoggerFactory.getLogger(AbstractAuthenticationService.class);
protected ApiContext apiContext;
protected Environment environment;
@ -86,7 +89,7 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
try {
credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret());
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return null;
}
}

View File

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

View File

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

View File

@ -2,6 +2,8 @@ package eu.eudat.logic.services.utilities;
import eu.eudat.models.data.mail.SimpleMail;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
@ -17,6 +19,7 @@ import java.io.*;
@Service("mailService")
public class MailServiceImpl implements MailService {
private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class);
private Environment env;
@ -54,7 +57,7 @@ public class MailServiceImpl implements MailService {
IOUtils.copy(inputStream, writer, "UTF-8");
return writer.toString();
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
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.logic.utilities.interfaces.ModelDefinition;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import java.util.LinkedList;
@ -12,15 +14,16 @@ import java.util.List;
import java.util.Map;
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) {
List<T> list = new LinkedList<T>();
for (U item : items) {
try {
list.add(item.toDatabaseDefinition(clazz.newInstance()));
} catch (InstantiationException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
return list;
@ -32,9 +35,9 @@ public class ModelBuilder {
try {
list.add(item.toDatabaseDefinition(clazz.newInstance()));
} catch (InstantiationException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
return list;
@ -48,9 +51,9 @@ public class ModelBuilder {
modelItem.fromDatabaseDefinition(item);
list.add(modelItem);
} catch (InstantiationException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
return list;

View File

@ -1,5 +1,7 @@
package eu.eudat.logic.utilities.builders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -21,6 +23,7 @@ import java.io.StringWriter;
public class XmlBuilder {
private static final Logger logger = LoggerFactory.getLogger(XmlBuilder.class);
public static Document getDocument() {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
@ -31,7 +34,7 @@ public class XmlBuilder {
return doc;
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error(e.getMessage(), e);
return null;
}
}
@ -48,7 +51,7 @@ public class XmlBuilder {
return writer.toString();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error(e.getMessage(), e);
return null;
}
}
@ -63,7 +66,7 @@ public class XmlBuilder {
return doc;
} catch (ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error(e.getMessage(), e);
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.CTLvl;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STNumberFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.math.BigInteger;
@ -27,6 +29,7 @@ import java.util.List;
import java.util.Map;
public class WordBuilder {
private static final Logger logger = LoggerFactory.getLogger(WordBuilder.class);
private Map<ParagraphStyle, ApplierWithValue<XWPFDocument, String, XWPFParagraph>> options = new HashMap<>();
private CTAbstractNum cTAbstractNum;
@ -186,7 +189,7 @@ public class WordBuilder {
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
number.setVal(BigInteger.valueOf(indent));
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
}

View File

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

View File

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

View File

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

View File

@ -2,11 +2,14 @@ package eu.eudat.models.data.dmp;
import eu.eudat.models.DataModel;
import eu.eudat.logic.utilities.helpers.LabelGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.UUID;
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 name;
private String id;
@ -104,7 +107,7 @@ public class Researcher implements DataModel<eu.eudat.data.entities.Researcher,
try {
throw new Exception("Researcher has no key value");
} 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.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsExternalSourcesModel> {
private static final Logger logger = LoggerFactory.getLogger(ProjectsExternalSourcesModel.class);
private static final ObjectMapper mapper = new ObjectMapper();
@Override
@ -61,7 +64,7 @@ public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsEx
this.add(model);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
return this;

View File

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