use of org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN in project che-server by eclipse-che.
the class DefaultEditorProvisioner method createReferencePluginComponent.
/**
* Evaluates a plugin FQN by retrieving it's meta.yaml, and sets it's name and reference to the
* appropriate values.
*
* @param pluginRef - The formatted plugin reference (e.g.
* eclipse/che-machine-exec-plugin/nightly)
* @param contentProvider - The content provider used to read YAML data
* @return - A {@link ComponentImpl} with it's ID and reference URL set.
* @throws InfrastructureException when the parser cannot evalute the plugin's FQN.
*/
private ComponentImpl createReferencePluginComponent(String pluginRef, FileContentProvider contentProvider) throws InfrastructureException {
ExtendedPluginFQN fqn = pluginFQNParser.evaluateFqn(pluginRef, contentProvider);
ComponentImpl component = new ComponentImpl();
component.setType(PLUGIN_COMPONENT_TYPE);
if (!isNullOrEmpty(fqn.getId())) {
component.setId(fqn.getId());
}
if (!isNullOrEmpty(fqn.getReference())) {
component.setReference(fqn.getReference());
}
return component;
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN in project che-server by eclipse-che.
the class DefaultEditorProvisioner method addMissingPlugins.
/**
* Tries to add default plugins to the Devfile components. Each plugin is initially parsed by
* plugin ref. If the plugin does not have a reference, it is added to the component list, and its
* plugin ID will be used to resolve it. If it has a reference, the Plugin is evaluated, so that
* its meta.yaml can be retrieved. From the meta.yaml, the new Component's ID and reference are
* properly set, and the Component is added to the list.
*
* @param devfileComponents - The list of Devfile components
* @param contentProvider - The content provider to retrieve YAML
* @param missingPluginsIdToRef - The list of default plugins that are not currently in the list
* of devfile components
* @throws InfrastructureException if the parser is unable to evaluate the FQN of the plugin.
*/
private void addMissingPlugins(List<ComponentImpl> devfileComponents, FileContentProvider contentProvider, Map<String, String> missingPluginsIdToRef) throws InfrastructureException {
for (String pluginRef : missingPluginsIdToRef.values()) {
ComponentImpl component;
ExtendedPluginFQN fqn = pluginFQNParser.parsePluginFQN(pluginRef);
if (!isNullOrEmpty(fqn.getId())) {
component = new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginRef);
} else {
component = createReferencePluginComponent(pluginRef, contentProvider);
}
devfileComponents.add(component);
}
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN in project devspaces-images by redhat-developer.
the class DefaultEditorProvisioner method addMissingPlugins.
/**
* Tries to add default plugins to the Devfile components. Each plugin is initially parsed by
* plugin ref. If the plugin does not have a reference, it is added to the component list, and its
* plugin ID will be used to resolve it. If it has a reference, the Plugin is evaluated, so that
* its meta.yaml can be retrieved. From the meta.yaml, the new Component's ID and reference are
* properly set, and the Component is added to the list.
*
* @param devfileComponents - The list of Devfile components
* @param contentProvider - The content provider to retrieve YAML
* @param missingPluginsIdToRef - The list of default plugins that are not currently in the list
* of devfile components
* @throws InfrastructureException if the parser is unable to evaluate the FQN of the plugin.
*/
private void addMissingPlugins(List<ComponentImpl> devfileComponents, FileContentProvider contentProvider, Map<String, String> missingPluginsIdToRef) throws InfrastructureException {
for (String pluginRef : missingPluginsIdToRef.values()) {
ComponentImpl component;
ExtendedPluginFQN fqn = pluginFQNParser.parsePluginFQN(pluginRef);
if (!isNullOrEmpty(fqn.getId())) {
component = new ComponentImpl(PLUGIN_COMPONENT_TYPE, pluginRef);
} else {
component = createReferencePluginComponent(pluginRef, contentProvider);
}
devfileComponents.add(component);
}
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN in project devspaces-images by redhat-developer.
the class EditorComponentToWorkspaceApplier method apply.
/**
* Applies changes on workspace config according to the specified editor component.
*
* @param workspaceConfig workspace config on which changes should be applied
* @param editorComponent plugin component that should be applied
* @param contentProvider optional content provider that may be used for external component
* resource fetching
* @throws IllegalArgumentException if specified workspace config or plugin component is null
* @throws IllegalArgumentException if specified component has type different from cheEditor
*/
@Override
public void apply(WorkspaceConfigImpl workspaceConfig, ComponentImpl editorComponent, FileContentProvider contentProvider) throws DevfileException {
checkArgument(workspaceConfig != null, "Workspace config must not be null");
checkArgument(editorComponent != null, "Component must not be null");
checkArgument(EDITOR_COMPONENT_TYPE.equals(editorComponent.getType()), format("Plugin must have `%s` type", EDITOR_COMPONENT_TYPE));
final String editorComponentAlias = editorComponent.getAlias();
final String editorId = editorComponent.getId();
final String registryUrl = editorComponent.getRegistryUrl();
final ExtendedPluginFQN fqn = componentFQNParser.evaluateFQN(editorComponent, contentProvider);
if (!isNullOrEmpty(fqn.getReference())) {
workspaceConfig.getAttributes().put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, fqn.getReference());
} else {
workspaceConfig.getAttributes().put(WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, componentFQNParser.getCompositeId(registryUrl, editorId));
}
workspaceConfig.getCommands().stream().filter(c -> editorComponentAlias != null && editorComponentAlias.equals(c.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE))).forEach(c -> c.getAttributes().put(PLUGIN_ATTRIBUTE, fqn.getId()));
// make sure id is set to be able to match component with plugin broker result
// when referenceContent is used
editorComponent.setId(fqn.getId());
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN in project devspaces-images by redhat-developer.
the class PluginComponentToWorkspaceApplier method apply.
/**
* Applies changes on workspace config according to the specified plugin component.
*
* @param workspaceConfig workspace config on which changes should be applied
* @param pluginComponent plugin component that should be applied
* @param contentProvider optional content provider that may be used for external component
* resource fetching
* @throws IllegalArgumentException if specified workspace config or plugin component is null
* @throws IllegalArgumentException if specified component has type different from chePlugin
*/
@Override
public void apply(WorkspaceConfigImpl workspaceConfig, ComponentImpl pluginComponent, @Nullable FileContentProvider contentProvider) throws DevfileException {
checkArgument(workspaceConfig != null, "Workspace config must not be null");
checkArgument(pluginComponent != null, "Component must not be null");
checkArgument(PLUGIN_COMPONENT_TYPE.equals(pluginComponent.getType()), format("Plugin must have `%s` type", PLUGIN_COMPONENT_TYPE));
String workspacePluginsAttribute = workspaceConfig.getAttributes().get(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE);
final String pluginId = pluginComponent.getId();
final String registryUrl = pluginComponent.getRegistryUrl();
final ExtendedPluginFQN fqn = componentFQNParser.evaluateFQN(pluginComponent, contentProvider);
if (!isNullOrEmpty(fqn.getReference())) {
workspaceConfig.getAttributes().put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, append(workspacePluginsAttribute, fqn.getReference()));
} else {
workspaceConfig.getAttributes().put(WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, append(workspacePluginsAttribute, componentFQNParser.getCompositeId(registryUrl, pluginId)));
}
for (CommandImpl command : workspaceConfig.getCommands()) {
String commandComponent = command.getAttributes().get(COMPONENT_ALIAS_COMMAND_ATTRIBUTE);
if (commandComponent == null) {
// command does not have component information
continue;
}
if (!commandComponent.equals(pluginComponent.getAlias())) {
continue;
}
command.getAttributes().put(PLUGIN_ATTRIBUTE, fqn.getId());
}
// make sure id is set to be able to match component with plugin broker result
// when referenceContent is used
pluginComponent.setId(fqn.getId());
}
Aggregations