How to load a new cockpit configuration without updating the system

The usual way to update the cockpit configuration is click on “Create Project Data” on the extension with the configuration. And then update the system. This may take some time. Here is a faster way.

import de.hybris.platform.core.initialization.SystemSetupContext;
import de.hybris.platform.cockpit.systemsetup.CockpitImportConfig;
import de.hybris.platform.core.Registry;
import java.io.PrintStream;
final String extensionName = "myextension";
 
try {
//We use the context to store the name of the extension.
SystemSetupContext context = new SystemSetupContext(null, null, null, extensionName);
//We get the bean from the application context to have it autowired.
CockpitImportConfig importer = (CockpitImportConfig) Registry.getApplicationContext().getBean("cockpitImportConfig");
importer.importCockpitConfig(context);
} catch (Exception e) {
  System.err.println("There was an error:");
  e.printStackTrace(System.err);
  return "Error, please see the console of the app server";
}
return "OK"

If you have errors in your configuration, you may turn on the logging of the importer adding the following line to the file local.properties:

log4j.logger.de.hybris.platform.cockpit.systemsetup.CockpitImportConfig=TRACE

–Based on SAP Hybris 6.1