1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.platform.wiki.creationjob.internal

File DefaultWikiCreator.java

 

Coverage histogram

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

Code metrics

2
10
3
1
81
48
5
0.5
3.33
3
1.67

Classes

Class Line # Actions
DefaultWikiCreator 46 10 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 3 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.platform.wiki.creationjob.internal;
21   
22    import java.util.Arrays;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Singleton;
27   
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.job.Job;
30    import org.xwiki.job.JobException;
31    import org.xwiki.job.JobExecutor;
32    import org.xwiki.job.JobStatusStore;
33    import org.xwiki.job.event.status.JobStatus;
34    import org.xwiki.platform.wiki.creationjob.WikiCreationRequest;
35    import org.xwiki.platform.wiki.creationjob.WikiCreator;
36    import org.xwiki.platform.wiki.creationjob.WikiCreationException;
37   
38    /**
39    * Default implementation for {@link org.xwiki.platform.wiki.creationjob.WikiCreator}.
40    *
41    * @version $Id: 8b0896530005f0df61ef86ad57a208f60a1f250a $
42    * @since 7.0M2
43    */
44    @Component
45    @Singleton
 
46    public class DefaultWikiCreator implements WikiCreator
47    {
48    @Inject
49    private JobExecutor jobExecutor;
50   
51    @Inject
52    private JobStatusStore jobStatusStore;
53   
 
54  5 toggle @Override
55    public Job createWiki(WikiCreationRequest request) throws WikiCreationException
56    {
57  5 try {
58  5 request.setId(getJobId(request.getWikiId()));
59  5 return jobExecutor.execute(WikiCreationJob.JOB_TYPE, request);
60    } catch (JobException e) {
61  1 throw new WikiCreationException("Failed to create a new wiki.", e);
62    }
63    }
64   
 
65  76 toggle @Override
66    public JobStatus getJobStatus(String wikiId)
67    {
68  76 List<String> jobId = getJobId(wikiId);
69  76 Job job = jobExecutor.getJob(jobId);
70  76 if (job != null) {
71  70 return job.getStatus();
72    } else {
73  6 return jobStatusStore.getJobStatus(jobId);
74    }
75    }
76   
 
77  81 toggle private List<String> getJobId(String wikiId)
78    {
79  81 return Arrays.asList(WikiCreationJob.JOB_ID_PREFIX, "createandinstall", wikiId);
80    }
81    }