Commit ae84be58 authored by George Kalampokis's avatar George Kalampokis

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

parent 476915b2
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;
}
......
......@@ -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;
}
......
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();
......
......@@ -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;
}
......
......@@ -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()));
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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()));
}
}
......
......@@ -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()));
}
}
......
......@@ -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."));
}
}
......
......@@ -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);
}
}
......@@ -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;
......
......@@ -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;
}
......
......@@ -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 {