Project

General

Profile

1
package eu.dnetlib.uoamonitorservice.controllers;
2

    
3
import eu.dnetlib.uoaadmintoolslibrary.handlers.utils.RolesUtils;
4
import eu.dnetlib.uoamonitorservice.dao.*;
5
import eu.dnetlib.uoamonitorservice.entities.*;
6
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
7
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
8
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
9
import org.apache.log4j.Logger;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.security.access.AccessDeniedException;
12
import org.springframework.security.access.prepost.PreAuthorize;
13
import org.springframework.web.bind.annotation.*;
14

    
15
import java.util.ArrayList;
16
import java.util.Date;
17
import java.util.Iterator;
18
import java.util.List;
19

    
20
@RestController
21
@CrossOrigin(origins = "*")
22
public class CategoryController {
23
    private final Logger log = Logger.getLogger(this.getClass());
24

    
25
    @Autowired
26
    private RolesUtils rolesUtils;
27

    
28
    @Autowired
29
    private StakeholderDAO stakeholderDAO;
30

    
31
    @Autowired
32
    private TopicDAO topicDAO;
33

    
34
    @Autowired
35
    private CategoryDAO categoryDAO;
36

    
37
    @Autowired
38
    private SubCategoryDAO subCategoryDAO;
39

    
40
    @Autowired
41
    private SubCategoryController subCategoryController;
42

    
43
    public Category<SubCategory> buildCategory(Category<SubCategory> categoryFull) {
44
        Category<String> category = new Category<>(categoryFull);
45

    
46
        List<String> subCategories = new ArrayList<>();
47
        List<SubCategory> subCategoriesFull = new ArrayList<>();
48
        for(SubCategory<Section<Indicator>> subCategory : categoryFull.getSubCategories()) {
49
            SubCategory<Section<Indicator>> subcategoryFull = subCategoryController.buildSubCategory(subCategory);
50
            subCategoriesFull.add(subcategoryFull);
51
            subCategories.add(subcategoryFull.getId());
52
        }
53
        categoryFull.setSubCategories(subCategoriesFull);
54
        category.setSubCategories(subCategories);
55

    
56
        Date date = new Date();
57
        category.setCreationDate(date);
58
        category.setUpdateDate(date);
59

    
60
        categoryFull.setCreationDate(date);
61
        categoryFull.setUpdateDate(date);
62

    
63
        categoryDAO.save(category);
64

    
65
        categoryFull.setId(category.getId());
66
        return categoryFull;
67
    }
68

    
69
    @PreAuthorize("isAuthenticated()")
70
    @RequestMapping(value = "/{stakeholderId}/{topicId}/save", method = RequestMethod.POST)
71
    public Category<SubCategory> saveCategory(@PathVariable("stakeholderId") String stakeholderId,
72
                                              @PathVariable("topicId") String topicId,
73
                                              @RequestBody Category<SubCategory> categoryFull) {
74
        log.debug("save category");
75
        log.debug("Alias: "+categoryFull.getAlias() + " - Id: "+categoryFull.getId() + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId);
76

    
77
        Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
78

    
79
        if(stakeholder != null) {
80

    
81
            List<String> roles = rolesUtils.getRoles();
82
            if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
83
                // EXCEPTION - Access denied
84
                throw new ForbiddenException("Save Category: You are not authorized to update stakeholder with id: "+stakeholderId);
85
            }
86

    
87
            Category<String> oldCategory = null;
88
            if(categoryFull.getId() != null) {
89
                oldCategory = categoryDAO.findById(categoryFull.getId());
90
                if(oldCategory == null) {
91
                    // EXCEPTION - Category not found
92
                    throw new EntityNotFoundException("save category: Category with id: " + categoryFull.getId() + " not found");
93
                }
94
            }
95

    
96
            Topic<String> topic = topicDAO.findById(topicId);
97
            if(topic != null) {
98
                if(stakeholder.getTopics().contains(topicId)) {
99
                    Category<String> category = new Category<>(categoryFull);
100

    
101
                    Date date = new Date();
102
                    category.setUpdateDate(date);
103
                    categoryFull.setUpdateDate(date);
104

    
105
                    List<String> subCategories = new ArrayList<>();
106

    
107
                    // if category not exists (no id), create a new default subcategory, identical to category
108
                    if(categoryFull.getId() == null) {
109
                        category.setCreationDate(date);
110
                        categoryFull.setCreationDate(date);
111

    
112
                        SubCategory<String> subCategory = new SubCategory<>();
113
                        subCategory.createOverviewSubCategory(categoryFull);
114

    
115
                        subCategoryDAO.save(subCategory);
116

    
117
                        List<SubCategory> subCategoriesFull = categoryFull.getSubCategories();
118
                        subCategoriesFull.add(subCategory);
119

    
120
                        for(SubCategory oldSubCategory : subCategoriesFull) {
121
                            subCategories.add(oldSubCategory.getId());
122
                        }
123
                    } else {
124
                        for(String subCategoryId : oldCategory.getSubCategories()) {
125
                            SubCategory subCategory = subCategoryDAO.findById(subCategoryId);
126
                            if (subCategory == null) {
127
                                // EXCEPTION - SubCategory not found
128
                                throw new EntityNotFoundException("Save category: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+category.getId()+")");
129
                            }
130
                            subCategories.add(subCategory.getId());
131
                        }
132
                    }
133

    
134
                    category.setSubCategories(subCategories);
135

    
136
                    if(stakeholder.getDefaultId() == null) {
137
                        if(categoryFull.getId() == null) {
138
                            categoryDAO.save(category);
139
                            onSaveDefaultCategory(category, topicId);
140
                        } else {
141
                            onUpdateDefaultCategory(category, oldCategory);
142
                            categoryDAO.save(category);
143
                        }
144
                    } else {
145
                        categoryDAO.save(category);
146
                    }
147

    
148
                    List<String> categories = topic.getCategories();
149
                    int index = categories.indexOf(category.getId());
150
                    if(index == -1) {
151
                        categories.add(category.getId());
152
                        topicDAO.save(topic);
153
                        log.debug("Category saved!");
154

    
155
                        categoryFull.setId(category.getId());
156
                    }
157

    
158
                    subCategories = null;
159
                    category = null;
160
                } else {
161
                    // EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
162
                    throw new PathNotValidException("Save category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
163
                }
164
            } else {
165
                // EXCEPTION - Topic not found
166
                throw new EntityNotFoundException("Save category: Topic with id: "+topicId+" not found");
167
            }
168
        } else {
169
            // EXCEPTION - Stakeholder not found
170
            throw new EntityNotFoundException("Save category: Stakeholder with id: "+stakeholderId+" not found");
171
        }
172
        return categoryFull;
173
    }
174

    
175
    public void onSaveDefaultCategory(Category<String> category, String topicId) {
176
        log.debug("On save default category");
177

    
178
        List<Topic> topics = topicDAO.findByDefaultId(topicId);
179
        for(Topic topic : topics) {
180
            Category categoryNew = new Category();
181
            categoryNew.copyFromDefault(category);
182

    
183
            categoryDAO.save(categoryNew);
184

    
185
            List<String> categories = topic.getCategories();
186
            categories.add(categoryNew.getId());
187

    
188
            topicDAO.save(topic);
189
        }
190
        String subCategoryOverviewId = category.getSubCategories().get(0);
191
        SubCategory subCategoryOverview = subCategoryDAO.findById(subCategoryOverviewId);
192
        subCategoryController.onSaveDefaultSubCategory(subCategoryOverview, category.getId());
193
    }
194

    
195
    public void onUpdateDefaultCategory(Category category, Category oldCategory) {
196
        log.debug("On update default category");
197

    
198
        List<Category> categories = categoryDAO.findByDefaultId(category.getId());
199
        boolean changed = false;
200
        for(Category categoryBasedOnDefault : categories) {
201
            if(category.getName() != null && !category.getName().equals(categoryBasedOnDefault.getName())
202
                    && (oldCategory.getName() == null || oldCategory.getName().equals(categoryBasedOnDefault.getName()))) {
203

    
204
                categoryBasedOnDefault.setName(category.getName());
205
                categoryBasedOnDefault.setAlias(category.getAlias());
206
                changed = true;
207
            }
208
            if(category.getDescription() != null && !category.getDescription().equals(categoryBasedOnDefault.getDescription())
209
                    && (oldCategory.getDescription() == null || oldCategory.getDescription().equals(categoryBasedOnDefault.getDescription()))) {
210

    
211
                categoryBasedOnDefault.setDescription(category.getDescription());
212
                changed = true;
213
            }
214

    
215
            if(!changed) {
216
//                break;
217
                continue;
218
            }
219

    
220
//            categoryBasedOnDefault.setName(category.getName());
221
//            categoryBasedOnDefault.setDescription(category.getDescription());
222
            categoryBasedOnDefault.setUpdateDate(category.getUpdateDate());
223
            categoryDAO.save(categoryBasedOnDefault);
224
        }
225
    }
226

    
227
    @PreAuthorize("isAuthenticated()")
228
    @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/delete", method = RequestMethod.DELETE)
229
    public boolean deleteCategory(@PathVariable("stakeholderId") String stakeholderId,
230
                                  @PathVariable("topicId") String topicId,
231
                                  @PathVariable("categoryId") String categoryId,
232
                                  @RequestParam(required = false) String children) {
233
        log.debug("delete category");
234
        log.debug("Id: "+categoryId + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId);
235

    
236
        Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
237

    
238
        if(stakeholder != null) {
239

    
240
            List<String> roles = rolesUtils.getRoles();
241
            if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
242
                // EXCEPTION - Access denied
243
                throw new ForbiddenException("Delete category: You are not authorized to update stakeholder with id: "+stakeholderId);
244
            }
245

    
246
            Topic<String> topic = topicDAO.findById(topicId);
247
            if(topic != null) {
248
                if(stakeholder.getTopics().contains(topicId)) {
249

    
250
                    Category<String> category = categoryDAO.findById(categoryId);
251
                    if(category != null) {
252

    
253
                        if(category.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) {
254
                            // EXCEPTION - Access denied
255
                            throw new ForbiddenException("Delete category: You are not authorized to delete a default Category in stakeholder with id: "+stakeholderId);
256
                        }
257

    
258

    
259
                        List<String> categories = topic.getCategories();
260
                        int index = categories.indexOf(categoryId);
261
                        if(index != -1) {
262
                            // this category belongs in default profile
263
                            if(topic.getDefaultId() == null && children != null) {
264
                                onDeleteDefaultCategory(categoryId, topicId, children);
265
                            }
266

    
267
//                            for(String subCategoryId : category.getSubCategories()) {
268
//                                SubCategory<String> subcategory = subCategoryDAO.findById(subCategoryId);
269
//                                if(subcategory == null) {
270
//                                    // EXCEPTION - SubCategory not found
271
//                                    throw new EntityNotFoundException("Delete category: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+categoryId+")");
272
//                                }
273
//
274
//                                for(String chartSectionId : subcategory.getCharts()) {
275
//                                    Section<String> chartSection = sectionDAO.findById(chartSectionId);
276
//                                    if (chartSection == null) {
277
//                                        // EXCEPTION - Section not found
278
//                                        throw new EntityNotFoundException("Delete topic: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
279
//                                    }
280
//
281
//                                    for (String chartId : chartSection.getIndicators()) {
282
//                                        indicatorDAO.delete(chartId);
283
//                                    }
284
//                                    subcategory.setCharts(null);
285
//                                    sectionDAO.delete(chartSectionId);
286
//                                }
287
//
288
//                                for(String numberSectionId : subcategory.getNumbers()) {
289
//                                    Section<String> numberSection = sectionDAO.findById(numberSectionId);
290
//                                    if (numberSection == null) {
291
//                                        // EXCEPTION - Section not found
292
//                                        throw new EntityNotFoundException("Delete topic: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
293
//                                    }
294
//
295
//                                    for (String numberId : numberSection.getIndicators()) {
296
//                                        indicatorDAO.delete(numberId);
297
//                                    }
298
//                                    subcategory.setNumbers(null);
299
//                                    sectionDAO.delete(numberSectionId);
300
//                                }
301
//
302
//                                subCategoryDAO.delete(subCategoryId);
303
//                            }
304
                            subCategoryController.deleteTree(category);
305

    
306
                            category.setSubCategories(null);
307

    
308
                            categories.remove(index);
309
                            topicDAO.save(topic);
310

    
311
                            categoryDAO.delete(categoryId);
312
                            log.debug("Category deleted!");
313
                        } else {
314
                            // EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
315
                            throw new PathNotValidException("Delete category: Category with id: "+categoryId+" not found in Topic: "+topicId);
316
                        }
317

    
318
                    } else {
319
                        // EXCEPTION - Category not found
320
                        throw new EntityNotFoundException("Delete category: Category with id: "+categoryId+" not found");
321
                    }
322
                } else {
323
                    // EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
324
                    throw new PathNotValidException("Delete category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
325
                }
326
            } else {
327
                // EXCEPTION - Topic not found
328
                throw new EntityNotFoundException("Delete category: Topic with id: "+topicId+" not found");
329
            }
330
        } else {
331
            // EXCEPTION - Stakeholder not found
332
            throw new EntityNotFoundException("Delete category: Stakeholder with id: "+stakeholderId+" not found");
333
        }
334
        return true;
335
    }
336

    
337

    
338
    public boolean onDeleteDefaultCategory(String defaultCategoryId, String defaultTopicId, String children) {
339
        if(children.equals("delete")) {
340
            List<Topic> topics = topicDAO.findByDefaultId(defaultTopicId);
341
            List<Category> categories = categoryDAO.findByDefaultId(defaultCategoryId);
342

    
343
            for(Topic topic : topics) {
344
                Iterator<Category> categoriesIterator = categories.iterator();
345
                while(categoriesIterator.hasNext()) {
346
                    Category category = categoriesIterator.next();
347

    
348
                    String categoryId = category.getId();
349

    
350
                    if(topic.getCategories() != null && topic.getCategories().contains(categoryId)) {
351
                        categoriesIterator.remove();
352

    
353
                        topic.getCategories().remove(categoryId);
354
                        topicDAO.save(topic);
355

    
356
                        subCategoryController.deleteTree(category);
357

    
358
                        categoryDAO.delete(categoryId);
359
                        log.debug("Category with id: "+categoryId+" deleted!");
360

    
361
                        break;
362
                    }
363
                }
364
            }
365
        } else if(children.equals("disconnect")) {
366
            List<Category> categories = categoryDAO.findByDefaultId(defaultCategoryId);
367
            for(Category category : categories) {
368
                subCategoryController.disConnectTree(category);
369

    
370
                category.setDefaultId(null);
371
                categoryDAO.save(category);
372

    
373
                log.debug("DefaultId for Category with id: "+category.getId()+" empty!");
374
            }
375
        }
376
        return true;
377
    }
378

    
379
    @PreAuthorize("isAuthenticated()")
380
    @RequestMapping(value = "/{stakeholderId}/{topicId}/reorder", method = RequestMethod.POST)
381
    public List<Category> reorderCategories(@PathVariable("stakeholderId") String stakeholderId,
382
                                             @PathVariable("topicId") String topicId,
383
                                             @RequestBody List<String> categories) {
384
        log.debug("reorder categories");
385
        log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId);
386

    
387
        Topic<String> topic = checkForExceptions(stakeholderId, topicId);
388

    
389
        List<String> oldCategories = topic.getCategories();
390
        for (String categoryId : oldCategories) {
391
            if (!categories.contains(categoryId)) {
392
                categories.add(categoryId);
393
            }
394
        }
395
        topic.setCategories(categories);
396

    
397
        List<Category> categoriesFull = new ArrayList<>();
398
        for(String categoryId : categories) {
399
            Category category = categoryDAO.findById(categoryId);
400
            if(category == null) {
401
                // EXCEPTION - Category not found
402
                throw new EntityNotFoundException("Reorder Categories: Category with id: " + categoryId + " not found");
403
            }
404
            categoriesFull.add(category);
405
        }
406

    
407
        topicDAO.save(topic);
408
        log.debug("Categories reordered!");
409

    
410
        return categoriesFull;
411
    }
412

    
413
//    @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/toggle-status", method = RequestMethod.POST)
414
//    public Boolean toggleCategoryStatus(@PathVariable("stakeholderId") String stakeholderId,
415
//                                        @PathVariable("topicId") String topicId,
416
//                                        @PathVariable("categoryId") String categoryId) {
417
//        log.debug("toggle category status (isActive)");
418
//        log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId);
419
//
420
//        Category category = categoryDAO.findById(categoryId);
421
//        if (category == null) {
422
//            // EXCEPTION - Category not found
423
//            throw new EntityNotFoundException("Toggle category status: Category with id: "+categoryId+" not found");
424
//        }
425
//        category.setIsActive(!category.getIsActive());
426
//
427
//        this.toggleCategory(stakeholderId, topicId, category);
428
//
429
//        return category.getIsActive();
430
//    }
431
//
432
//    @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/toggle-access", method = RequestMethod.POST)
433
//    public Boolean toggleCategoryAccess(@PathVariable("stakeholderId") String stakeholderId,
434
//                                        @PathVariable("topicId") String topicId,
435
//                                        @PathVariable("categoryId") String categoryId) {
436
//        log.debug("toggle category access (isPublic)");
437
//        log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId);
438
//
439
//        Category category = categoryDAO.findById(categoryId);
440
//        if (category == null) {
441
//            // EXCEPTION - Category not found
442
//            throw new EntityNotFoundException("Toggle category access: Category with id: "+categoryId+" not found");
443
//        }
444
//        category.setIsPublic(!category.getIsPublic());
445
//
446
//        this.toggleCategory(stakeholderId, topicId, category);
447
//
448
//        return category.getIsPublic();
449
//    }
450

    
451
    @PreAuthorize("isAuthenticated()")
452
    @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/change-visibility", method = RequestMethod.POST)
453
    public Visibility changeCategoryVisibility(@PathVariable("stakeholderId") String stakeholderId,
454
                                            @PathVariable("topicId") String topicId,
455
                                            @PathVariable("categoryId") String categoryId,
456
                                            @RequestParam("visibility") Visibility visibility) {
457
        log.debug("change category visibility: "+visibility);
458
        log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId);
459

    
460
        Category category = categoryDAO.findById(categoryId);
461
        if (category == null) {
462
            // EXCEPTION - Category not found
463
            throw new EntityNotFoundException("Change topic visibility: Category with id: "+categoryId+" not found");
464
        }
465
        category.setVisibility(visibility);
466

    
467
        this.toggleCategory(stakeholderId, topicId, category);
468

    
469
        return category.getVisibility();
470
    }
471

    
472
    public void toggleCategory(String stakeholderId, String topicId, Category category) {
473
        Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
474

    
475
        if (stakeholder != null) {
476

    
477
            List<String> roles = rolesUtils.getRoles();
478
            if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
479
                // EXCEPTION - Access denied
480
                throw new ForbiddenException("Toggle category: You are not authorized to update stakeholder with id: "+stakeholderId);
481
            }
482

    
483
            Topic<String> topic = topicDAO.findById(topicId);
484
            if (topic != null) {
485
                if (stakeholder.getTopics().contains(topicId)) {
486
                    if (topic.getCategories().contains(category.getId())) {
487
                        categoryDAO.save(category);
488
                        log.debug("Category toggled!");
489
                    } else {
490
                        // EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
491
                        throw new PathNotValidException("Toggle category: Category with id: "+category.getId()+" not found in Topic: "+topicId);
492
                    }
493
                } else {
494
                    // EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
495
                    throw new PathNotValidException("Toggle category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
496
                }
497
            } else {
498
                // EXCEPTION - Topic not found
499
                throw new EntityNotFoundException("Toggle category: Topic with id: "+topicId+" not found");
500
            }
501
        } else {
502
            // EXCEPTION - Stakeholder not found
503
            throw new EntityNotFoundException("Toggle category: Stakeholder with id: "+stakeholderId+" not found");
504
        }
505
    }
506

    
507

    
508
    private Topic checkForExceptions(String stakeholderId, String topicId) {
509

    
510
        Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
511

    
512
        if(stakeholder == null) {
513
            // EXCEPTION - Stakeholder not found
514
            throw new EntityNotFoundException("checkForExceptions category: Stakeholder with id: " + stakeholderId + " not found");
515
        }
516

    
517
        List<String> roles = rolesUtils.getRoles();
518
        if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
519
            // EXCEPTION - Access denied
520
            throw new ForbiddenException("checkForExceptions category: You are not authorized to update stakeholder with id: "+stakeholderId);
521
        }
522

    
523
        Topic<String> topic = topicDAO.findById(topicId);
524
        if(topic == null) {
525
            // EXCEPTION - Topic not found
526
            throw new EntityNotFoundException("checkForExceptions category: Topic with id: "+topicId+" not found");
527
        }
528

    
529
        if(!stakeholder.getTopics().contains(topicId)) {
530
            // EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
531
            throw new PathNotValidException("checkForExceptions category: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
532
        }
533

    
534
        return  topic;
535
    }
536

    
537
    public void deleteTree(Topic topic) {
538
        List<String> categories = topic.getCategories();
539
        for(String categoryId : categories) {
540
            Category category = categoryDAO.findById(categoryId);
541
            if (category == null) {
542
                // EXCEPTION - Category not found
543
                throw new EntityNotFoundException("Category delete tree: Category with id: "+categoryId+" not found (category exists in topic: "+topic.getId()+")");
544
            }
545

    
546
            subCategoryController.deleteTree(category);
547

    
548
            categoryDAO.delete(categoryId);
549
        }
550
    }
551

    
552
    public void disConnectTree(Topic topic) {
553
        List<String> categories = topic.getCategories();
554
        for(String categoryId : categories) {
555
            Category category = categoryDAO.findById(categoryId);
556
            if (category == null) {
557
                // EXCEPTION - Category not found
558
                throw new EntityNotFoundException("Category disconnect tree: Category with id: "+categoryId+" not found (category exists in topic: "+topic.getId()+")");
559
            }
560

    
561
            subCategoryController.disConnectTree(category);
562

    
563
            category.setDefaultId(null);
564
            categoryDAO.save(category);
565
        }
566
    }
567
}
(1-1/9)