| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 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 |
|
@link |
| 40 |
|
|
| 41 |
|
@version |
| 42 |
|
@since |
| 43 |
|
|
| 44 |
|
@Component |
| 45 |
|
@Singleton |
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 46 |
|
public class DefaultWikiCreator implements WikiCreator |
| 47 |
|
{ |
| 48 |
|
@Inject |
| 49 |
|
private JobExecutor jobExecutor; |
| 50 |
|
|
| 51 |
|
@Inject |
| 52 |
|
private JobStatusStore jobStatusStore; |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 54 |
5 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 65 |
76 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
81 |
private List<String> getJobId(String wikiId)... |
| 78 |
|
{ |
| 79 |
81 |
return Arrays.asList(WikiCreationJob.JOB_ID_PREFIX, "createandinstall", wikiId); |
| 80 |
|
} |
| 81 |
|
} |