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