/** * Copies all the templates matching the class name ID, class PK, and type. This method creates * new templates, extracting all the values from the old ones and updating their class PKs. * * @param classNameId the primary key of the class name for template's related model * @param classPK the primary key of the original template's related entity * @param newClassPK the primary key of the new template's related entity * @param type the template's type. For more information, see {@link * com.liferay.portlet.dynamicdatamapping.model.DDMTemplateConstants}. * @param serviceContext the service context to be applied. Must have the <code>ddmResource</code> * attribute to check permissions. Can set the UUID, creation date, modification date, guest * permissions, and group permissions for the template. * @return the new template * @throws PortalException if the user did not have permission to add the template or if a portal * exception occurred * @throws SystemException if a system exception occurred */ @Override public List<DDMTemplate> copyTemplates( long classNameId, long classPK, long newClassPK, String type, ServiceContext serviceContext) throws PortalException, SystemException { DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); DDMPermission.check( getPermissionChecker(), serviceContext.getScopeGroupId(), ddmDisplay.getResourceName(classNameId), ddmDisplay.getAddTemplateActionId()); return ddmTemplateLocalService.copyTemplates( getUserId(), classNameId, classPK, newClassPK, type, serviceContext); }
/** * Adds a template with additional parameters. * * @param groupId the primary key of the group * @param classNameId the primary key of the class name for template's related model * @param classPK the primary key of the template's related entity * @param templateKey the unique string identifying the template (optionally <code>null</code>) * @param nameMap the template's locales and localized names * @param descriptionMap the template's locales and localized descriptions * @param type the template's type. For more information, see {@link * com.liferay.portlet.dynamicdatamapping.model.DDMTemplateConstants}. * @param mode the template's mode. For more information, see {@link * com.liferay.portlet.dynamicdatamapping.model.DDMTemplateConstants}. * @param language the template's script language. For more information, see {@link * com.liferay.portlet.dynamicdatamapping.model.DDMTemplateConstants}. * @param script the template's script * @param cacheable whether the template is cacheable * @param smallImage whether the template has a small image * @param smallImageURL the template's small image URL (optionally <code>null</code>) * @param smallImageFile the template's small image file (optionally <code>null</code>) * @param serviceContext the service context to be applied. Must have the <code>ddmResource</code> * attribute to check permissions. Can set the UUID, creation date, modification date, guest * permissions, and group permissions for the template. * @return the template * @throws PortalException if the user did not have permission to add the template or if a portal * exception occurred * @throws SystemException if a system exception occurred */ @Override public DDMTemplate addTemplate( long groupId, long classNameId, long classPK, String templateKey, Map<Locale, String> nameMap, Map<Locale, String> descriptionMap, String type, String mode, String language, String script, boolean cacheable, boolean smallImage, String smallImageURL, File smallImageFile, ServiceContext serviceContext) throws PortalException, SystemException { DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); DDMPermission.check( getPermissionChecker(), serviceContext.getScopeGroupId(), ddmDisplay.getResourceName(classNameId), ddmDisplay.getAddTemplateActionId()); return ddmTemplateLocalService.addTemplate( getUserId(), groupId, classNameId, classPK, templateKey, nameMap, descriptionMap, type, mode, language, script, cacheable, smallImage, smallImageURL, smallImageFile, serviceContext); }
@Override public DDMTemplate copyTemplate(long templateId, ServiceContext serviceContext) throws PortalException, SystemException { DDMDisplay ddmDisplay = DDMUtil.getDDMDisplay(serviceContext); DDMTemplate template = ddmTemplatePersistence.findByPrimaryKey(templateId); long classNameId = template.getClassNameId(); DDMPermission.check( getPermissionChecker(), serviceContext.getScopeGroupId(), ddmDisplay.getResourceName(classNameId), ddmDisplay.getAddTemplateActionId()); return ddmTemplateLocalService.copyTemplate(getUserId(), templateId, serviceContext); }