use of fi.otavanopisto.muikku.plugins.workspace.rest.model.WorkspaceFeeInfo in project muikku by otavanopisto.
the class WorkspaceRESTService method getFeeInfo.
@GET
@Path("/workspaces/{ID}/feeInfo")
@RESTPermit(value = MuikkuPermissions.VIEW_WORKSPACE_FEE, requireLoggedIn = true)
public Response getFeeInfo(@PathParam("ID") Long workspaceEntityId) {
SchoolDataIdentifier userIdentifier = sessionController.getLoggedUser();
if (userIdentifier == null) {
return Response.status(Status.UNAUTHORIZED).build();
}
User user = userController.findUserByIdentifier(userIdentifier);
if (user == null) {
return Response.status(Status.FORBIDDEN).build();
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).build();
}
Workspace workspace = workspaceController.findWorkspace(workspaceEntity);
if (workspace == null) {
return Response.status(Status.NOT_FOUND).build();
}
// #3069: If the user has evaluation fees and a school set, all workspaces have an
// evaluation fee. Otherwise it depends on the applicability of the workspace itself.
boolean evaluationFees = user.hasEvaluationFees() && (StringUtils.isNotEmpty(user.getSchool()) || workspace.isEvaluationFeeApplicable());
return Response.ok(new WorkspaceFeeInfo(evaluationFees)).build();
}
Aggregations