1. Add roles for aai
2. Changes on converter file for new interface object 3. Move emailUtils to avoid bug on bean definitions 4. Add openaire provider authorities mapper class 5. Bug fixes on controllers
This commit is contained in:
parent
cd2e30610a
commit
cbb0848d5c
|
@ -27,9 +27,6 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
|||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
|
||||
LOGGER.info(request);
|
||||
LOGGER.info(response);
|
||||
|
||||
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
||||
Cookie sessionCookie = new Cookie("currentUser", authOIDC.getSub());
|
||||
int expireSec = -1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.service.utils;
|
||||
package eu.dnetlib.repo.manager.service.config;
|
||||
|
||||
import com.nimbusds.jwt.JWT;
|
||||
import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
|
||||
|
@ -10,23 +10,24 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class OMTDAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||
public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OMTDAuthoritiesMapper.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(OpenAireProviderAuthoritiesMapper.class);
|
||||
|
||||
final private static String ROLE_CLAIMS = "edu_person_entitlements";
|
||||
|
||||
private Map<String,SimpleGrantedAuthority> userRolesMap;
|
||||
|
||||
OMTDAuthoritiesMapper(Map<String,String> userRoles) {
|
||||
OpenAireProviderAuthoritiesMapper(Map<String,String> userRoles) {
|
||||
userRolesMap = new HashMap<>();
|
||||
userRoles.forEach((omtdRole, appRole) -> userRolesMap.put(omtdRole, new SimpleGrantedAuthority(appRole)));
|
||||
userRoles.forEach((openaireRole, appRole) -> userRolesMap.put(openaireRole, new SimpleGrantedAuthority(appRole)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
|
||||
Set<GrantedAuthority> out = new HashSet<>();
|
||||
out.add(new SimpleGrantedAuthority("ROLE_USER"));
|
||||
|
||||
if(userInfo.getSource().getAsJsonArray(ROLE_CLAIMS) != null) {
|
||||
userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
|
||||
SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
|
||||
|
@ -38,4 +39,4 @@ public class OMTDAuthoritiesMapper implements OIDCAuthoritiesMapper {
|
|||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.service.utils;
|
||||
package eu.dnetlib.repo.manager.service.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.functionality.UserProfile;
|
||||
|
||||
public interface EmailUtils {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.repo.manager.service.utils;
|
||||
package eu.dnetlib.repo.manager.service.controllers;
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader;
|
||||
|
@ -15,7 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
@Component("emailUtils")
|
||||
public class EmailUtilsImpl implements EmailUtils {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class);
|
||||
|
@ -39,7 +39,6 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
@Value("${services.repomanager.usagestats.adminEmail}")
|
||||
private String usageStatsAdminEmail;
|
||||
|
||||
|
||||
@Override
|
||||
public void reportException(Exception exception) {
|
||||
Writer writer = new StringWriter();
|
||||
|
@ -187,7 +186,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
|
||||
private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
|
||||
|
||||
/* try {
|
||||
try {
|
||||
if (sendToSpecial) {
|
||||
recipients.addAll(this.specialRecipients);
|
||||
}
|
||||
|
@ -205,7 +204,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
} catch (Exception e) {
|
||||
LOGGER.error("Error sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message, e);
|
||||
throw new Exception(e);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private String getEmailProperty(String key) {
|
|
@ -50,8 +50,6 @@ public class MonitorApiImpl implements MonitorApi {
|
|||
LOGGER.debug("Getting jobs of user : " + user);
|
||||
LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
||||
JobsOfUser retJobs = new JobsOfUser();
|
||||
LOGGER.debug("Size of jobs list -> " + getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
|
||||
Integer.parseInt(limit), dateFrom, dateTo, validationStatus).size());
|
||||
retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
|
||||
Integer.parseInt(limit), dateFrom, dateTo, validationStatus));
|
||||
if (Boolean.parseBoolean(includeJobsTotal)) {
|
||||
|
@ -62,21 +60,24 @@ public class MonitorApiImpl implements MonitorApi {
|
|||
}
|
||||
|
||||
//TODO fix status with new validator version
|
||||
for(StoredJob job :retJobs.getJobs()){
|
||||
if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) {
|
||||
job.setValidationStatus("ongoing");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && job.getContentJobScore() > 50 && job.getUsageJobScore() > 50)
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() > 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() > 50)) {
|
||||
job.setValidationStatus("successful");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && (job.getContentJobScore() <= 50 || job.getUsageJobScore() <= 50))
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() <= 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) {
|
||||
job.setValidationStatus("failed");
|
||||
}
|
||||
if(retJobs.getJobs() != null){
|
||||
for(StoredJob job :retJobs.getJobs()){
|
||||
if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) {
|
||||
job.setValidationStatus("ongoing");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && job.getContentJobScore() > 50 && job.getUsageJobScore() > 50)
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() > 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() > 50)) {
|
||||
job.setValidationStatus("successful");
|
||||
} else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && (job.getContentJobScore() <= 50 || job.getUsageJobScore() <= 50))
|
||||
|| (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() <= 50)
|
||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) {
|
||||
job.setValidationStatus("failed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return retJobs;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package eu.dnetlib.repo.manager.service.controllers;
|
|||
|
||||
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.functionality.UserProfile;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -31,4 +34,14 @@ public interface PiWikApi {
|
|||
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
String getOpenaireId(String repositoryid);
|
||||
|
||||
|
||||
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
void markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
|
||||
|
||||
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void enableMetricsForRepository(PiwikInfo piwikInfo) throws RepositoryServiceException;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package eu.dnetlib.repo.manager.service.controllers;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.PiwikInfo;
|
||||
import eu.dnetlib.utils.md5.MD5;
|
||||
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
@ -12,13 +14,14 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class PiWikApiImpl implements PiWikApi{
|
||||
|
@ -27,6 +30,15 @@ public class PiWikApiImpl implements PiWikApi{
|
|||
@Qualifier("repomanager.dataSource")
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
@Value("${services.repomanager.analyticsURL}")
|
||||
private String analyticsURL;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("emailUtils")
|
||||
EmailUtils emailUtils;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
.getLogger(PiWikApiImpl.class);
|
||||
|
||||
|
@ -39,6 +51,7 @@ public class PiWikApiImpl implements PiWikApi{
|
|||
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
||||
|
||||
|
||||
|
||||
private RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"),
|
||||
rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"),
|
||||
rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment"));
|
||||
|
@ -85,5 +98,68 @@ public class PiWikApiImpl implements PiWikApi{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
|
||||
try {
|
||||
approvePiwikSite(repositoryId);
|
||||
|
||||
PiwikInfo piwikInfo = getPiwikSiteForRepo(repositoryId);
|
||||
emailUtils.sendAdministratorMetricsEnabled(piwikInfo);
|
||||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
LOGGER.error("Error while approving piwik site: ", e);
|
||||
emailUtils.reportException(e);
|
||||
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableMetricsForRepository(@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
|
||||
|
||||
try {
|
||||
String URL = analyticsURL + "siteName=" + URLEncoder.encode(piwikInfo.getRepositoryName(), "UTF-8")
|
||||
+ "&url=" + piwikInfo.getSiteId();
|
||||
Map<String, Object> map = new ObjectMapper().readValue(new URL(URL), Map.class);
|
||||
|
||||
/* String siteId = null;
|
||||
if(map.get("value")!=null) {
|
||||
siteId = map.get("value").toString();
|
||||
}
|
||||
|
||||
String authenticationToken = "32846584f571be9b57488bf4088f30ea";
|
||||
|
||||
PiwikInfo piwikInfo = new PiwikInfo();
|
||||
piwikInfo.setRepositoryId(repository.getId());
|
||||
piwikInfo.setRepositoryName(repository.getOfficialName());
|
||||
piwikInfo.setCountry(repository.getCountryName());
|
||||
piwikInfo.setSiteId(siteId);
|
||||
piwikInfo.setAuthenticationToken(authenticationToken);
|
||||
piwikInfo.setRequestorEmail(userProfile.getEmail());
|
||||
piwikInfo.setRequestorName(userProfile.getFirstname() + " " + userProfile.getLastname());
|
||||
piwikInfo.setValidated(false);
|
||||
*/
|
||||
savePiwikInfo(piwikInfo);
|
||||
|
||||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
LOGGER.error("Error while creating piwikScript URL", uee);
|
||||
emailUtils.reportException(uee);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("Error while creating piwik site", ioe);
|
||||
emailUtils.reportException(ioe);
|
||||
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.repo.manager.service.controllers;
|
|||
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.domain.functionality.UserProfile;
|
||||
import eu.dnetlib.repo.manager.shared.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.json.JSONException;
|
||||
|
@ -68,8 +69,7 @@ public interface RepositoryApi {
|
|||
Repository addRepository(String datatype, Repository repository) throws Exception;
|
||||
|
||||
|
||||
@RequestMapping(value = "/deleteInterface", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
|
||||
void deleteRepositoryInterface(String id);
|
||||
|
||||
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
||||
|
@ -134,6 +134,11 @@ public interface RepositoryApi {
|
|||
@ResponseBody
|
||||
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
|
||||
|
||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
RepositoryInterface updateRepositoryInterface(String repositoryId,RepositoryInterface repositoryInterface) throws JSONException;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -151,16 +151,15 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
|
||||
String countryCode = countriesMap.get(country);
|
||||
String filterKey = "UNKNOWN";
|
||||
if (mode.equalsIgnoreCase("opendoar")) {
|
||||
if (mode.equalsIgnoreCase("opendoar"))
|
||||
filterKey = "openaire____::opendoar";
|
||||
} else if (mode.equalsIgnoreCase("re3data")) {
|
||||
else if (mode.equalsIgnoreCase("re3data"))
|
||||
filterKey = "openaire____::re3data";
|
||||
} else if (mode.equalsIgnoreCase("jour_aggr")) {
|
||||
filterKey = "infrastruct_::openaire";
|
||||
}
|
||||
|
||||
|
||||
LOGGER.debug("Country code equals : " + countryCode);
|
||||
LOGGER.debug("Filter mode equals : " + filterKey);
|
||||
|
||||
UriComponents uriComponents = searchDatasource(String.valueOf(page),String.valueOf(size));
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(countryCode);
|
||||
|
@ -168,14 +167,9 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
while (jsonArray.length() > 0 ) {
|
||||
List<Repository> rep = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
|
||||
Collection<Repository> repos = this.getRepositoriesByMode(filterKey, rep);
|
||||
resultSet.addAll(repos);
|
||||
|
||||
resultSet.addAll(this.getRepositoriesByMode(filterKey, Converter.jsonToRepositoryList(new JSONObject(rs))));
|
||||
page += 1;
|
||||
uriComponents = searchDatasource(String.valueOf(page),String.valueOf(size));
|
||||
|
||||
rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
}
|
||||
|
@ -198,6 +192,7 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
for (Repository r : rs) {
|
||||
if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode))
|
||||
reps.add(r);
|
||||
|
||||
}
|
||||
return reps;
|
||||
}
|
||||
|
@ -298,38 +293,7 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
|
||||
repository = this.setRepositoryFeatures(datatype,repository);
|
||||
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
|
||||
if (!datatype.equalsIgnoreCase("opendoar") && !datatype.equalsIgnoreCase("re3data")) {
|
||||
if (datatype.equalsIgnoreCase("journal") || datatype.equalsIgnoreCase("aggregator")) {
|
||||
LOGGER.debug("looking if " + datatype + " " + repository.getOfficialName() + " is already in datasources");
|
||||
if (getRepositoryById(repository.getId()) != null) {
|
||||
String retMessage = datatype + " '" + repository.getOfficialName() + "' is already in datasources.";
|
||||
repository.getInterfaces().clear();
|
||||
LOGGER.debug(retMessage);
|
||||
} else {
|
||||
LOGGER.debug(datatype + " " + repository.getOfficialName() + " is not in datasources. Inserting..");
|
||||
this.storeRepository(repository);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.updateRepository(repository);
|
||||
}
|
||||
|
||||
LOGGER.debug("Inserting Interfaces");
|
||||
Iterator var11 = repository.getInterfaces().iterator();
|
||||
|
||||
while (var11.hasNext()) {
|
||||
RepositoryInterface iFace = (RepositoryInterface) var11.next();
|
||||
if (!iFace.getBaseUrl().isEmpty() && !iFace.getDesiredCompatibilityLevel().isEmpty()) {
|
||||
if (iFace.getId() != null && !iFace.getId().isEmpty()) {
|
||||
LOGGER.debug("updating iface..");
|
||||
this.updateInterface(datatype,iFace);
|
||||
LOGGER.debug("updated successfully");
|
||||
} else {
|
||||
LOGGER.debug("adding new iface..");
|
||||
this.registerRepositoryInterface(repository.getId(),iFace,datatype);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.storeRepository(repository);
|
||||
return repository;
|
||||
}
|
||||
|
||||
|
@ -345,19 +309,6 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
return repository;
|
||||
}
|
||||
|
||||
private void updateRegisteredByValue(String id, String registeredBy) {
|
||||
|
||||
LOGGER.debug("Updating registered by value with : " + registeredBy );
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/registeredby/")
|
||||
.queryParam("dsId",id)
|
||||
.queryParam("registeredBy", registeredBy)
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
restTemplate.postForObject(uriComponents.toUri(), null,String.class);
|
||||
}
|
||||
|
||||
private Repository setRepositoryFeatures(String datatype, Repository repository) {
|
||||
|
||||
//TODO update map
|
||||
|
@ -415,45 +366,13 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
|
||||
}
|
||||
|
||||
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
|
||||
|
||||
iFace.setContentDescription("metadata");
|
||||
iFace.setCompliance("UNKNOWN");
|
||||
if (datatype.equals("re3data")) {
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
} else {
|
||||
iFace.setAccessFormat("oai_dc");
|
||||
}
|
||||
|
||||
if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty()) {
|
||||
iFace.setTypology(repo.getDatasourceClass());
|
||||
} else if (datatype.equalsIgnoreCase("journal")) {
|
||||
iFace.setTypology("pubsrepository::journal");
|
||||
} else if (datatype.equalsIgnoreCase("aggregator")) {
|
||||
iFace.setTypology("aggregator::pubsrepository::unknown");
|
||||
} else if (datatype.equalsIgnoreCase("opendoar")) {
|
||||
iFace.setTypology("pubsrepository::unknown");
|
||||
} else if (datatype.equalsIgnoreCase("re3data")) {
|
||||
iFace.setTypology("datarepository::unknown");
|
||||
}
|
||||
|
||||
iFace.setRemovable(true);
|
||||
iFace.setAccessProtocol("oai");
|
||||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||
if (iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
||||
iFace.removeAccessSet();
|
||||
}
|
||||
return iFace;
|
||||
}
|
||||
|
||||
private void storeRepository(Repository repository) throws JSONException {
|
||||
|
||||
Date utilDate = new Date();
|
||||
Timestamp date = new Timestamp(utilDate.getTime());
|
||||
repository.setDateOfCollection(date);
|
||||
repository.setAggregator("OPENAIRE");
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/add/")
|
||||
|
@ -465,11 +384,12 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteRepositoryInterface(@PathVariable("id") String id){
|
||||
public void deleteRepositoryInterface(@RequestParam("id") String id){
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
.path("/{id}/")
|
||||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
LOGGER.debug(uriComponents.toUri());
|
||||
restTemplate.delete(uriComponents.toUri());
|
||||
}
|
||||
|
||||
|
@ -477,26 +397,19 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||
@RequestParam("repoId") String repoId,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws JSONException {
|
||||
return registerRepositoryInterface(repoId,repositoryInterface,datatype);
|
||||
}
|
||||
|
||||
private RepositoryInterface registerRepositoryInterface(String repoId, RepositoryInterface iFace, String datatype) {
|
||||
Repository e = null;
|
||||
try {
|
||||
e = this.getRepositoryById(repoId);
|
||||
iFace = createRepositoryInterface(e,iFace,datatype);
|
||||
Repository e = this.getRepositoryById(repoId);
|
||||
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
|
||||
String json_interface = Converter.repositoryInterfaceObjectToJson(e,repositoryInterface);
|
||||
|
||||
String json_interface = Converter.repositoryInterfaceObjectToJson(e,iFace);
|
||||
LOGGER.debug("iFace equals -> " + json_interface);
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/add/")
|
||||
.build()
|
||||
.encode();
|
||||
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity <String> (json_interface,httpHeaders);
|
||||
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
|
||||
return iFace;
|
||||
return repositoryInterface;
|
||||
|
||||
} catch (JSONException e1) {
|
||||
LOGGER.debug("Error parsing json ",e1);
|
||||
|
@ -504,6 +417,39 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
return null;
|
||||
}
|
||||
|
||||
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
|
||||
|
||||
iFace.setContentDescription("metadata");
|
||||
iFace.setCompliance("UNKNOWN");
|
||||
|
||||
if (datatype.equals("re3data"))
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
else
|
||||
iFace.setAccessFormat("oai_dc");
|
||||
|
||||
|
||||
if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty())
|
||||
iFace.setTypology(repo.getDatasourceClass());
|
||||
else if (datatype.equalsIgnoreCase("journal"))
|
||||
iFace.setTypology("pubsrepository::journal");
|
||||
else if (datatype.equalsIgnoreCase("aggregator"))
|
||||
iFace.setTypology("aggregator::pubsrepository::unknown");
|
||||
else if (datatype.equalsIgnoreCase("opendoar"))
|
||||
iFace.setTypology("pubsrepository::unknown");
|
||||
else if (datatype.equalsIgnoreCase("re3data"))
|
||||
iFace.setTypology("datarepository::unknown");
|
||||
|
||||
iFace.setRemovable(true);
|
||||
iFace.setAccessProtocol("oai");
|
||||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||
if (iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
||||
iFace.removeAccessSet();
|
||||
}
|
||||
return iFace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDnetCountries() {
|
||||
LOGGER.debug("Getting dnet-countries!");
|
||||
|
@ -656,6 +602,36 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(1).getLastCollectionDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws JSONException {
|
||||
|
||||
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
|
||||
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
|
||||
return repositoryInterface;
|
||||
}
|
||||
|
||||
|
||||
private void updateBaseUrl(String repositoryId, String repositoryInterfaceId, String baseUrl) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/baseurl")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("baseUrl",baseUrl)
|
||||
.build().encode();
|
||||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private void updateCompliance(String repositoryId, String repositoryInterfaceId,String compliance) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/compliance")
|
||||
.queryParam("dsId",repositoryId)
|
||||
.queryParam("apiId",repositoryInterfaceId)
|
||||
.queryParam("compliance",compliance)
|
||||
.build().encode();
|
||||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private MetricsNumbers getMetricsNumbers(String openAIREID) throws BrokerException {
|
||||
|
||||
//build the uri params
|
||||
|
|
|
@ -30,11 +30,14 @@ public class UserApiImpl implements UserApi {
|
|||
LOGGER.debug("User authentication : " + authentication);
|
||||
Map<String,Object> body = new HashMap<>();
|
||||
body.put("sub",authentication.getSub());
|
||||
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals("")) {
|
||||
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
|
||||
body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName());
|
||||
} else {
|
||||
else
|
||||
body.put("name",authentication.getUserInfo().getName());
|
||||
}
|
||||
|
||||
for (GrantedAuthority authority : authentication.getAuthorities())
|
||||
LOGGER.debug("Role: " + authority.getAuthority());
|
||||
|
||||
body.put("email",authentication.getUserInfo().getEmail());
|
||||
List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||
body.put("role",roles);
|
||||
|
|
|
@ -3,7 +3,6 @@ package eu.dnetlib.repo.manager.service.utils;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.service.controllers.PiWikApi;
|
||||
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
||||
import eu.dnetlib.repo.manager.shared.Timezone;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
@ -11,8 +10,6 @@ import org.apache.log4j.Logger;
|
|||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -34,83 +31,53 @@ public class Converter {
|
|||
|
||||
if( datasource.equals(null))
|
||||
return null;
|
||||
|
||||
repository.setActivationId(datasource.get("activationId").toString());
|
||||
repository.setAggregator(datasource.get("aggregator").toString());
|
||||
// repository.setCertificates(datasource.get("certificates").toString());
|
||||
// repository.setCitationGuidelineUrl(datasource.get("citationguidelineurl").toString());
|
||||
repository.setCollectedFrom( datasource.get("collectedfrom").toString());
|
||||
|
||||
repository.setContactEmail(datasource.get("contactemail").toString());
|
||||
if(repository.getContactEmail().equals("null"))
|
||||
repository.setContactEmail("");
|
||||
|
||||
// repository.setDatabaseAccessRestriction(datasource.get("databaseaccessrestriction").toString());
|
||||
// repository.setDatabaseAccessType(datasource.get("databaseaccesstype").toString());
|
||||
// repository.setDataUploadRestriction(datasource.get("datauploadrestriction").toString());
|
||||
// repository.setDataUploadType(datasource.get("datauploadtype").toString());
|
||||
repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString()));
|
||||
repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString()));
|
||||
|
||||
repository.setDescription(datasource.get("description").toString());
|
||||
if(repository.getDescription().equals("null"))
|
||||
repository.setDescription("");
|
||||
|
||||
repository.setEissn(datasource.get("eissn").toString());
|
||||
repository.setId(datasource.get("id").toString());
|
||||
repository.setOfficialName(datasource.get("officialname").toString());
|
||||
|
||||
repository.setEnglishName( datasource.get("englishname").toString());
|
||||
if(repository.getEnglishName().equals("null"))
|
||||
repository.setEnglishName("");
|
||||
|
||||
|
||||
repository.setId(datasource.get("id").toString());
|
||||
repository.setIssn(datasource.get("issn").toString());
|
||||
repository.setOdLanguages(datasource.get("languages").toString());
|
||||
repository.setLatitude( toDouble(datasource.get("latitude").toString()));
|
||||
repository.setLissn(datasource.get("lissn").toString());
|
||||
|
||||
repository.setWebsiteUrl(datasource.get("websiteurl").toString());
|
||||
repository.setLogoUrl(datasource.get("logourl").toString());
|
||||
if(repository.getLogoUrl().equals("null"))
|
||||
repository.setLogoUrl("");
|
||||
|
||||
repository.setContactEmail(datasource.get("contactemail").toString());
|
||||
repository.setLatitude( toDouble(datasource.get("latitude").toString()));
|
||||
repository.setLongitude(toDouble(datasource.get("longitude").toString()));
|
||||
//datasource.get("managed");
|
||||
// repository.setMissionStatementUrl(datasource.get("missionstatementurl").toString());
|
||||
repository.setNamespacePrefix(datasource.get("namespaceprefix").toString());
|
||||
// repository.setOdContentTypes(datasource.get("od_contenttypes").toString());
|
||||
repository.setOfficialName(datasource.get("officialname").toString());
|
||||
if(repository.getOfficialName().equals("null"))
|
||||
repository.setOfficialName("");
|
||||
|
||||
// repository.setPidSystems(datasource.get("pidsystems").toString());
|
||||
//datasource.get("platform");
|
||||
// repository.setProvenanceActionClass( datasource.get("provenanceaction").toString());
|
||||
// repository.setQualityManagementKind(datasource.get("qualitymanagementkind").toString());
|
||||
repository.setRegisteredBy(datasource.get("registeredby").toString());
|
||||
|
||||
if(Objects.equals(repository.getRegisteredBy(),"null"))
|
||||
repository.setRegistered(true);
|
||||
|
||||
// repository.setReleaseEndDate(convertStringToDate(datasource.get("releaseenddate").toString()));
|
||||
// repository.setReleaseStartDate(convertStringToDate(datasource.get("releasestartdate").toString()));
|
||||
// repository.setServiceProvider(Boolean.valueOf(datasource.get("serviceprovider").toString()));
|
||||
//datasource.get("subjects");
|
||||
Double timezone = toDouble(datasource.get("timezone").toString());
|
||||
repository.setTimezone(timezone!=null?timezone:0.0);
|
||||
repository.setNamespacePrefix(datasource.get("namespaceprefix").toString());
|
||||
repository.setOdLanguages(datasource.get("languages").toString());
|
||||
repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString()));
|
||||
|
||||
/* typology -> platform
|
||||
* datasource class -> typology */
|
||||
repository.setTypology(datasource.get("platform").toString());
|
||||
// repository.setVersioning(Boolean.valueOf(datasource.get("versioning").toString()));
|
||||
repository.setWebsiteUrl(datasource.get("websiteurl").toString());
|
||||
if(repository.getTypology().equals("null"))
|
||||
repository.setTypology("");
|
||||
repository.setDatasourceClass(datasource.get("typology").toString());
|
||||
|
||||
//TODO change organization to list
|
||||
JSONArray organizations = ((JSONArray)datasource.get("organizations"));
|
||||
if(organizations.length() != 0) {
|
||||
repository.setOrganization(((JSONArray) datasource.get("organizations")).getJSONObject(0).get("legalname").toString());
|
||||
String countryCode = ((JSONArray) datasource.get("organizations")).getJSONObject(0).get("country").toString();
|
||||
repository.setCountryCode(countryCode);
|
||||
}
|
||||
repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString()));
|
||||
repository.setActivationId(datasource.get("activationId").toString());
|
||||
|
||||
repository.setDescription(datasource.get("description").toString());
|
||||
if(repository.getDescription().equals("null"))
|
||||
repository.setDescription("");
|
||||
|
||||
repository.setIssn(datasource.get("issn").toString());
|
||||
repository.setLissn(datasource.get("lissn").toString());
|
||||
repository.setEissn(datasource.get("eissn").toString());
|
||||
repository.setRegisteredBy(datasource.get("registeredby").toString());
|
||||
|
||||
/* managed field */
|
||||
repository.setRegistered(Boolean.parseBoolean(datasource.get("managed").toString()));
|
||||
|
||||
//subjects
|
||||
repository.setAggregator(datasource.get("aggregator").toString());
|
||||
|
||||
|
||||
String collectedFrom = datasource.get("collectedfrom").toString();
|
||||
//TODO check data consistency
|
||||
String type = "UNKNOWN";
|
||||
|
@ -121,7 +88,20 @@ public class Converter {
|
|||
} else if (collectedFrom.equalsIgnoreCase("infrastruct_::openaire")) {
|
||||
type = "journal";
|
||||
}
|
||||
/* collected from field */
|
||||
repository.setDatasourceType(type);
|
||||
repository.setCollectedFrom(collectedFrom);
|
||||
|
||||
//TODO change organization to list
|
||||
JSONArray organizations = ((JSONArray)datasource.get("organizations"));
|
||||
if(organizations.length() != 0) {
|
||||
repository.setOrganization(((JSONArray) datasource.get("organizations")).getJSONObject(0).get("legalname").toString());
|
||||
String countryCode = ((JSONArray) datasource.get("organizations")).getJSONObject(0).get("country").toString();
|
||||
repository.setCountryCode(countryCode);
|
||||
}
|
||||
|
||||
/* identities field */
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
|
@ -177,18 +157,21 @@ public class Converter {
|
|||
|
||||
RepositoryInterface repositoryInterface = new RepositoryInterface();
|
||||
|
||||
repositoryInterface.setBaseUrl(repositoryInterfaceObject.get("baseurl").toString());
|
||||
repositoryInterface.setContentDescription(repositoryInterfaceObject.get("contentdescription").toString());
|
||||
repositoryInterface.setId(repositoryInterfaceObject.get("id").toString());
|
||||
// repositoryInterface.setMetadataIdentifierPath(repositoryInterfaceObject.get("metadataIdentifierPath").toString());
|
||||
repositoryInterface.setAccessProtocol(repositoryInterfaceObject.get("protocol").toString());
|
||||
repositoryInterface.setContentDescription(repositoryInterfaceObject.get("contentdescription").toString());
|
||||
repositoryInterface.setTypology(repositoryInterfaceObject.get("typology").toString());
|
||||
repositoryInterface.setDesiredCompatibilityLevel(repositoryInterfaceObject.get("compatibility").toString());
|
||||
//repositoryInterface.setActive(Boolean.parseBoolean(repositoryInterfaceObject.get("active").toString()));
|
||||
repositoryInterface.setRemovable(Boolean.parseBoolean(repositoryInterfaceObject.get("removable").toString()));
|
||||
repositoryInterface.setCompliance(repositoryInterfaceObject.get("compatibility").toString());
|
||||
repositoryInterface.setLastCollectionDate(repositoryInterfaceObject.get("lastCollectionDate").toString());
|
||||
|
||||
repositoryInterface.setBaseUrl(repositoryInterfaceObject.get("baseurl").toString());
|
||||
repositoryInterface.setRemovable(Boolean.parseBoolean(repositoryInterfaceObject.get("removable").toString()));
|
||||
|
||||
|
||||
// repositoryInterface.setMetadataIdentifierPath(repositoryInterfaceObject.get("metadataIdentifierPath").toString());
|
||||
repositoryInterface.setDesiredCompatibilityLevel(repositoryInterfaceObject.get("compatibility").toString());
|
||||
//repositoryInterface.setActive(Boolean.parseBoolean(repositoryInterfaceObject.get("active").toString()));
|
||||
|
||||
|
||||
Map<String, String> accessParams = new HashMap<>();
|
||||
Map<String, String> extraFields = new HashMap<>();
|
||||
|
@ -199,6 +182,8 @@ public class Converter {
|
|||
for(int i=0;i<apiparams.length();i++)
|
||||
accessParams.put(apiparams.getJSONObject(i).getString("param"),apiparams.getJSONObject(i).getString("value"));
|
||||
|
||||
repositoryInterface.setAccessParams(accessParams);
|
||||
|
||||
return repositoryInterface;
|
||||
}
|
||||
|
||||
|
@ -219,22 +204,40 @@ public class Converter {
|
|||
jsonObject.put("namespaceprefix",repository.getNamespacePrefix());
|
||||
jsonObject.put("languages",repository.getOdLanguages());
|
||||
jsonObject.put("dateofvalidation",convertDateToString(repository.getDateOfValidation()));
|
||||
jsonObject.put("typology",repository.getTypology());
|
||||
|
||||
/*
|
||||
* typology -> platform
|
||||
* datasource class -> typology
|
||||
* */
|
||||
jsonObject.put("typology",repository.getDatasourceClass());
|
||||
jsonObject.put("platform",repository.getTypology());
|
||||
|
||||
jsonObject.put("dateofcollection",convertDateToString(repository.getDateOfCollection()));
|
||||
// jsonObject.put("platform",repository.getPlatform());
|
||||
jsonObject.put("activationId",repository.getActivationId());
|
||||
jsonObject.put("description",repository.getDescription());
|
||||
jsonObject.put("eissn",repository.getEissn());
|
||||
jsonObject.put("issn",repository.getIssn());
|
||||
jsonObject.put("lissn",repository.getLissn());
|
||||
jsonObject.put("registeredby",repository.getRegisteredBy());
|
||||
// jsonObject.put("subjects",repository.getSubjects());
|
||||
|
||||
jsonObject.put("aggregator",repository.getAggregator());
|
||||
jsonObject.put("collectedfrom",repository.getCollectedFrom());
|
||||
// jsonObject.put("managed",repository.getIsManaged());
|
||||
|
||||
// jsonObject.put("organizations",repository.getOrganization());
|
||||
// for(repository.getOrganization())
|
||||
jsonObject.put("managed",repository.isRegistered());
|
||||
|
||||
JSONObject organization = new JSONObject();
|
||||
organization.put("legalname",repository.getOrganization());
|
||||
organization.put("country",repository.getCountryCode());
|
||||
organization.put("legalshortname","");
|
||||
organization.put("websiteurl","");
|
||||
organization.put("logourl","");
|
||||
|
||||
JSONArray organizations = new JSONArray();
|
||||
organizations.put(organization);
|
||||
jsonObject.put("organizations",organizations);
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO check fields
|
||||
/* jsonObject.put("certificates",repository.getCertificates());
|
||||
|
@ -262,20 +265,26 @@ public class Converter {
|
|||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
jsonObject.put("baseurl",repositoryInterface.getBaseUrl());
|
||||
jsonObject.put("contentdescription",repositoryInterface.getContentDescription());
|
||||
jsonObject.put("id",repositoryInterface.getId());
|
||||
jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
|
||||
jsonObject.put("protocol",repositoryInterface.getAccessProtocol());
|
||||
jsonObject.put("datasource",repository.getId());
|
||||
jsonObject.put("contentdescription",repositoryInterface.getContentDescription());
|
||||
jsonObject.put("typology",repositoryInterface.getTypology());
|
||||
jsonObject.put("compatibility",repositoryInterface.getDesiredCompatibilityLevel());
|
||||
jsonObject.put("datasource",repository.getId());
|
||||
jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
|
||||
jsonObject.put("protocol",repositoryInterface.getAccessProtocol());
|
||||
jsonObject.put("compatibilityOverride",repositoryInterface.getDesiredCompatibilityLevel());
|
||||
|
||||
jsonObject.put("lastCollectionTotal","");
|
||||
|
||||
jsonObject.put("lastCollectionDate",repositoryInterface.getLastCollectionDate());
|
||||
jsonObject.put("lastAggregationTotal","");
|
||||
jsonObject.put("lastAggregationDate","");
|
||||
jsonObject.put("lastDownloadTotal","");
|
||||
jsonObject.put("lastDownloadDate","");
|
||||
|
||||
jsonObject.put("baseurl",repositoryInterface.getBaseUrl());
|
||||
jsonObject.put("removable",repositoryInterface.isRemovable());
|
||||
jsonObject.put("active",repositoryInterface.isActive());
|
||||
|
||||
|
||||
|
||||
JSONArray apiparams = new JSONArray();
|
||||
for(String param: repositoryInterface.getAccessParams().keySet()){
|
||||
JSONObject jo = new JSONObject();
|
||||
|
@ -283,19 +292,11 @@ public class Converter {
|
|||
jo.put("value",repositoryInterface.getAccessParams().get(param));
|
||||
apiparams.put(jo);
|
||||
}
|
||||
jsonObject.put("apiparam",apiparams);
|
||||
jsonObject.put("apiParams",apiparams);
|
||||
|
||||
|
||||
jsonObject.put("lastCollectionDate",repositoryInterface.getLastCollectionDate());
|
||||
//jsonObject.put("lastCollectionMdid",repositoryInterface);
|
||||
//jsonObject.put("lastCollectionTotal");
|
||||
//jsonObject.put("lastDownloadDate");
|
||||
// jsonObject.put("lastDownloadMdid");
|
||||
// jsonObject.put("lastDownloadTotal");
|
||||
// jsonObject.put("lastValidationJob");
|
||||
//jsonObject.put("lastAggregationDate");
|
||||
//jsonObject.put("lastAggregationMdid");
|
||||
//jsonObject.put("lastAggregationTotal");
|
||||
// jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
|
||||
|
||||
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
|
|
|
@ -50,7 +50,7 @@ transport.soap.force.local.address = false
|
|||
|
||||
# the email of the administrator
|
||||
# he will receive all the automatic bug reports and feedback created
|
||||
services.repo-manager.adminEmail = nikonas@di.uoa.gr
|
||||
services.repo-manager.adminEmail = pkanakakis@di.uoa.gr
|
||||
|
||||
# if set to true, getRepositories will return dummy repositories
|
||||
services.repo-manager.repository.testing.mode = false
|
||||
|
@ -81,12 +81,12 @@ services.validator.mail.mode = ssl
|
|||
# used by eu.dnetlib.utils.MailLibrary to control debuggin messages
|
||||
services.validator.mail.debug = false
|
||||
# if services.validator.mail.override is true then all mails will be send only to this address
|
||||
services.validator.mail.overrideEmail = nikonas@di.uoa.gr
|
||||
services.validator.mail.overrideEmail = pkanakakis@di.uoa.gr
|
||||
# a comma-seperated list of address that will receive all mails about validations and repo registrations
|
||||
services.validator.mail.specialRecipients = nikonas@di.uoa.gr
|
||||
services.validator.mail.specialRecipients = pkanakakis@di.uoa.gr
|
||||
|
||||
# a comma-seperated list of addresses that have the ability to register repos without the need for validation and registration
|
||||
services.validator.repoRegistration.override = nikonas@di.uoa.gr
|
||||
services.validator.repoRegistration.override = pkanakakis@di.uoa.gr
|
||||
|
||||
|
||||
repomanager.db.driverClassName = org.postgresql.Driver
|
||||
|
@ -98,9 +98,14 @@ services.repomanager.analyticsURL = http://analytics.openaire.eu/addsite.php?
|
|||
|
||||
topic_types.url = https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:topic_types.json
|
||||
|
||||
oidc.issuer = https://aai.openminted.eu/oidc/
|
||||
oidc.id = 24e83176-1312-4ba3-bc0b-ffeebea1603e
|
||||
oidc.secret = U_gLOupYu2trYIOwfxGgZkkZoOHG_zGfaViOUsXcZ7qVQuF1rcJeQYKIDX1TY3z27CIoHaqq9ht2rmAiUmBRYQ
|
||||
#oidc.issuer = https://aai.openminted.eu/oidc/
|
||||
#oidc.id = 24e83176-1312-4ba3-bc0b-ffeebea1603e
|
||||
#oidc.secret = U_gLOupYu2trYIOwfxGgZkkZoOHG_zGfaViOUsXcZ7qVQuF1rcJeQYKIDX1TY3z27CIoHaqq9ht2rmAiUmBRYQ
|
||||
|
||||
oidc.issuer = https://aai.openaire.eu/oidc/
|
||||
oidc.id = 767422b9-5461-4807-a80a-f9a2072d3a7d
|
||||
oidc.secret = AMQtGlbTXNjwjhF0st28LmM6V0XypMdaVS7tJmGuYFlmH36iIv4t7tVqYuLYrNPkhnZ_GPUJvhymBhFupdgb6aU
|
||||
|
||||
oidc.dev.home = http://194.177.192.121:8380/repomanager-service-dev/openid_connect_login
|
||||
webapp.dev.front = http://194.177.192.121:3000
|
||||
|
||||
|
@ -111,4 +116,5 @@ redis.password = E#Szvnidd
|
|||
|
||||
services.repomanager.usageStatisticsDiagramsBaseURL = https://beta.openaire.eu/stats3/
|
||||
services.repomanager.usageStatisticsNumbersBaseURL = https://beta.services.openaire.eu/usagestats/datasources/
|
||||
services.repomanager.usagestats.adminEmail = repositoryusagestats@openaire.eu
|
||||
#services.repomanager.usagestats.adminEmail = repositoryusagestats@openaire.eu
|
||||
services.repomanager.usagestats.adminEmail = pkanakakis@di.uoa.gr
|
|
@ -36,24 +36,15 @@
|
|||
|
||||
<bean id="openIdConnectAuthenticationProvider" class="org.mitre.openid.connect.client.OIDCAuthenticationProvider">
|
||||
<property name="authoritiesMapper">
|
||||
<bean class="org.mitre.openid.connect.client.NamedAdminAuthoritiesMapper">
|
||||
<property name="admins" ref="namedAdmins" />
|
||||
<bean class="eu.dnetlib.repo.manager.service.config.OpenAireProviderAuthoritiesMapper">
|
||||
<constructor-arg name="userRoles" ref="userRoles"/>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<util:set id="namedAdmins" value-type="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
|
||||
<!--
|
||||
This is an example of how to set up a user as an administrator: they'll be given ROLE_ADMIN in addition to ROLE_USER.
|
||||
Note that having an administrator role on the IdP doesn't grant administrator access on this client.
|
||||
|
||||
These are values from the demo "openid-connect-server-webapp" project of MITREid Connect.
|
||||
-->
|
||||
<bean class="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
|
||||
<constructor-arg name="subject" value="subject_value" />
|
||||
<constructor-arg name="issuer" value="${oidc.issuer}" />
|
||||
</bean>
|
||||
</util:set>
|
||||
<util:map id="userRoles">
|
||||
<entry key="urn:geant:openaire.eu:group:Super+Administrator" value="ROLE_ADMIN"/>
|
||||
</util:map>
|
||||
|
||||
|
||||
<bean class="eu.dnetlib.repo.manager.service.config.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect">
|
||||
|
|
|
@ -19,6 +19,18 @@
|
|||
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
|
||||
|
||||
|
||||
<bean id="maillib" class="eu.dnetlib.utils.MailLibrary" init-method="init">
|
||||
<property name="mailhost" value="${services.validator.mail.host}"/>
|
||||
<property name="smtpPort" value="${services.validator.mail.port}"/>
|
||||
<property name="authenticate" value="${services.validator.mail.authenticate}"/>
|
||||
<property name="username" value="${services.validator.mail.username}"/>
|
||||
<property name="password" value="${services.validator.mail.password}"/>
|
||||
<property name="from" value="${services.validator.mail.fromAddress}"/>
|
||||
<property name="replyTo" value="${services.validator.mail.replyToAddress}"/>
|
||||
<property name="mode" value="${services.validator.mail.mode}"/>
|
||||
<property name="debug" value="${services.validator.mail.debug}"/>
|
||||
</bean>
|
||||
|
||||
<bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader"
|
||||
id="propertyLoader">
|
||||
<property name="order" value="2"/>
|
||||
|
@ -77,4 +89,5 @@
|
|||
<mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
|
||||
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||
<bean class="eu.dnetlib.repo.manager.service.config.SwaggerConfig"/>
|
||||
|
||||
</beans>
|
Loading…
Reference in New Issue