no message
This commit is contained in:
parent
693dfc5bb0
commit
a6e2dd60b4
|
@ -49,7 +49,7 @@ public class DMPs extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DataManagementPlanListingModel>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||
public @ResponseBody ResponseItem<DataTableData<DataManagementPlanListingModel>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest,Principal principal) {
|
||||
try {
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(this.getApiContext().getDatabaseRepository().getDmpDao(), dataManagementPlanTableRequest);
|
||||
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
@ -61,9 +61,9 @@ public class DMPs extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataManagementPlan> getSingle(@PathVariable String id) {
|
||||
public @ResponseBody ResponseItem<DataManagementPlan> getSingle(@PathVariable String id,Principal principal) {
|
||||
try {
|
||||
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(this.getApiContext().getDatabaseRepository().getDmpDao(), id);
|
||||
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(this.getApiContext().getDatabaseRepository().getDmpDao(), id,principal);
|
||||
return new ResponseItem<DataManagementPlan>().status(HttpStatus.OK).payload(project);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -88,7 +88,7 @@ public class DMPs extends BaseController {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DataManagementPlan>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria) {
|
||||
public @ResponseBody ResponseItem<List<DataManagementPlan>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria,Principal principal) {
|
||||
try {
|
||||
List<DataManagementPlan> dataTable = new DataManagementPlanManager().getWithCriteria(this.getApiContext().getDatabaseRepository().getDmpDao(), dataManagementPlanCriteria);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DatasetWizardController extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id) {
|
||||
public @ResponseBody ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id,Principal principal) {
|
||||
try {
|
||||
DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class DatasetWizardController extends BaseController{
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/createOrUpdate" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile) {
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile,Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset= DatasetManager.createOrUpdate(this.getApiContext(),profile);
|
||||
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset);
|
||||
|
|
|
@ -13,6 +13,7 @@ import eu.eudat.models.dataset.DatasetTableRequest;
|
|||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -57,7 +58,7 @@ public class Datasets extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasets/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) {
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest,Principal principal) {
|
||||
try {
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext().getDatabaseRepository().getDatasetDao(), datasetTableRequest);
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class Projects extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<eu.eudat.models.project.Project>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest) {
|
||||
public @ResponseBody ResponseItem<DataTableData<eu.eudat.models.project.Project>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest,Principal principal) {
|
||||
try {
|
||||
DataTableData<eu.eudat.models.project.Project> dataTable = new ProjectManager().getPaged(this.getApiContext().getDatabaseRepository().getProjectDao(), projectTableRequest);
|
||||
return new ResponseItem<DataTableData<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
|
@ -79,7 +79,7 @@ public class Projects extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/projects/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.models.project.Project> getPaged(@PathVariable String id) {
|
||||
public @ResponseBody ResponseItem<eu.eudat.models.project.Project> getPaged(@PathVariable String id,Principal principal) {
|
||||
try {
|
||||
eu.eudat.models.project.Project project = new ProjectManager().getSingle(this.getApiContext().getDatabaseRepository().getProjectDao(), id);
|
||||
return new ResponseItem<eu.eudat.models.project.Project>().payload(project).status(HttpStatus.OK);
|
||||
|
@ -104,7 +104,7 @@ public class Projects extends BaseController{
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = { "/projects/inactivate/{id}" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Project> inactivate(@PathVariable String id) {
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Project> inactivate(@PathVariable String id,Principal principal) {
|
||||
try {
|
||||
Project project = new ProjectManager().inactivate(this.getApiContext().getDatabaseRepository().getProjectDao(),id);
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
|
||||
|
@ -115,7 +115,7 @@ public class Projects extends BaseController{
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getWithExternal" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria,Principal principal) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria,this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
|
@ -126,7 +126,7 @@ public class Projects extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> get(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> get(@RequestBody ProjectCriteriaRequest projectCriteria,Principal principal) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria,this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
|
@ -140,7 +140,7 @@ public class Projects extends BaseController{
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/projects" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<ProjectsExternalSourcesModel> listExternalProjects(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseItem<ProjectsExternalSourcesModel> listExternalProjects(@RequestParam(value="query", required=false) String query ,Principal principal){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getProjects(query);
|
||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/4/2018.
|
||||
|
@ -39,6 +40,18 @@ public class UserInvitationController extends BaseController{
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/exchange/{invitationID}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<UUID> exchange(@PathVariable UUID invitationID, Principal principal) {
|
||||
try {
|
||||
UUID dmpId = InvitationsManager.assignUserAcceptedInvitation(this.getApiContext(),invitationID,principal);
|
||||
return new ResponseItem<UUID>().status(HttpStatus.OK).payload(dmpId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseItem<UUID>().message(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/getUsers" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<UserInfoInvitationModel>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) {
|
||||
try {
|
||||
|
|
|
@ -262,6 +262,7 @@ public class DMP implements Serializable,DataEntity<DMP> {
|
|||
this.description = entity.getDescription();
|
||||
this.researchers = entity.getResearchers();
|
||||
this.organisations = entity.getOrganisations();
|
||||
this.users = entity.getUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,11 +2,13 @@ package eu.eudat.managers;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.exceptions.UnauthorisedException;
|
||||
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.models.criteria.OrganisationCriteria;
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
|
@ -34,9 +36,11 @@ public class DataManagementPlanManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id) throws InstantiationException, IllegalAccessException{
|
||||
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id,Principal principal) throws InstantiationException, IllegalAccessException{
|
||||
DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id));
|
||||
if(dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size()==0)throw new UnauthorisedException();
|
||||
eu.eudat.models.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.dmp.DataManagementPlan();
|
||||
datamanagementPlan.fromDataModel(dmpsRepository.find(UUID.fromString(id)));
|
||||
datamanagementPlan.fromDataModel(dataManagementPlanEntity);
|
||||
return datamanagementPlan;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ import eu.eudat.queryable.QueryableList;
|
|||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -24,14 +26,25 @@ public class InvitationsManager {
|
|||
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
||||
List<UserInfo> alreadySignedInUsersEntities = new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(alreadySignedInUsers);
|
||||
DMP dataManagementPlan = apiContext.getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
||||
apiContext.getInvitationService().createInvitations(apiContext.getDatabaseRepository().getInvitationDao(),new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(invitation.getUsers()),dataManagementPlan,principalUser);
|
||||
apiContext.getInvitationService().createInvitations(apiContext.getDatabaseRepository().getInvitationDao(), apiContext.getMailService(), new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(invitation.getUsers()), dataManagementPlan, principalUser);
|
||||
apiContext.getInvitationService().assignToDmp(apiContext.getDatabaseRepository().getDmpDao(), alreadySignedInUsersEntities, dataManagementPlan);
|
||||
apiContext.getInvitationService().sendInvitations(invitation.getUsers());
|
||||
}
|
||||
|
||||
public static List<UserInfoInvitationModel> getUsers(ApiContext apiContext,UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
||||
public static List<UserInfoInvitationModel> getUsers(ApiContext apiContext, UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
||||
QueryableList<UserInfo> users = apiContext.getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoRequestItem.getCriteria());
|
||||
List<UserInfoInvitationModel> userModels = new DomainModelConverter<UserInfo,UserInfoInvitationModel>().fromDataModel(users.toList(),UserInfoInvitationModel.class);
|
||||
List<UserInfoInvitationModel> userModels = new DomainModelConverter<UserInfo, UserInfoInvitationModel>().fromDataModel(users.toList(), UserInfoInvitationModel.class);
|
||||
return userModels;
|
||||
}
|
||||
|
||||
public static UUID assignUserAcceptedInvitation(ApiContext apiContext, UUID invitationID, Principal principal) throws Exception {
|
||||
eu.eudat.entities.Invitation invitation = apiContext.getDatabaseRepository().getInvitationDao().find(invitationID);
|
||||
if (invitation == null) throw new Exception("There is no Data Management Plan assigned to this Link");
|
||||
if (invitation.getAcceptedInvitation()) throw new Exception("This Url Has Expired");
|
||||
UserInfo invitedUser = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
DMP datamanagementPlan = invitation.getDmp();
|
||||
apiContext.getInvitationService().assignToDmp(apiContext.getDatabaseRepository().getDmpDao(), invitedUser, datamanagementPlan);
|
||||
invitation.setAcceptedInvitation(true);
|
||||
apiContext.getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
||||
return datamanagementPlan.getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,17 +65,17 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
|
||||
UserInfoCriteria criteria = new UserInfoCriteria();
|
||||
criteria.setEmail(payload.getEmail());
|
||||
UserInfo userInfo = userInfoDao.getWithCriteria(criteria).toList().get(0);
|
||||
|
||||
List<UserInfo> users = userInfoDao.getWithCriteria(criteria).toList();
|
||||
UserInfo userInfo = null;
|
||||
if(users.size()>0)userInfo = users.get(0);
|
||||
final Credential credential = new Credential();
|
||||
credential.setId(UUID.randomUUID());
|
||||
credential.setCreationTime(new Date());
|
||||
credential.setStatus(1);
|
||||
credential.setLastUpdateTime(new Date());
|
||||
credential.setProvider(1);
|
||||
credential.setSecret(token);
|
||||
credential.setPublicValue(userInfo.getName());
|
||||
if(userInfo == null) {
|
||||
credential.setId(UUID.randomUUID());
|
||||
userInfo = new UserInfo();
|
||||
userInfo.setName((String)payload.get("name"));
|
||||
userInfo.setVerified_email(payload.getEmailVerified());
|
||||
|
@ -85,6 +85,9 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
userInfo.setAuthorization_level(new Short("1"));
|
||||
userInfo.setUsertype(new Short("1"));
|
||||
userInfo = userInfoDao.createOrUpdate(userInfo);
|
||||
|
||||
credential.setPublicValue(userInfo.getName());
|
||||
|
||||
credential.setUserInfo(userInfo);
|
||||
credentialDao.createOrUpdate(credential);
|
||||
}
|
||||
|
@ -98,6 +101,8 @@ public class GoogleTokenValidator implements TokenValidator {
|
|||
else{
|
||||
credential.setUserInfo(userInfo);
|
||||
credential.setId(UUID.randomUUID());
|
||||
credential.setPublicValue(userInfo.getName());
|
||||
|
||||
credentialDao.createOrUpdate(credential);
|
||||
userInfo.getCredentials().add(credential);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface InvitationService {
|
|||
|
||||
void assignToDmp(DMPDao dmpDao, eu.eudat.entities.UserInfo user, DMP dmp);
|
||||
|
||||
void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp, eu.eudat.entities.UserInfo creator);
|
||||
void createInvitations(InvitationDao invitationDao,MailService mailService, List<eu.eudat.entities.UserInfo> users, DMP dmp, eu.eudat.entities.UserInfo creator);
|
||||
|
||||
void sendInvitations(List<UserInfoInvitationModel> users);
|
||||
void sendInvitation(DMP dmp, Invitation invitation,MailService mailService);
|
||||
}
|
||||
|
|
|
@ -4,11 +4,15 @@ import eu.eudat.dao.entities.DMPDao;
|
|||
import eu.eudat.dao.entities.InvitationDao;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Invitation;
|
||||
import eu.eudat.models.mail.SimpleMail;
|
||||
import eu.eudat.models.userinfo.UserInfo;
|
||||
import eu.eudat.models.userinfo.UserInfoInvitationModel;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +22,7 @@ import java.util.UUID;
|
|||
public class InvitationServiceImpl implements InvitationService {
|
||||
@Override
|
||||
public void assignToDmp(DMPDao dmpDao, List<eu.eudat.entities.UserInfo> users, DMP dmp) {
|
||||
for(eu.eudat.entities.UserInfo user : users){
|
||||
for (eu.eudat.entities.UserInfo user : users) {
|
||||
dmp.getUsers().add(user);
|
||||
}
|
||||
dmpDao.createOrUpdate(dmp);
|
||||
|
@ -31,20 +35,36 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp, eu.eudat.entities.UserInfo creator) {
|
||||
for(eu.eudat.entities.UserInfo userInfo : users){
|
||||
public void createInvitations(InvitationDao invitationDao, MailService mailService, List<eu.eudat.entities.UserInfo> users, DMP dmp, eu.eudat.entities.UserInfo creator) {
|
||||
for (eu.eudat.entities.UserInfo userInfo : users) {
|
||||
Invitation invitation = new Invitation();
|
||||
invitation.setDmp(dmp);
|
||||
invitation.setInvitationEmail(userInfo.getEmail());
|
||||
invitation.setUser(creator);
|
||||
invitation.setToken(UUID.randomUUID());
|
||||
invitation.setAcceptedInvitation(userInfo.getId()!=null);
|
||||
invitation.setAcceptedInvitation(userInfo.getId() != null);
|
||||
invitationDao.createOrUpdate(invitation);
|
||||
sendInvitation(dmp, invitation, mailService);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendInvitations(List<UserInfoInvitationModel> users) {
|
||||
public void sendInvitation(DMP dmp, Invitation invitation, MailService mailService) {
|
||||
SimpleMail mail = new SimpleMail();
|
||||
mail.setSubject(createSubject(dmp, mailService.getMailTemplateSubject()));
|
||||
mail.setContent(createContent(invitation.getId(), dmp, mailService.getMailTemplateContent()));
|
||||
mail.setTo(invitation.getInvitationEmail());
|
||||
mailService.sendSimpleMail(mail);
|
||||
}
|
||||
|
||||
private String createSubject(DMP dmp, String templateSubject) {
|
||||
String subject = templateSubject.replace("{dmpname}", dmp.getLabel());
|
||||
return subject;
|
||||
}
|
||||
|
||||
private String createContent(UUID invitationID, DMP dmp, String templateContent) {
|
||||
String content = templateContent.replace("{dmpname}", dmp.getLabel());
|
||||
content = templateContent.replace("{invitationID}", invitationID.toString());
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,4 +7,6 @@ import eu.eudat.models.mail.SimpleMail;
|
|||
*/
|
||||
public interface MailService {
|
||||
void sendSimpleMail(SimpleMail mail);
|
||||
String getMailTemplateContent();
|
||||
String getMailTemplateSubject();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.services;
|
|||
|
||||
import eu.eudat.models.mail.SimpleMail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -11,6 +12,8 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service("mailService")
|
||||
public class MailServiceImpl implements MailService{
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Autowired
|
||||
private JavaMailSender emailSender;
|
||||
|
@ -21,7 +24,21 @@ public class MailServiceImpl implements MailService{
|
|||
message.setSubject(mail.getSubject());
|
||||
message.setText(mail.getContent());
|
||||
message.setTo(mail.getTo());
|
||||
message.setFrom(mail.getFrom());
|
||||
message.setFrom(env.getProperty("mail.from"));
|
||||
this.emailSender.send(message);
|
||||
}
|
||||
|
||||
public Environment getEnv() {
|
||||
return env;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMailTemplateContent() {
|
||||
return env.getProperty("mail.content");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMailTemplateSubject() {
|
||||
return env.getProperty("mail.subject");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,20 @@ eu.eudat.proxy.allowed.host = https://eestore.paas2.uninett.no
|
|||
configuration.externalUrls = file:///C:\\Users\\ikalyvas\\Documents\\Projects\\OpenAIRE-EUDAT-DMP-service-pilot\\dmp-backend\\src\\main\\resources\\ExternalUrls.xml
|
||||
#######################################################
|
||||
|
||||
########################Persistence/Hibernate Generic#############################
|
||||
#persistence.hibernate.show_sql = false
|
||||
#persistence.hibernate.hbm2dll = validate
|
||||
#persistence.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
||||
#persistence.hibernate.dialect = org.hibernate.spatial.dialect.postgis.PostgisDialect
|
||||
########################/Email#############################
|
||||
spring.mail.default-encoding=UTF-8
|
||||
spring.mail.host=smtp.gmail.com
|
||||
spring.mail.username=kalivasioan@gmail.com
|
||||
spring.mail.password=A3b*1*92
|
||||
spring.mail.port=587
|
||||
spring.mail.protocol=smtp
|
||||
spring.mail.test-connection=false
|
||||
spring.mail.properties.mail.smtp.auth=true
|
||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
mail.subject = Invitation to DMP Plan {dmpname}
|
||||
mail.content = You have been invited to {dmpname} data management plan.Follow the link localhost:4200/invitation/{invitationID} to submit it
|
||||
mail.from = citesagrdev@gmail.com
|
||||
|
||||
########################Persistence/Hibernate Generic#############################
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { InvitationAcceptedComponent } from './invitation-accepted/invitation-accepted.component';
|
||||
import { InvitationComponent } from './invitation/invitation.component';
|
||||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
@ -30,7 +31,7 @@ const appRoutes: Routes = [
|
|||
{ path: 'dataset/new', component: DatasetWizardComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'dataset/:id', component: DatasetWizardComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'datasets/new', component: DatasetWizardComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'invite/:id', component: InvitationComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'invitation/:id', component: InvitationAcceptedComponent},
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' },
|
||||
{ path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard] },
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { InvitationAcceptedComponent } from './invitation-accepted/invitation-accepted.component';
|
||||
import { InvitationComponent } from './invitation/invitation.component';
|
||||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
|
||||
import { PaginationService } from './form/pagination/pagination-service';
|
||||
|
@ -83,6 +84,7 @@ import { AutocompleteComponent } from './shared/components/autocomplete/autocomp
|
|||
ProjectEditorComponent,
|
||||
DataManagementPlanEditorComponent,
|
||||
InvitationComponent,
|
||||
InvitationAcceptedComponent,
|
||||
DatasetWizardComponent,
|
||||
FigurecardComponent,
|
||||
DatasetEditorComponent,
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||
import { UserInvitationCriteria } from '../models/criteria/invitation/UserInvitationCriteria';
|
||||
import { RequestItem } from '../models/criteria/RequestItem';
|
||||
import { Invitation } from '../models/invitation/Invitation';
|
||||
import { InvitationService } from '../services/invitation/invitation.service';
|
||||
import { User } from '../models/invitation/User';
|
||||
import { Component, OnInit, Inject } from "@angular/core";
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { Params, ActivatedRoute, Router } from '@angular/router';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-invitation-accepted-component',
|
||||
templateUrl: 'invitation-accepted.component.html',
|
||||
providers: [InvitationService]
|
||||
|
||||
})
|
||||
export class InvitationAcceptedComponent implements OnInit {
|
||||
constructor(
|
||||
private invitationService: InvitationService,
|
||||
private route: ActivatedRoute,
|
||||
public router: Router
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.params.subscribe(params => {
|
||||
let id = params["id"]
|
||||
this.invitationService.exchange(id).subscribe(id=>{
|
||||
this.router.navigate(["dmp/"+id])
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
|
@ -30,4 +30,8 @@ export class InvitationService {
|
|||
public getUsers(usersInvitationRequestItem: RequestItem<UserInvitationCriteria>): Observable<User[]> {
|
||||
return this.http.post<User[]>(this.actionUrl + "getUsers", usersInvitationRequestItem, { headers: this.headers });
|
||||
}
|
||||
|
||||
public exchange(id:String): Observable<String> {
|
||||
return this.http.get<String>(this.actionUrl + "exchange/"+id, { headers: this.headers });
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ export class BaseHttpService {
|
|||
private authService: AuthService,
|
||||
public language: TranslateService,
|
||||
public snackBar: MatSnackBar,
|
||||
|
||||
public route: ActivatedRoute
|
||||
) {
|
||||
}
|
||||
get<T>(url: string, options?: any): Observable<T> {
|
||||
|
@ -74,14 +74,15 @@ export class BaseHttpService {
|
|||
duration: 3000,
|
||||
extraClasses: ['snackbar-success']
|
||||
})
|
||||
this.router.navigate(['/unauthorized']);
|
||||
let currentPage = this.router.url;
|
||||
this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: currentPage } });
|
||||
//this.notification.httpError(error);
|
||||
return Observable.of<T>();
|
||||
} else {
|
||||
return Observable.throw(error);
|
||||
}
|
||||
})
|
||||
.map(response => {
|
||||
.map(response => {
|
||||
if (response.statusCode < 200 || response.statusCode >= 300) {
|
||||
//throw new Error('Request failed');
|
||||
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||
|
|
Loading…
Reference in New Issue