Search in sources :

Example 6 with DataAccessRequest

use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.

the class DataAccessRequestResource method get.

@PUT
@Timed
public Response get(@PathParam("id") String id, Mica.DataAccessRequestDto dto) {
    subjectAclService.checkPermission("/data-access-request", "EDIT", id);
    if (!id.equals(dto.getId()))
        throw new BadRequestException();
    DataAccessRequest request = dtos.fromDto(dto);
    dataAccessRequestService.save(request);
    return Response.noContent().build();
}
Also used : BadRequestException(javax.ws.rs.BadRequestException) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 7 with DataAccessRequest

use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.

the class DataAccessRequestResource method review.

private Response review(@PathParam("id") String id) {
    DataAccessRequest request = dataAccessRequestService.findById(id);
    boolean fromConditionallyApproved = request.getStatus() == DataAccessRequest.Status.CONDITIONALLY_APPROVED;
    if (fromConditionallyApproved) {
        // remove applicant permissions
        subjectAclService.removePermission("/data-access-request", "EDIT,DELETE", id);
        subjectAclService.removePermission("/data-access-request/" + id, "EDIT", "_status");
        // data access officers can change the status of the request
        subjectAclService.addGroupPermission(Roles.MICA_DAO, "/data-access-request/" + id, "EDIT", "_status");
    }
    return updateStatus(id, DataAccessRequest.Status.REVIEWED);
}
Also used : DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest)

Example 8 with DataAccessRequest

use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.

the class DataAccessRequestResource method get.

@GET
@Timed
public Mica.DataAccessRequestDto get(@PathParam("id") String id) {
    subjectAclService.checkPermission("/data-access-request", "VIEW", id);
    DataAccessRequest request = dataAccessRequestService.findById(id);
    return dtos.asDto(request);
}
Also used : DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 9 with DataAccessRequest

use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.

the class ProjectService method dataAccessRequestUpdated.

// 
// Event handling
// 
@Async
@Subscribe
public void dataAccessRequestUpdated(DataAccessRequestUpdatedEvent event) {
    DataAccessRequest request = event.getPersistable();
    if (!projectRepository.exists(request.getId()) && request.getStatus() == DataAccessRequest.Status.APPROVED) {
        Project project = new Project();
        project.setId(event.getPersistable().getId());
        project.setDataAccessRequestId(event.getPersistable().getId());
        String title = dataAccessRequestUtilService.getRequestTitle(request);
        if (!Strings.isNullOrEmpty(title)) {
            project.setTitle(LocalizedString.from(micaConfigService.getConfig().getLocales(), title));
        }
        String summary = dataAccessRequestUtilService.getRequestSummary(request);
        if (!Strings.isNullOrEmpty(summary)) {
            project.setSummary(LocalizedString.from(micaConfigService.getConfig().getLocales(), summary));
        }
        save(project, "Created from Data Access Request");
    }
}
Also used : Project(org.obiba.mica.project.domain.Project) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) LocalizedString(org.obiba.mica.core.domain.LocalizedString) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 10 with DataAccessRequest

use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.

the class DataAccessRequestCommentMailNotification method send.

@Override
public void send(Comment comment) {
    if (comment == null)
        return;
    DataAccessForm dataAccessForm = dataAccessFormService.find().get();
    if (!dataAccessForm.isNotifyCommented())
        return;
    DataAccessRequest request = dataAccessRequestService.findById(comment.getInstanceId());
    Map<String, String> ctx = Maps.newHashMap();
    String organization = micaConfigService.getConfig().getName();
    String id = request.getId();
    String title = dataAccessRequestUtilService.getRequestTitle(request);
    ctx.put("organization", organization);
    ctx.put("publicUrl", micaConfigService.getPublicUrl());
    ctx.put("id", id);
    if (Strings.isNullOrEmpty(title))
        title = id;
    ctx.put("title", title);
    ctx.put("applicant", request.getApplicant());
    ctx.put("status", request.getStatus().name());
    mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getCommentedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestCommentAdded", ctx, request.getApplicant());
    mailService.sendEmailToGroups(mailService.getSubject(dataAccessForm.getCommentedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestCommentAdded", ctx, Roles.MICA_DAO);
}
Also used : DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Aggregations

DataAccessRequest (org.obiba.mica.access.domain.DataAccessRequest)25 Timed (com.codahale.metrics.annotation.Timed)6 DateTime (org.joda.time.DateTime)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 Map (java.util.Map)3 NotNull (javax.validation.constraints.NotNull)3 BadRequestException (javax.ws.rs.BadRequestException)3 Attachment (org.obiba.mica.file.Attachment)3 DataAccessForm (org.obiba.mica.micaConfig.domain.DataAccessForm)3 Strings (com.google.common.base.Strings)2 EventBus (com.google.common.eventbus.EventBus)2 DocumentException (com.itextpdf.text.DocumentException)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 ForbiddenException (javax.ws.rs.ForbiddenException)2 PUT (javax.ws.rs.PUT)2 SecurityUtils (org.apache.shiro.SecurityUtils)2 NoSuchDataAccessRequestException (org.obiba.mica.access.NoSuchDataAccessRequestException)2