Revision 49691
Added by Antonis Lempesis over 6 years ago
RepositoryServiceImpl.java | ||
---|---|---|
5 | 5 |
import eu.dnetlib.domain.data.Repository; |
6 | 6 |
import eu.dnetlib.domain.data.RepositoryInterface; |
7 | 7 |
import eu.dnetlib.domain.enabling.Vocabulary; |
8 |
import eu.dnetlib.domain.functionality.UserProfile; |
|
8 | 9 |
import eu.dnetlib.gwt.server.service.SpringGwtRemoteServiceServlet; |
9 | 10 |
import eu.dnetlib.repo.manager.client.services.RepositoryService; |
10 | 11 |
import eu.dnetlib.repo.manager.server.utils.EmailUtils; |
... | ... | |
550 | 551 |
} |
551 | 552 |
|
552 | 553 |
@Override |
553 |
public void enableMetricsForRepository(Repository repository) throws RepositoryServiceException { |
|
554 |
public void enableMetricsForRepository(Repository repository, UserProfile requestor) throws RepositoryServiceException {
|
|
554 | 555 |
|
555 | 556 |
String URL = analyticsURL + "siteName=" + repository.getOfficialName() + "&url=" + repository.getWebsiteUrl(); |
556 | 557 |
|
... | ... | |
560 | 561 |
// |
561 | 562 |
// String siteId = (String) map.get("value"); |
562 | 563 |
|
563 |
String siteId = "49"; |
|
564 |
String siteId = new Random(new Date().getTime()).nextInt(200) + ""; |
|
565 |
String authenticationToken = new Random(new Date().getTime()).nextInt(1000000000) + ""; |
|
566 |
|
|
564 | 567 |
PiwikInfo piwikInfo = new PiwikInfo(); |
565 | 568 |
piwikInfo.setRepositoryId(repository.getId()); |
569 |
piwikInfo.setRepositoryName(repository.getOfficialName()); |
|
570 |
piwikInfo.setCountry(repository.getCountryName()); |
|
566 | 571 |
piwikInfo.setSiteId(siteId); |
572 |
piwikInfo.setAuthenticationToken(authenticationToken); |
|
573 |
piwikInfo.setRequestorEmail(requestor.getEmail()); |
|
574 |
piwikInfo.setRequestorName(requestor.getFirstname() + " " + requestor.getLastname()); |
|
575 |
piwikInfo.setApproved(false); |
|
567 | 576 |
|
568 | 577 |
this.piwikDAO.savePiwikInfo(piwikInfo); |
569 | 578 |
|
579 |
//TODO send this in an email as well to the usage stats admin list |
|
580 |
|
|
570 | 581 |
// } catch (IOException e) { |
571 | 582 |
// LOGGER.error("Error while creating piwik site", e); |
572 | 583 |
// emailUtils.reportException(e); |
... | ... | |
587 | 598 |
} |
588 | 599 |
} |
589 | 600 |
|
601 |
@Override |
|
602 |
public List<PiwikInfo> getPiwikSitesForRepositories() throws RepositoryServiceException { |
|
603 |
try { |
|
604 |
|
|
605 |
List<PiwikInfo> piwikInfos = new ArrayList<>(); |
|
606 |
piwikInfos = this.piwikDAO.getPiwikSitesForRepos(); |
|
607 |
|
|
608 |
return piwikInfos; |
|
609 |
|
|
610 |
} catch (EmptyResultDataAccessException e) { |
|
611 |
LOGGER.error("Error while getting list of piwik sites: ", e); |
|
612 |
emailUtils.reportException(e); |
|
613 |
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
614 |
} |
|
615 |
} |
|
616 |
|
|
617 |
@Override |
|
618 |
public void approvePiwikSite(String repositoryId) throws RepositoryServiceException { |
|
619 |
try { |
|
620 |
|
|
621 |
this.piwikDAO.approvePiwikSite(repositoryId); |
|
622 |
|
|
623 |
} catch (EmptyResultDataAccessException e) { |
|
624 |
LOGGER.error("Error while approving piwik site: ", e); |
|
625 |
emailUtils.reportException(e); |
|
626 |
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); |
|
627 |
} |
|
628 |
} |
|
629 |
|
|
590 | 630 |
private String getCountryCode(String countryName) { |
591 | 631 |
Vocabulary countries = this.getVocabulary("dnet:countries"); |
592 | 632 |
|
Also available in: Unified diff
svn merge -r49522:HEAD https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-repository-manager-gui/trunk .