cleanup unused code
This commit is contained in:
parent
b273ca4ed7
commit
e2505039df
|
@ -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));
|
||||
}
|
||||
|
||||
@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
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/registerDOIToken"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
|
|
|
@ -2038,32 +2038,6 @@ public class DataManagementPlanManager {
|
|||
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 {
|
||||
DMP dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(UUID.fromString(depositRequest.getDmpId()));
|
||||
if (!isUserOwnerOfDmp(dmp, principal))
|
||||
|
|
|
@ -159,31 +159,10 @@ public class UserManager {
|
|||
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 {
|
||||
this.updateDOIToken(ZenodoAccessType.AUTHORIZATION_CODE, doiRequest.getZenodoRequest().getCode(), doiRequest.getRedirectUri(), principal);
|
||||
}
|
||||
|
||||
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);
|
||||
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());
|
||||
Map<String, Object> settings = new HashMap<>();
|
||||
settings.put("zenodoEmail", responseToken.getEmail());
|
||||
settings.put("zenodoRefresh", responseToken.getRefreshToken());
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
|
@ -28,7 +28,6 @@ configuration.schematics=Schematics.json
|
|||
configuration.h2020template=documents/h2020.docx
|
||||
configuration.h2020datasettemplate=documents/h2020_dataset.docx
|
||||
configuration.configurable_login_providers=configurableLoginProviders.json
|
||||
configuration.doi_funder=DOI_Funder.json
|
||||
|
||||
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
|
||||
email.invite=classpath:templates/email/email.html
|
||||
|
@ -79,8 +78,6 @@ conf_email.expiration_time_seconds=14400
|
|||
conf_email.subject=OpenDMP email confirmation
|
||||
|
||||
#############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.client_id=
|
||||
zenodo.login.client_secret=
|
||||
|
|
|
@ -27,7 +27,6 @@ configuration.rda=RDACommonStandards.txt
|
|||
configuration.h2020template=documents/h2020.docx
|
||||
configuration.h2020datasettemplate=documents/h2020_dataset.docx
|
||||
configuration.configurable_login_providers=configurableLoginProviders.json
|
||||
configuration.doi_funder=DOI_Funder.json
|
||||
|
||||
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
|
||||
email.invite=classpath:templates/email/email.html
|
||||
|
@ -100,14 +99,11 @@ conf_email.expiration_time_seconds=14400
|
|||
conf_email.subject=OpenDMP email confirmation
|
||||
|
||||
#############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.client_id=
|
||||
zenodo.login.client_secret=
|
||||
zenodo.login.redirect_uri=http://localhost:8080/login/external/zenodo
|
||||
|
||||
|
||||
#############CONTACT EMAIL CONFIGURATIONS#########
|
||||
contact_email.mail=
|
||||
logging.config=classpath:logging/logback-${spring.profiles.active}.xml
|
||||
|
|
|
@ -54,7 +54,6 @@ configuration.schematics=Schematics.json
|
|||
configuration.h2020template=documents/h2020.docx
|
||||
configuration.h2020datasettemplate=documents/h2020_dataset.docx
|
||||
configuration.configurable_login_providers=configurableLoginProviders.json
|
||||
configuration.doi_funder=DOI_Funder.json
|
||||
|
||||
####################EMAIL FILE TEMPLATES OVERRIDES CONFIGURATIONS##########
|
||||
email.invite=file:templates/email/email.html
|
||||
|
|
|
@ -57,11 +57,6 @@ export class UserService {
|
|||
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> {
|
||||
const url = this.actionUrl + 'registerDOIToken';
|
||||
return this.http.post(url, {zenodoRequest: {code: code}, redirectUri: redirectUri}, { headers: this.headers });
|
||||
|
|
|
@ -53,7 +53,6 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
|
|||
breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
|
||||
isUserOwner: boolean;
|
||||
expand = false;
|
||||
hasDOIToken = false;
|
||||
researchers: ResearcherModel[];
|
||||
users: UserInfoListingModel[];
|
||||
lockStatus: Boolean;
|
||||
|
|
|
@ -64,7 +64,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
|
||||
isUserOwner: boolean;
|
||||
expand = false;
|
||||
hasDOIToken = false;
|
||||
lockStatus: Boolean;
|
||||
textMessage: any;
|
||||
versions: VersionListingModel[];
|
||||
|
@ -510,7 +509,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
if (result.length > 0) {
|
||||
this.dmp.dois = result;
|
||||
this.selectedModel = this.dmp.dois[this.dmp.dois.length - 1];
|
||||
this.hasDOIToken = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue