1. Fix new dev api

2. Fix bugs on validator / broker / piwik api.
3. JSON changes on convert file for dev api
4. Add new class RequestFilter on utils package for search queries.
This commit is contained in:
Panagiotis Kanakakis 2018-02-21 15:05:02 +00:00
parent 04ce834f59
commit 7f00c2f321
11 changed files with 363 additions and 66 deletions

View File

@ -18,23 +18,32 @@ import java.util.Map;
@Api(description = "Broker API", tags = {"broker"}) @Api(description = "Broker API", tags = {"broker"})
public interface BrokerApi { public interface BrokerApi {
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException; DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException;
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException; List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException;
@RequestMapping(value = "/advancedShowEvents/{page}/{size}" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/advancedShowEvents/{page}/{size}" , method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
EventsPage advancedShowEvents(String page, EventsPage advancedShowEvents(String page,
String size, String size,
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException; AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException;
@RequestMapping(value = "/showEvents/{datasourceName}/{topic}/{page}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/showEvents/{datasourceName}/{topic}/{page}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
EventsPage showEvents(String datasourceName, EventsPage showEvents(String datasourceName,
String topic, String topic,
String page) throws BrokerException, JSONException; String page) throws BrokerException, JSONException;
@RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException; Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;

View File

@ -24,11 +24,11 @@ public interface PiWikApi {
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
List<PiwikInfo> getPiwikSitesForRepos(); List<PiwikInfo> getPiwikSitesForRepos();
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
@ResponseBody @ResponseBody
void approvePiwikSite(String repositoryId); void approvePiwikSite(String repositoryId);
@RequestMapping(value = "/getOpenaireId/{repositoryid}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
String getOpenaireId(String repositoryid); String getOpenaireId(String repositoryid);
} }

View File

@ -77,14 +77,16 @@ public class PiWikApiImpl implements PiWikApi{
} }
@Override @Override
public String getOpenaireId(@PathVariable("repositoryId") String repositoryid) { public String getOpenaireId(@PathVariable("repositoryId") String repositoryId) {
LOGGER.debug("Getting openaire id for repository: " + repositoryId);
try { try {
if (repositoryid != null && repositoryid.contains("::")) if (repositoryId != null && repositoryId.contains("::")) {
return repositoryid.split("::")[0] + "::" + MD5.encrypt2Hex(repositoryid.split("::")[1]); return repositoryId.split("::")[0] + "::" + MD5.encrypt2Hex(repositoryId.split("::")[1]);
}
else else
return null; return null;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
e.printStackTrace(); LOGGER.debug(e);
} }
return null; return null;
} }

View File

@ -199,7 +199,6 @@ public class RepositoryApiImpl implements RepositoryApi {
List<Repository> reps = new ArrayList<>(); List<Repository> reps = new ArrayList<>();
for (Repository r : rs) { for (Repository r : rs) {
LOGGER.debug(r.getCollectedFrom());
if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode)) if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode))
reps.add(r); reps.add(r);
} }
@ -216,7 +215,7 @@ public class RepositoryApiImpl implements RepositoryApi {
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setRegisteredby(userEmail); requestFilter.setRegisteredby(userEmail);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
LOGGER.debug(rs);
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
for (Repository r : repos) for (Repository r : repos)
this.getRepositoryInfo(r); this.getRepositoryInfo(r);
@ -227,13 +226,13 @@ public class RepositoryApiImpl implements RepositoryApi {
@Override @Override
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException { public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException {
UriComponents uriComponents = UriComponentsBuilder LOGGER.debug("Retreiving repositories with id : " + id );
.fromHttpUrl(baseAddress + "/ds/get/") UriComponents uriComponents = searchDatasource("0","100");
.path("/{id}/") RequestFilter requestFilter = new RequestFilter();
.build().expand(id).encode(); requestFilter.setId(id);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
Repository repo = Converter.jsonToRepositoryObject(new JSONObject(rs)); Repository repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
if (repo != null) if (repo != null)
getRepositoryInfo(repo); getRepositoryInfo(repo);
return repo; return repo;
@ -243,20 +242,20 @@ public class RepositoryApiImpl implements RepositoryApi {
@Override @Override
public Aggregations getRepositoryAggregations(@PathVariable("id") String id) throws JSONException { public Aggregations getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
UriComponents uriComponents = UriComponentsBuilder LOGGER.debug("Retreiving aggregations for repository with id : " + id );
.fromHttpUrl(baseAddress + "/ds/get/") UriComponents uriComponents = searchDatasource("0","100");
.path("/{id}/") RequestFilter requestFilter = new RequestFilter();
.build().expand(id).encode(); requestFilter.setId(id);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
JSONObject repository = new JSONObject(rs); JSONObject repository = new JSONObject(rs);
Aggregations aggregations = new Aggregations(); Aggregations aggregations = new Aggregations();
try { try {
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository)); LOGGER.debug(repository.getJSONArray("datasourceInfo").getJSONObject(0));
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository)); aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository)); aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
return aggregations; return aggregations;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.debug("JSON aggregation exception ", e); LOGGER.debug("JSON aggregation exception ", e);
@ -269,13 +268,13 @@ public class RepositoryApiImpl implements RepositoryApi {
public List<Repository> getRepositoriesByName(@PathVariable("name") String name, public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
@PathVariable("page") String page, @PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException { @PathVariable("size") String size) throws JSONException {
UriComponents uriComponents = UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/search/name/")
.path("/{page}/{size}")
.queryParam("name", name)
.build().expand(page, size).encode();
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); LOGGER.debug("Retreiving repositories with official name : " + name );
UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter();
requestFilter.setOfficialname(name);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
for (Repository r : repos) for (Repository r : repos)
getRepositoryInfo(r); getRepositoryInfo(r);

View File

@ -31,9 +31,9 @@ public interface ValidatorApi {
@ResponseBody @ResponseBody
List<RuleSet> getRuleSets(String mode); List<RuleSet> getRuleSets(String mode);
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getSetsOfRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
List<String> getSetsOfRepository(@RequestBody String url); List<String> getSetsOfRepository(String url);
@RequestMapping(value = "/identifyRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/identifyRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody

View File

@ -126,7 +126,7 @@ public class ValidatorApiImpl implements ValidatorApi{
} }
@Override @Override
public List<String> getSetsOfRepository(@PathVariable("url") String url) { public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
LOGGER.debug("Getting sets of repository with url : " + url); LOGGER.debug("Getting sets of repository with url : " + url);
try { try {
return OaiTools.getSetsOfRepo(url); return OaiTools.getSetsOfRepo(url);
@ -137,7 +137,7 @@ public class ValidatorApiImpl implements ValidatorApi{
} }
@Override @Override
public boolean identifyRepo(@PathVariable("url") String url) { public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) {
LOGGER.debug("Identify repository with url : " + url); LOGGER.debug("Identify repository with url : " + url);
try { try {
return OaiTools.identifyRepository(url); return OaiTools.identifyRepository(url);
@ -185,7 +185,7 @@ public class ValidatorApiImpl implements ValidatorApi{
} }
@Override @Override
public InterfaceInformation getInterfaceInformation(@PathVariable("baseUrl") String baseUrl) throws ValidationServiceException { public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
try { try {
LOGGER.debug("Getting interface information with url: " + baseUrl); LOGGER.debug("Getting interface information with url: " + baseUrl);
InterfaceInformation interfaceInformation = new InterfaceInformation(); InterfaceInformation interfaceInformation = new InterfaceInformation();

View File

@ -1,5 +1,6 @@
package eu.dnetlib.repo.manager.service.utils; package eu.dnetlib.repo.manager.service.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.domain.data.Repository; import eu.dnetlib.domain.data.Repository;
import eu.dnetlib.domain.data.RepositoryInterface; import eu.dnetlib.domain.data.RepositoryInterface;
@ -22,8 +23,6 @@ public class Converter {
Repository repository = new Repository(); Repository repository = new Repository();
LOGGER.debug("datasource response -> " + repositoryObject);
JSONObject datasource = repositoryObject.getJSONObject("datasource"); JSONObject datasource = repositoryObject.getJSONObject("datasource");
if( datasource.equals(null)) if( datasource.equals(null))
@ -97,9 +96,12 @@ public class Converter {
repository.setDatasourceClass(datasource.get("typology").toString()); repository.setDatasourceClass(datasource.get("typology").toString());
//TODO change organization to list //TODO change organization to list
repository.setOrganization( ((JSONArray)datasource.get("organizations")).getJSONObject(0).get("legalname").toString()); JSONArray organizations = ((JSONArray)datasource.get("organizations"));
String countryCode = ((JSONArray)datasource.get("organizations")).getJSONObject(0).get("country").toString(); 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.setCountryCode(countryCode);
}
String collectedFrom = datasource.get("collectedfrom").toString(); String collectedFrom = datasource.get("collectedfrom").toString();
@ -300,19 +302,13 @@ public class Converter {
return list; return list;
} }
public static List<AggregationDetails> getAggregationHistoryFromJson(JSONObject repositoryObject) throws JSONException { public static List<AggregationDetails> getAggregationHistoryFromJson(JSONObject datasourceInfo) throws JSONException {
/* if( repositoryObject.get("aggregationHistory").toString().equals("[]") ||
repositoryObject.get("aggregationHistory")!= null) if(datasourceInfo.get("aggregationHistory").toString().equals("[]"))
return null;*/
if(repositoryObject.get("aggregationHistory").toString().equals("[]"))
return null; return null;
JSONArray rs = new JSONArray(datasourceInfo.get("aggregationHistory").toString());
JSONArray rs = new JSONArray(repositoryObject.get("aggregationHistory").toString());
LOGGER.debug(rs.length());
List<AggregationDetails> aggregationDetailsList = new ArrayList<>(); List<AggregationDetails> aggregationDetailsList = new ArrayList<>();
for(int i=0;i<rs.length();i++) for(int i=0;i<rs.length();i++)
aggregationDetailsList.add(jsonToAggregationDetails(rs.getJSONObject(i))); aggregationDetailsList.add(jsonToAggregationDetails(rs.getJSONObject(i)));
@ -331,20 +327,20 @@ public class Converter {
return aggregationDetails; return aggregationDetails;
} }
public static AggregationDetails getLastCollectionFromJson(JSONObject repositoryObject) throws JSONException { public static AggregationDetails getLastCollectionFromJson(JSONObject datasourceInfo) throws JSONException {
if( repositoryObject.get("lastCollection").equals(null)) if( datasourceInfo.get("lastCollection").equals(null))
return null; return null;
return jsonToAggregationDetails(repositoryObject.getJSONObject("lastCollection")); return jsonToAggregationDetails(datasourceInfo.getJSONObject("lastCollection"));
} }
public static AggregationDetails getLastTransformationFromJson(JSONObject repositoryObject) throws JSONException { public static AggregationDetails getLastTransformationFromJson(JSONObject datasourceInfo) throws JSONException {
if( repositoryObject.get("lastTransformation").equals(null)) if( datasourceInfo.get("lastTransformation").equals(null))
return null; return null;
return jsonToAggregationDetails(repositoryObject.getJSONObject("lastTransformation")); return jsonToAggregationDetails(datasourceInfo.getJSONObject("lastTransformation"));
} }
public static List<Timezone> toTimezones(List<String> timezones) { public static List<Timezone> toTimezones(List<String> timezones) {

View File

@ -0,0 +1,18 @@
package eu.dnetlib.repo.manager.service.utils;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.domain.functionality.UserProfile;
public interface EmailUtils {
void reportException(Exception exception);
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
}

View File

@ -0,0 +1,251 @@
package eu.dnetlib.repo.manager.service.utils;
import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader;
import eu.dnetlib.utils.MailLibrary;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
@Component
public class EmailUtilsImpl implements EmailUtils {
private static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class);
private List<String> specialRecipients = new ArrayList<String>();
private boolean override = false, logonly = false;
private String overrideEmail = null, from = null;
@Autowired
private MailLibrary mailLibrary;
@Autowired
private CascadingPropertyLoader pLoader;
@Value("${services.repo-manager.baseUrl}")
private String baseUrl;
@Value("${services.repo-manager.adminEmail}")
private String adminEmail;
@Value("${services.repomanager.usagestats.adminEmail}")
private String usageStatsAdminEmail;
@Override
public void reportException(Exception exception) {
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
exception.printStackTrace(printWriter);
List<String> recipients = new ArrayList<String>();
try {
recipients.add(this.adminEmail);
String message = "An exception has occurred:\n"+writer.toString();
String subject = "Automatic Bug Report";
this.sendMail(recipients, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error sending error report", e);
}
}
@Override
public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
try {
String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics";
String message = "Dear administrator,\n" +
"\n" +
"we have received a request to enable the OpenAIRE usage statistics for the following repository \n" +
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
"\n" +
"For more information about this request, go here: \n" +
this.baseUrl + "/#admin/metrics\n" +
"\n" +
"Best,\n" +
"The OpenAIRE team";
this.sendMail(this.usageStatsAdminEmail, subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e);
throw e;
}
}
@Override
public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception {
try {
String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics";
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
"\n" +
"we have received your request to enable the OpenAIRE usage statistics for your repository\n" +
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
"\n" +
"In order to enable the usage statistics, you must install the OpenAIRE's tracking code in your repository software. " +
"OpenAIRE's usage statistics service tracking code is maintained on Github as a patch for various versions of DSpace " +
"(https://github.com/openaire/OpenAIRE-Piwik-DSpace) and as an Eprints plugin for version 3 " +
"(https://github.com/openaire/EPrints-OAPiwik). In case the platform is different from DSpace or EPrints please contact " +
"the OpenAIRE team in repositoryusagestats@openaire.eu in order to find a solution.\n" +
"\n" +
"For more information about your request and configuration details, go here: \n" +
this.baseUrl + "/#getImpact/instructions/" + piwikInfo.getRepositoryId() + "\n" +
"\n" +
"Once you have finished configuring your repository or if you have any questions, please notify the OpenAIRE team by sending \n" +
"an email to repositoryusagestats@openaire.eu\n" +
"\n" +
"Best,\n" +
"The OpenAIRE team";
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e);
throw e;
}
}
@Override
public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
try {
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
String message = "Dear administrator,\n" +
"\n" +
"The installation and configuration of OpenAIRE's tracking code for the following repository " +
"has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
"\n" +
"Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" +
"Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" +
"Piwik ID - " + piwikInfo.getSiteId() + "\n" +
"Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" +
"\n" +
"Best,\n" +
"The OpenAIRE team";
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e);
throw e;
}
}
@Override
public void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception {
try {
String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled";
String message = "Dear " + piwikInfo.getRequestorName() + ",\n" +
"\n" +
"The installation and configuration of OpenAIRE's tracking code for your repository \"" + piwikInfo.getRepositoryName() +
"\" has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" +
"\n" +
"You can preview the statistics in your repository's dashboard: \n" +
this.baseUrl + "/#getImpact/" + piwikInfo.getRepositoryId() + "\n" +
"\n" +
" For more information and questions, you can contact the openaire support team by sending an email to " +
"repositoryusagestats@openaire.eu\n" +
"\n" +
"Best,\n" +
"The OpenAIRE team";
this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null);
} catch (Exception e) {
LOGGER.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e);
throw e;
}
}
private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
ArrayList<String> to = new ArrayList<String>();
to.add(email);
this.sendMail(to,subject,message,sendToSpecial,repoAdminMails);
}
private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
/* try {
if (sendToSpecial) {
recipients.addAll(this.specialRecipients);
}
if (repoAdminMails != null)
recipients.addAll(repoAdminMails);
if (this.override) {
recipients.clear();
recipients.add(overrideEmail);
}
if (!logonly)
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
LOGGER.debug("Sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message);
} 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) {
return pLoader.getProperties().getProperty(key);
}
public void setSpecialRecipients(String specialRecipients) {
String[] recps = specialRecipients.split(",");
for (String recp : recps) {
recp = recp.trim();
this.specialRecipients.add(recp);
}
}
public void setOverride(boolean override) {
this.override = override;
}
public void setOverrideEmail(String overrideEmail) {
this.overrideEmail = overrideEmail;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public boolean isLogonly() {
return logonly;
}
public void setLogonly(boolean logonly) {
this.logonly = logonly;
}
}

View File

@ -1,11 +1,15 @@
package eu.dnetlib.repo.manager.service.utils; package eu.dnetlib.repo.manager.service.utils;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RequestFilter{ public class RequestFilter{
private String registeredby = ""; private String registeredby = null;
private String typology = ""; private String typology = null;
private String country = ""; private String country = null;
private String id = null;
private String officialname = null;
public RequestFilter() { public RequestFilter() {
@ -35,4 +39,20 @@ public class RequestFilter{
public void setCountry(String country) { public void setCountry(String country) {
this.country = country; this.country = country;
} }
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOfficialname() {
return officialname;
}
public void setOfficialname(String officialname) {
this.officialname = officialname;
}
} }

View File

@ -95,4 +95,6 @@ public class Subscription implements IsSerializable {
public void setConditionsAsList(List<MapConditions> conditionsAsList) { public void setConditionsAsList(List<MapConditions> conditionsAsList) {
this.conditionsAsList = conditionsAsList; this.conditionsAsList = conditionsAsList;
} }
} }