use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class ClientsController method getAvailableRedirectUriScopes.
@RequestMapping(value = "/get-available-scopes.json", method = RequestMethod.GET)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public List<String> getAvailableRedirectUriScopes() {
List<String> scopes = new ArrayList<String>();
// Ignore these scopes
List<ScopePathType> ignoreScopes = new ArrayList<ScopePathType>(Arrays.asList(ScopePathType.ORCID_PATENTS_CREATE, ScopePathType.ORCID_PATENTS_READ_LIMITED, ScopePathType.ORCID_PATENTS_UPDATE, ScopePathType.WEBHOOK, ScopePathType.ORCID_PROFILE_CREATE, ScopePathType.FUNDING_READ_LIMITED, ScopePathType.AFFILIATIONS_READ_LIMITED, ScopePathType.READ_PUBLIC));
for (ScopePathType t : ScopePathType.values()) {
if (!ignoreScopes.contains(t))
scopes.add(t.value());
}
Collections.sort(scopes);
return scopes;
}
use of org.orcid.jaxb.model.message.ScopePathType in project ORCID-Source by ORCID.
the class AddScopesToExistingClients method updateScopes.
private void updateScopes(ClientDetailsEntity clientDetails) {
for (ScopePathType scope : scopes) {
boolean alreadyHaveScope = false;
for (ClientScopeEntity existingScope : clientDetails.getClientScopes()) {
if (scope.value().equals(existingScope.getScopeType())) {
alreadyHaveScope = true;
break;
}
}
if (!alreadyHaveScope) {
ClientScopeEntity clientScope = new ClientScopeEntity();
clientScope.setClientDetailsEntity(clientDetails);
clientScope.setScopeType(scope.value());
clientScope.setDateCreated(new Date());
clientScope.setLastModified(new Date());
clientDetails.getClientScopes().add(clientScope);
clientDetailsManager.merge(clientDetails);
clientsUpdated += 1;
System.out.println("Client " + clientDetails.getId() + " has been updated");
} else {
System.out.println("Client " + clientDetails.getId() + " already have the " + scope.value() + " scope");
}
}
}
Aggregations