Skip to content
Snippets Groups Projects
Commit f4495115 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

details

parent e4b9e841
No related branches found
No related tags found
No related merge requests found
...@@ -117,8 +117,6 @@ public class ModelsApi { ...@@ -117,8 +117,6 @@ public class ModelsApi {
LOGGER.info("Create a model"); LOGGER.info("Create a model");
model = getModelWithDataset(model);
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
model.setTitle(model.getConfig().getTitle().get("text")); model.setTitle(model.getConfig().getTitle().get("text"));
...@@ -129,7 +127,8 @@ public class ModelsApi { ...@@ -129,7 +127,8 @@ public class ModelsApi {
model.setValid(false); model.setValid(false);
} }
long count = 1; // Ensure the title is unique
long count = 1; //
for(int i = 1; count > 0; i++) for(int i = 1; count > 0; i++)
{ {
count = modelRepository.countByTitle(model.getTitle()); count = modelRepository.countByTitle(model.getTitle());
...@@ -145,14 +144,16 @@ public class ModelsApi { ...@@ -145,14 +144,16 @@ public class ModelsApi {
} }
} }
// Slugify
String slug = null; String slug = null;
try { try {
slug = new Slugify().slugify(model.getTitle()); slug = new Slugify().slugify(model.getTitle());
} catch (IOException e) { } catch (IOException e) {
slug = ""; slug = ""; // Should never happen
LOGGER.trace(e); LOGGER.trace(e);
} }
// Ensure slug is unique
boolean alreadyExists = true; boolean alreadyExists = true;
for(int i = 1; alreadyExists; i++) for(int i = 1; alreadyExists; i++)
{ {
...@@ -205,9 +206,7 @@ public class ModelsApi { ...@@ -205,9 +206,7 @@ public class ModelsApi {
User user = securityConfiguration.getUser(); User user = securityConfiguration.getUser();
Model model = null; Model model = modelRepository.findOne(slug);
model = modelRepository.findOne(slug);
if (!model.getValid() && !model.getCreatedBy().getUsername().equals(user.getUsername())) if (!model.getValid() && !model.getCreatedBy().getUsername().equals(user.getUsername()))
{ {
return new ResponseEntity<>(HttpStatus.FORBIDDEN); return new ResponseEntity<>(HttpStatus.FORBIDDEN);
......
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