use of edu.stanford.bmir.protege.web.server.project.Project in project webprotege by protegeproject.
the class CreateDownloadTask method call.
@Override
public Void call() throws Exception {
if (Files.exists(downloadPath)) {
logger.info("{} {} Project download already exists. Not recreating download. ({})", projectId, userId, downloadPath.toAbsolutePath());
return null;
}
logger.info("{} {} Creating project download", projectId, userId);
MemoryMonitor memoryMonitor = new MemoryMonitor(logger);
memoryMonitor.monitorMemoryUsage();
Project project = projectManager.getProject(projectId, userId);
memoryMonitor.monitorMemoryUsage();
ProjectDownloader downloader = new ProjectDownloader(projectDisplayName, project, revisionNumber, format, applicationName);
logger.info("{} {} Writing download to file: {}", projectId, userId, downloadPath);
Files.createDirectories(downloadPath.getParent());
try (BufferedOutputStream outputStream = new BufferedOutputStream(Files.newOutputStream(downloadPath))) {
downloader.writeProject(outputStream);
}
double sizeInMB = Files.size(downloadPath) / (1024.0 * 1024);
logger.info("{} {} Finished creating download ({} MB)", projectId, userId, String.format("%.4f", sizeInMB));
memoryMonitor.monitorMemoryUsage();
return null;
}
use of edu.stanford.bmir.protege.web.server.project.Project in project webprotege by protegeproject.
the class GetProjectEventsActionHandler method execute.
@Nonnull
@Override
public GetProjectEventsResult execute(@Nonnull GetProjectEventsAction action, @Nonnull ExecutionContext executionContext) {
EventTag sinceTag = action.getSinceTag();
ProjectId projectId = action.getProjectId();
UserId userId = executionContext.getUserId();
if (!accessManager.hasPermission(forUser(userId), forProject(action.getProjectId()), VIEW_PROJECT)) {
return getEmptyResult(projectId, sinceTag);
}
if (!projectManager.isActive(projectId)) {
return getEmptyResult(projectId, sinceTag);
}
Optional<Project> project = projectManager.getProjectIfActive(projectId);
if (!project.isPresent()) {
return getEmptyResult(projectId, sinceTag);
}
EventManager<ProjectEvent<?>> eventManager = project.get().getEventManager();
EventList<ProjectEvent<?>> eventList = eventManager.getEventsFromTag(sinceTag);
ProjectEventList projectEventList = ProjectEventList.builder(eventList.getStartTag(), projectId, eventList.getEndTag()).addEvents(eventList.getEvents()).build();
return new GetProjectEventsResult(projectEventList);
}
Aggregations