1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.services.wcm.category;
18
19 import javax.jcr.Node;
20
21 import org.exoplatform.container.configuration.ConfigurationManager;
22 import org.exoplatform.container.xml.InitParams;
23 import org.exoplatform.services.cms.actions.ActionServiceContainer;
24 import org.exoplatform.services.cms.taxonomy.TaxonomyService;
25 import org.exoplatform.services.jcr.RepositoryService;
26 import org.exoplatform.services.jcr.ext.common.SessionProvider;
27 import org.exoplatform.services.wcm.portal.artifacts.RemovePortalPlugin;
28
29
30
31
32
33
34
35 public class RemoveTaxonomyPlugin extends RemovePortalPlugin {
36
37
38 private TaxonomyService taxonomyService;
39
40 private ActionServiceContainer actionServiceContainer;
41
42 private RepositoryService repositoryService;
43
44
45
46
47
48
49
50
51
52
53
54
55 public RemoveTaxonomyPlugin(InitParams params,
56 ConfigurationManager configurationManager,
57 RepositoryService repositoryService,
58 TaxonomyService taxonomyService,
59 ActionServiceContainer actionServiceContainer) throws Exception {
60 super(params, configurationManager, repositoryService);
61 this.repositoryService = repositoryService;
62 this.taxonomyService = taxonomyService;
63 this.actionServiceContainer = actionServiceContainer;
64 }
65
66
67
68
69
70
71
72
73 public void invalidateFromPortal(SessionProvider sessionProvider, String portalName) throws Exception {
74 String repository = repositoryService.getCurrentRepository().getConfiguration().getName();
75 if (taxonomyService.hasTaxonomyTree(portalName)) {
76 Node taxonomyTreeNode = taxonomyService.getTaxonomyTree(portalName, true);
77 if (taxonomyTreeNode!=null) {
78 actionServiceContainer.removeAction(taxonomyTreeNode, repository);
79 }
80 taxonomyService.removeTaxonomyTree(portalName);
81 }
82 }
83 }