Search in sources :

Example 6 with ProjectResource

use of edu.stanford.bmir.protege.web.server.access.ProjectResource in project webprotege by protegeproject.

the class ProjectDownloadServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    final WebProtegeSession webProtegeSession = new WebProtegeSessionImpl(req.getSession());
    UserId userId = webProtegeSession.getUserInSession();
    FileDownloadParameters downloadParameters = new FileDownloadParameters(req);
    if (!downloadParameters.isProjectDownload()) {
        logger.info("Bad project download request from {} at {}.  Request URI: {}  Query String: {}", webProtegeSession.getUserInSession(), formatAddr(req), req.getRequestURI(), req.getQueryString());
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return;
    }
    logger.info("Received download request from {} at {} for project {}", userId, formatAddr(req), downloadParameters.getProjectId());
    if (!accessManager.hasPermission(Subject.forUser(userId), new ProjectResource(downloadParameters.getProjectId()), BuiltInAction.DOWNLOAD_PROJECT)) {
        logger.info("Denied download request as user does not have permission to download this project.");
        resp.sendError(HttpServletResponse.SC_FORBIDDEN);
    } else if (downloadParameters.isProjectDownload()) {
        startProjectDownload(resp, userId, downloadParameters);
    }
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) WebProtegeSession(edu.stanford.bmir.protege.web.server.session.WebProtegeSession) ProjectResource(edu.stanford.bmir.protege.web.server.access.ProjectResource) WebProtegeSessionImpl(edu.stanford.bmir.protege.web.server.session.WebProtegeSessionImpl)

Aggregations

ProjectResource (edu.stanford.bmir.protege.web.server.access.ProjectResource)6 Subject (edu.stanford.bmir.protege.web.server.access.Subject)4 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)4 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)3 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)3 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)3 Inject (javax.inject.Inject)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Subject.forAnySignedInUser (edu.stanford.bmir.protege.web.server.access.Subject.forAnySignedInUser)2 HasGetUserIdByUserIdOrEmail (edu.stanford.bmir.protege.web.server.user.HasGetUserIdByUserIdOrEmail)2 RoleId (edu.stanford.bmir.protege.web.shared.access.RoleId)2 PersonId (edu.stanford.bmir.protege.web.shared.sharing.PersonId)2 ProjectSharingSettings (edu.stanford.bmir.protege.web.shared.sharing.ProjectSharingSettings)2 SharingPermission (edu.stanford.bmir.protege.web.shared.sharing.SharingPermission)2 SharingSetting (edu.stanford.bmir.protege.web.shared.sharing.SharingSetting)2 java.util (java.util)2 Collections.emptySet (java.util.Collections.emptySet)2 Collectors.toMap (java.util.stream.Collectors.toMap)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2