use of org.orcid.persistence.jpa.entities.IdentityProviderEntity in project ORCID-Source by ORCID.
the class IdentityProviderManagerImpl method retrieveFreshIdentitifyProviderName.
@Override
@Transactional
public String retrieveFreshIdentitifyProviderName(String providerid, Locale locale) {
IdentityProviderEntity idp = identityProviderDao.findByProviderid(providerid);
List<IdentityProviderNameEntity> names = idp.getNames();
if (names != null) {
Optional<IdentityProviderNameEntity> idpNameEntity = names.stream().filter(n -> n.getLang().equals(locale.getLanguage())).findFirst();
if (idpNameEntity.isPresent()) {
return idpNameEntity.get().getDisplayName();
}
}
return idp.getDisplayName();
}
use of org.orcid.persistence.jpa.entities.IdentityProviderEntity in project ORCID-Source by ORCID.
the class IdentityProviderManagerTest method testCreateEntityFromXml.
@Test
public void testCreateEntityFromXml() throws SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(getClass().getResourceAsStream("example_idp.xml"));
Element idpElement = doc.getDocumentElement();
IdentityProviderEntity result = identityProviderManager.createEntityFromXml(idpElement);
assertNotNull(result);
assertEquals("https://idp.example.ch/idp/shibboleth", result.getProviderid());
List<IdentityProviderNameEntity> names = result.getNames();
assertNotNull(names);
assertEquals(4, names.size());
Map<String, IdentityProviderNameEntity> mapByLang = names.stream().collect(Collectors.toMap(IdentityProviderNameEntity::getLang, Function.identity()));
assertEquals("Universität Example Display", mapByLang.get("de").getDisplayName());
assertEquals("University of Example Display", mapByLang.get("en").getDisplayName());
assertEquals("Université de Example Display", mapByLang.get("fr").getDisplayName());
assertEquals("Università di Example Display", mapByLang.get("it").getDisplayName());
assertEquals("Universität Example Display", result.getDisplayName());
assertEquals("support@example.ch", result.getSupportEmail());
assertNull(result.getAdminEmail());
assertEquals("technical@example.ch", result.getTechEmail());
}
Aggregations