clean up code

This commit is contained in:
Efstratios Giannopoulos 2024-02-13 09:53:33 +02:00
parent 8b267ef5ff
commit 28d08d99e8
36 changed files with 50 additions and 201 deletions

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>data</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>eu.eudat</groupId>
<artifactId>dmp-backend</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>eu.eudat</groupId>
<artifactId>core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>dmp-backend</groupId>
<artifactId>queryable</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.20</version>
</dependency>
</dependencies>
</project>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dmp-backend</groupId>
<artifactId>queryable</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>eu.eudat</groupId>
<artifactId>dmp-backend</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>eu.eudat</groupId>
<artifactId>core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.model.persist.ContactSupportPersist;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.commons.scope.user.UserScope;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import gr.cite.tools.validation.ValidationFilterAnnotation;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
@ -9,12 +9,10 @@ import eu.eudat.model.censorship.DmpCensor;
import eu.eudat.model.censorship.PublicDmpCensor;
import eu.eudat.model.persist.*;
import eu.eudat.model.result.QueryResult;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.lookup.DmpLookup;
import eu.eudat.service.dmp.DmpService;
import eu.eudat.service.elastic.ElasticQueryHelperService;
import eu.eudat.types.ApiMessageCode;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory;
@ -29,7 +27,6 @@ import jakarta.xml.bind.JAXBException;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -228,7 +225,7 @@ public class DmpController {
@PostMapping("{id}/invite-users")
@Transactional
@ValidationFilterAnnotation(validator = DmpUserInvitePersist.DmpUserInvitePersistValidator.ValidatorName, argumentName = "model")
public ResponseEntity<ResponseItem<String>> inviteUsers(@PathVariable("id") UUID id, @RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException, IOException {
public boolean inviteUsers(@PathVariable("id") UUID id, @RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException, IOException {
logger.debug(new MapLogEntry("inviting users to dmp").And("model", model));
this.dmpService.inviteUsers(id, model);
@ -237,12 +234,12 @@ public class DmpController {
new AbstractMap.SimpleEntry<String, Object>("model", model)
));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Invite Users Success"));
return true;
}
@GetMapping("{id}/token/{token}/invite-accept")
@Transactional
public ResponseEntity<ResponseItem<String>> acceptInvitation(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException, IOException {
public boolean acceptInvitation(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException, IOException {
logger.debug(new MapLogEntry("inviting users to dmp").And("id", id));
this.dmpService.dmpInvitationAccept(token);
@ -251,7 +248,7 @@ public class DmpController {
new AbstractMap.SimpleEntry<String, Object>("token", token)
));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).payload("Invite Accept Success"));
return true;
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;

View File

@ -1,15 +1,11 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.authorization.Permission;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.logic.services.ExternalValidationService;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@ -26,13 +22,10 @@ public class ExternalValidationController {
}
@GetMapping(path = {""}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Boolean>> validate(
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
public @ResponseBody Boolean validate(@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
) throws HugeResultSetException, MyNotFoundException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
Boolean isValid = this.externalValidationService.validateIdentifier(query, type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(isValid).status(ApiMessageCode.NO_MESSAGE));
return this.externalValidationService.validateIdentifier(query, type);
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.file.transformer.models.misc.FileFormat;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.Permission;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import gr.cite.tools.validation.ValidationFilterAnnotation;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.models.Account;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.Permission;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;

View File

@ -1,4 +1,4 @@
package eu.eudat.controllers.v2;
package eu.eudat.controllers;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;

View File

@ -1,12 +1,8 @@
package eu.eudat.controllers;
package eu.eudat.controllers.old;
import eu.eudat.logic.managers.LocalFetchManager;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.models.old.local.LocalFetchModel;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -24,8 +20,8 @@ public class CurrencyController {
}
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<ResponseItem<List<LocalFetchModel>>> getCurrencies( @RequestParam(value = "query", required = false) String query) throws Exception {
public List<LocalFetchModel> getCurrencies( @RequestParam(value = "query", required = false) String query) throws Exception {
List<LocalFetchModel> currencies = localFetchManager.getCurrency(query);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<LocalFetchModel>>().status(ApiMessageCode.NO_MESSAGE).payload(currencies));
return currencies;
}
}

View File

@ -1,14 +1,10 @@
package eu.eudat.controllers;
package eu.eudat.controllers.old;
import eu.eudat.authorization.Permission;
import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -30,25 +26,25 @@ public class ManagementController{
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addSemantics"})
public ResponseEntity addSemanticsInDatasetProfiles() throws Exception {
public boolean addSemanticsInDatasetProfiles() throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole);
try {
this.datasetProfileManager.addSemanticsInDatasetProfiles();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
return true;
} catch (Exception exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
return false;
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addRdaInSemantics"})
public ResponseEntity addRdaInSemanticsInDatasetProfiles() throws Exception {
public boolean addRdaInSemanticsInDatasetProfiles() throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole);
try {
this.datasetProfileManager.addRdaInSemanticsInDatasetProfiles();
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
return true;
} catch (Exception exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
return false;
}
}
}

View File

@ -1,15 +1,11 @@
package eu.eudat.controllers;
package eu.eudat.controllers.old;
import eu.eudat.authorization.Permission;
import eu.eudat.logic.managers.ValidationManager;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@ -28,13 +24,13 @@ public class Validation {
@RequestMapping(method = RequestMethod.GET, value = {"/external/validation"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Boolean>> validate(
Boolean validate(
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type
) throws HugeResultSetException, MyNotFoundException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
Boolean isValid = this.validationManager.validateIdentifier(query, type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(isValid).status(ApiMessageCode.NO_MESSAGE));
return isValid;
}
}

View File

@ -15,13 +15,13 @@ import eu.eudat.model.mapper.publicapi.DescriptionToPublicApiDatasetMapper;
import eu.eudat.model.mapper.publicapi.DmpToPublicApiDmpListingMapper;
import eu.eudat.model.publicapi.listingmodels.DatasetPublicListingModel;
import eu.eudat.model.publicapi.overviewmodels.DatasetPublicModel;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.controllers.publicapi.types.ResponseItem;
import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.lookup.DescriptionLookup;
import eu.eudat.query.lookup.DmpLookup;
import eu.eudat.service.publicapi.PublicApiProperties;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.controllers.publicapi.types.ApiMessageCode;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyNotFoundException;

View File

@ -15,13 +15,13 @@ import eu.eudat.model.publicapi.listingmodels.DataManagementPlanPublicListingMod
import eu.eudat.model.publicapi.overviewmodels.DataManagementPlanPublicModel;
import eu.eudat.model.referencedefinition.Definition;
import eu.eudat.model.referencedefinition.Field;
import eu.eudat.models.old.helpers.responses.ResponseItem;
import eu.eudat.controllers.publicapi.types.ResponseItem;
import eu.eudat.query.DmpDescriptionTemplateQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.EntityDoiQuery;
import eu.eudat.query.lookup.DmpLookup;
import eu.eudat.service.publicapi.PublicApiProperties;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.controllers.publicapi.types.ApiMessageCode;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyNotFoundException;

View File

@ -1,4 +1,4 @@
package eu.eudat.types;
package eu.eudat.controllers.publicapi.types;
public enum ApiMessageCode {
NO_MESSAGE(0), SUCCESS_MESSAGE(200), WARN_MESSAGE(300), ERROR_MESSAGE(400),

View File

@ -1,4 +1,4 @@
package eu.eudat.types;
package eu.eudat.controllers.publicapi.types;
/**
* Created by ikalyvas on 3/5/2018.

View File

@ -1,7 +1,4 @@
package eu.eudat.models.old.helpers.responses;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.ApiResponseType;
package eu.eudat.controllers.publicapi.types;
public class ResponseItem<T> {

View File

@ -1,38 +0,0 @@
package eu.eudat.models.old.dashboard.recent;
import java.util.Date;
/**
* Created by ikalyvas on 3/14/2018.
*/
public class RecentActivityData {
private String label;
private String id;
private Date timestamp;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View File

@ -1,24 +0,0 @@
package eu.eudat.models.old.helpers.common;
import java.util.List;
public class DataTableData<T> {
private Long totalCount;
private List<T> data;
public Long getTotalCount() {
return totalCount;
}
public void setTotalCount(Long totalCount) {
this.totalCount = totalCount;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}