Commit e7388c7a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

change in user privileges doesn't crash project upload

parent 05305712
minerva (12.1.4) stable; urgency=medium
* Bug fix: upload of the project failed when another project was removed
during upload
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 28 Dec 2018 14:00:00 +0200
minerva (12.1.3) stable; urgency=medium
* Bug fix: add project button is disabled when user has no privileges
* Bug fix: projectId was missing in the edit window
......
......@@ -809,6 +809,7 @@ public class ProjectService implements IProjectService {
file.setOwner(owner);
project.setInputData(file);
}
addUsers(project, params);
createModel(params, project);
Model originalModel = project.getModels().iterator().next().getModel();
......@@ -821,7 +822,6 @@ public class ProjectService implements IProjectService {
}
}
addUsers(project, params);
createImages(originalModel, params);
for (Layout layout : originalModel.getLayouts()) {
......
......@@ -43,7 +43,9 @@ import lcsb.mapviewer.model.map.model.SubmodelType;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.user.ConfigurationOption;
import lcsb.mapviewer.model.user.ObjectPrivilege;
import lcsb.mapviewer.model.user.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.model.user.UserAnnotationSchema;
import lcsb.mapviewer.model.user.UserClassAnnotators;
import lcsb.mapviewer.model.user.UserClassValidAnnotations;
......@@ -92,7 +94,7 @@ public class ProjectServiceTest extends ServiceTestFunctions {
}
@Test
public void test() throws Exception {
public void testGetAllProjects() throws Exception {
try {
List<Project> projects = projectService.getAllProjects(adminToken);
......@@ -124,6 +126,81 @@ public class ProjectServiceTest extends ServiceTestFunctions {
}
}
@Test
public void testUserPrivilegeChangeDuringUpload() throws Exception {
try {
User admin = userService.getUserByToken(adminToken);
Project defaultProject = projectService.getAllProjects().get(0);
userService.setUserPrivilege(admin,
new ObjectPrivilege(defaultProject, 1, PrivilegeType.EDIT_COMMENTS_PROJECT, admin));
admin = userService.getUserByToken(adminToken);
String project_id = "test_id";
Thread addProjectThread = new Thread(new Runnable() {
@Override
public void run() {
try {
projectService.createProject(new CreateProjectParams().//
authenticationToken(adminToken).//
projectId(project_id).//
version("").//
projectFile("testFiles/sample.xml").//
images(false).//
analyzeAnnotations(true).//
addUser("admin", "admin").//
projectDir(tmpResultDir));
} catch (Exception e) {
e.printStackTrace();
}
}
});
addProjectThread.start();
Thread dropPrivilegesThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(100);
userService.dropPrivilegesForObjectType(PrivilegeType.VIEW_PROJECT, defaultProject.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
});
dropPrivilegesThread.start();
dropPrivilegesThread.join();
addProjectThread.join();
Project project = projectService.getProjectByProjectId(project_id, adminToken);
assertEquals(ProjectStatus.DONE, project.getStatus());
Thread removeProjectThread = new Thread(new Runnable() {
@Override
public void run() {
try {
Project project = projectService.getProjectByProjectId(project_id, adminToken);
assertEquals(ProjectStatus.DONE, project.getStatus());
projectService.removeProject(project, null, false, adminToken);
} catch (Exception e) {
e.printStackTrace();
}
}
});
removeProjectThread.start();
removeProjectThread.join();
assertNull(projectService.getProjectByProjectId(project_id, adminToken));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testUpdater() throws Exception {
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment