no message

This commit is contained in:
annabakouli 2018-01-08 16:57:21 +02:00
parent 0bb338e468
commit 37ae617dfa
11 changed files with 42 additions and 23 deletions

View File

@ -51,7 +51,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,Principal principal) {
try {
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(this.getApiContext().getDatabaseRepository().getDmpDao(), dataManagementPlanTableRequest);
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(this.getApiContext(), dataManagementPlanTableRequest,principal);
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable);
} catch (Exception ex) {

View File

@ -1,5 +1,6 @@
package eu.eudat.controllers;
import eu.eudat.exceptions.UnauthorisedException;
import eu.eudat.managers.InvitationsManager;
import eu.eudat.models.helpers.responses.ResponseItem;
import eu.eudat.models.invitation.Invitation;
@ -46,7 +47,11 @@ public class UserInvitationController extends BaseController{
try {
UUID dmpId = InvitationsManager.assignUserAcceptedInvitation(this.getApiContext(),invitationID,principal);
return new ResponseItem<UUID>().status(HttpStatus.OK).payload(dmpId);
} catch (Exception e) {
}catch (UnauthorisedException e){
e.printStackTrace();
throw e;
}
catch (Exception e) {
e.printStackTrace();
return new ResponseItem<UUID>().message(e.getMessage());
}

View File

@ -25,5 +25,7 @@ public interface DMPDao {
DMP find(UUID id);
Long count();
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query,UserInfo principal);
}

View File

@ -16,6 +16,7 @@ import eu.eudat.entities.Project;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.criteria.DataManagementPlanCriteria;
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
import eu.eudat.models.security.Principal;
import eu.eudat.queryable.QueryableList;
import org.hibernate.query.Query;
@ -43,6 +44,11 @@ public class DMPDaoImpl implements DMPDao {
return query;
}
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query,UserInfo principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("creator"),principal),builder.isMember(principal,root.get("users"))));
return query;
}
@Override
public DMP createOrUpdate(DMP item) {
return this.databaseService.createOrUpdate(item,DMP.class);

View File

@ -25,9 +25,12 @@ import eu.eudat.utilities.builders.DomainModelConverter;
public class DataManagementPlanManager {
public DataTableData<DataManagementPlanListingModel> getPaged(DMPDao dmpsRepository, DataManagementPlanTableRequest dataManagementPlanTableRequest) throws IllegalAccessException, InstantiationException{
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanTableRequest.getCriteria());
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(items,dataManagementPlanTableRequest);
public DataTableData<DataManagementPlanListingModel> getPaged(ApiContext apiContext, DataManagementPlanTableRequest dataManagementPlanTableRequest,Principal principal) throws IllegalAccessException, InstantiationException{
UserInfo userInfo = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
QueryableList<DMP> items = apiContext.getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
QueryableList<DMP> authItems = apiContext.getDatabaseRepository().getDmpDao().getAuthenticated(items,userInfo);
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems,dataManagementPlanTableRequest);
if(dataManagementPlanTableRequest.getWithHint())pagedItems.withHint("fullyDetailed");
List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, DataManagementPlanListingModel>().fromDataModel( pagedItems.toList(), DataManagementPlanListingModel.class);
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<DataManagementPlanListingModel>();

View File

@ -2,6 +2,7 @@ package eu.eudat.managers;
import eu.eudat.entities.DMP;
import eu.eudat.entities.UserInfo;
import eu.eudat.exceptions.UnauthorisedException;
import eu.eudat.models.invitation.Invitation;
import eu.eudat.models.security.Principal;
import eu.eudat.models.userinfo.UserInfoInvitationModel;
@ -36,10 +37,10 @@ public class InvitationsManager {
return userModels;
}
public static UUID assignUserAcceptedInvitation(ApiContext apiContext, UUID invitationID, Principal principal) throws Exception {
public static UUID assignUserAcceptedInvitation(ApiContext apiContext, UUID invitationID, Principal principal) throws UnauthorisedException {
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");
if (invitation == null) throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
if (invitation.getAcceptedInvitation()) throw new UnauthorisedException("This Url Has Expired");
UserInfo invitedUser = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
DMP datamanagementPlan = invitation.getDmp();
apiContext.getInvitationService().assignToDmp(apiContext.getDatabaseRepository().getDmpDao(), invitedUser, datamanagementPlan);

View File

@ -42,7 +42,7 @@ public class InvitationServiceImpl implements InvitationService {
invitation.setInvitationEmail(userInfo.getEmail());
invitation.setUser(creator);
invitation.setToken(UUID.randomUUID());
invitation.setAcceptedInvitation(userInfo.getId() != null);
invitation.setAcceptedInvitation(false);
invitationDao.createOrUpdate(invitation);
sendInvitation(dmp, invitation, mailService);
}
@ -64,7 +64,7 @@ public class InvitationServiceImpl implements InvitationService {
private String createContent(UUID invitationID, DMP dmp, String templateContent) {
String content = templateContent.replace("{dmpname}", dmp.getLabel());
content = templateContent.replace("{invitationID}", invitationID.toString());
content = content.replace("{invitationID}", invitationID.toString());
return content;
}
}

View File

@ -1,5 +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';
import { RouterModule, Routes } from '@angular/router';

View File

@ -119,6 +119,9 @@ import { AutocompleteComponent } from './shared/components/autocomplete/autocomp
DatasetService,
BaseHttpService
],
entryComponents: [
InvitationComponent,
],
bootstrap: [AppComponent]
})
export class AppModule {

View File

@ -1,8 +1,7 @@
import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service';
import { FormGroup, Form, FormArray } from '@angular/forms';
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
import { CompositeField } from '@app/models/CompositeField';
import { Section } from '@app/models/Section';
import { CompositeField } from '../../models/CompositeField';
@Component({
@ -32,6 +31,7 @@ export class DynamicFormSectionComponent implements OnInit {
}
isVisible(fieldSet:CompositeField):boolean{
if(!this.visibilityRulesService.isElementVisible(null,fieldSet.id)) return false;
for(var i=0; i<fieldSet.fields.length; i++){
if (!this.visibilityRulesService.isElementVisible(null,fieldSet.fields[i].id))
return false;