use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class XWiki method initXWiki.
/**
* Initialize all xwiki subsystems.
*
* @param config the object holding the XWiki configuration read from {@code xwiki.cfg}
* @param context see {@link XWikiContext}
* @param engineContext the XWiki object wrapping the {@link javax.servlet.ServletContext} and which allows to set
* data that live on as long as the XWiki webapp is not stopped in the Servlet Container
* @param noupdate true if the whole initialization should be done (create mandatory xlcasses, initialize stats
* service), i.e. if this is not an update, and false otherwise
* @throws XWikiException if an error happened during initialization (failure to initialize some cache for example)
* @deprecated since 6.1M2, use {@link #initXWiki(XWikiContext, XWikiEngineContext, boolean)} instead
*/
@Deprecated
public void initXWiki(XWikiConfig config, XWikiContext context, XWikiEngineContext engineContext, boolean noupdate) throws XWikiException {
getProgress().pushLevelProgress(4, this);
try {
getProgress().startStep(this);
setDatabase(context.getMainXWiki());
setEngineContext(engineContext);
context.setWiki(this);
// "Pre-initialize" XWikiStubContextProvider with a XWikiContext containing a XWiki instance as soon as
// possible
Utils.<XWikiStubContextProvider>getComponent(XWikiStubContextProvider.class).initialize(context);
// Prepare the store
if (config != null) {
setConfig(config);
}
try {
initializeStores();
} catch (ComponentLookupException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Failed to initialize stores", e);
}
setCriteriaService((XWikiCriteriaService) createClassFromConfig("xwiki.criteria.class", "com.xpn.xwiki.criteria.impl.XWikiCriteriaServiceImpl", context));
// "Pre-initialize" XWikiStubContextProvider so that rendering engine, plugins or listeners reacting to
// potential document changes can use it
Utils.<XWikiStubContextProvider>getComponent(XWikiStubContextProvider.class).initialize(context);
getProgress().endStep(this);
getProgress().startStep(this);
// Make sure these classes exists
if (noupdate) {
initializeMandatoryDocuments(context);
getStatsService(context);
}
getProgress().endStep(this);
getProgress().startStep(this);
// Prepare the Plugin Engine
preparePlugins(context);
getProgress().endStep(this);
getProgress().startStep(this);
String ro = getConfiguration().getProperty("xwiki.readonly", "no");
this.isReadOnly = ("yes".equalsIgnoreCase(ro) || "true".equalsIgnoreCase(ro) || "1".equalsIgnoreCase(ro));
// Save the configured syntaxes
String syntaxes = getConfiguration().getProperty("xwiki.rendering.syntaxes", "xwiki/1.0");
this.configuredSyntaxes = Arrays.asList(StringUtils.split(syntaxes, " ,"));
getObservationManager().addListener(this);
} finally {
getProgress().popLevelProgress(this);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class AbstractPanelsUIExtensionManager method get.
@Override
public List<UIExtension> get(String extensionPointId) {
List<UIExtension> panels = new ArrayList<UIExtension>();
String panelConfigurationString = getConfiguration();
// Verify that there's a panel configuration property defined, and if not don't return any panel extension.
if (!StringUtils.isEmpty(panelConfigurationString)) {
List<String> panelSerializedReferences = new ArrayList<String>();
for (String serializedReference : getConfiguration().split(",")) {
panelSerializedReferences.add(serializer.serialize(resolver.resolve(serializedReference.trim())));
}
try {
List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class);
for (String panelSerializedReference : panelSerializedReferences) {
for (UIExtension extension : allExtensions) {
if (extension.getId().equals(panelSerializedReference)) {
panels.add(extension);
}
}
}
} catch (ComponentLookupException e) {
logger.error("Failed to lookup Panels instances, error: [{}]", e);
}
}
return panels;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class PanelWikiUIExtensionComponentBuilder method buildComponents.
@Override
public List<WikiComponent> buildComponents(BaseObject baseObject) throws WikiComponentException {
String content = baseObject.getStringValue("content");
Syntax syntax = baseObject.getOwnerDocument().getSyntax();
DocumentReference documentReference = baseObject.getOwnerDocument().getDocumentReference();
DocumentReference authorReference = baseObject.getOwnerDocument().getAuthorReference();
XDOM xdom = this.parser.parse(content, syntax, documentReference);
try {
return Collections.<WikiComponent>singletonList(new PanelWikiUIExtension(baseObject.getReference(), authorReference, xdom, syntax, this.componentManager));
} catch (ComponentLookupException e) {
throw new WikiComponentException(String.format("Failed to initialize Panel UI extension [%s]", baseObject), e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultRestURLGenerator method getURL.
@Override
public URL getURL(EntityReference entityReference) throws XWikiRestException {
try {
ParameterizedType type = new DefaultParameterizedType(null, ParametrizedRestURLGenerator.class, entityReference.getClass());
ParametrizedRestURLGenerator parametrizedRestURLGenerator = componentManager.getInstance(type);
return parametrizedRestURLGenerator.getURL(entityReference);
} catch (ComponentLookupException e) {
throw new XWikiRestException(String.format("Unsupported entity type: [%s]", entityReference.getClass()), e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class UIExtensionScriptService method getExtensions.
/**
* Retrieves the list of {@link UIExtension} for a given Extension Point.
*
* Examples:
* <ul>
* <li>Get only the {@link UIExtension}s with the given IDs for the Extension Point "platform.example"
* <pre>$services.uix.getExtensions('platform.example', {'select' : 'id1, id2, id3'})</pre></li>
* <li>Get all the {@link UIExtension}s for the Extension Point "platform.example" except the
* {@link UIExtension}s with the IDs "id2" and "id3"
* <pre>$services.uix.getExtensions('platform.example', {'exclude' : 'id2, id3'})</pre></li>
* <li>Get all the {@link UIExtension}s for the Extension Point "platform.example" and order them by one of their
* parameter
* <pre>$services.uix.getExtensions('platform.example', {'sortByParameter' : 'parameterKey'})</pre></li>
* <li>Get only the {@link UIExtension}s with the given IDs for the Extension Point "platform.example" and order
* them by one of their parameter
* <pre>$services.uix.getExtensions('platform.example',
* {'select' : 'id1, id2, id3', 'sortByParameter' : 'parameterKey'})</pre></li>
* </ul>
*
* @param extensionPointId The ID of the Extension Point to retrieve the {@link UIExtension}s for
* @param filters Optional filters to apply before retrieving the list
* @return the list of {@link UIExtension} for the given Extension Point
*/
public List<UIExtension> getExtensions(String extensionPointId, Map<String, String> filters) {
List<UIExtension> extensions = getExtensions(extensionPointId);
for (Map.Entry<String, String> entry : filters.entrySet()) {
String filterHint = entry.getKey();
try {
UIExtensionFilter filter = contextComponentManagerProvider.get().getInstance(UIExtensionFilter.class, filterHint);
extensions = filter.filter(extensions, this.parseFilterParameters(entry.getValue()));
} catch (ComponentLookupException e) {
logger.warn("Unable to find a UIExtensionFilter for hint [{}] " + "while getting UIExtensions for extension point [{}]", filterHint, extensionPointId);
}
}
return extensions;
}
Aggregations