Clover Coverage Report - XWiki Commons - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 17:13:48 CET
../../../../../../img/srcFileCovDistChart0.png 69% of files have more coverage
26   112   7   13
6   68   0.27   2
2     3.5  
1    
 
  XWikiExtension       Line # 47 26 0% 7 34 0% 0.0
 
No Tests
 
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.repository.xwiki.internal;
21   
22    import java.io.IOException;
23    import java.io.StringReader;
24    import java.net.MalformedURLException;
25    import java.net.URL;
26    import java.util.List;
27   
28    import org.apache.commons.io.IOUtils;
29    import org.xwiki.extension.AbstractExtension;
30    import org.xwiki.extension.DefaultExtensionAuthor;
31    import org.xwiki.extension.DefaultExtensionDependency;
32    import org.xwiki.extension.Extension;
33    import org.xwiki.extension.ExtensionId;
34    import org.xwiki.extension.ExtensionLicense;
35    import org.xwiki.extension.ExtensionLicenseManager;
36    import org.xwiki.extension.repository.xwiki.model.jaxb.ExtensionAuthor;
37    import org.xwiki.extension.repository.xwiki.model.jaxb.ExtensionDependency;
38    import org.xwiki.extension.repository.xwiki.model.jaxb.ExtensionVersion;
39    import org.xwiki.extension.repository.xwiki.model.jaxb.License;
40    import org.xwiki.extension.version.internal.DefaultVersionConstraint;
41   
42    /**
43    * XWiki Repository implementation of {@link Extension}.
44    *
45    * @version $Id: a0377ff02d2532f294cbc4f4e31c167b13275c52 $
46    */
 
47    public class XWikiExtension extends AbstractExtension
48    {
 
49  0 toggle public XWikiExtension(XWikiExtensionRepository repository, ExtensionVersion extension,
50    ExtensionLicenseManager licenseManager)
51    {
52  0 super(repository, new ExtensionId(extension.getId(), extension.getVersion()), extension.getType());
53   
54  0 setName(extension.getName());
55  0 setSummary(extension.getSummary());
56  0 setDescription(extension.getDescription());
57  0 setWebsite(extension.getWebsite());
58   
59  0 setFeatures(extension.getFeatures());
60   
61    // Authors
62  0 for (ExtensionAuthor author : extension.getAuthors()) {
63  0 URL url;
64  0 try {
65  0 url = new URL(author.getUrl());
66    } catch (MalformedURLException e) {
67  0 url = null;
68    }
69   
70  0 addAuthor(new DefaultExtensionAuthor(author.getName(), url));
71    }
72   
73    // License
74   
75  0 for (License license : extension.getLicenses()) {
76  0 if (license.getName() != null) {
77  0 ExtensionLicense extensionLicense = licenseManager.getLicense(license.getName());
78  0 if (extensionLicense != null) {
79  0 addLicense(extensionLicense);
80    } else {
81  0 List<String> content = null;
82  0 if (license.getContent() != null) {
83  0 try {
84  0 content = IOUtils.readLines(new StringReader(license.getContent()));
85    } catch (IOException e) {
86    // That should never happen
87    }
88    }
89   
90  0 addLicense(new ExtensionLicense(license.getName(), content));
91    }
92    }
93    }
94   
95    // Dependencies
96   
97  0 for (ExtensionDependency dependency : extension.getDependencies()) {
98  0 addDependency(new DefaultExtensionDependency(dependency.getId(), new DefaultVersionConstraint(
99    dependency.getConstraint())));
100    }
101   
102    // File
103   
104  0 setFile(new XWikiExtensionFile(repository, getId()));
105    }
106   
 
107  0 toggle @Override
108    public XWikiExtensionRepository getRepository()
109    {
110  0 return (XWikiExtensionRepository) super.getRepository();
111    }
112    }