1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.distribution.internal

File WikiDistributionWikiEventListener.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

4
7
4
1
82
38
6
0.86
1.75
4
1.5

Classes

Class Line # Actions
WikiDistributionWikiEventListener 41 7 0% 6 1
0.9333333493.3%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.distribution.internal;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25   
26    import org.xwiki.bridge.event.WikiCopiedEvent;
27    import org.xwiki.bridge.event.WikiDeletedEvent;
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.observation.AbstractEventListener;
30    import org.xwiki.observation.event.Event;
31   
32    /**
33    * Various reactions to wiki events.
34    *
35    * @version $Id: 9274c1a83a5e2a1ae8bf018d0b0f6f3e4eee6133 $
36    * @since 5.0.2
37    */
38    @Component
39    @Singleton
40    @Named("distribution.wiki.WikiDistributionWikiEventListener")
 
41    public class WikiDistributionWikiEventListener extends AbstractEventListener
42    {
43    /**
44    * The component used to get information about the current distribution.
45    */
46    @Inject
47    private DistributionManager distributionManager;
48   
49    /**
50    * Setup event listener properties.
51    */
 
52  1 toggle public WikiDistributionWikiEventListener()
53    {
54  1 super("distribution.wiki.WikiDistributionWikiEventListener", new WikiCopiedEvent(), new WikiDeletedEvent());
55    }
56   
 
57  5 toggle @Override
58    public void onEvent(Event event, Object o, Object context)
59    {
60  5 if (event instanceof WikiCopiedEvent) {
61  2 onWikiCopied((WikiCopiedEvent) event);
62  3 } else if (event instanceof WikiDeletedEvent) {
63  3 onWikiDeleted((WikiDeletedEvent) event);
64    }
65    }
66   
67    /**
68    * @param event copied wiki event
69    */
 
70  2 toggle private void onWikiCopied(WikiCopiedEvent event)
71    {
72  2 this.distributionManager.copyPreviousWikiJobStatus(event.getSourceWikiId(), event.getTargetWikiId());
73    }
74   
75    /**
76    * @param event deleted wiki event
77    */
 
78  3 toggle private void onWikiDeleted(WikiDeletedEvent event)
79    {
80  3 this.distributionManager.deletePreviousWikiJobStatus(event.getWikiId());
81    }
82    }