Esempio n. 1
0
  protected DDMTemplate addTemplate(
      long userId,
      long groupId,
      DDMTemplate template,
      long classPK,
      File smallFile,
      ServiceContext serviceContext)
      throws Exception {

    DDMTemplate newTemplate = null;

    try {
      return DDMTemplateLocalServiceUtil.addTemplate(
          userId,
          groupId,
          template.getClassNameId(),
          classPK,
          template.getTemplateKey(),
          template.getNameMap(),
          template.getDescriptionMap(),
          template.getType(),
          template.getMode(),
          template.getLanguage(),
          template.getScript(),
          template.isCacheable(),
          template.isSmallImage(),
          template.getSmallImageURL(),
          smallFile,
          serviceContext);
    } catch (TemplateDuplicateTemplateKeyException tdtke) {
      newTemplate =
          DDMTemplateLocalServiceUtil.addTemplate(
              userId,
              groupId,
              template.getClassNameId(),
              classPK,
              null,
              template.getNameMap(),
              template.getDescriptionMap(),
              template.getType(),
              template.getMode(),
              template.getLanguage(),
              template.getScript(),
              template.isCacheable(),
              template.isSmallImage(),
              template.getSmallImageURL(),
              smallFile,
              serviceContext);

      if (_log.isWarnEnabled()) {
        _log.warn(
            "A template with the key "
                + template.getTemplateKey()
                + " already exists. The new generated key is "
                + newTemplate.getTemplateKey());
      }
    }

    return newTemplate;
  }
  protected DDMTemplate addTemplate(
      long classNameId,
      long classPK,
      long sourceClassNameId,
      String templateKey,
      String name,
      String description,
      String type,
      String mode,
      String language,
      String script)
      throws Exception {

    return DDMTemplateLocalServiceUtil.addTemplate(
        TestPropsValues.getUserId(),
        group.getGroupId(),
        classNameId,
        classPK,
        sourceClassNameId,
        templateKey,
        getDefaultLocaleMap(name),
        getDefaultLocaleMap(description),
        type,
        mode,
        language,
        script,
        false,
        false,
        null,
        null,
        ServiceContextTestUtil.getServiceContext());
  }