use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class ProjectService method index.
/**
* Index a specific {@link Project} without updating it.
*
* @param id
* @throws NoSuchProjectException
*/
public void index(@NotNull String id) throws NoSuchProjectException {
ProjectState projectState = getEntityState(id);
Project project = findById(id);
eventBus.post(new ProjectUpdatedEvent(project));
if (projectState.isPublished())
eventBus.post(new ProjectPublishedEvent(project, getCurrentUsername()));
else
eventBus.post(new ProjectUpdatedEvent(project));
}
use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class ProjectService method delete.
/**
* Delete a {@link Project}.
*
* @param id
* @throws NoSuchProjectException
*/
public void delete(@NotNull String id) throws NoSuchProjectException {
Project project = findById(id);
fileSystemService.delete(FileUtils.getEntityPath(project));
projectStateRepository.delete(id);
projectRepository.delete(id);
gitService.deleteGitRepository(project);
eventBus.post(new ProjectDeletedEvent(project));
}
use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class DataAccessRequestDtos method asDto.
@NotNull
public Mica.DataAccessRequestDto asDto(@NotNull DataAccessRequest request) {
Mica.DataAccessRequestDto.Builder builder = Mica.DataAccessRequestDto.newBuilder();
//
builder.setApplicant(request.getApplicant()).setStatus(//
request.getStatus().name()).setTimestamps(//
TimestampsDtos.asDto(request));
//
if (request.hasContent())
builder.setContent(request.getContent());
if (!request.isNew())
builder.setId(request.getId());
String title = dataAccessRequestUtilService.getRequestTitle(request);
if (!Strings.isNullOrEmpty(title)) {
builder.setTitle(title);
}
request.getAttachments().forEach(attachment -> builder.addAttachments(attachmentDtos.asDto(attachment)));
request.getStatusChangeHistory().forEach(statusChange -> builder.addStatusChangeHistory(statusChangeDtos.asDto(statusChange)));
// possible actions depending on the caller
if (subjectAclService.isPermitted("/data-access-request", "VIEW", request.getId())) {
builder.addActions("VIEW");
}
if (subjectAclService.isPermitted("/data-access-request", "EDIT", request.getId())) {
builder.addActions("EDIT");
}
if (subjectAclService.isPermitted("/data-access-request", "DELETE", request.getId())) {
builder.addActions("DELETE");
}
if (subjectAclService.isPermitted(Paths.get("/data-access-request", request.getId()).toString(), "EDIT", "_status")) {
builder.addActions("EDIT_STATUS");
}
if (SecurityUtils.getSubject().hasRole(Roles.MICA_DAO) || subjectAclService.isPermitted(Paths.get("/data-access-request", request.getId(), "_attachments").toString(), "EDIT")) {
builder.addActions("EDIT_ATTACHMENTS");
}
try {
Project project = projectService.findById(request.getId());
Mica.PermissionsDto permissionsDto = permissionsDtos.asDto(project);
Mica.ProjectSummaryDto.Builder projectSummaryDtoBuilder = Mica.ProjectSummaryDto.newBuilder();
projectSummaryDtoBuilder.setId(project.getId());
projectSummaryDtoBuilder.setPermissions(permissionsDto);
builder.setProject(projectSummaryDtoBuilder.build());
} catch (NoSuchProjectException e) {
// do nothing
}
ObibaRealm.Subject profile = userProfileService.getProfile(request.getApplicant());
if (profile != null) {
builder.setProfile(userProfileDtos.asDto(profile));
}
// possible status transitions
dataAccessRequestUtilService.nextStatus(request).forEach(status -> builder.addNextStatus(status.toString()));
return builder.build();
}
use of org.obiba.mica.project.domain.Project in project mica2 by obiba.
the class DraftProjectsResource method create.
@POST
@Path("/projects")
@Timed
@RequiresPermissions("/draft/project:ADD")
public Response create(Mica.ProjectDto projectDto, @Context UriInfo uriInfo, @Nullable @QueryParam("comment") String comment) {
Project project = dtos.fromDto(projectDto);
projectService.save(project, comment);
return Response.created(uriInfo.getBaseUriBuilder().segment("draft", "project", project.getId()).build()).build();
}
Aggregations