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:
parent
04ce834f59
commit
7f00c2f321
|
@ -18,23 +18,32 @@ import java.util.Map;
|
|||
@Api(description = "Broker API", tags = {"broker"})
|
||||
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;
|
||||
|
||||
@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;
|
||||
|
||||
@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,
|
||||
String size,
|
||||
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,
|
||||
String topic,
|
||||
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
|
||||
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ public interface PiWikApi {
|
|||
@RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<PiwikInfo> getPiwikSitesForRepos();
|
||||
|
||||
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
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
|
||||
String getOpenaireId(String repositoryid);
|
||||
}
|
||||
|
|
|
@ -77,14 +77,16 @@ public class PiWikApiImpl implements PiWikApi{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getOpenaireId(@PathVariable("repositoryId") String repositoryid) {
|
||||
public String getOpenaireId(@PathVariable("repositoryId") String repositoryId) {
|
||||
LOGGER.debug("Getting openaire id for repository: " + repositoryId);
|
||||
try {
|
||||
if (repositoryid != null && repositoryid.contains("::"))
|
||||
return repositoryid.split("::")[0] + "::" + MD5.encrypt2Hex(repositoryid.split("::")[1]);
|
||||
if (repositoryId != null && repositoryId.contains("::")) {
|
||||
return repositoryId.split("::")[0] + "::" + MD5.encrypt2Hex(repositoryId.split("::")[1]);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.debug(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -199,7 +199,6 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
|
||||
List<Repository> reps = new ArrayList<>();
|
||||
for (Repository r : rs) {
|
||||
LOGGER.debug(r.getCollectedFrom());
|
||||
if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode))
|
||||
reps.add(r);
|
||||
}
|
||||
|
@ -216,7 +215,7 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setRegisteredby(userEmail);
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
LOGGER.debug(rs);
|
||||
|
||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||
for (Repository r : repos)
|
||||
this.getRepositoryInfo(r);
|
||||
|
@ -227,13 +226,13 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
@Override
|
||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/get/")
|
||||
.path("/{id}/")
|
||||
.build().expand(id).encode();
|
||||
|
||||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
Repository repo = Converter.jsonToRepositoryObject(new JSONObject(rs));
|
||||
LOGGER.debug("Retreiving repositories with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
Repository repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
|
||||
if (repo != null)
|
||||
getRepositoryInfo(repo);
|
||||
return repo;
|
||||
|
@ -243,20 +242,20 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
@Override
|
||||
public Aggregations getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/get/")
|
||||
.path("/{id}/")
|
||||
.build().expand(id).encode();
|
||||
|
||||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
LOGGER.debug("Retreiving aggregations for repository with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||
JSONObject repository = new JSONObject(rs);
|
||||
|
||||
Aggregations aggregations = new Aggregations();
|
||||
|
||||
try {
|
||||
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository));
|
||||
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository));
|
||||
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository));
|
||||
LOGGER.debug(repository.getJSONArray("datasourceInfo").getJSONObject(0));
|
||||
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||
return aggregations;
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("JSON aggregation exception ", e);
|
||||
|
@ -269,13 +268,13 @@ public class RepositoryApiImpl implements RepositoryApi {
|
|||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||
@PathVariable("page") String page,
|
||||
@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));
|
||||
for (Repository r : repos)
|
||||
getRepositoryInfo(r);
|
||||
|
|
|
@ -31,9 +31,9 @@ public interface ValidatorApi {
|
|||
@ResponseBody
|
||||
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
|
||||
List<String> getSetsOfRepository(@RequestBody String url);
|
||||
List<String> getSetsOfRepository(String url);
|
||||
|
||||
@RequestMapping(value = "/identifyRepository/{url}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
|
|
|
@ -126,7 +126,7 @@ public class ValidatorApiImpl implements ValidatorApi{
|
|||
}
|
||||
|
||||
@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);
|
||||
try {
|
||||
return OaiTools.getSetsOfRepo(url);
|
||||
|
@ -137,7 +137,7 @@ public class ValidatorApiImpl implements ValidatorApi{
|
|||
}
|
||||
|
||||
@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);
|
||||
try {
|
||||
return OaiTools.identifyRepository(url);
|
||||
|
@ -185,7 +185,7 @@ public class ValidatorApiImpl implements ValidatorApi{
|
|||
}
|
||||
|
||||
@Override
|
||||
public InterfaceInformation getInterfaceInformation(@PathVariable("baseUrl") String baseUrl) throws ValidationServiceException {
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
|
||||
try {
|
||||
LOGGER.debug("Getting interface information with url: " + baseUrl);
|
||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.dnetlib.repo.manager.service.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import eu.dnetlib.domain.data.Repository;
|
||||
import eu.dnetlib.domain.data.RepositoryInterface;
|
||||
|
@ -21,9 +22,7 @@ public class Converter {
|
|||
public static Repository jsonToRepositoryObject(JSONObject repositoryObject) throws JSONException {
|
||||
|
||||
Repository repository = new Repository();
|
||||
|
||||
|
||||
LOGGER.debug("datasource response -> " + repositoryObject);
|
||||
|
||||
JSONObject datasource = repositoryObject.getJSONObject("datasource");
|
||||
|
||||
if( datasource.equals(null))
|
||||
|
@ -97,11 +96,14 @@ public class Converter {
|
|||
repository.setDatasourceClass(datasource.get("typology").toString());
|
||||
|
||||
//TODO change organization to list
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
String collectedFrom = datasource.get("collectedfrom").toString();
|
||||
//TODO check data consistency
|
||||
String type = "UNKNOWN";
|
||||
|
@ -300,19 +302,13 @@ public class Converter {
|
|||
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)
|
||||
return null;*/
|
||||
if(repositoryObject.get("aggregationHistory").toString().equals("[]"))
|
||||
|
||||
if(datasourceInfo.get("aggregationHistory").toString().equals("[]"))
|
||||
return null;
|
||||
|
||||
|
||||
JSONArray rs = new JSONArray(repositoryObject.get("aggregationHistory").toString());
|
||||
|
||||
LOGGER.debug(rs.length());
|
||||
|
||||
JSONArray rs = new JSONArray(datasourceInfo.get("aggregationHistory").toString());
|
||||
List<AggregationDetails> aggregationDetailsList = new ArrayList<>();
|
||||
for(int i=0;i<rs.length();i++)
|
||||
aggregationDetailsList.add(jsonToAggregationDetails(rs.getJSONObject(i)));
|
||||
|
@ -331,20 +327,20 @@ public class Converter {
|
|||
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 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 jsonToAggregationDetails(repositoryObject.getJSONObject("lastTransformation"));
|
||||
return jsonToAggregationDetails(datasourceInfo.getJSONObject("lastTransformation"));
|
||||
}
|
||||
|
||||
public static List<Timezone> toTimezones(List<String> timezones) {
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
package eu.dnetlib.repo.manager.service.utils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RequestFilter{
|
||||
|
||||
private String registeredby = "";
|
||||
private String typology = "";
|
||||
private String country = "";
|
||||
private String registeredby = null;
|
||||
private String typology = null;
|
||||
private String country = null;
|
||||
private String id = null;
|
||||
private String officialname = null;
|
||||
|
||||
|
||||
public RequestFilter() {
|
||||
|
@ -35,4 +39,20 @@ public class RequestFilter{
|
|||
public void setCountry(String 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,4 +95,6 @@ public class Subscription implements IsSerializable {
|
|||
public void setConditionsAsList(List<MapConditions> conditionsAsList) {
|
||||
this.conditionsAsList = conditionsAsList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue