cleanup unused code

This commit is contained in:
Bernaldo Mihasi 2023-02-21 14:09:33 +02:00
parent b273ca4ed7
commit e2505039df
10 changed files with 3 additions and 146 deletions

View File

@ -88,16 +88,6 @@ public class Users extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
} }
@RequestMapping(method = RequestMethod.GET, value = {"/hasDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<Boolean>> hasDOIToken(Principal principal) throws NullEmailException {
try {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(this.userManager.isDOITokenValid(principal)).status(ApiMessageCode.NO_MESSAGE));
} catch (NonValidTokenException | ExpiredTokenException | IOException e) {
return ResponseEntity.status(460).body(new ResponseItem<Boolean>().payload(false).status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
}
}
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/registerDOIToken"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/registerDOIToken"}, consumes = "application/json", produces = "application/json")
public @ResponseBody public @ResponseBody

View File

@ -2038,32 +2038,6 @@ public class DataManagementPlanManager {
return null; return null;
} }
private String getUnpublishedDOI(String DOI, String token, Integer version) {
try {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
Map createResponse = null;
LinkedHashMap<String, String> links = null;
LinkedHashMap<String, String> metadata = null;
String listUrl = this.environment.getProperty("zenodo.url") + "deposit/depositions" + "?q=conceptdoi:\"" + DOI + "\"&access_token=" + token;
ResponseEntity<Map[]> listResponses = restTemplate.getForEntity(listUrl, Map[].class);
createResponse = listResponses.getBody()[0];
metadata = (LinkedHashMap<String, String>) createResponse.get("metadata");
links = (LinkedHashMap<String, String>) createResponse.get("links");
if (metadata.get("version").equals(version.toString())) {
return links.get("publish");
} else {
return null;
}
}catch (Exception e) {
logger.warn(e.getMessage(), e);
return null;
}
}
public Doi createDoi(DepositRequest depositRequest, Principal principal) throws Exception { public Doi createDoi(DepositRequest depositRequest, Principal principal) throws Exception {
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(UUID.fromString(depositRequest.getDmpId())); DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(UUID.fromString(depositRequest.getDmpId()));
if (!isUserOwnerOfDmp(dmp, principal)) if (!isUserOwnerOfDmp(dmp, principal))

View File

@ -159,31 +159,10 @@ public class UserManager {
return dataTableData; return dataTableData;
} }
public Boolean isDOITokenValid(Principal principal) throws NonValidTokenException, ExpiredTokenException, IOException {
if (principal.getZenodoToken() != null && !principal.getZenodoToken().isEmpty()) {
if (Instant.now().isBefore(principal.getZenodoDuration())) {
return true;
}
try {
this.updateDOIToken(ZenodoAccessType.REFRESH_TOKEN, principal.getZenodoRefresh(), this.environment.getProperty("zenodo.login.redirect_uri"), principal);
return true;
}catch (Exception e) {
this.deleteDOIToken(principal);
throw new ExpiredTokenException("Zenodo Token is expired.");
}
}
throw new NonValidTokenException("This account has no Zenodo Token");
}
public void registerDOIToken(DOIRequest doiRequest, Principal principal) throws IOException { public void registerDOIToken(DOIRequest doiRequest, Principal principal) throws IOException {
this.updateDOIToken(ZenodoAccessType.AUTHORIZATION_CODE, doiRequest.getZenodoRequest().getCode(), doiRequest.getRedirectUri(), principal); ZenodoResponseToken responseToken = this.zenodoCustomProvider.getAccessToken(ZenodoAccessType.AUTHORIZATION_CODE,
} doiRequest.getZenodoRequest().getCode(), this.environment.getProperty("zenodo.login.client_id"),
this.environment.getProperty("zenodo.login.client_secret"), doiRequest.getRedirectUri());
private void updateDOIToken(ZenodoAccessType accessType, String code, String redirectUri, Principal principal) throws IOException {
ZenodoResponseToken responseToken = this.zenodoCustomProvider.getAccessToken(accessType, code
, this.environment.getProperty("zenodo.login.client_id")
, this.environment.getProperty("zenodo.login.client_secret")
, redirectUri);
Map<String, Object> settings = new HashMap<>(); Map<String, Object> settings = new HashMap<>();
settings.put("zenodoEmail", responseToken.getEmail()); settings.put("zenodoEmail", responseToken.getEmail());
settings.put("zenodoRefresh", responseToken.getRefreshToken()); settings.put("zenodoRefresh", responseToken.getRefreshToken());

View File

@ -1,70 +0,0 @@
[
{
"Funder": "Australian Research Council",
"DOI": "10.13039/501100000923"
},
{
"Funder": "Austrian Science Fund",
"DOI": "10.13039/501100002428"
},
{
"Funder": "European Commission",
"DOI": "10.13039/501100000780"
},
{
"Funder": "European Environment Agency",
"DOI": "10.13039/501100000806"
},
{
"Funder": "Academy of Finland",
"DOI": "10.13039/501100002341"
},
{
"Funder": "Hrvatska Zaklada za Znanost",
"DOI": "10.13039/501100004488"
},
{
"Funder": "Fundação para a Ciência e a Tecnologia",
"DOI": "10.13039/501100001871"
},
{
"Funder": "Ministarstvo Prosvete, Nauke i Tehnološkog Razvoja",
"DOI": "10.13039/501100004564"
},
{
"Funder": "Ministarstvo Znanosti, Obrazovanja i Sporta",
"DOI": "10.13039/501100006588"
},
{
"Funder": "National Health and Medical Research Council",
"DOI": "10.13039/501100000925"
},
{
"Funder": "National Institutes of Health",
"DOI": "10.13039/100000002"
},
{
"Funder": "National Science Foundation",
"DOI": "10.13039/100000001"
},
{
"Funder": "Nederlandse Organisatie voor Wetenschappelijk Onderzoek",
"DOI": "10.13039/501100003246"
},
{
"Funder": "Research Councils",
"DOI": "10.13039/501100000690"
},
{
"Funder": "Schweizerischer Nationalfonds zur Förderung der wissenschaftlichen Forschung",
"DOI": "10.13039/501100001711"
},
{
"Funder": "Science Foundation Ireland",
"DOI": "10.13039/501100001602"
},
{
"Funder": "Wellcome Trust",
"DOI": "10.13039/100004440"
}
]

View File

@ -28,7 +28,6 @@ configuration.schematics=Schematics.json
configuration.h2020template=documents/h2020.docx configuration.h2020template=documents/h2020.docx
configuration.h2020datasettemplate=documents/h2020_dataset.docx configuration.h2020datasettemplate=documents/h2020_dataset.docx
configuration.configurable_login_providers=configurableLoginProviders.json configuration.configurable_login_providers=configurableLoginProviders.json
configuration.doi_funder=DOI_Funder.json
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS########## ####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
email.invite=classpath:templates/email/email.html email.invite=classpath:templates/email/email.html
@ -79,8 +78,6 @@ conf_email.expiration_time_seconds=14400
conf_email.subject=OpenDMP email confirmation conf_email.subject=OpenDMP email confirmation
#############ZENODO CONFIGURATIONS######### #############ZENODO CONFIGURATIONS#########
zenodo.url=https://sandbox.zenodo.org/api/
zenodo.access_token=
zenodo.login.access_token_url=https://sandbox.zenodo.org/oauth/token zenodo.login.access_token_url=https://sandbox.zenodo.org/oauth/token
zenodo.login.client_id= zenodo.login.client_id=
zenodo.login.client_secret= zenodo.login.client_secret=

View File

@ -27,7 +27,6 @@ configuration.rda=RDACommonStandards.txt
configuration.h2020template=documents/h2020.docx configuration.h2020template=documents/h2020.docx
configuration.h2020datasettemplate=documents/h2020_dataset.docx configuration.h2020datasettemplate=documents/h2020_dataset.docx
configuration.configurable_login_providers=configurableLoginProviders.json configuration.configurable_login_providers=configurableLoginProviders.json
configuration.doi_funder=DOI_Funder.json
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS########## ####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
email.invite=classpath:templates/email/email.html email.invite=classpath:templates/email/email.html
@ -100,14 +99,11 @@ conf_email.expiration_time_seconds=14400
conf_email.subject=OpenDMP email confirmation conf_email.subject=OpenDMP email confirmation
#############ZENODO CONFIGURATIONS######### #############ZENODO CONFIGURATIONS#########
zenodo.url=https://sandbox.zenodo.org/api/
zenodo.access_token=
zenodo.login.access_token_url=https://sandbox.zenodo.org/oauth/token zenodo.login.access_token_url=https://sandbox.zenodo.org/oauth/token
zenodo.login.client_id= zenodo.login.client_id=
zenodo.login.client_secret= zenodo.login.client_secret=
zenodo.login.redirect_uri=http://localhost:8080/login/external/zenodo zenodo.login.redirect_uri=http://localhost:8080/login/external/zenodo
#############CONTACT EMAIL CONFIGURATIONS######### #############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail= contact_email.mail=
logging.config=classpath:logging/logback-${spring.profiles.active}.xml logging.config=classpath:logging/logback-${spring.profiles.active}.xml

View File

@ -54,7 +54,6 @@ configuration.schematics=Schematics.json
configuration.h2020template=documents/h2020.docx configuration.h2020template=documents/h2020.docx
configuration.h2020datasettemplate=documents/h2020_dataset.docx configuration.h2020datasettemplate=documents/h2020_dataset.docx
configuration.configurable_login_providers=configurableLoginProviders.json configuration.configurable_login_providers=configurableLoginProviders.json
configuration.doi_funder=DOI_Funder.json
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS########## ####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
email.invite=file:templates/email/email.html email.invite=file:templates/email/email.html

View File

@ -57,11 +57,6 @@ export class UserService {
return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers}); return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers});
} }
public hasDOIToken(): Observable<any> {
const url = this.actionUrl + 'hasDOIToken';
return this.http.get(url, { headers: this.headers });
}
public registerDOIToken(code: string, redirectUri: string): Observable<any> { public registerDOIToken(code: string, redirectUri: string): Observable<any> {
const url = this.actionUrl + 'registerDOIToken'; const url = this.actionUrl + 'registerDOIToken';
return this.http.post(url, {zenodoRequest: {code: code}, redirectUri: redirectUri}, { headers: this.headers }); return this.http.post(url, {zenodoRequest: {code: code}, redirectUri: redirectUri}, { headers: this.headers });

View File

@ -53,7 +53,6 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
breadCrumbs: Observable<BreadcrumbItem[]> = observableOf(); breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
isUserOwner: boolean; isUserOwner: boolean;
expand = false; expand = false;
hasDOIToken = false;
researchers: ResearcherModel[]; researchers: ResearcherModel[];
users: UserInfoListingModel[]; users: UserInfoListingModel[];
lockStatus: Boolean; lockStatus: Boolean;

View File

@ -64,7 +64,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
breadCrumbs: Observable<BreadcrumbItem[]> = observableOf(); breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
isUserOwner: boolean; isUserOwner: boolean;
expand = false; expand = false;
hasDOIToken = false;
lockStatus: Boolean; lockStatus: Boolean;
textMessage: any; textMessage: any;
versions: VersionListingModel[]; versions: VersionListingModel[];
@ -510,7 +509,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
if (result.length > 0) { if (result.length > 0) {
this.dmp.dois = result; this.dmp.dois = result;
this.selectedModel = this.dmp.dois[this.dmp.dois.length - 1]; this.selectedModel = this.dmp.dois[this.dmp.dois.length - 1];
this.hasDOIToken = true;
} }
} }