Search in sources :

Example 1 with DataAccessAmendment

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

the class DataAccessAmendmentResource method update.

@PUT
@Timed
public Response update(Mica.DataAccessRequestDto dto) {
    subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
    if (!id.equals(dto.getId()))
        throw new BadRequestException();
    DataAccessAmendment amendment = dtos.fromAmendmentDto(dto);
    DataAccessRequest request = dataAccessRequestService.findById(parentId);
    if (request.isArchived())
        throw new BadRequestException("Data access request is archived");
    dataAccessAmendmentService.save(amendment);
    return Response.noContent().build();
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) Timed(com.codahale.metrics.annotation.Timed)

Example 2 with DataAccessAmendment

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

the class DataAccessAmendmentResource method setModel.

@PUT
@Path("/model")
@Consumes("application/json")
public Response setModel(String content) {
    subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
    DataAccessRequest request = dataAccessRequestService.findById(parentId);
    if (request.isArchived())
        throw new BadRequestException("Data access request is archived");
    DataAccessAmendment amendment = dataAccessAmendmentService.findById(id);
    amendment.setContent(content);
    dataAccessAmendmentService.save(amendment);
    return Response.ok().build();
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest)

Example 3 with DataAccessAmendment

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

the class DataAccessAmendmentsResource method create.

@POST
@Path("/_empty")
public Response create(@Context UriInfo uriInfo) {
    DataAccessAmendment amendment = new DataAccessAmendment();
    amendment.setContent("{}");
    return saveNew(amendment, uriInfo);
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment)

Example 4 with DataAccessAmendment

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

the class SubjectAclService method dataAccessAmendmentDeleted.

@Async
@Subscribe
public void dataAccessAmendmentDeleted(DataAccessAmendmentDeletedEvent event) {
    DataAccessAmendment amendment = event.getPersistable();
    String resource = String.format("/data-access-request/%s/amendment", amendment.getParentId());
    String id = amendment.getId();
    removeResourcePermissions(resource, id);
    removeResourcePermissions(resource + "/" + id, "_status");
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 5 with DataAccessAmendment

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

the class DataAccessAmendmentResource method deleteVariablesSet.

@DELETE
@Path("/variables")
public Response deleteVariablesSet() {
    subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
    DataAccessAmendment amendment = getService().findById(id);
    if (amendment.hasVariablesSet())
        variableSetService.delete(amendment.getVariablesSet());
    return Response.noContent().build();
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment)

Aggregations

DataAccessAmendment (org.obiba.mica.access.domain.DataAccessAmendment)10 DataAccessRequest (org.obiba.mica.access.domain.DataAccessRequest)3 Timed (com.codahale.metrics.annotation.Timed)2 DocumentContext (com.jayway.jsonpath.DocumentContext)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Subscribe (com.google.common.eventbus.Subscribe)1 DataAccessEntityStatus (org.obiba.mica.access.domain.DataAccessEntityStatus)1 DataAccessAmendmentUpdatedEvent (org.obiba.mica.access.event.DataAccessAmendmentUpdatedEvent)1 Async (org.springframework.scheduling.annotation.Async)1