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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations