Commit 3515cb67 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1073-plugin-url-verification' into 'devel_14.0.x'

url must be unique

See merge request minerva/core!1043
parents e8b441c0 37a03a7a
......@@ -106,4 +106,11 @@ public class Plugin implements Serializable {
public void setPublic(boolean isPublic) {
this.isPublic = isPublic;
}
public void addUrl(String string) {
if (!urls.contains(string)) {
urls.add(string);
}
}
}
......@@ -24,9 +24,22 @@ public class PluginDaoTest extends PersistTestFunctions {
plugin.setHash("x");
plugin.setName("Plugin name");
plugin.setVersion("0.0.1");
plugin.getUrls().add("htpp://google.pl/");
plugin.addUrl("htpp://google.pl/");
pluginDao.add(plugin);
assertTrue(pluginDao.getAll().size() > 0);
}
@Test
public void testAddPluginWithUrls() {
Plugin plugin = new Plugin();
plugin.setHash("x");
plugin.setName("Plugin name");
plugin.setVersion("0.0.1");
plugin.addUrl("htpp://google.pl/");
plugin.addUrl("htpp://google.pl/");
pluginDao.add(plugin);
pluginDao.flush();
assertTrue(pluginDao.getAll().size() > 0);
}
}
......@@ -34,7 +34,7 @@ public class PluginRestImpl extends BaseRestImpl {
}
Plugin plugin = pluginDao.getByHash(hash);
if (plugin != null) {
plugin.getUrls().add(url);
plugin.addUrl(url);
plugin.setPublic(plugin.isPublic() || isPublic);
pluginDao.update(plugin);
} else {
......@@ -44,7 +44,7 @@ public class PluginRestImpl extends BaseRestImpl {
plugin.setVersion(version);
plugin.setPublic(isPublic);
if (!url.isEmpty()) {
plugin.getUrls().add(url);
plugin.addUrl(url);
}
pluginDao.add(plugin);
}
......
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