Search in sources :

Example 56 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspaceController method deleteWorkspace.

public void deleteWorkspace(Workspace workspace) {
    WorkspaceEntity workspaceEntity = workspaceSchoolDataController.findWorkspaceEntity(workspace);
    if (workspaceEntity != null) {
        deleteWorkspaceEntity(workspaceEntity);
    }
    workspaceSchoolDataController.removeWorkspace(workspace);
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)

Example 57 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspaceEntityController method createWorkspaceEntity.

public WorkspaceEntity createWorkspaceEntity(String dataSource, String identifier, String urlName) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
    if (schoolDataSource == null) {
        logger.severe("Could not find school data source: " + dataSource);
        return null;
    }
    WorkspaceEntity workspaceEntity = workspaceEntityDAO.create(schoolDataSource, identifier, urlName, WorkspaceAccess.LOGGED_IN, Boolean.FALSE, Boolean.FALSE);
    return workspaceEntity;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)

Example 58 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class WorkspaceSchoolDataController method createWorkspaceUser.

/* Workspace Users */
public WorkspaceUser createWorkspaceUser(Workspace workspace, User user, String roleSchoolDataSource, String roleIdentifier) {
    WorkspaceEntity workspaceEntity = findWorkspaceEntity(workspace);
    WorkspaceSchoolDataBridge workspaceBridge = getWorkspaceBridge(workspaceEntity.getDataSource());
    if (workspaceBridge != null) {
        return workspaceBridge.createWorkspaceUser(workspace, user, roleSchoolDataSource, roleIdentifier);
    } else {
        logger.log(Level.SEVERE, "School Data Bridge not found: " + workspaceEntity.getDataSource());
    }
    return null;
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)

Example 59 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class DeusNexMachinaRESTService method cleanWorkspaceMaterials.

@GET
@Path("/cleanworkspacematerials/{ID}")
@RESTPermit(DeusNexMachinaPermissions.CLEAN_WORKSPACE_MATERIALS)
public Response cleanWorkspaceMaterials(@PathParam("ID") Long workspaceEntityId, @Context Request request) {
    WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityById(workspaceEntityId);
    if (workspaceEntity != null) {
        WorkspaceNode rootFolder = workspaceMaterialController.findWorkspaceRootFolderByWorkspaceEntity(workspaceEntity);
        try {
            List<WorkspaceNode> nodes = workspaceMaterialController.listWorkspaceNodesByParent(rootFolder);
            cleanMaterials(nodes);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Cleaning materials of workspace " + workspaceEntityId + " failed", e);
            return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
        }
    } else {
        return Response.status(Status.NOT_FOUND).entity("Unknown workspace " + workspaceEntityId).build();
    }
    return Response.status(Status.OK).entity("Workspace " + workspaceEntityId + " materials successfully cleaned").build();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) WorkspaceNode(fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceNode) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.security.rest.RESTPermit) GET(javax.ws.rs.GET)

Example 60 with WorkspaceEntity

use of fi.otavanopisto.muikku.model.workspace.WorkspaceEntity in project muikku by otavanopisto.

the class DeusNexServiceUpdater method findDocuments.

@Schedule(hour = "*", minute = "*/1", second = "0", persistent = false)
public void findDocuments() {
    if (contextInitialized) {
        if (!running) {
            try {
                running = true;
                List<Document> documents = Arrays.asList(client.listDocuments());
                Collections.sort(documents, new Comparator<Document>() {

                    @Override
                    public int compare(Document o1, Document o2) {
                        return o1.getPriority() - o2.getPriority();
                    }
                });
                List<Long> importNos = deusNexImportQueueController.getImportNos();
                List<Long> newImports = new ArrayList<>();
                for (Document document : documents) {
                    if (importNos != null && !importNos.contains(document.getId())) {
                        continue;
                    }
                    if (deusNexImportQueueController.isDownloaded(document.getId())) {
                        continue;
                    }
                    if (deusNexImportQueueController.isPendingDownload(document.getId())) {
                        continue;
                    }
                    if (document.getPath() == null) {
                        logger.log(Level.SEVERE, "Document " + document.getId() + " has no path");
                    }
                    String path = document.getPath();
                    int slashIndex = path.indexOf('/');
                    String dnmId = slashIndex > -1 ? path.substring(0, slashIndex) : path;
                    Long workspaceEntityId = deusNexMachinaController.getWorkspaceEntityIdDnmId(dnmId);
                    if (workspaceEntityId == null) {
                        logger.log(Level.WARNING, String.format("Postponing import because dnm id <> workspace entity id mapping for document %s could not be found", document.getPath()));
                        return;
                    } else {
                        WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
                        if (workspaceEntity != null) {
                            newImports.add(document.getId());
                        } else {
                            logger.log(Level.WARNING, String.format("Postponing import because workspace for document %s could not be found", document.getPath()));
                            return;
                        }
                    }
                }
                if (!newImports.isEmpty()) {
                    logger.info(String.format("Queued %d dnm imports", newImports.size()));
                    deusNexImportQueueController.addPendingDownloads(newImports);
                }
                deusNexImportQueueController.setLastUpdate(System.currentTimeMillis());
            } finally {
                running = false;
            }
        }
    }
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) ArrayList(java.util.ArrayList) Schedule(javax.ejb.Schedule)

Aggregations

WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)190 Path (javax.ws.rs.Path)102 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)82 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)65 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)51 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)49 GET (javax.ws.rs.GET)46 ArrayList (java.util.ArrayList)38 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)29 POST (javax.ws.rs.POST)26 WorkspaceMaterial (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceMaterial)25 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)21 Workspace (fi.otavanopisto.muikku.schooldata.entity.Workspace)21 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)20 RequestAction (org.ocpsoft.rewrite.annotation.RequestAction)19 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)17 Date (java.util.Date)17 DELETE (javax.ws.rs.DELETE)17 PUT (javax.ws.rs.PUT)16 WorkspaceRootFolder (fi.otavanopisto.muikku.plugins.workspace.model.WorkspaceRootFolder)15