Commit 54e57077 authored by Piotr Gawron's avatar Piotr Gawron

remove plugin permanently from admin panel

parent e8fbea4d
Pipeline #26541 passed with stage
in 13 minutes and 11 seconds
......@@ -6,6 +6,8 @@ minerva (14.0.12) stable; urgency=medium
* Bug fix: doi annotation was inproperly parsed from CellDesigner file and
resulted in not clickable link (#1231)
* Bug fix: when plugin data was too big 500 error was returned (#1232)
* Bug fix: removing plugin in admin panel removes it from server permanently
(#1211)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 11 May 2020 17:00:00 +0200
......
......@@ -43,4 +43,10 @@ public class PluginDataEntryDao extends BaseDao<PluginDataEntry> {
}
}
public List<PluginDataEntry> getByPlugin(Plugin plugin) {
List<Pair<String, Object>> params = new ArrayList<>();
params.add(new Pair<>("plugin_id", plugin.getId()));
return getElementsByParameters(params);
}
}
......@@ -58,8 +58,8 @@ public class PluginController extends BaseController {
// FIXME: check if this takes priority over filter chain
@PreAuthorize("hasAuthority('IS_ADMIN')")
@DeleteMapping(value = "/{hash}")
public Map<String, Object> removePlugin(@PathVariable(value = "hash") String hash) throws ObjectNotFoundException {
return pluginRest.removePlugin(hash);
public void removePlugin(@PathVariable(value = "hash") String hash) throws ObjectNotFoundException {
pluginRest.removePlugin(hash);
}
@PostMapping(value = "/{hash}/data/users/{key}")
......
......@@ -145,14 +145,16 @@ public class PluginRestImpl extends BaseRestImpl {
return result;
}
public Map<String, Object> removePlugin(String hash) throws ObjectNotFoundException {
public void removePlugin(String hash) throws ObjectNotFoundException {
Plugin plugin = pluginDao.getByHash(hash);
if (plugin != null) {
plugin.setPublic(false);
pluginDao.update(plugin);
List<PluginDataEntry> entries = pluginDataEntryDao.getByPlugin(plugin);
for (PluginDataEntry pluginDataEntry : entries) {
pluginDataEntryDao.delete(pluginDataEntry);
}
pluginDao.delete(plugin);
} else {
throw new ObjectNotFoundException("Plugin doesn't exist");
}
return getPlugin(hash);
}
}
package lcsb.mapviewer.web;
import static org.junit.Assert.assertEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Arrays;
......@@ -263,6 +262,18 @@ public class PluginControllerIntegrationTest extends ControllerIntegrationTest {
}
@Test
public void testRemovePlugin() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
Plugin plugin = createPlugin();
RequestBuilder request = delete("/plugins/" + plugin.getHash() + "/").session(session);
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful());
}
private Plugin createPlugin() {
Plugin plugin = new Plugin();
plugin.setHash("XYZ");
......
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