Media Files

SAP Commerce supports media files. A media file can be anything that can be saved on a file system.

Media files include a Flash animation file, a JPEG image, an MPEG video file, a CSV file, a text file, an XML file, and more. The SAP Commerce platform does not store media files in its database. Instead, it defines a media item type that names and describes a particular media file, and knows where the file is physically stored. In other words, media items in SAP Commerce are not the media files themselves, but references (URLs) to those files. The actual referenced media files can be stored in various locations. You can keep them locally, or store them remotely using Amazon S3, Windows Azure Blob, or MongoDB GridFS solutions, for example.

In addition to a unique ID and a description, a media item has the following attributes:

  • It is assigned to a catalog version. Media items for products can be synchronized between catalog versions at the same time as the related product details.

  • It can have access to it controlled through lists of permitted and denied principals (users).

  • It is associated with a media format that is used to tag different media items as being appropriate for the same uses.

  • It is included in a media container, typically used to group media files of the same content that are in different formats: for example, the same image but in different sizes or encodings (png, jpg, bmp).

To make the band pages a little more interesting, you can include pictures of each band. Use a smaller version of the image for the list page, and a larger one for the details page.

Add Media Files

Add images for the yRock band. You can of course add images for others, too.

Prerequisites

The following acceptance test is included in your Hybris123Tests.java file.
public void testBandImages() throws Exception {
canLoginToHybrisCommerce();
navigateTo("https://localhost:9002/concerttours/bands");
waitForValidImage();
navigateTo("https://localhost:9002/concerttours/bands/A006");
assertTrue( waitForValidImage());	
}
Before you begin this step, run the test to confirm that it fails by executing this command:
cd $HYBRIS_HOME_DIR/hybris123; mvn -Dtest=com.hybris.hybris123.runtime.tests.Hybris123Tests#testBandImages test
cd %HYBRIS_HOME_DIR%\hybris123 & mvn -Dtest=com.hybris.hybris123.runtime.tests.Hybris123Tests#testBandImages test

Procedure

  1. Stop SAP Commerce.
    cd $HYBRIS_HOME_DIR/hybris/bin/platform; ./hybrisserver.sh stop
    cd %HYBRIS_HOME_DIR%\hybris\bin\platform & hybrisserver.bat stop
  2. Modify the Band business logic to include images.
    1. Add a media container attribute to the Band item type.

      Add the following attribute definition to the Band item type in the concerttours-items.xml file in the resources folder of the concerttours extension:

      <attribute qualifier="image" type="MediaContainer">
          <description>picture of band in different formats</description>
          <persistence type="property" />
      </attribute>

      SAP Commerce 123 Interactive Shortcut: If you are unable to edit the concerttours-items.xml file, or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/resources/concerttours-items.xml with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/resources/concerttours-itemsWithMedia.xml .

      ditto $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/resources/concerttours-itemsWithMedia.xml $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/concerttours-items.xml
      echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\resources\concerttours-itemsWithMedia.xml %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\resources\concerttours-items.xml
    2. Add a URL attribute to the BandData bean.

      Add the following attribute definition to the BandData definition in the concerttours-beans.xml file in the resources folder of the concerttours extension:

      <bean class = "concerttours.data.BandData" >
             <description>Data object representing a Band</description>
             <property name = "id" type = "String" />
             <property name = "name" type = "String" />
             <property name = "description" type = "String" />
             <property name = "albumsSold" type = "Long" />
             <property name = "genres" type="java.util.List&lt;String&gt;"/>
             <property name = "tours" type="java.util.List&lt;concerttours.data.TourSummaryData&gt;"/>
             <property name="imageURL" type="String" />
      </bean>

      SAP Commerce 123 Interactive Shortcut: If you are unable to edit the concerttours-beans.xml file, or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/resources/concerttours-beans.xml with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/resources/concerttours-beansWithMedia.xml .

      ditto $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/resources/concerttours-beansWithMedia.xml $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/concerttours-beans.xml
      echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\resources\concerttours-beansWithMedia.xml %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\resources\concerttours-beans.xml
    3. Update the facades to retrieve the image in the relevant format.

      Modify the contents of the DefaultBandFacade class to add the handling of the different formats of images:

      package concerttours.facades.impl;
      import de.hybris.platform.core.model.media.MediaContainerModel;
      import de.hybris.platform.core.model.media.MediaFormatModel;
      import de.hybris.platform.core.model.product.ProductModel;
      import de.hybris.platform.servicelayer.media.MediaService;
      import java.util.ArrayList;
      import java.util.List;
      import org.springframework.beans.factory.annotation.Required;
      import concerttours.data.BandData;
      import concerttours.data.TourSummaryData;
      import concerttours.enums.MusicType;
      import concerttours.facades.BandFacade;
      import concerttours.model.BandModel;
      import concerttours.service.BandService;
      import java.util.Locale;
      
      public class DefaultBandFacade implements BandFacade
      {
          private BandService bandService;
          private MediaService mediaService;
          @Override
          public List<BandData> getBands()
          {
              final List<BandModel> bandModels = bandService.getBands();
              final List<BandData> bandFacadeData = new ArrayList<>();
              final MediaFormatModel format = mediaService.getFormat("bandList");
              for (final BandModel sm : bandModels)
              {
                  final BandData sfd = new BandData();
                  sfd.setId(sm.getCode());
                  sfd.setName(sm.getName());
                  sfd.setDescription(sm.getHistory(Locale.ENGLISH));
                  sfd.setAlbumsSold(sm.getAlbumSales());
                  sfd.setImageURL(getImageURL(sm, format));
                  bandFacadeData.add(sfd);
              }
              return bandFacadeData;
          }
          @Override
          public BandData getBand(final String name)
          {
              if (name == null)
              {
                  throw new IllegalArgumentException("Band name cannot be null");
              }
              final BandModel band = bandService.getBandForCode(name);
              if (band == null)
              {
                  return null;
              }
              // Create a list of genres
              final List<String> genres = new ArrayList<>();
              if (band.getTypes() != null)
              {
                  for (final MusicType musicType : band.getTypes())
                  {
                      genres.add(musicType.getCode());
                  }
              }
              // Create a list of TourSummaryData from the matches
              final List<TourSummaryData> tourHistory = new ArrayList<>();
              if (band.getTours() != null)
              {
                  for (final ProductModel tour : band.getTours())
                  {
                      final TourSummaryData summary = new TourSummaryData();
                      summary.setId(tour.getCode());
                      summary.setTourName(tour.getName(Locale.ENGLISH));
                      // making the big assumption that all variants are concerts and ignore product catalogs
                      summary.setNumberOfConcerts(Integer.toString(tour.getVariants().size()));
                      tourHistory.add(summary);
                  }
              }
              // Now we can create the BandData transfer object
              final MediaFormatModel format = mediaService.getFormat("bandDetail");
              final BandData bandData = new BandData();
              bandData.setId(band.getCode());
              bandData.setName(band.getName());
              bandData.setAlbumsSold(band.getAlbumSales());
              bandData.setImageURL(getImageURL(band, format));
              bandData.setDescription(band.getHistory(Locale.ENGLISH));
              bandData.setGenres(genres);
              bandData.setTours(tourHistory);
              return bandData;
          }
          protected String getImageURL(final BandModel sm, final MediaFormatModel format)
          {
              final MediaContainerModel container = sm.getImage();
              if (container != null)
              {
                  return mediaService.getMediaByFormat(container, format).getDownloadURL();
              }
              return null;
          }
          @Required
          public void setBandService(final BandService bandService)
          {
              this.bandService = bandService;
          }
          @Required
          public void setMediaService(final MediaService mediaService)
          {
              this.mediaService = mediaService;
          }
      }

      SAP Commerce 123 Interactive Shortcut: If you are unable to edit the DefaultBandFacade, or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/src/concerttours/facades/impl/DefaultBandFacade.java with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/src/concerttours/facades/impl/DefaultBandFacadeWithMedia.java.

      ditto $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/src/concerttours/facades/impl/DefaultBandFacadeWithMedia.java $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/src/concerttours/facades/impl/DefaultBandFacade.java
      echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\src\concerttours\facades\impl\DefaultBandFacadeWithMedia.java %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\src\concerttours\facades\impl\DefaultBandFacade.java
    4. Update concerttours-spring.xml to inject the DefaultBandFacade with the MediaService.
      <alias name = "defaultBandFacade" alias = "bandFacade" />
      <bean id = "defaultBandFacade" class ="concerttours.facades.impl.DefaultBandFacade" >
          <property name = "bandService" ref = "bandService" />
          <property name="mediaService" ref="mediaService"/>
      </bean>

      SAP Commerce 123 Interactive Shortcut: If you are unable to edit the concerttours-beans.xml file, or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/resources/concerttours-spring.xml with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/resources/concerttours-spring-withMedia.xml .

      ditto $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/resources/concerttours-spring-withMedia.xml $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/concerttours-spring.xml
      echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\resources\concerttours-spring-withMedia.xml %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\resources\concerttours-spring.xml
  3. Initialize and update your system.
    cd $HYBRIS_HOME_DIR/hybris/bin/platform; ant clean all build initialize updatesystem
    cd %HYBRIS_HOME_DIR%\hybris\bin\platform & ant clean all build initialize updatesystem
  4. Modify the Band JSPs to include images by updating theBandList.jsp and BandDetails.jsp pages as follows.
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <!doctype html>
    <html>
    <title>Band Details</title>
    <body>
        <h1>Band Details</h1>
        Band Details for ${band.name}
        <p><img src="${band.imageURL}"/></p>
        <p>${band.description}</p>
        <p>Music type:</p>
        <ul>
            <c:forEach var="genre" items="${band.genres}">
                <li>${genre}</li>
            </c:forEach>
        </ul>
        <p>Tour History:</p>
        <ul>
            <c:forEach var="tour" items="${band.tours}">
                <li><a href="../tours/${tour.id}">${tour.tourName}</a>(number of concerts: ${tour.numberOfConcerts})</li>
            </c:forEach>
        </ul>
        <a href="../bands">Back to Band List</a>
    </body>
    </html>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <!doctype html>
    <html>
        <title>Band List</title>
        <body>
            <h1>Band List</h1>
         <ul>
         <c:forEach var="band" items="${bands}">
            <li><a href="./bands/${band.id}"><img src="${band.imageURL}" />${band.name}</a></li>
          </c:forEach>
          </ul>
        </body>
    </html>

    SAP Commerce 123 Interactive Shortcut: If you are unable to edit the JSP files or you want to skip this step, replace button to create two new media formats. The first with qualifier <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/web/webroot/WEB-INF/views/BandList.jsp with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/web/webroot/WEB-INF/views/BandListWithMedia.jsp, and <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/web/webroot/WEB-INF/views/BandDetails.jsp with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/web/webroot/WEB-INF/views/BandDetailsWithMedia.jsp.

    ditto $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/web/webroot/WEB-INF/views/BandListWithMedia.jsp $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/web/webroot/WEB-INF/views/BandList.jsp
    ditto $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/web/webroot/WEB-INF/views/BandDetailsWithMedia.jsp $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/web/webroot/WEB-INF/views/BandDetails.jsp
    echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\web\webroot\WEB-INF\views\BandListWithMedia.jsp %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\web\webroot\WEB-INF\views\BandList.jsp
    echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\web\webroot\WEB-INF\views\BandDetailsWithMedia.jsp %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\web\webroot\WEB-INF\views\BandDetails.jsp
  5. Start SAP Commerce.
    cd $HYBRIS_HOME_DIR/hybris/bin/platform; ./hybrisserver.sh start
    cd %HYBRIS_HOME_DIR%\hybris\bin\platform & hybrisserver.bat start
  6. Add two new media formats.
    1. In the Backoffice Administration Cockpit, navigate to the Start of the navigation pathMultimedia Next navigation step Media FormatsEnd of the navigation path item in the Explorer Tree.
    2. Click on the plus button to create two new media formats. The first with qualifier bandDetail and name Band Detail Format, and the second with qualifier bandList and name Band List Format.
  7. Find appropriate images for each of the six bands.
  8. Use an image editing tool to create two JPEG versions of each image: one 600 pixels wide for the details page and one 100 pixels wide for the list page.

    Give the images the following names:

    • bigbandBig.jpg
    • bigbandSmall.jpg
    • danceBig.jpg
    • danceSmall.jpg
    • jazzBig.jpg
    • jazzSmall.jpg
    • omphaBig.jpg
    • omphaSmall.jpg
    • orchestraBig.jpg
    • orchestraSmall.jpg
    • rockBig.jpg
    • rockSmall.jpg
  9. Add two new media items for the yRock band.
    1. In the Backoffice Administration Cockpit, navigate to the Start of the navigation pathMultimedia Next navigation step MediaEnd of the navigation path item in the Explorer Tree.
    2. Create one new media item with the identifier yRockSmall and catalog version concertoursProductCatalog: Online.
    3. Add a second new media item with the identifier yRockLarge and catalog version concertoursProductCatalog: Online.
  10. Create a media container for the yRock band images.
    1. In the Backoffice Administration Cockpit, navigate to the Start of the navigation pathMultimedia Next navigation step Media ContainersEnd of the navigation path item in the Explorer Tree.
    2. Click on the plus button to create a new media container with the name and qualifier set to yRockImageContainer.
  11. Add an image to each item.
    1. In the Backoffice Administration Cockpit, navigate to the Start of the navigation pathMultimedia Next navigation step MediaEnd of the navigation path item in the Explorer Tree.
    2. Click search to list all media items, including rockSmall.jpg and rockLarge.jpg.
    3. Click on yRockSmall, upload the image rockSmall.jpg, specify bandList as the Media format, and yRockImageContainer as the Media container.
    4. Click on yRockLarge, upload the image rockBig.jpg and specify bandDetail as the Media format, and yRockImageContainer as the Media container.
  12. Assign the media container to its respective band.
    1. In the Backoffice Administration Cockpit, navigate to Start of the navigation pathSystem Next navigation step TypesEnd of the navigation path in the Explorer pane.
    2. Search for the yRock band.
    3. Set its Band.image field to yRockImageContainer.
  13. Verify that you can see the images on the band pages.

    You should see the images on the following pages:

    • https://localhost:9002/concerttours/bands

    • https://localhost:9002/concerttours/bands/A001

  14. To define multiple media items, formats, and containers, use ImpEx and define them as essential data so that the media format items are loaded into the database before you load the project data
    1. Create a new file called essentialdata-mediaformats.impex in the resources/impex folder of the conccerttours extension, and setting the contents as follows.
      INSERT_UPDATE MediaFormat;qualifier[unique=true];name
      ;bandList;Band List Format
      ;bandDetail;Band Detail Format

      SAP Commerce 123 Interactive Shortcut: If you are unable to create the ImpEx file or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/impex/media/essentialdata-mediaformats.impex with the contents of <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/resources/impex/

      cp $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/impex/media/essentialdata-mediaformats.impex $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/impex/
      copy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\impex\media\essentialdata-mediaformats.impex %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\resources\impex\
    2. Add media files to the project by copying the band images into a new folder called bandimages under the existing resources/concerttours folder in the concerttours extension.

      SAP Commerce 123 Interactive Shortcut: If you are unable to add the media files or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/bandimages/* with the contents of <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/resources/concerttours/bandimages/

      mkdir -p $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/concerttours/bandimages; cp $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/bandimages/* $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/concerttours/bandimages/
      
      echo a | xcopy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\bandimages\* %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\resources\concerttours\bandimages\
    3. Add media data to the bands ImpEx file by updating the contents of the concerttours-bands.impex file in the resources/impex folder of the conccerttours extension as follows.
      # ImpEx for Importing Bands into Little Concert Tours Store
       
      # Macros / Replacement Parameter definitions
      $productCatalog=concertoursProductCatalog
      $catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Online'])[unique=true,default=$productCatalog:Online]
      $medias=medias(code, $catalogVersion)
      $siteResource=jar:concerttours.constants.ConcerttoursConstants&/concerttours/bandimages
         
      # Product catalog
      INSERT_UPDATE Catalog;id[unique=true]
      ;$productCatalog
       
      # Product catalog version
      INSERT_UPDATE CatalogVersion;catalog(id)[unique=true];version[unique=true];active;languages(isoCode);readPrincipals(uid)
      ;$productCatalog;Online;true;en;employeegroup
        
      INSERT_UPDATE Media;mediaFormat(qualifier);code[unique=true];@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator];mime[default='image/jpeg'];$catalogVersion
      ;bandList;rockSmall.jpg;$siteResource/rockSmall.jpg;;
      ;bandDetail;rockBig.jpg;$siteResource/rockBig.jpg;;
      ;bandList;danceSmall.jpg;$siteResource/danceSmall.jpg;;
      ;bandDetail;danceBig.jpg;$siteResource/danceBig.jpg;;
      ;bandList;jazzSmall.jpg;$siteResource/jazzSmall.jpg;;
      ;bandDetail;jazzBig.jpg;$siteResource/jazzBig.jpg;;
      ;bandList;bigbandSmall.jpg;$siteResource/bigbandSmall.jpg;;
      ;bandDetail;bigbandBig.jpg;$siteResource/bigbandBig.jpg;;
      ;bandList;omphaSmall.jpg;$siteResource/omphaSmall.jpg;;
      ;bandDetail;omphaBig.jpg;$siteResource/omphaBig.jpg;;
      ;bandList;orchestraSmall.jpg;$siteResource/orchestraSmall.jpg;;
      ;bandDetail;orchestraBig.jpg;$siteResource/orchestraBig.jpg;;
      INSERT_UPDATE MediaContainer;qualifier[unique=true];$medias;$catalogVersion
      ;yRockImage;rockSmall.jpg,rockBig.jpg;
      ;yBandImage;danceSmall.jpg,danceBig.jpg;
      ;yJazzImage;jazzSmall.jpg,jazzBig.jpg;
      ;BannedImage;bigbandSmall.jpg,bigbandBig.jpg;
      ;SirkenImage;omphaSmall.jpg,omphaBig.jpg;
      ;TheChoirImage;orchestraSmall.jpg,orchestraBig.jpg;
       
      INSERT_UPDATE Band;code[unique=true];name;albumSales;image(qualifier)
      ;A001;yRock;1000000;yRockImage
      ;A006;yBand;;yBandImage
      ;A003;yJazz;7;yJazzImage
      ;A004;Banned;427;BannedImage
      ;A002;Sirken;2000;SirkenImage
      ;A005;The Choir;49000;TheChoirImage
      ;A007;The Quiet;1200;;

      SAP Commerce 123 Interactive Shortcut: If you are unable to create the ImpEx file or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/impex/media/concerttours-bands.impex with the contents of <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/resources/impex/

      cp $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/impex/media/concerttours-bands.impex $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/resources/impex/
      copy %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\impex\media\concerttours-bands.impex %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\resources\impex\
    4. Stop SAP Commerce.
      cd $HYBRIS_HOME_DIR/hybris/bin/platform; ./hybrisserver.sh stop
      cd %HYBRIS_HOME_DIR%\hybris\bin\platform & hybrisserver.bat stop
    5. Initialize the system.
      cd $HYBRIS_HOME_DIR/hybris/bin/platform; ant initialize
      cd %HYBRIS_HOME_DIR%/hybris/bin/platform & ant initialize
  15. Start SAP Commerce.
    cd $HYBRIS_HOME_DIR/hybris/bin/platform; ./hybrisserver.sh start
    cd %HYBRIS_HOME_DIR%\hybris\bin\platform & hybrisserver.bat start
  16. Verify that you can see the images on the band pages.

    You should see the images on the following pages:

    • https://localhost:9002/concerttours/bands

    • https://localhost:9002/concerttours/bands/A001

  17. Stop SAP Commerce.
    cd $HYBRIS_HOME_DIR/hybris/bin/platform; ./hybrisserver.sh stop
    cd %HYBRIS_HOME_DIR%\hybris\bin\platform & hybrisserver.bat stop
  18. Fix the test cases.
    1. Add a call to importCsv to the setUp() method of the DefaultBandFacadeIntegrationTest class.
      @Before
      public void setUp() throws Exception
      {
          try {
              Thread.sleep(TimeUnit.SECONDS.toMillis(1));
      	new JdbcTemplate(Registry.getCurrentTenant().getDataSource()).execute("CHECKPOINT");
      	Thread.sleep(TimeUnit.SECONDS.toMillis(1));
          }
          catch (InterruptedException exc) {}
          importCsv("/impex/essentialdata-mediaformats.impex", "UTF-8");
        
          // This instance of a BandModel will be used by the tests
          bandModel = modelService.create(BandModel.class); 
          bandModel.setCode(BAND_CODE);
          bandModel.setName(BAND_NAME);      
          
          bandModel.setHistory(BAND_HISTORY);
          bandModel.setAlbumSales(ALBUMS_SOLD);
      }

      SAP Commerce 123 Interactive Shortcut: If you are unable to edit the integration test or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/testsrc/concerttours/facades/impl/DefaultBandFacadeIntegrationTest.java with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/testsrc/concerttours/facades/impl/DefaultBandFacadeIntegrationTestWithImportCSV.java.

      cp $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/testsrc/concerttours/facades/impl/DefaultBandFacadeIntegrationTestWithImportCSV.java $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/testsrc/concerttours/facades/impl/DefaultBandFacadeIntegrationTest.java
      copy /y %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\testsrc\concerttours\facades\impl\DefaultBandFacadeIntegrationTestWithImportCSV.java %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\testsrc\concerttours\facades\impl\DefaultBandFacadeIntegrationTest.java
    2. Add a call to importCsv to the testBandServiceTours() method of the DefaultBandServiceIntegrationTest class.
      @Test
      public void testBandServiceTours() throws Exception
      {
          createCoreData();
          importCsv("/impex/essentialdata-mediaformats.impex", "UTF-8");
          importCsv("/impex/concerttours-bands.impex", "utf-8");
          importCsv("/impex/concerttours-yBandTour.impex", "utf-8");
          final BandModel band = bandService.getBandForCode("A001");
          assertNotNull("No band found", band);
          final Set<ProductModel> tours = band.getTours();
          assertNotNull("No tour found", tours);
          Assert.assertEquals("not found one tour", 1, tours.size());
          final Object[] objects = new Object[5];
          final Collection<VariantProductModel> concerts = ((ProductModel) tours.toArray(objects)[0]).getVariants();
          assertNotNull("No tour found", tours);
          Assert.assertEquals("not found one tour", 6, concerts.size());
      }

      SAP Commerce 123 Interactive Shortcut: If you are unable to edit the integration test or you want to skip this step, replace <HYBRIS_HOME_DIR>/hybris/bin/custom/concerttours/testsrc/concerttours/service/impl/DefaultBandServiceIntegrationTest.java with the contents of <HYBRIS_HOME_DIR>/hybris123/src/main/webapp/resources/concerttours/testsrc/concerttours/service/impl/DefaultBandServiceIntegrationTestWithImportCSV.java.

      cp $HYBRIS_HOME_DIR/hybris123/src/main/webapp/resources/concerttours/testsrc/concerttours/service/impl/DefaultBandServiceIntegrationTestWithImportCSV.java $HYBRIS_HOME_DIR/hybris/bin/custom/concerttours/testsrc/concerttours/service/impl/DefaultBandServiceIntegrationTest.java
      copy /y %HYBRIS_HOME_DIR%\hybris123\src\main\webapp\resources\concerttours\testsrc\concerttours\service\impl\DefaultBandServiceIntegrationTestWithImportCSV.java %HYBRIS_HOME_DIR%\hybris\bin\custom\concerttours\testsrc\concerttours\service\impl\DefaultBandServiceIntegrationTest.java
    3. Initialize the system.
      cd $HYBRIS_HOME_DIR/hybris/bin/platform; ant clean all yunitinit
      cd %HYBRIS_HOME_DIR%\hybris\bin\platform & ant clean all yunitinit
    4. Run the tests to confirm that they all pass.
      ant alltests -Dtestclasses.packages="concerttours.*"
      ant alltests -Dtestclasses.packages=concerttours.*
  19. Start SAP Commerce.
    cd $HYBRIS_HOME_DIR/hybris/bin/platform; ./hybrisserver.sh start
    cd %HYBRIS_HOME_DIR%\hybris\bin\platform & hybrisserver.bat start
  20. Run the testBandImages acceptance test again and confirm that now passes.
    cd $HYBRIS_HOME_DIR/hybris123; mvn -Dtest=com.hybris.hybris123.runtime.tests.Hybris123Tests#testBandImages test
    cd %HYBRIS_HOME_DIR%\hybris123 & mvn -Dtest=com.hybris.hybris123.runtime.tests.Hybris123Tests#testBandImages test
  21. Commit the changes to your local Git repository.
    cd $HYBRIS_HOME_DIR/hybris; git add . ; git commit -m "Add Media Files"
    cd %HYBRIS_HOME_DIR%\hybris & git add . & git commit -m "Add Media Files"