use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultSolrReferenceResolver method getResover.
/**
* @param reference the reference
* @return the resolver associated to the reference type
* @throws SolrIndexerException when failed to find a resolve associated to the passed reference
*/
private SolrReferenceResolver getResover(EntityReference reference) throws SolrIndexerException {
EntityType type = reference.getType();
SolrReferenceResolver resolver;
try {
resolver = this.componentManager.getInstance(SolrReferenceResolver.class, type.getLowerCase());
} catch (ComponentLookupException e) {
throw new SolrIndexerException("Failed to get SolrDocumentReferenceResolver corresponding to entity type [" + type + "]", e);
}
return resolver;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultWikiProvisioningJobExecutor method createAndExecuteJob.
@Override
public WikiProvisioningJob createAndExecuteJob(String wikiId, String provisioningJobName, Object parameter) throws WikiProvisioningJobException {
try {
// Get the context
XWikiContext xcontext = xcontextProvider.get();
// Create the job
WikiProvisioningJob job = componentManager.getInstance(Job.class, provisioningJobName);
// Id of the new job
List<String> jobId = new ArrayList<String>();
jobId.add("wiki");
jobId.add("provisioning");
jobId.add(provisioningJobName);
jobId.add(wikiId);
// Initialize it
job.initialize(new WikiProvisioningJobRequest(jobId, wikiId, parameter, xcontext.getUserReference()));
// Add it to the list of jobs
jobs.put(jobId, job);
// Pass it to the executor
jobExecutor.execute(job);
// Return the job
return job;
} catch (ComponentLookupException e) {
throw new WikiProvisioningJobException(String.format("Failed to lookup provisioning job component for role [%s]", provisioningJobName), e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class ExtensionInstaller method installExtension.
/**
* Install an extension on a wiki.
*
* @param wikiId id of the wiki
* @param extensionId id of the extension to install
* @throws org.xwiki.platform.wiki.creationjob.WikiCreationException if problem occurs
*/
public void installExtension(String wikiId, ExtensionId extensionId) throws WikiCreationException {
try {
// Create the install request
InstallRequest installRequest = new InstallRequest();
installRequest.setId(Arrays.asList(WikiCreationJob.JOB_ID_PREFIX, "install", wikiId));
installRequest.addExtension(extensionId);
installRequest.addNamespace("wiki:" + wikiId);
// To avoid problem with Programming Rights, we install everything with superadmin
installRequest.setProperty(PROPERTY_USERREFERENCE, SUPERADMIN_REFERENCE);
InstallJob job = componentManager.getInstance(Job.class, InstallJob.JOBTYPE);
job.initialize(installRequest);
job.run();
} catch (ComponentLookupException e) {
throw new WikiCreationException(String.format("Failed to install the extension [%s] on the wiki [%s].", extensionId.toString(), wikiId), e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class WikiCreationJob method runInternal.
@Override
protected void runInternal() throws Exception {
try {
// Consider that the owner id is a serialized user reference and put it in the context as the current user
// so that all steps are executed under that user.
this.xcontextProvider.get().setUserReference(this.defaultDocumentReferenceResolver.resolve(getRequest().getOwnerId()));
List<WikiCreationStep> wikiCreationStepList = componentManager.getInstanceList(WikiCreationStep.class);
// Some extra steps needs to be executed AFTER some others, so we have introduce a getOrder() method in the
// interface. We use this method to sort the list of extra steps by this order.
Collections.sort(wikiCreationStepList, new Comparator<WikiCreationStep>() {
@Override
public int compare(WikiCreationStep o1, WikiCreationStep o2) {
return o1.getOrder() - o2.getOrder();
}
});
// Now we can execute these extra steps
this.progressManager.pushLevelProgress(wikiCreationStepList.size(), this);
for (WikiCreationStep step : wikiCreationStepList) {
this.progressManager.startStep(this);
step.execute(request);
this.progressManager.endStep(this);
}
this.progressManager.popLevelProgress(this);
} catch (WikiCreationException | ComponentLookupException e) {
throw new WikiCreationException(String.format("Failed to execute creation steps on the wiki [%s].", request.getWikiId()), e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class ChartMacro method generateChart.
/**
* Builds the chart image according to the specifications passed in.
*
* @param parameters the macro parameters
* @param content the macro content
* @param context the macro transformation context, used for example to find out the current document reference
* @throws MacroExecutionException if an error occurs while generating / saving the chart image
*/
private void generateChart(ChartMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException {
String source = computeSource(parameters.getSource(), content);
DataSource dataSource;
try {
dataSource = this.componentManager.getInstance(DataSource.class, source);
} catch (ComponentLookupException e) {
throw new MacroExecutionException(String.format("Invalid source parameter [%s]", parameters.getSource()), e);
}
Map<String, String> sourceParameters = getSourceParameters(parameters, source);
dataSource.buildDataset(content, sourceParameters, context);
try {
this.imageWriter.writeImage(new ImageId(parameters), this.chartGenerator.generate(dataSource.getChartModel(), sourceParameters));
} catch (ChartGeneratorException e) {
throw new MacroExecutionException("Error while rendering chart", e);
}
}
Aggregations