Search in sources :

Example 1 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method createPasswordChangeEntry.

@POST
@Path("/passwordchange/{EMAIL}")
@RESTPermit(handling = Handling.UNSECURED)
public Response createPasswordChangeEntry(@PathParam("EMAIL") String email) {
    UserEntity userEntity = userEntityController.findUserEntityByEmailAddress(email);
    if (userEntity == null)
        return Response.status(Status.NOT_FOUND).build();
    String confirmationHash = "testtesttest";
    userPendingPasswordChangeDAO.create(userEntity, confirmationHash);
    return Response.noContent().build();
}
Also used : UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) UserGroupUserEntity(fi.otavanopisto.muikku.model.users.UserGroupUserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 2 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method createCommunicatorUserLabel.

@POST
@Path("/communicator/labels/user/{ID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response createCommunicatorUserLabel(@PathParam("ID") Long userId, fi.otavanopisto.muikku.atests.CommunicatorUserLabelRESTModel payload) {
    UserEntity userEntity = userEntityController.findUserEntityById(userId);
    CommunicatorUserLabelRESTModel newUserLabel = new CommunicatorUserLabelRESTModel(null, payload.getName(), payload.getColor());
    communicatorController.createUserLabel(newUserLabel.getName(), newUserLabel.getColor(), userEntity);
    return Response.ok().build();
}
Also used : UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) UserGroupUserEntity(fi.otavanopisto.muikku.model.users.UserGroupUserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) POST(javax.ws.rs.POST)

Example 3 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method deletePasswordChangeEntry.

@DELETE
@Path("/passwordchange/{EMAIL}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deletePasswordChangeEntry(@PathParam("EMAIL") String email) {
    UserEntity userEntity = userEntityController.findUserEntityByEmailAddress(email);
    if (userEntity == null)
        return Response.status(Status.NOT_FOUND).build();
    UserPendingPasswordChange userPendingPasswordChange = userPendingPasswordChangeDAO.findByUserEntity(userEntity);
    userPendingPasswordChangeDAO.delete(userPendingPasswordChange);
    return Response.noContent().build();
}
Also used : UserPendingPasswordChange(fi.otavanopisto.muikku.plugins.user.UserPendingPasswordChange) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) UserGroupUserEntity(fi.otavanopisto.muikku.model.users.UserGroupUserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 4 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class AcceptanceTestsRESTService method test_reindex.

@GET
@Path("/reindex")
@Produces("text/plain")
@RESTPermit(handling = Handling.UNSECURED)
public Response test_reindex() {
    logger.log(Level.INFO, "Acceptance tests plugin reindex task started.");
    List<WorkspaceEntity> workspaceEntities = workspaceEntityController.listWorkspaceEntities();
    for (int i = 0; i < workspaceEntities.size(); i++) {
        WorkspaceEntity workspaceEntity = workspaceEntities.get(i);
        workspaceIndexer.indexWorkspace(workspaceEntity);
    }
    logger.log(Level.INFO, "Reindexed " + workspaceEntities.size() + " workspaces");
    List<UserEntity> users = userEntityController.listUserEntities();
    for (int i = 0; i < users.size(); i++) {
        UserEntity userEntity = users.get(i);
        userIndexer.indexUser(userEntity);
    }
    logger.log(Level.INFO, "Reindexed " + users.size() + " users");
    return Response.ok().build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) UserGroupUserEntity(fi.otavanopisto.muikku.model.users.UserGroupUserEntity) WorkspaceUserEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with UserEntity

use of fi.otavanopisto.muikku.model.users.UserEntity in project muikku by otavanopisto.

the class AnnouncerRESTService method listAnnouncements.

@GET
@Path("/announcements")
@RESTPermit(handling = Handling.INLINE)
public Response listAnnouncements(@QueryParam("hideEnvironmentAnnouncements") @DefaultValue("false") boolean hideEnvironmentAnnouncements, @QueryParam("hideWorkspaceAnnouncements") @DefaultValue("false") boolean hideWorkspaceAnnouncements, @QueryParam("hideGroupAnnouncements") @DefaultValue("false") boolean hideGroupAnnouncements, @QueryParam("workspaceEntityId") Long workspaceEntityId, @QueryParam("onlyMine") @DefaultValue("false") boolean onlyMine, @QueryParam("onlyEditable") @DefaultValue("false") boolean onlyEditable, @QueryParam("onlyArchived") @DefaultValue("false") boolean onlyArchived, @QueryParam("timeFrame") @DefaultValue("CURRENT") AnnouncementTimeFrame timeFrame) {
    UserEntity currentUserEntity = sessionController.getLoggedUserEntity();
    if (currentUserEntity == null) {
        return Response.noContent().build();
    }
    List<Announcement> announcements = null;
    AnnouncementEnvironmentRestriction environment = hideEnvironmentAnnouncements ? AnnouncementEnvironmentRestriction.NONE : sessionController.hasEnvironmentPermission(AnnouncerPermissions.LIST_ENVIRONMENT_GROUP_ANNOUNCEMENTS) ? AnnouncementEnvironmentRestriction.PUBLICANDGROUP : AnnouncementEnvironmentRestriction.PUBLIC;
    if (workspaceEntityId == null) {
        boolean includeGroups = !hideGroupAnnouncements;
        boolean includeWorkspaces = !hideWorkspaceAnnouncements;
        announcements = announcementController.listAnnouncements(includeGroups, includeWorkspaces, environment, timeFrame, currentUserEntity, onlyMine, onlyArchived);
    } else {
        WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
        if (workspaceEntity == null) {
            return Response.status(Status.BAD_REQUEST).entity("Workspace entity with given ID not found").build();
        }
        if (!sessionController.hasWorkspacePermission(AnnouncerPermissions.LIST_WORKSPACE_ANNOUNCEMENTS, workspaceEntity)) {
            return Response.status(Status.FORBIDDEN).entity("You don't have the permission to list workspace announcements").build();
        }
        announcements = announcementController.listWorkspaceAnnouncements(Arrays.asList(workspaceEntity), environment, timeFrame, currentUserEntity, onlyMine, onlyArchived);
    }
    List<AnnouncementRESTModel> restModels = new ArrayList<>();
    for (Announcement announcement : announcements) {
        if (onlyEditable && !canEdit(announcement, currentUserEntity)) {
            continue;
        }
        List<AnnouncementUserGroup> announcementUserGroups = announcementController.listAnnouncementUserGroups(announcement);
        List<AnnouncementWorkspace> announcementWorkspaces = announcementController.listAnnouncementWorkspacesSortByUserFirst(announcement, currentUserEntity);
        AnnouncementRESTModel restModel = createRESTModel(announcement, announcementUserGroups, announcementWorkspaces);
        restModels.add(restModel);
    }
    return Response.ok(restModels).build();
}
Also used : Announcement(fi.otavanopisto.muikku.plugins.announcer.model.Announcement) AnnouncementUserGroup(fi.otavanopisto.muikku.plugins.announcer.model.AnnouncementUserGroup) ArrayList(java.util.ArrayList) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) AnnouncementWorkspace(fi.otavanopisto.muikku.plugins.announcer.workspace.model.AnnouncementWorkspace) AnnouncementEnvironmentRestriction(fi.otavanopisto.muikku.plugins.announcer.dao.AnnouncementEnvironmentRestriction) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)163 Path (javax.ws.rs.Path)101 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)88 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)65 GET (javax.ws.rs.GET)58 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)54 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)50 User (fi.otavanopisto.muikku.schooldata.entity.User)36 ArrayList (java.util.ArrayList)35 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)27 POST (javax.ws.rs.POST)26 Date (java.util.Date)24 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)22 HashMap (java.util.HashMap)20 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)18 EnvironmentUser (fi.otavanopisto.muikku.model.users.EnvironmentUser)14 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)14 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)13 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)12 PUT (javax.ws.rs.PUT)12