56 |
56 |
private ConfigurationService configurationService;
|
57 |
57 |
|
58 |
58 |
/**
|
59 |
|
* This method is called by the GET method and initializes
|
60 |
|
* the main page of the application (index). Loads all projects
|
61 |
|
* stored in the db and all implemented AP.
|
|
59 |
* This method is called by the GET method and initializes
|
|
60 |
* the main page of the application (index). Loads all projects
|
|
61 |
* stored in the db and all implemented AP.
|
62 |
62 |
*
|
63 |
63 |
* @param model object for passing data to the UI
|
64 |
64 |
* @return html file name for thymeleaf template
|
... | ... | |
66 |
66 |
@GetMapping("/")
|
67 |
67 |
public String index(Model model) {
|
68 |
68 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
|
69 |
LOGGER.info("@GetMapping(\"/\") - Accessing main page");
|
69 |
70 |
return "index";
|
70 |
71 |
}
|
71 |
72 |
|
72 |
73 |
/**
|
73 |
|
* Method for obtaining project by ID.
|
|
74 |
* Method for obtaining project by ID.
|
74 |
75 |
*
|
75 |
|
* @param id project ID
|
|
76 |
* @param id project ID
|
76 |
77 |
* @param model object for passing data to the UI
|
77 |
78 |
* @return html file name for thymeleaf template
|
78 |
79 |
*/
|
... | ... | |
80 |
81 |
public String getProjectById(@PathVariable Long id, Model model) {
|
81 |
82 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
82 |
83 |
model.addAttribute("project", projectService.getProjectById(id));
|
|
84 |
LOGGER.info("@GetMapping(\"projects/" + id + ")");
|
83 |
85 |
return "project";
|
84 |
86 |
}
|
85 |
87 |
|
86 |
88 |
/**
|
87 |
89 |
* Method for obtaining all AP.
|
|
90 |
*
|
88 |
91 |
* @return list of AP
|
89 |
92 |
*/
|
90 |
93 |
@GetMapping("/anti-patterns")
|
91 |
|
public @ResponseBody List<AntiPattern> getAllAntiPatterns(Model model) {
|
|
94 |
public @ResponseBody
|
|
95 |
List<AntiPattern> getAllAntiPatterns(Model model) {
|
92 |
96 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
|
97 |
LOGGER.info("GetMapping(\"/anti-patterns\") and obtaining all APs.");
|
93 |
98 |
return antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns());
|
94 |
99 |
}
|
95 |
100 |
|
96 |
101 |
/**
|
97 |
102 |
* Method for obtaining AP by ID.
|
98 |
103 |
*
|
99 |
|
* @param id AP ID
|
|
104 |
* @param id AP ID
|
100 |
105 |
* @param model object for passing data to the UI
|
101 |
106 |
* @return html file name for thymeleaf template
|
102 |
107 |
*/
|
... | ... | |
108 |
113 |
model.addAttribute("description", antiPatternService.getDescriptionFromCatalogue(id));
|
109 |
114 |
model.addAttribute("operationalizationText", antiPatternService.getOperationalizationText(antiPatternService.getAntiPatternById(id).getAntiPatternModel().getName()));
|
110 |
115 |
model.addAttribute("configurations", configurationService.getConfigurationByName(currentConfigurationName));
|
|
116 |
LOGGER.info("GetMapping(\"/anti-patterns/ " + id + ") and obtaining AP by ID");
|
111 |
117 |
return "anti-pattern";
|
112 |
118 |
}
|
113 |
119 |
|
114 |
120 |
/**
|
115 |
121 |
* Method that processes requirements for analyzing selected projects and AP.
|
116 |
122 |
*
|
117 |
|
* @param model object for passing data to the UI
|
118 |
|
* @param selectedProjects selected project to analyze
|
|
123 |
* @param model object for passing data to the UI
|
|
124 |
* @param selectedProjects selected project to analyze
|
119 |
125 |
* @param selectedAntiPatterns selected AP to analyze
|
120 |
126 |
* @return html file name for thymeleaf template
|
121 |
127 |
*/
|
... | ... | |
130 |
136 |
model.addAttribute("errorMessage", "No project selected." +
|
131 |
137 |
" Select at least one project.");
|
132 |
138 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
|
139 |
LOGGER.warn("@PostMapping(\"/analyze\") - Processing requirements for analyzing selected projects and AP with an error. " +
|
|
140 |
"selectedProjects are null!");
|
133 |
141 |
return "index";
|
134 |
142 |
}
|
135 |
143 |
|
... | ... | |
137 |
145 |
model.addAttribute("errorMessage", "No anti-pattern selected." +
|
138 |
146 |
" Select at least one anti-pattern.");
|
139 |
147 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
|
148 |
LOGGER.warn("@PostMapping(\"/analyze\") - Processing requirements for analyzing selected projects and AP with an error. " +
|
|
149 |
"selectedAntiPatterns are null!");
|
140 |
150 |
return "index";
|
141 |
151 |
}
|
142 |
152 |
|
... | ... | |
152 |
162 |
model.addAttribute("queryResults", results);
|
153 |
163 |
model.addAttribute("recalculationTime", DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalTime.now()));
|
154 |
164 |
|
|
165 |
|
|
166 |
LOGGER.info("@PostMapping(\"/analyze\") - Processing SUCCESSFULLY requirements for analyzing selected projects and AP.");
|
155 |
167 |
return "result";
|
156 |
168 |
}
|
157 |
169 |
|
... | ... | |
172 |
184 |
model.addAttribute("queryResults", antiPatternService.getResults());
|
173 |
185 |
model.addAttribute("recalculationTime", DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalTime.now()));
|
174 |
186 |
|
|
187 |
LOGGER.info("@GetMapping(\"/analyze\") - ??");
|
175 |
188 |
return "result";
|
176 |
189 |
}
|
177 |
190 |
|
... | ... | |
183 |
196 |
@GetMapping("/about")
|
184 |
197 |
public String about(Model model) {
|
185 |
198 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
|
199 |
LOGGER.info("@GetMapping(\"/about\") - Accessing about page");
|
186 |
200 |
return "about";
|
187 |
201 |
}
|
188 |
202 |
|
... | ... | |
205 |
219 |
/**
|
206 |
220 |
* Method of saving changes of current configuration
|
207 |
221 |
*
|
208 |
|
* @param model object for passing data to the UI
|
|
222 |
* @param model object for passing data to the UI
|
209 |
223 |
* @param thresholdValues changed configuration values
|
210 |
|
* @param thresholdNames changed configuration names
|
|
224 |
* @param thresholdNames changed configuration names
|
211 |
225 |
* @return html file name for thymeleaf template
|
212 |
226 |
*/
|
213 |
227 |
@PostMapping(value = "/configuration", params = "configuration-save-button")
|
214 |
228 |
public String configurationSavePost(Model model,
|
215 |
|
@RequestParam(value = "thresholdValues", required = false) String[] thresholdValues,
|
216 |
|
@RequestParam(value = "thresholdNames", required = false) String[] thresholdNames,
|
217 |
|
@RequestParam(value = "antiPatternNames", required = false) String[] antiPatternNames,
|
218 |
|
HttpSession session, RedirectAttributes redirectAttributes) {
|
|
229 |
@RequestParam(value = "thresholdValues", required = false) String[] thresholdValues,
|
|
230 |
@RequestParam(value = "thresholdNames", required = false) String[] thresholdNames,
|
|
231 |
@RequestParam(value = "antiPatternNames", required = false) String[] antiPatternNames,
|
|
232 |
HttpSession session, RedirectAttributes redirectAttributes) {
|
219 |
233 |
|
220 |
234 |
String currentConfigurationName = configurationGetFromSession(session);
|
221 |
235 |
|
... | ... | |
225 |
239 |
|
226 |
240 |
if (wrongParameters.isEmpty()) {
|
227 |
241 |
model.addAttribute("successMessage", "All configuration values have been successfully saved.");
|
|
242 |
LOGGER.info("@PostMapping(value = \"/configuration\", params = \"configuration-save-button\") - " +
|
|
243 |
"input parameters were successfully processed...");
|
228 |
244 |
} else {
|
229 |
245 |
model.addAttribute("errorMessage", "One or more configuration values are not in correct format, see messages below.");
|
230 |
246 |
antiPatternService.setErrorMessages(query.getAntiPatterns(), wrongParameters);
|
|
247 |
LOGGER.warn("@PostMapping(value = \"/configuration\", params = \"configuration-save-button\") ended with an error!" +
|
|
248 |
"Some parameters seem to be wrong!");
|
231 |
249 |
}
|
232 |
250 |
|
233 |
251 |
model.addAttribute("query", query);
|
234 |
252 |
|
235 |
253 |
model.addAttribute("configurations", configurationService.getConfigurationByName(currentConfigurationName));
|
|
254 |
LOGGER.info("@PostMapping(value = \"/configuration\", params = \"configuration-save-button\") - Save Button was pressed");
|
236 |
255 |
return "configuration";
|
237 |
256 |
}
|
238 |
257 |
|
239 |
258 |
/**
|
240 |
259 |
* Method for saving full new configuration
|
241 |
260 |
*
|
242 |
|
* @param model object for passing data to the UI
|
|
261 |
* @param model object for passing data to the UI
|
243 |
262 |
* @param thresholdValues changed configuration values
|
244 |
|
* @param thresholdNames changed configuration names
|
|
263 |
* @param thresholdNames changed configuration names
|
245 |
264 |
* @return html file name for thymeleaf template
|
246 |
265 |
*/
|
247 |
266 |
@PostMapping(value = "/configuration", params = "configuration-save-as-button")
|
248 |
267 |
public String configurationSaveAsPost(Model model,
|
249 |
|
@RequestParam(value = "thresholdValues", required = false) String[] thresholdValues,
|
250 |
|
@RequestParam(value = "thresholdNames", required = false) String[] thresholdNames,
|
251 |
|
@RequestParam(value = "antiPatternNames", required = false) String[] antiPatternNames,
|
252 |
|
@RequestParam(value = "configuration-save-as-input", required = false) String newConfigName,
|
253 |
|
HttpSession session, RedirectAttributes redirectAttributes) {
|
|
268 |
@RequestParam(value = "thresholdValues", required = false) String[] thresholdValues,
|
|
269 |
@RequestParam(value = "thresholdNames", required = false) String[] thresholdNames,
|
|
270 |
@RequestParam(value = "antiPatternNames", required = false) String[] antiPatternNames,
|
|
271 |
@RequestParam(value = "configuration-save-as-input", required = false) String newConfigName,
|
|
272 |
HttpSession session, RedirectAttributes redirectAttributes) {
|
254 |
273 |
|
255 |
274 |
Query query = new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns()));
|
256 |
275 |
String currentConfigurationName = configurationGetFromSession(session);
|
257 |
276 |
|
258 |
277 |
List<String> allConfigurationNames = configurationService.getAllConfigurationNames();
|
259 |
|
if (newConfigName == null || newConfigName.length() == 0 || allConfigurationNames.contains(newConfigName)) {
|
|
278 |
if (newConfigName == null || newConfigName.length() == 0 || allConfigurationNames.contains(newConfigName)) {
|
260 |
279 |
model.addAttribute("configurations", configurationService.getConfigurationByName(currentConfigurationName));
|
261 |
280 |
model.addAttribute("errorMessage", "Configuration name is not possible.");
|
|
281 |
LOGGER.error("@PostMapping(value = \"/configuration\", params = \"configuration-save-as-button\") - " +
|
|
282 |
"new configuration could not be saved because the name was not entered!");
|
262 |
283 |
return "configuration";
|
263 |
284 |
}
|
264 |
285 |
|
... | ... | |
268 |
289 |
model.addAttribute("successMessage", "New configuration has been successfully saved.");
|
269 |
290 |
session.setAttribute("configuration", newConfigName);
|
270 |
291 |
model.addAttribute("configurations", configurationService.getConfigurationByName(newConfigName));
|
|
292 |
LOGGER.warn("@PostMapping(value = \"/configuration\", params = \"configuration-save-as-button\") - " +
|
|
293 |
"some parameters seem to be wrong!");
|
271 |
294 |
} else {
|
272 |
295 |
model.addAttribute("errorMessage", "One or more configuration values are not in correct format, see messages below.");
|
273 |
296 |
antiPatternService.setErrorMessages(query.getAntiPatterns(), wrongParameters);
|
274 |
297 |
model.addAttribute("configurations", configurationService.getConfigurationByName(currentConfigurationName));
|
|
298 |
LOGGER.info("@PostMapping(value = \"/configuration\", params = \"configuration-save-as-button\") - " +
|
|
299 |
"parameters were successfully processed...");
|
275 |
300 |
}
|
276 |
301 |
|
277 |
302 |
model.addAttribute("query", query);
|
... | ... | |
279 |
304 |
model.addAttribute("configurationList", configurationsGetList(session));
|
280 |
305 |
model.addAttribute("selectedConfiguration", session.getAttribute("configuration"));
|
281 |
306 |
|
|
307 |
LOGGER.info("@PostMapping(value = \"/configuration\", params = \"configuration-save-as-button\") - " +
|
|
308 |
"everything successfully processed... Returning configuration.html");
|
282 |
309 |
return "configuration";
|
283 |
310 |
}
|
284 |
311 |
|
285 |
312 |
/**
|
286 |
313 |
* Method for saving changes of one AP in current configuration
|
287 |
314 |
*
|
288 |
|
* @param model object for passing data to the UI
|
289 |
|
* @param id id of AP
|
|
315 |
* @param model object for passing data to the UI
|
|
316 |
* @param id id of AP
|
290 |
317 |
* @param thresholdValues new config values
|
291 |
|
* @param thresholdNames configuration names
|
292 |
|
* @param redirectAttrs attributes for redirection
|
|
318 |
* @param thresholdNames configuration names
|
|
319 |
* @param redirectAttrs attributes for redirection
|
293 |
320 |
* @return redirected html file name for thymeleaf template
|
294 |
321 |
*/
|
295 |
322 |
@PostMapping("/anti-patterns/{id}")
|
... | ... | |
305 |
332 |
List<AntiPattern> antiPatterns = antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns());
|
306 |
333 |
|
307 |
334 |
AntiPattern antiPattern = antiPatternService.antiPatternToModel(antiPatternService.getAntiPatternById(id));
|
308 |
|
List<String> wrongParameters = configurationService.saveNewConfiguration(antiPatterns, currentConfigurationName,antiPatternNames, thresholdNames, thresholdValues, false);
|
|
335 |
List<String> wrongParameters = configurationService.saveNewConfiguration(antiPatterns, currentConfigurationName, antiPatternNames, thresholdNames, thresholdValues, false);
|
309 |
336 |
|
310 |
337 |
|
311 |
338 |
if (wrongParameters.isEmpty()) {
|
312 |
339 |
redirectAttrs.addFlashAttribute("successMessage", "All threshold values has been successfully saved.");
|
|
340 |
LOGGER.info("@PostMapping(\"/anti-patterns/{id}\") - Success");
|
313 |
341 |
} else {
|
314 |
342 |
redirectAttrs.addFlashAttribute("errorMessage", "One or more configuration values are not in correct format, see messages below.");
|
315 |
343 |
antiPatternService.setErrorMessages(antiPattern, wrongParameters);
|
|
344 |
LOGGER.warn("@PostMapping(\"/anti-patterns/{id}\") - Some parameters seem to be wrong!");
|
316 |
345 |
}
|
317 |
346 |
|
318 |
347 |
model.addAttribute("antiPatterns", antiPattern);
|
319 |
348 |
model.addAttribute("configurations", configurationService.getConfigurationByName(currentConfigurationName));
|
|
349 |
|
|
350 |
LOGGER.info("@PostMapping(\"/anti-patterns/{id}\") - redirecting to current anti pattern id");
|
320 |
351 |
return "redirect:/anti-patterns/{id}";
|
321 |
352 |
}
|
322 |
353 |
|
323 |
354 |
/**
|
324 |
355 |
* Method for storing operationalization detail for individual AP
|
325 |
356 |
*
|
326 |
|
* @param model object for passing data to the UI
|
327 |
|
* @param id id of AP
|
328 |
|
* @param innerText operationalization text (HTML)
|
|
357 |
* @param model object for passing data to the UI
|
|
358 |
* @param id id of AP
|
|
359 |
* @param innerText operationalization text (HTML)
|
329 |
360 |
* @param redirectAttrs attributes for redirection
|
330 |
361 |
* @return redirected html file name for thymeleaf template
|
331 |
362 |
*/
|
... | ... | |
345 |
376 |
writer.close();
|
346 |
377 |
redirectAttrs.addFlashAttribute("successMessage", "Operationalization detail has been successfully saved.");
|
347 |
378 |
} catch (Exception e) {
|
|
379 |
LOGGER.error("@PostMapping(\"/anti-patterns/{id}/operationalization\") - " +
|
|
380 |
"An error has occurred while trying to create new BufferedWriter or FileWriter!");
|
348 |
381 |
}
|
349 |
382 |
return "redirect:/anti-patterns/{id}";
|
350 |
383 |
}
|
... | ... | |
357 |
390 |
* @throws Exception If image is not in the folder
|
358 |
391 |
*/
|
359 |
392 |
@GetMapping("/operationalizations/images/{imageName}")
|
360 |
|
public @ResponseBody byte[] imageGet(@PathVariable String imageName) throws Exception {
|
|
393 |
public @ResponseBody
|
|
394 |
byte[] imageGet(@PathVariable String imageName) throws Exception {
|
361 |
395 |
File f = new File(antiPatternService.getOperationalizationImageFilePath(imageName));
|
362 |
396 |
return Files.readAllBytes(f.toPath());
|
363 |
397 |
}
|
... | ... | |
369 |
403 |
* @return result
|
370 |
404 |
*/
|
371 |
405 |
@PostMapping("/uploadImage")
|
372 |
|
public ResponseEntity<?> handleFileUpload(@RequestParam("file") MultipartFile file ) {
|
|
406 |
public ResponseEntity<?> handleFileUpload(@RequestParam("file") MultipartFile file) {
|
373 |
407 |
|
374 |
408 |
String fileName = file.getOriginalFilename();
|
375 |
409 |
|
376 |
|
if(new File(antiPatternService.getOperationalizationImageFilePath(fileName)).isFile()){
|
|
410 |
if (new File(antiPatternService.getOperationalizationImageFilePath(fileName)).isFile()) {
|
377 |
411 |
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
378 |
412 |
}
|
379 |
413 |
|
380 |
414 |
try {
|
381 |
415 |
file.transferTo(new File(antiPatternService.getOperationalizationImageFilePath(fileName)));
|
382 |
416 |
} catch (Exception e) {
|
|
417 |
LOGGER.error("An error with uploading images has occurred!");
|
383 |
418 |
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
384 |
419 |
}
|
385 |
420 |
return ResponseEntity.ok("File uploaded successfully.");
|
... | ... | |
391 |
426 |
* @return html file name for thymeleaf template
|
392 |
427 |
*/
|
393 |
428 |
@GetMapping("/login")
|
394 |
|
public String login(Model model){
|
|
429 |
public String login(Model model) {
|
395 |
430 |
model.addAttribute("query", new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())));
|
396 |
431 |
return "login";
|
397 |
432 |
}
|
398 |
433 |
|
399 |
434 |
/**
|
400 |
435 |
* Processing login details
|
401 |
|
* @param session current session
|
402 |
|
* @param nameInput input field for name
|
403 |
|
* @param passInput input field for password
|
|
436 |
*
|
|
437 |
* @param session current session
|
|
438 |
* @param nameInput input field for name
|
|
439 |
* @param passInput input field for password
|
404 |
440 |
* @param redirectAttrs redirect attributes for adding flash message
|
405 |
441 |
* @return html file name for thymeleaf template
|
406 |
442 |
*/
|
... | ... | |
410 |
446 |
@RequestParam(value = "passInput", required = false) String passInput,
|
411 |
447 |
RedirectAttributes redirectAttrs) {
|
412 |
448 |
|
413 |
|
if(userAccountService.checkCredentials(nameInput, passInput)){
|
|
449 |
if (userAccountService.checkCredentials(nameInput, passInput)) {
|
414 |
450 |
session.setAttribute("user", nameInput);
|
415 |
451 |
return "redirect:/";
|
416 |
452 |
}
|
... | ... | |
421 |
457 |
|
422 |
458 |
/**
|
423 |
459 |
* Getting the name of the logged user from the session
|
424 |
|
* @param model object for passing data to the UI
|
|
460 |
*
|
|
461 |
* @param model object for passing data to the UI
|
425 |
462 |
* @param session current session
|
426 |
463 |
* @return html file name for thymeleaf template
|
427 |
464 |
*/
|
428 |
465 |
@GetMapping("/userLogged")
|
429 |
|
public String userLogged(Model model, HttpSession session){
|
|
466 |
public String userLogged(Model model, HttpSession session) {
|
430 |
467 |
String user = (String) session.getAttribute("user");
|
431 |
468 |
model.addAttribute("user", user);
|
432 |
469 |
return "redirect:/";
|
... | ... | |
434 |
471 |
|
435 |
472 |
/**
|
436 |
473 |
* Processing logout, removing user from session
|
437 |
|
* @param model object for passing data to the UI
|
|
474 |
*
|
|
475 |
* @param model object for passing data to the UI
|
438 |
476 |
* @param session current session
|
439 |
477 |
* @return html file name for thymeleaf template
|
440 |
478 |
*/
|
441 |
479 |
@GetMapping("/logout")
|
442 |
|
public String userLogout(Model model, HttpSession session, RedirectAttributes redirectAttrs){
|
|
480 |
public String userLogout(Model model, HttpSession session, RedirectAttributes redirectAttrs) {
|
443 |
481 |
session.removeAttribute("user");
|
444 |
482 |
session.removeAttribute("configuration");
|
445 |
483 |
return "redirect:/";
|
... | ... | |
447 |
485 |
|
448 |
486 |
/**
|
449 |
487 |
* Model attribute for getting list of configurations
|
|
488 |
*
|
450 |
489 |
* @param session current session
|
451 |
490 |
* @return list of configurations
|
452 |
491 |
*/
|
453 |
492 |
@ModelAttribute("configurationList")
|
454 |
|
public List<String> configurationsGetList(HttpSession session){
|
|
493 |
public List<String> configurationsGetList(HttpSession session) {
|
455 |
494 |
List<String> configurationList;
|
456 |
495 |
|
457 |
|
if(session.getAttribute("user") != null)
|
|
496 |
if (session.getAttribute("user") != null)
|
458 |
497 |
configurationList = configurationService.getAllConfigurationNames();
|
459 |
498 |
else
|
460 |
499 |
configurationList = configurationService.getDefaultConfigurationNames();
|
... | ... | |
464 |
503 |
|
465 |
504 |
/**
|
466 |
505 |
* Model attribute for getting current configuration
|
|
506 |
*
|
467 |
507 |
* @param session current session
|
468 |
508 |
* @return name of current configuration
|
469 |
509 |
*/
|
470 |
510 |
@ModelAttribute("selectedConfiguration")
|
471 |
|
public String configurationGetFromSession(HttpSession session){
|
472 |
|
if(session.getAttribute("configuration") != null)
|
|
511 |
public String configurationGetFromSession(HttpSession session) {
|
|
512 |
if (session.getAttribute("configuration") != null)
|
473 |
513 |
return session.getAttribute("configuration").toString(); // return configuration stored in session
|
474 |
|
else{
|
|
514 |
else {
|
475 |
515 |
List<String> configurationList = configurationService.getDefaultConfigurationNames();
|
476 |
|
if(configurationList.size() == 0)
|
|
516 |
if (configurationList.size() == 0)
|
477 |
517 |
return null;
|
478 |
518 |
|
479 |
519 |
return configurationList.get(0); // return first item from the list of default configurations
|
... | ... | |
482 |
522 |
|
483 |
523 |
/**
|
484 |
524 |
* Processing select of configuration from select box
|
485 |
|
* @param session current session
|
|
525 |
*
|
|
526 |
* @param session current session
|
486 |
527 |
* @param selectedConfigName name of selected configuration
|
487 |
|
* @param redirectAttrs attributes for redirection
|
|
528 |
* @param redirectAttrs attributes for redirection
|
488 |
529 |
* @return html page for redirect
|
489 |
530 |
*/
|
490 |
531 |
@PostMapping("/setSelectedConfiguration")
|
491 |
532 |
public String setSelectedConfiguration(HttpSession session,
|
492 |
533 |
@RequestParam(value = "current-configuration-select", required = false) String selectedConfigName,
|
493 |
|
RedirectAttributes redirectAttrs){
|
|
534 |
RedirectAttributes redirectAttrs) {
|
494 |
535 |
|
495 |
536 |
session.setAttribute("configuration", selectedConfigName); // storing selected configuration to session
|
496 |
537 |
|
... | ... | |
499 |
540 |
|
500 |
541 |
/**
|
501 |
542 |
* Checking if configuration is default and editable by user
|
502 |
|
* @param model object for passing data to the UI
|
503 |
|
* @param session current session
|
|
543 |
*
|
|
544 |
* @param model object for passing data to the UI
|
|
545 |
* @param session current session
|
504 |
546 |
* @param configurationName name of the curren configuration
|
505 |
547 |
* @return html template
|
506 |
548 |
*/
|
507 |
549 |
@GetMapping("/isConfigEditable/{configurationName}")
|
508 |
|
public String isConfigEditableForUser(Model model, HttpSession session, @PathVariable String configurationName){
|
509 |
|
List<String> defaultConfigurationNames = configurationService.getDefaultConfigurationNames();
|
|
550 |
public String isConfigEditableForUser(Model model, HttpSession session, @PathVariable String configurationName) {
|
|
551 |
List<String> defaultConfigurationNames = configurationService.getDefaultConfigurationNames();
|
510 |
552 |
|
511 |
|
for(int i = 0; i < defaultConfigurationNames.size(); i++){
|
512 |
|
if(defaultConfigurationNames.get(i).equals(configurationName))
|
|
553 |
for (int i = 0; i < defaultConfigurationNames.size(); i++) {
|
|
554 |
if (defaultConfigurationNames.get(i).equals(configurationName))
|
513 |
555 |
model.addAttribute("default", "true"); // configuration is default
|
514 |
556 |
}
|
515 |
557 |
|
#26 Adding logging mechanism