Commit 1241bff2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch...

Merge branch '351-internal-server-error-when-updating-project-that-doesn-t-have-model' into 'master'

Resolve "Internal Server Error when updating project that doesn't have model"

Closes #351

See merge request piotr.gawron/minerva!257
parents 13487b97 0b97bed5
Pipeline #4351 passed with stage
in 1 minute and 29 seconds
......@@ -45,30 +45,38 @@
"litemol": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b"
},
"dependencies": {
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
}
}
},
"jquery": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
"dev": true
}
}
},
"ProtVista": {
"version": "git://github.com/davidhoksza/protvista.git#4e4bb737ba1e183291505bd25f8bae2e651ce21e",
"dev": true,
"requires": {
"d3": "3.5.17",
"file-saver": "1.3.3",
"jquery": "2.2.4",
"jszip": "3.1.4",
"underscore": "1.8.3"
},
"dependencies": {
"jquery": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz",
"integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI=",
"dev": true
},
"litemol": {
"version": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b",
"dev": true,
"requires": {
"@types/react": "15.6.14",
"@types/react-dom": "15.5.7"
}
}
}
},
......@@ -2050,14 +2058,6 @@
"immediate": "3.0.6"
}
},
"litemol": {
"version": "github:dsehnal/LiteMol#a5419c696faa84530dd93acd55b747cf8136902b",
"dev": true,
"requires": {
"@types/react": "15.6.14",
"@types/react-dom": "15.5.7"
}
},
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
......
......@@ -870,17 +870,16 @@ public class ProjectService implements IProjectService {
modelDao.update(originalModel);
if (params.isAnalyzeAnnotations()) {
analyzeAnnotations(originalModel, params);
}
Logger.getRootLogger().removeAppender(appender);
project.addLoggingInfo(appender);
if (params.isCacheModel()) {
cacheData(originalModel, params);
}
updateProjectStatus(project, ProjectStatus.DONE, IProgressUpdater.MAX_PROGRESS, params);
if (project.getNotifyEmail() != null && !project.getNotifyEmail().equals("")) {
try {
......@@ -1351,7 +1350,10 @@ public class ProjectService implements IProjectService {
public void updateProject(Project project, String token) throws SecurityException {
projectDao.update(project);
if (token != null) {
modelService.getLastModelByProjectId(project.getProjectId(), token).setProject(project);
Model model = modelService.getLastModelByProjectId(project.getProjectId(), token);
if (model != null) {
model.setProject(project);
}
}
}
......
......@@ -327,7 +327,6 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCopyComplexWithCompartments() throws Exception {
try {
String projectId = "Some_id";
ZipEntryFile entry1 = new ModelZipEntryFile("main.xml", "main", true, false, SubmodelType.UNKNOWN);
ZipEntryFile entry2 = new ModelZipEntryFile("s1.xml", "s1", false, false, SubmodelType.UNKNOWN);
ZipEntryFile entry3 = new ModelZipEntryFile("s2.xml", "s2", false, false, SubmodelType.UNKNOWN);
......@@ -601,11 +600,10 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCreateComplexWithImages() throws Exception {
try {
String name = "Some_id";
String filename = "testFiles/complexModel/complex_model_with_images.zip";
Project project = createComplexProject(name, filename);
Project project = createComplexProject(projectId, filename);
Model model = modelService.getLastModelByProjectId(name, adminToken);
Model model = modelService.getLastModelByProjectId(projectId, adminToken);
assertNotNull(model);
assertEquals("main", model.getName());
assertEquals(ProjectStatus.DONE, project.getStatus());
......@@ -623,7 +621,6 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCreateComplexWithLayoutOrder() throws Exception {
try {
String name = "Some_id";
String filename = "testFiles/complexModel/complex_model_with_images.zip";
CreateProjectParams params = new CreateProjectParams();
......@@ -650,7 +647,7 @@ public class ProjectServiceTest extends ServiceTestFunctions {
analyzeAnnotations(true));
Project project = projectService.getProjectByProjectId(projectId, adminToken);
Model model = modelService.getLastModelByProjectId(name, adminToken);
Model model = modelService.getLastModelByProjectId(projectId, adminToken);
assertNotNull(model);
assertEquals("main", model.getName());
assertEquals(ProjectStatus.DONE, project.getStatus());
......@@ -667,7 +664,6 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test(timeout = 15000)
public void testCreateComplexWithLayouts() throws Exception {
String projectId = "Some_id";
try {
String filename = "testFiles/complexModel/complex_model_with_layouts.zip";
Project project = createComplexProject(projectId, filename);
......@@ -698,11 +694,10 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCreateComplexWithSumbaps() throws Exception {
try {
String name = "Some_id";
String filename = "testFiles/complexModel/complex_model_with_submaps.zip";
Project project = createComplexProject(name, filename);
Project project = createComplexProject(projectId, filename);
Model model = modelService.getLastModelByProjectId(name, adminToken);
Model model = modelService.getLastModelByProjectId(projectId, adminToken);
assertNotNull(model);
assertEquals("main", model.getName());
assertEquals(ProjectStatus.DONE, project.getStatus());
......@@ -717,11 +712,10 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCreateEmptyComplex() throws Exception {
try {
String name = "Some_id";
String filename = "testFiles/complexModel/empty_complex_model.zip";
Project project = createComplexProject(name, filename);
Project project = createComplexProject(projectId, filename);
Model model = modelService.getLastModelByProjectId(name, adminToken);
Model model = modelService.getLastModelByProjectId(projectId, adminToken);
assertNotNull(model);
assertEquals(ProjectStatus.DONE, project.getStatus());
projectService.removeProject(project, null, false, adminToken);
......@@ -734,11 +728,10 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCreateEmptyComplex2() throws Exception {
try {
String name = "Some_id";
String filename = "testFiles/complexModel/empty_complex_model2.zip";
Project project = createComplexProject(name, filename);
Project project = createComplexProject(projectId, filename);
Model model = modelService.getLastModelByProjectId(name, adminToken);
Model model = modelService.getLastModelByProjectId(projectId, adminToken);
assertNotNull(model);
assertEquals(ProjectStatus.DONE, project.getStatus());
projectService.removeProject(project, null, false, adminToken);
......@@ -751,11 +744,10 @@ public class ProjectServiceTest extends ServiceTestFunctions {
@Test
public void testCreateEmptyComplex3() throws Exception {
try {
String name = "Some_id";
String filename = "testFiles/complexModel/empty_complex_model3.zip";
Project project = createComplexProject(name, filename);
Project project = createComplexProject(projectId, filename);
Model model = modelService.getLastModelByProjectId(name, adminToken);
Model model = modelService.getLastModelByProjectId(projectId, adminToken);
assertNotNull(model);
assertEquals(ProjectStatus.DONE, project.getStatus());
projectService.removeProject(project, null, false, adminToken);
......@@ -770,9 +762,8 @@ public class ProjectServiceTest extends ServiceTestFunctions {
try {
createUser();
String name = "Some_id";
String filename = "testFiles/complexModel/empty_complex_model.zip";
Project project = createComplexProject(name, filename);
Project project = createComplexProject(projectId, filename);
for (PrivilegeType type : PrivilegeType.values()) {
if (Project.class.equals(type.getPrivilegeObjectType())) {
......@@ -789,4 +780,20 @@ public class ProjectServiceTest extends ServiceTestFunctions {
}
}
@Test
public void testUpdateProjectWithoutModel() throws Exception {
try {
createUser();
Project project = new Project();
project.setProjectId(projectId);
projectDao.add(project);
projectService.updateProject(project, adminToken);
projectService.removeProject(project, null, false, adminToken);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
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