use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class XarExtensionHandler method uninstall.
@Override
public void uninstall(InstalledExtension installedExtension, String namespace, Request request) throws UninstallException {
try {
initializePagesIndex(request);
initJobPackageConfiguration(request, false);
} catch (Exception e) {
throw new UninstallException("Failed to initialize extension plan index", e);
}
// probably not be in an expected state)
if (!request.isRemote()) {
Job currentJob;
try {
currentJob = this.componentManager.<JobContext>getInstance(JobContext.class).getCurrentJob();
} catch (ComponentLookupException e) {
currentJob = null;
}
if (currentJob == null) {
String wiki;
try {
wiki = XarHandlerUtils.getWikiFromNamespace(namespace);
} catch (UnsupportedNamespaceException e) {
throw new UninstallException("Failed to extract wiki id from namespace", e);
}
PackageConfiguration configuration = createPackageConfiguration(null, request, wiki);
try {
XarInstalledExtension xarLocalExtension = (XarInstalledExtension) this.xarRepository.resolve(installedExtension.getId());
Collection<XarEntry> pages = xarLocalExtension.getXarPackage().getEntries();
this.packager.unimportPages(pages, configuration);
} catch (Exception e) {
// Not supposed to be possible
throw new UninstallException("Failed to get xar extension [" + installedExtension.getId() + "] from xar repository", e);
}
} else {
// The actual delete of pages is done in XarExtensionJobFinishedListener
}
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class UntypedEventListener method onEvent.
@Override
public void onEvent(Event event, Object source, Object data) {
try {
// Get every UntypedEventDescriptor registered in the ComponentManager
List<UntypedRecordableEventDescriptor> descriptors = this.componentManagerProvider.get().getInstanceList(UntypedRecordableEventDescriptor.class);
// Filter the event descriptors concerned by the event, then create the concerned events
for (UntypedRecordableEventDescriptor descriptor : descriptors) {
// If the event is expected by our descriptor
if (eventMatchesDescriptor(event, source, descriptor)) {
Set<String> target = getTarget(event, source, descriptor.getAuthorReference(), descriptor.getTargetExpression());
observationManager.notify(new DefaultUntypedRecordableEvent(descriptor.getEventType(), target), EVENT_STREAM_MODULE, source);
}
}
} catch (ComponentLookupException e) {
logger.error("Unable to retrieve a list of registered UntypedRecordableEventDescriptor " + "from the ComponentManager.", e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultDistributionJob method createSteps.
@Override
protected List<DistributionStep> createSteps() {
List<DistributionStep> steps = new ArrayList<>();
boolean isMainWiki = isMainWiki();
// Create admin user if needed
if (isMainWiki) {
try {
steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class, FirstAdminUserStep.ID));
} catch (ComponentLookupException e) {
this.logger.error("Failed to get first admin step instance", e);
}
}
// Install/upgrade main wiki UI
addDefaultUIStep(steps, isMainWiki);
// Upgrade other wikis
if (isMainWiki) {
ExtensionId wikiUI = this.distributionManager.getWikiUIExtensionId();
if (wikiUI != null && StringUtils.isNotBlank(wikiUI.getId())) {
// ... but only if the wiki extension ID is defined
try {
steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class, WikisDefaultUIDistributionStep.ID));
} catch (ComponentLookupException e) {
this.logger.error("Failed to get all in one default UI step instance", e);
}
} else {
// TODO: Display the wikis flavor step
}
}
// Upgrade outdated extensions
try {
steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class, OutdatedExtensionsDistributionStep.ID));
} catch (ComponentLookupException e) {
this.logger.error("Failed to get outdated extensions step instance", e);
}
return steps;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultRecordableEventDescriptorManager method getRecordableEventDescriptors.
@Override
public List<RecordableEventDescriptor> getRecordableEventDescriptors(boolean allWikis) throws EventStreamException {
try {
// We use an hashSet to be sure we won't store the same descriptor twice (in case the same application
// is installed on several wikis).
Set<RecordableEventDescriptor> recordableEventDescriptors = new HashSet<>();
// Load the component from the context component manager (root + wiki + user component managers, etc...)
recordableEventDescriptors.addAll(contextComponentManager.getInstanceList(RecordableEventDescriptor.class));
// Maybe add components of the other wikis too
if (allWikis) {
for (String wikiId : wikiDescriptorManager.getAllIds()) {
recordableEventDescriptors.addAll(getDescriptorsFromWiki(wikiId));
}
}
return new ArrayList<>(recordableEventDescriptors);
} catch (WikiManagerException | ComponentLookupException e) {
throw new EventStreamException("Failed to get the list of all Recordable Event Descriptors.", e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class AbstractMailScriptService method checkPermissions.
/**
* Check authorization to send mail.
*
* @throws MessagingException when not authorized to send mail
*/
private void checkPermissions() throws MessagingException {
// Load the configured permission checker
ScriptServicePermissionChecker checker;
String hint = this.senderConfiguration.getScriptServicePermissionCheckerHint();
try {
checker = this.componentManagerProvider.get().getInstance(ScriptServicePermissionChecker.class, hint);
} catch (ComponentLookupException e) {
// authorized to send emails!
throw new MessagingException(String.format("Failed to locate Permission Checker [%s]. " + "The mail has not been sent.", hint), e);
}
try {
checker.check();
} catch (MessagingException e) {
throw new MessagingException(String.format("Not authorized by the Permission Checker [%s] to send mail! " + "No mail has been sent.", hint), e);
}
}
Aggregations