use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.
the class PyramusSchoolDataWorkspaceUsersUpdateScheduler method synchronize.
public void synchronize() {
int currentOffset = getAndUpdateCurrentOffset(BATCH_SIZE);
int count = 0;
try {
logger.fine("Synchronizing Pyramus workspace users");
List<WorkspaceEntity> workspaceEntities = workspaceEntityController.listWorkspaceEntitiesByDataSource(SchoolDataPyramusPluginDescriptor.SCHOOL_DATA_SOURCE, currentOffset, BATCH_SIZE);
if (workspaceEntities.size() == 0) {
resetCurrentOffset();
} else {
for (WorkspaceEntity workspaceEntity : workspaceEntities) {
Long courseId = identityMapper.getPyramusCourseId(workspaceEntity.getIdentifier());
count += pyramusUpdater.updateCourseStaffMembers(courseId);
}
}
} finally {
logger.fine(String.format("Synchronized %d Pyramus workspace users", count));
}
}
use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method createWorkspace.
@POST
@Path("/workspaces")
@RESTPermit(handling = Handling.UNSECURED)
public Response createWorkspace(fi.otavanopisto.muikku.atests.Workspace payload) {
SchoolDataWorkspaceDiscoveredEvent event = new SchoolDataWorkspaceDiscoveredEvent(payload.getSchoolDataSource(), payload.getIdentifier(), payload.getName(), null);
schoolDataWorkspaceDiscoveredEvent.fire(event);
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(event.getDiscoveredWorkspaceEntityId());
if (payload.getPublished() != null) {
workspaceEntityController.updatePublished(workspaceEntity, payload.getPublished());
}
return Response.ok(createRestEntity(workspaceEntity, payload.getName())).build();
}
use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method createWorkspaceDiscussion.
@POST
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions")
@RESTPermit(handling = Handling.UNSECURED)
public Response createWorkspaceDiscussion(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, fi.otavanopisto.muikku.atests.Discussion payload) {
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
}
ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
if (group == null) {
return Response.status(Status.NOT_FOUND).entity("Group not found").build();
}
if (StringUtils.isBlank(payload.getName())) {
return Response.status(Status.BAD_REQUEST).entity("Mandatory name is missing").build();
}
return Response.ok(createRestEntity(forumController.createWorkspaceForumArea(workspaceEntity, payload.getName(), payload.getDescription(), group.getId()))).build();
}
use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method deleteWorkspaceDiscussion.
@DELETE
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteWorkspaceDiscussion(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId) {
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
}
ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
if (group == null) {
return Response.status(Status.NOT_FOUND).entity("Group not found").build();
}
ForumArea forumArea = forumController.getForumArea(discussionId);
if (forumArea == null) {
return Response.status(Status.NOT_FOUND).entity("Discussion not found").build();
}
List<ForumThread> threads = forumController.listForumThreads(forumArea, 0, Integer.MAX_VALUE, true);
for (ForumThread thread : threads) {
List<ForumThreadReply> replies = forumController.listForumThreadReplies(thread, 0, Integer.MAX_VALUE, true);
for (ForumThreadReply reply : replies) {
forumController.deleteReply(reply);
}
forumController.deleteThread(thread);
}
forumController.deleteArea(forumArea);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity 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();
}
Aggregations