class DBService implements RolesProvider {

    void executePutDomainTemplate(ResourceContext ctx, String domainName, DomainTemplate domainTemplate,
            String auditRef, String caller) {

        // our exception handling code does the check for retry count
        // and throws the exception it had received when the retry
        // count reaches 0

        for (int retryCount = defaultRetryCount; ; retryCount--) {

            try (ObjectStoreConnection con = store.getConnection(false, true)) {

                // first verify that auditing requirements are met

                checkDomainAuditEnabled(con, domainName, auditRef, caller, getPrincipalName(ctx), AUDIT_TYPE_TEMPLATE);

                // go through our list of templates and add the specified
                // roles and polices to our domain

                StringBuilder auditDetails = new StringBuilder(ZMSConsts.STRING_BLDR_SIZE_DEFAULT);
                auditDetails.append("{\"add-templates\": ");
                boolean firstEntry = true;

                for (String templateName : domainTemplate.getTemplateNames()) {
                    firstEntry = auditLogSeparator(auditDetails, firstEntry);
                    if (!addSolutionTemplate(con, domainName, templateName, getPrincipalName(ctx),
                            domainTemplate.getParams(), auditRef, auditDetails)) {
                        con.rollbackChanges();
                        throw ZMSUtils.internalServerError("unable to put domain templates: " + domainName, caller);
                    }
                }
                auditDetails.append("}");

                // update our domain time-stamp and save changes

                saveChanges(con, domainName);

                // audit log the request

                auditLogRequest(ctx, domainName, auditRef, caller, ZMSConsts.HTTP_PUT,
                        domainName, auditDetails.toString());

                return;

            } catch (ResourceException ex) {
                if (!shouldRetryOperation(ex, retryCount)) {
                    throw ex;
                }
            }
        }
    }

    public  DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator);

}