/**
   * This will create a new asset. It will be saved, but not checked in. The initial state will be
   * the draft state. Returns the UUID of the asset.
   */
  public String createNewRule(
      NewAssetWithContentConfiguration<? extends PortableObject> configuration)
      throws SerializationException {

    final String assetName = configuration.getAssetName();
    final String description = configuration.getDescription();
    final String initialCategory = configuration.getInitialCategory();
    final String packageName = configuration.getPackageName();
    final String format = configuration.getFormat();
    final PortableObject content = configuration.getContent();

    log.info(
        "USER:"******" CREATING new asset name ["
            + assetName
            + "] in package ["
            + packageName
            + "]");

    try {

      // Create new Asset
      ModuleItem pkg = rulesRepository.loadModule(packageName);
      AssetItem assetItem = pkg.addAsset(assetName, description, initialCategory, format);

      // Set the Assets content - no need to use AssetTemplateCreator().applyPreBuiltTemplates() as
      // we are provided a model
      // Use a transient Asset object so we can use ContentHandler to convert between model and
      // persisted format correctly.
      Asset asset = new AssetPopulator().populateFrom(assetItem);
      ContentHandler handler = ContentManager.getHandler(assetItem.getFormat());
      asset.setContent(content);
      handler.storeAssetContent(asset, assetItem);

      rulesRepository.save();

      push("categoryChange", initialCategory);
      push("packageChange", pkg.getName());

      return assetItem.getUUID();

    } catch (RulesRepositoryException e) {
      // If we want to display an explicit error message of "duplicate asset", we can achieve this
      // in client error handler.
      /*            if ( e.getCause() instanceof ItemExistsException ) {
          return "DUPLICATE";
      }*/
      log.error(
          "An error occurred creating new asset ["
              + assetName
              + "] in package ["
              + packageName
              + "]: ",
          e);
      throw new SerializationException(e.getMessage());
    }
  }