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

File LESSExportActionListener.java

 

Coverage histogram

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

Code metrics

2
7
3
1
77
41
4
0.57
2.33
3
1.33

Classes

Class Line # Actions
LESSExportActionListener 48 7 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

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.lesscss.internal.listeners;
21   
22    import java.util.Arrays;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Singleton;
28   
29    import org.xwiki.bridge.event.ActionExecutingEvent;
30    import org.xwiki.component.annotation.Component;
31    import org.xwiki.lesscss.internal.LESSContext;
32    import org.xwiki.observation.EventListener;
33    import org.xwiki.observation.event.Event;
34   
35    import com.xpn.xwiki.XWikiContext;
36    import com.xpn.xwiki.web.XWikiRequest;
37   
38    /**
39    * Used to flush the LESS cache if we're doing an HTML export because we need that URLs located in less file be
40    * recomputed (see ExportURLFactory).
41    *
42    * @version $Id: 14a4fd2ff6dc7946f2ffc8ec44fc762244c59da0 $
43    * @since 6.2RC1
44    */
45    @Component
46    @Named("lessexport")
47    @Singleton
 
48    public class LESSExportActionListener implements EventListener
49    {
50    @Inject
51    private LESSContext lessContext;
52   
 
53  182 toggle @Override
54    public String getName()
55    {
56  182 return "lessexport";
57    }
58   
 
59  62 toggle @Override
60    public List<Event> getEvents()
61    {
62  62 return Arrays.<Event>asList(new ActionExecutingEvent("export"));
63    }
64   
 
65  2 toggle @Override
66    public void onEvent(Event event, Object source, Object data)
67    {
68    // Do not use the the LESS cache if we're doing an HTML export because we need that URLs located in less file be
69    // recomputed (see ExportURLFactory).
70  2 XWikiContext xcontext = (XWikiContext) data;
71  2 XWikiRequest request = xcontext.getRequest();
72  2 String format = request.get("format");
73  2 if ("html".equals(format)) {
74  1 lessContext.setHtmlExport(true);
75    }
76    }
77    }