Monday, 3 November 2014

How to load a new cockpit configuration without performing the update running system in SAP Hybris

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.
  • Go to HAC and then to Console > Bean Shell and paste the code below:
import de.hybris.platform.core.initialization.SystemSetupContext;
import de.hybris.platform.cockpit.systemsetup.CockpitImportConfig;
import de.hybris.platform.core.Registry;
  
// We use the context to store the name of the extension.
SystemSetupContext context = new SystemSetupContext(null, null, null, "myextension");
// We get the bean from the application context to have it autowired.
CockpitImportConfig importer = (CockpitImportConfig) Registry.getApplicationContext().getBean("cockpitImportConfig");
importer.importCockpitConfig(context);
  • Change myextension with the name of the extension which contains the configuration you want to import (for example: bwcore).
  • Click on execute
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

How to remove all items in Hybris using Impex

You can use an impex file or write down the content below directly in HAC:
REMOVE MyItemType[batchmode=true];itemtype(code)[unique=true]
;MyItemType

Friday, 5 September 2014

How to split logs by package in Log4J

Here an example with properties file
# ---------------------------------------------
#  Logging
# ---------------------------------------------
log4j.appender.SECURITY_FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.SECURITY_FILE.File=${HYBRIS_LOG_DIR}/tomcat/spring-security.log
log4j.appender.SECURITY_FILE.DatePattern='.'yyyy-MM-dd
log4j.appender.SECURITY_FILE.ImmediateFlush=true
log4j.appender.SECURITY_FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.SECURITY_FILE.layout.ConversionPattern=%d - %m%n
log4j.appender.SECURITY_FILE.MaxBackupIndex=10
log4j.additivity.org.springframework.security=false
log4j.logger.org.springframework.security=info,SECURITY_FILE
It sends all "info" level logs from the package "org.springframework.security" into the file "spring-security.log".

Try it and let me know!