use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class AbstractDistributionJob method createNewStatus.
@Override
protected DistributionJobStatus createNewStatus(R request) {
List<DistributionStep> steps = createSteps();
if (getRequest().isInteractive()) {
// Add Welcome step
try {
DistributionStep welcomeStep = this.componentManager.<DistributionStep>getInstance(DistributionStep.class, WelcomeDistributionStep.ID);
welcomeStep.setState(State.COMPLETED);
steps.add(0, welcomeStep);
} catch (ComponentLookupException e1) {
this.logger.error("Failed to get step instance for id [{}]", WelcomeDistributionStep.ID);
}
// Add Report step
try {
DistributionStep welcomeStep = this.componentManager.<DistributionStep>getInstance(DistributionStep.class, ReportDistributionStep.ID);
welcomeStep.setState(State.COMPLETED);
steps.add(welcomeStep);
} catch (ComponentLookupException e1) {
this.logger.error("Failed to get step instance for id [{}]", ReportDistributionStep.ID);
}
}
// Create status
DistributionJobStatus status = createNewDistributionStatus(request, steps);
if (this.distributionManager.getDistributionExtension() != null) {
DistributionJobStatus previousStatus = getPreviousStatus();
if (previousStatus != null && previousStatus.getDistributionExtension() != null && !Objects.equals(previousStatus.getDistributionExtension(), this.distributionManager.getDistributionExtension().getId())) {
status.setPreviousDistributionExtension(previousStatus.getDistributionExtension());
status.setPreviousDistributionExtensionUI(previousStatus.getDistributionExtensionUI());
}
status.setDistributionExtension(this.distributionManager.getDistributionExtension().getId());
status.setDistributionExtensionUI(getUIExtensionId());
}
return status;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class JGroupsNetworkAdapter method createChannel.
/**
* Create a new channel.
*
* @param channelId the identifier of the channel to create
* @return the new channel
* @throws Exception failed to create new channel
*/
private JChannel createChannel(String channelId) throws Exception {
// load configuration
ProtocolStackConfigurator channelConf = loadChannelConfiguration(channelId);
// get Receiver
JGroupsReceiver channelReceiver;
try {
channelReceiver = this.componentManager.getInstance(JGroupsReceiver.class, channelId);
} catch (ComponentLookupException e) {
channelReceiver = this.componentManager.getInstance(JGroupsReceiver.class);
}
// create channel
JChannel channel = new JChannel(channelConf);
channel.setReceiver(channelReceiver);
channel.setDiscardOwnMessages(true);
return channel;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultNotificationPreferenceManager method savePreferences.
@Override
public void savePreferences(List<NotificationPreference> preferences) throws NotificationException {
// We construct a map where each key is a provider hint and each value is a list of associated providers
// this allows calling each provider only once
Map<String, List<NotificationPreference>> preferencesMapping = new HashMap<>();
for (NotificationPreference notificationPreference : preferences) {
// Try to get the corresponding provider, if no provider can be found, discard the save of the preference
String providerHint = notificationPreference.getProviderHint();
if (componentManager.hasComponent(NotificationPreferenceProvider.class, providerHint)) {
if (!preferencesMapping.containsKey(providerHint)) {
preferencesMapping.put(providerHint, new ArrayList<>());
}
preferencesMapping.get(providerHint).add(notificationPreference);
}
}
// Once we have created the mapping, save all the preferences using their correct providers
for (String providerHint : preferencesMapping.keySet()) {
try {
NotificationPreferenceProvider provider = componentManager.getInstance(NotificationPreferenceProvider.class, providerHint);
provider.savePreferences(preferencesMapping.get(providerHint));
} catch (ComponentLookupException e) {
logger.error("Unable to retrieve the notification preference provide for hint {}: {}", providerHint, e);
}
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultNotificationPreferenceManager method getProviders.
private List<NotificationPreferenceProvider> getProviders() throws NotificationException {
try {
// Get every registered notification provider
List<NotificationPreferenceProvider> providers = componentManager.getInstanceList(NotificationPreferenceProvider.class);
// We handle conflicts between similar preferences by sorting the providers by order. Since
// notificationPreferences is a set, only the first occurrence of a preference is stored.
Collections.sort(providers, (o1, o2) -> o2.getProviderPriority() - o1.getProviderPriority());
return providers;
} catch (ComponentLookupException e) {
throw new NotificationException("Unable to fetch the notifications preferences providers from the component manager", e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class InternalTemplateManager method render.
private void render(XDOM xdom, Writer writer) {
WikiPrinter printer = new WriterWikiPrinter(writer);
BlockRenderer blockRenderer;
try {
blockRenderer = this.componentManagerProvider.get().getInstance(BlockRenderer.class, getTargetSyntax().toIdString());
} catch (ComponentLookupException e) {
blockRenderer = this.plainRenderer;
}
blockRenderer.render(xdom, printer);
}
Aggregations