From 286247b2e5fe92a90a0896a07ea456c984007516 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 4 Jun 2024 09:58:09 +0530 Subject: [PATCH 01/17] Notification Template API implementation --- .../pom.xml | 60 + .../template/common/Constants.java | 152 +++ .../common/TemplatesServiceHolder.java | 28 + .../common/factory/OSGIServiceFactory.java | 56 + .../pom.xml | 179 +++ .../template/v1/NotificationApi.java | 726 ++++++++++ .../template/v1/NotificationApiService.java | 95 ++ .../NotificationApiServiceFactory.java | 32 + .../template/v1/model/EmailTemplate.java | 171 +++ .../v1/model/EmailTemplateWithID.java | 106 ++ .../notification/template/v1/model/Error.java | 165 +++ .../template/v1/model/SMSTemplate.java | 101 ++ .../template/v1/model/SMSTemplateWithID.java | 106 ++ .../template/v1/model/SimpleTemplate.java | 125 ++ .../template/v1/model/TemplateType.java | 125 ++ .../v1/model/TemplateTypeOverview.java | 101 ++ .../template/v1/model/TemplateTypeWithID.java | 106 ++ .../v1/core/ApplicationTemplatesService.java | 440 ++++++ .../template/v1/core/TemplateTypeService.java | 158 +++ .../v1/impl/NotificationApiServiceImpl.java | 288 ++++ .../notification/template/v1/util/Util.java | 334 +++++ .../notification-template-server-v1-cxf.xml | 28 + .../main/resources/notification-template.yml | 1178 +++++++++++++++++ .../pom.xml | 37 + pom.xml | 7 + 25 files changed, 4904 insertions(+) create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml new file mode 100644 index 0000000000..41f71c6d5b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -0,0 +1,60 @@ + + + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template + 1.2.196-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.identity.api.server.notification.template.common + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + javax.ws.rs + javax.ws.rs-api + provided + + + org.wso2.carbon.identity.event.handler.notification + org.wso2.carbon.email.mgt + + + org.springframework + spring-web + provided + + + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java new file mode 100644 index 0000000000..11c15e7a9e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.notification.template.common; + +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.core.Response.Status; + +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_ADDING_TEMPLATE; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_UPDATING_TEMPLATE; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_ALREADY_EXISTS; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_NOT_FOUND; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_ALREADY_EXISTS; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_NOT_FOUND; + +/** + * Constants related to notification templates. + */ +public class Constants { + + public static final String NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX = "NTM-"; + public static final String NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL = "/email"; + public static final String NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS = "/sms"; + public static final String NOTIFICATION_TEMPLATES_API_PATH = "/notification"; + public static final String TEMPLATE_TYPES_PATH = "/template-types"; + public static final String APP_TEMPLATES_PATH = "/app-templates"; + public static final String ORG_TEMPLATES_PATH = "/org-templates"; + public static final String PATH_SEPARATOR = "/"; + public static final String NOTIFICATION_CHANNEL_EMAIL = "email"; + public static final String NOTIFICATION_CHANNEL_SMS = "sms"; + + // ERROR MESSAGES + private static final Map NTM_ERROR_CODE_MAP = new HashMap<>(); + + /** + * Enum for error messages. + */ + public enum ErrorMessage { + + ERROR_TEMPLATE_TYPE_ALREADY_EXISTS("65001", Status.CONFLICT, + "Template Type already exists in the system.", + "A template type for the provided template display name already exists " + + "in the system."), + ERROR_TEMPLATE_TYPE_NOT_FOUND("65002", Status.NOT_FOUND, + "Template Type does not exist.", + "Specified template type does not exist in the system."), + ERROR_TEMPLATE_ALREADY_EXISTS("65003", Status.CONFLICT, + "Template already exists in the system.", + "A template for the provided template id already exists in the system."), + ERROR_TEMPLATE_NOT_FOUND("65004", Status.NOT_FOUND, + "Template does not exist.", + "Specified template does not exist in the system."), + ERROR_ERROR_RETRIEVING_TEMPLATE_TYPES("60002", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve template types.", + "Server encountered an error while retrieving template types."), + ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE("60003", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve the template type.", + "Server encountered an error while retrieving the template " + + "type identified by the given template-type-id."), + ERROR_ERROR_ADDING_TEMPLATE_TYPE("60004", Status.INTERNAL_SERVER_ERROR, + "Unable to add the template type.", + "Server encountered an error while adding template type."), + ERROR_ERROR_DELETING_TEMPLATE_TYPE("60005", Status.INTERNAL_SERVER_ERROR, + "Unable to delete the template type.", + "Server encountered an error while deleting the template type."), + ERROR_ERROR_ADDING_TEMPLATE("60006", Status.INTERNAL_SERVER_ERROR, + "Unable to add the template.", + "Server encountered an error while adding the template to the system."), + ERROR_ERROR_UPDATING_TEMPLATE("60007", Status.INTERNAL_SERVER_ERROR, + "Unable to update the template.", + "Server encountered an error while updating the template."), + ERROR_ERROR_RETRIEVING_TEMPLATE("60008", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve the template.", + "Server encountered an error while retrieving the template " + + "identified by the given template-type-id and the template-id."), + ERROR_ERROR_DELETING_EMAIL_TEMPLATE("60009", Status.INTERNAL_SERVER_ERROR, + "Unable to delete the email template.", + "Server encountered an error while deleting the email template."), + ERROR_ERROR_DELETING_SMS_TEMPLATE("60010", Status.INTERNAL_SERVER_ERROR, + "Unable to delete the SMS template.", + "Server encountered an error while deleting the SMS template."); + + private final String message; + private final Status httpStatus; + private final String code; + private final String description; + + ErrorMessage(String code, Status httpStatus, String message, String description) { + + this.code = code; + this.httpStatus = httpStatus; + this.message = message; + this.description = description; + } + + public String getCode() { + + return NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX + code; + } + + public String getMessage() { + + return message; + } + + public String getDescription() { + + return description; + } + + public Status getHttpStatus() { + + return httpStatus; + } + + @Override + public String toString() { + + return code + " | " + message; + } + } + + static { + NTM_ERROR_CODE_MAP.put(TEMPLATE_TYPE_ALREADY_EXISTS, ErrorMessage.ERROR_TEMPLATE_TYPE_ALREADY_EXISTS); + NTM_ERROR_CODE_MAP.put(TEMPLATE_TYPE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + NTM_ERROR_CODE_MAP.put(TEMPLATE_ALREADY_EXISTS, ErrorMessage.ERROR_TEMPLATE_ALREADY_EXISTS); + NTM_ERROR_CODE_MAP.put(TEMPLATE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + NTM_ERROR_CODE_MAP.put(ERROR_ADDING_TEMPLATE, ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + NTM_ERROR_CODE_MAP.put(ERROR_UPDATING_TEMPLATE, ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + + public static ErrorMessage getNTMMappedErrorMessage(String errorCode) { + + return NTM_ERROR_CODE_MAP.get(errorCode); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java new file mode 100644 index 0000000000..60b7d34f8b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java @@ -0,0 +1,28 @@ +package org.wso2.carbon.identity.api.server.notification.template.common; + + +import org.wso2.carbon.identity.governance.service.notification.NotificationTemplateManager; + +/** + * This class is used to hold the TemplateManager service. + */ +public class TemplatesServiceHolder { + + private static NotificationTemplateManager notificationTemplateManager; + + /** + * Get TemplateManager osgi service. + * @return TemplateManager + */ + public static NotificationTemplateManager getNotificationTemplateManager() { + return notificationTemplateManager; + } + + /** + * Set TemplateManager osgi service. + * @param notificationTemplateManager TemplateManager + */ + public static void setNotificationTemplateManager(NotificationTemplateManager notificationTemplateManager) { + TemplatesServiceHolder.notificationTemplateManager = notificationTemplateManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java new file mode 100644 index 0000000000..f2a067ac23 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.notification.template.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.governance.service.notification.NotificationTemplateManager; + +import java.util.Hashtable; + +/** + * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to + * instantiate the NotificationTemplateManager type of object inside the container. + */ +public class OSGIServiceFactory extends AbstractFactoryBean { + + private NotificationTemplateManager notificationTemplateManager; + + @Override + public Class getObjectType() { + return Object.class; + } + + @Override + protected NotificationTemplateManager createInstance() throws Exception { + + if (this.notificationTemplateManager == null) { + Hashtable serviceProperties = new Hashtable<>(); + serviceProperties.put("service.name", "NotificationTemplateManager"); + NotificationTemplateManager taskOperationService = (NotificationTemplateManager) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService(NotificationTemplateManager.class, serviceProperties); + if (taskOperationService != null) { + this.notificationTemplateManager = taskOperationService; + } else { + throw new Exception("Unable to retrieve NotificationTemplateManager service."); + } + } + return this.notificationTemplateManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml new file mode 100644 index 0000000000..0e5584f085 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -0,0 +1,179 @@ + + + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template + 1.2.196-SNAPSHOT + + + 4.0.0 + org.wso2.carbon.identity.rest.api.server.notification.template.v1 + jar + + WSO2 Identity Server - Notification Templates Rest API v1 + WSO2 Identity Server - Notification Templates Rest API v1 + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + org.springframework + spring-web + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.event.handler.notification + org.wso2.carbon.email.mgt + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template.common + + + org.wso2.carbon.identity.governance + org.wso2.carbon.identity.recovery + provided + + + javax.ws.rs + jsr311-api + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + + + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java new file mode 100644 index 0000000000..96bcbbcda0 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -0,0 +1,726 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1; + +import org.springframework.beans.factory.annotation.Autowired; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.io.InputStream; +import java.util.List; + +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.Error; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/notification") +@Api(description = "The notification API") + +public class NotificationApi { + + @Autowired + private NotificationApiService delegate; + + @Valid + @POST + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scopes required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { + + return delegate.addAppEmailTemplate(templateTypeId, appUuid, emailTemplateWithID ); + } + + @Valid + @POST + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new application SMS template to an existing SMS template type.", notes = "Another application SMS template with the same locale should not already exist in the respective SMS template type.
Scopes required:
* internal_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { + + return delegate.addAppSMSTemplate(templateTypeId, appUuid, smSTemplateWithID ); + } + + @Valid + @POST + @Path("/email/template-types") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scopes required:
* internal_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addEmailTemplateType(@ApiParam(value = "Email template type to be added." ) @Valid TemplateTypeOverview templateTypeOverview) { + + return delegate.addEmailTemplateType(templateTypeOverview ); + } + + @Valid + @POST + @Path("/email/template-types/{template-type-id}/org-templates") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scopes required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { + + return delegate.addOrgEmailTemplate(templateTypeId, emailTemplateWithID ); + } + + @Valid + @POST + @Path("/sms/template-types/{template-type-id}/org-templates") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scopes required:
* internal_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { + + return delegate.addOrgSMSTemplate(templateTypeId, smSTemplateWithID ); + } + + @Valid + @POST + @Path("/sms/template-types") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scopes required:
* internal_sms_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be added." ) @Valid TemplateTypeOverview templateTypeOverview) { + + return delegate.addSMSTemplateType(templateTypeOverview ); + } + + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteAppEmailTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteAppSMSTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteEmailTemplateType(templateTypeId ); + } + + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteOrgEmailTemplate(templateTypeId, locale ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an organization SMS template.", notes = "Removes an organization SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteOrgSMSTemplate(templateTypeId, locale ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteSMSTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/email/template-types") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scopes required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAllEmailTemplateTypes() { + + return delegate.getAllEmailTemplateTypes(); + } + + @Valid + @GET + @Path("/sms/template-types") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scopes required:
* internal_sms_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAllSMSTemplateTypes() { + + return delegate.getAllSMSTemplateTypes(); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of application email templates in the template type id.", notes = "Retrieves the list of application email templates in the template type id.
Scope required:
* internal_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + + return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of application SMS templates in the template type id.", notes = "Retrieves the list of application SMS templates in the template type id.
Scope required:
* internal_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + + return delegate.getAppTemplatesListOfSMSTemplateType(templateTypeId, appUuid ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scopes required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getEmailTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getOrgEmailTemplate(templateTypeId, locale ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getOrgSMSTemplate(templateTypeId, locale ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/org-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of organization email templates in the template type id.", notes = "Retrieves the list of organization email templates in the template type id.
Scope required:
* internal_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getOrgTemplatesListOfEmailTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/org-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of organization SMS templates in the template type id.", notes = "Retrieves the list of organization SMS templates in the template type id.
Scope required:
* internal_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getOrgTemplatesListOfSMSTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scopes required:
* internal_sms_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getSMSTemplateType(templateTypeId ); + } + + @Valid + @PUT + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + + return delegate.updateAppEmailTemplate(templateTypeId, appUuid, locale, emailTemplate ); + } + + @Valid + @PUT + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing application SMS template.", notes = "Replaces the application SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid SMSTemplate smSTemplate) { + + return delegate.updateAppSMSTemplate(templateTypeId, appUuid, locale, smSTemplate ); + } + + @Valid + @PUT + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + + return delegate.updateOrgEmailTemplate(templateTypeId, locale, emailTemplate ); + } + + @Valid + @PUT + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing organization SMS template.", notes = "Replaces the organization SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "SMS templates for the template type." ) @Valid SMSTemplate smSTemplate) { + + return delegate.updateOrgSMSTemplate(templateTypeId, locale, smSTemplate ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java new file mode 100644 index 0000000000..3548a1cfce --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1; + +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.*; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.*; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.io.InputStream; +import java.util.List; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.Error; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import javax.ws.rs.core.Response; + + +public interface NotificationApiService { + + public Response addAppEmailTemplate(String templateTypeId, String appUuid, EmailTemplateWithID emailTemplateWithID); + + public Response addAppSMSTemplate(String templateTypeId, String appUuid, SMSTemplateWithID smSTemplateWithID); + + public Response addEmailTemplateType(TemplateTypeOverview templateTypeOverview); + + public Response addOrgEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID); + + public Response addOrgSMSTemplate(String templateTypeId, SMSTemplateWithID smSTemplateWithID); + + public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview); + + public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale); + + public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale); + + public Response deleteEmailTemplateType(String templateTypeId); + + public Response deleteOrgEmailTemplate(String templateTypeId, String locale); + + public Response deleteOrgSMSTemplate(String templateTypeId, String locale); + + public Response deleteSMSTemplateType(String templateTypeId); + + public Response getAllEmailTemplateTypes(); + + public Response getAllSMSTemplateTypes(); + + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale); + + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale); + + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid); + + public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid); + + public Response getEmailTemplateType(String templateTypeId); + + public Response getOrgEmailTemplate(String templateTypeId, String locale); + + public Response getOrgSMSTemplate(String templateTypeId, String locale); + + public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId); + + public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId); + + public Response getSMSTemplateType(String templateTypeId); + + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate); + + public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smSTemplate); + + public Response updateOrgEmailTemplate(String templateTypeId, String locale, EmailTemplate emailTemplate); + + public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smSTemplate); +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java new file mode 100644 index 0000000000..8e708a033b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.factories; + +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.impl.NotificationApiServiceImpl; + +public class NotificationApiServiceFactory { + + private final static NotificationApiService service = new NotificationApiServiceImpl(); + + public static NotificationApiService getNotificationApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java new file mode 100644 index 0000000000..9f0c5e716b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class EmailTemplate { + + private String contentType; + private String subject; + private String body; + private String footer; + + /** + * Content type of the email template. + **/ + public EmailTemplate contentType(String contentType) { + + this.contentType = contentType; + return this; + } + + @ApiModelProperty(example = "text/html", required = true, value = "Content type of the email template.") + @JsonProperty("contentType") + @Valid + @NotNull(message = "Property contentType cannot be null.") + + public String getContentType() { + return contentType; + } + public void setContentType(String contentType) { + this.contentType = contentType; + } + + /** + * The subject of the email. + **/ + public EmailTemplate subject(String subject) { + + this.subject = subject; + return this; + } + + @ApiModelProperty(example = "WSO2 - Account Confirmation", required = true, value = "The subject of the email.") + @JsonProperty("subject") + @Valid + @NotNull(message = "Property subject cannot be null.") + + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + + /** + * The body of the email. + **/ + public EmailTemplate body(String body) { + + this.body = body; + return this; + } + + @ApiModelProperty(example = "HTML Body", required = true, value = "The body of the email.") + @JsonProperty("body") + @Valid + @NotNull(message = "Property body cannot be null.") + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + + /** + * The footer of the email. + **/ + public EmailTemplate footer(String footer) { + + this.footer = footer; + return this; + } + + @ApiModelProperty(example = "WSO2 Identity Server Team", value = "The footer of the email.") + @JsonProperty("footer") + @Valid + public String getFooter() { + return footer; + } + public void setFooter(String footer) { + this.footer = footer; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EmailTemplate emailTemplate = (EmailTemplate) o; + return Objects.equals(this.contentType, emailTemplate.contentType) && + Objects.equals(this.subject, emailTemplate.subject) && + Objects.equals(this.body, emailTemplate.body) && + Objects.equals(this.footer, emailTemplate.footer); + } + + @Override + public int hashCode() { + return Objects.hash(contentType, subject, body, footer); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class EmailTemplate {\n"); + + sb.append(" contentType: ").append(toIndentedString(contentType)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" footer: ").append(toIndentedString(footer)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java new file mode 100644 index 0000000000..758785ca4b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class EmailTemplateWithID extends EmailTemplate { + + private String locale; + + /** + * Locale of the email template. + **/ + public EmailTemplateWithID locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US", required = true, value = "Locale of the email template.") + @JsonProperty("locale") + @Valid + @NotNull(message = "Property locale cannot be null.") + + public String getLocale() { + return locale; + } + public void setLocale(String locale) { + this.locale = locale; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + EmailTemplateWithID emailTemplateWithID = (EmailTemplateWithID) o; + return Objects.equals(this.locale, emailTemplateWithID.locale); + } + + @Override + public int hashCode() { + return Objects.hash(locale); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class EmailTemplateWithID {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java new file mode 100644 index 0000000000..2ae19eb2ca --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "NTM-50000", required = true, value = "") + @JsonProperty("code") + @Valid + @NotNull(message = "Property code cannot be null.") + + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some Error Message", required = true, value = "") + @JsonProperty("message") + @Valid + @NotNull(message = "Property message cannot be null.") + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some Error Description", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "TR0001", value = "") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.traceId, error.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java new file mode 100644 index 0000000000..788fce7c25 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SMSTemplate { + + private String body; + + /** + * The body of the SMS. + **/ + public SMSTemplate body(String body) { + + this.body = body; + return this; + } + + @ApiModelProperty(example = "SMS Body", required = true, value = "The body of the SMS.") + @JsonProperty("body") + @Valid + @NotNull(message = "Property body cannot be null.") + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SMSTemplate smSTemplate = (SMSTemplate) o; + return Objects.equals(this.body, smSTemplate.body); + } + + @Override + public int hashCode() { + return Objects.hash(body); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SMSTemplate {\n"); + + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java new file mode 100644 index 0000000000..406165c35e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SMSTemplateWithID extends SMSTemplate { + + private String locale; + + /** + * Locale of the SMS template. + **/ + public SMSTemplateWithID locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US", required = true, value = "Locale of the SMS template.") + @JsonProperty("locale") + @Valid + @NotNull(message = "Property locale cannot be null.") + + public String getLocale() { + return locale; + } + public void setLocale(String locale) { + this.locale = locale; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + SMSTemplateWithID smSTemplateWithID = (SMSTemplateWithID) o; + return Objects.equals(this.locale, smSTemplateWithID.locale); + } + + @Override + public int hashCode() { + return Objects.hash(locale); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SMSTemplateWithID {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java new file mode 100644 index 0000000000..e47e891a59 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SimpleTemplate { + + private String locale; + private String self; + + /** + * Locale of the template. + **/ + public SimpleTemplate locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US", required = true, value = "Locale of the template.") + @JsonProperty("locale") + @Valid + @NotNull(message = "Property locale cannot be null.") + + public String getLocale() { + return locale; + } + public void setLocale(String locale) { + this.locale = locale; + } + + /** + * Location of the created/updated resource. + **/ + public SimpleTemplate self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US", required = true, value = "Location of the created/updated resource.") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SimpleTemplate simpleTemplate = (SimpleTemplate) o; + return Objects.equals(this.locale, simpleTemplate.locale) && + Objects.equals(this.self, simpleTemplate.self); + } + + @Override + public int hashCode() { + return Objects.hash(locale, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SimpleTemplate {\n"); + + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java new file mode 100644 index 0000000000..a054eb72c2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class TemplateType { + + private String displayName; + private String self; + + /** + * Display name of the email template type. + **/ + public TemplateType displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Account Confirmation", required = true, value = "Display name of the email template type.") + @JsonProperty("displayName") + @Valid + @NotNull(message = "Property displayName cannot be null.") + + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Location of the created/updated resource. + **/ + public TemplateType self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/email/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Location of the created/updated resource.") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateType templateType = (TemplateType) o; + return Objects.equals(this.displayName, templateType.displayName) && + Objects.equals(this.self, templateType.self); + } + + @Override + public int hashCode() { + return Objects.hash(displayName, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateType {\n"); + + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java new file mode 100644 index 0000000000..1b60b13fbc --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class TemplateTypeOverview { + + private String displayName; + + /** + * Display name of the template type. + **/ + public TemplateTypeOverview displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Account Confirmation", required = true, value = "Display name of the template type.") + @JsonProperty("displayName") + @Valid + @NotNull(message = "Property displayName cannot be null.") + + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateTypeOverview templateTypeOverview = (TemplateTypeOverview) o; + return Objects.equals(this.displayName, templateTypeOverview.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateTypeOverview {\n"); + + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java new file mode 100644 index 0000000000..dccfb2930f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateType; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class TemplateTypeWithID extends TemplateType { + + private String id; + + /** + * Unique ID of the template type. + **/ + public TemplateTypeWithID id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Unique ID of the template type.") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + TemplateTypeWithID templateTypeWithID = (TemplateTypeWithID) o; + return Objects.equals(this.id, templateTypeWithID.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateTypeWithID {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java new file mode 100644 index 0000000000..8609987e86 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; + +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.governance.model.NotificationTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; + +import java.util.List; + +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; + +/** + * Service class for application email templates. + */ +public class ApplicationTemplatesService { + + /** + * Adds a new organization email template to the given template type. Template ID should not exist in the system. + * + * @param templateTypeId Template type in which the template should be added. + * @param emailTemplateWithID New email template. + * @return Location of the newly created template if successful, 409 if template already exists, 500 otherwise. + */ + public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID) { + + SimpleTemplate simpleTemplate = addEmailTemplate(templateTypeId, emailTemplateWithID, null); + simpleTemplate.setSelf(getOrgTemplateLocation(templateTypeId, emailTemplateWithID.getLocale(), + Constants.NOTIFICATION_CHANNEL_EMAIL)); + return simpleTemplate; + } + + /** + * Adds a new application email template to the given template type. Template ID should not exist in the system. + * + * @param templateTypeId Template type in which the template should be added. + * @param emailTemplateWithID New email template. + * @param applicationUuid Application UUID. + * @return Location of the newly created template if successful, 409 if template already exists, 500 otherwise. + */ + public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID, + String applicationUuid) { + + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithEmailTemplateWithID( + templateTypeId, emailTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + + // Create and send the location of the created object as the response. + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); + simpleEmailTemplate.setSelf(getApplicationTemplateLocation(templateTypeId, applicationUuid, + notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_EMAIL)); + simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); + return simpleEmailTemplate; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + } + } + + /** + * Adds a new organization SMS template to the given template type. Template ID should not exist in the system. + * + * @param templateTypeId Template type in which the template should be added. + * @param smsTemplateWithID New SMS template. + * @return Location of the newly created template if successful, 409 if template already exists, 500 otherwise. + */ + public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID smsTemplateWithID) { + + SimpleTemplate simpleTemplate = addSMSTemplate(templateTypeId, smsTemplateWithID, null); + simpleTemplate.setSelf(getOrgTemplateLocation(templateTypeId, smsTemplateWithID.getLocale(), + Constants.NOTIFICATION_CHANNEL_SMS)); + return simpleTemplate; + } + + /** + * Adds a new application SMS template to the given template type. Template ID should not exist in the system. + * + * @param templateTypeId Template type in which the template should be added. + * @param smsTemplateWithID New SMS template. + * @param applicationUuid Application UUID. + * @return Location of the newly created template if successful, 409 if template already exists, 500 otherwise. + */ + public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID smsTemplateWithID, + String applicationUuid) { + + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithSMSTemplateWithID( + templateTypeId, smsTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + + // Create and send the location of the created object as the response. + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); + simpleEmailTemplate.setSelf(getApplicationTemplateLocation(templateTypeId, applicationUuid, + notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_SMS)); + simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); + return simpleEmailTemplate; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + } + } + + /** + * Retrieves the list of organization email templates of the given template type. + * + * @param templateTypeId Template type ID. + * @return List of email templates. + */ + public List getTemplatesListOfEmailTemplateType(String templateTypeId) { + + return getTemplatesListOfEmailTemplateType(templateTypeId, null); + } + + /** + * Retrieves the list of application email templates of the given template type. + * + * @param templateTypeId Template type ID. + * @param applicationUuid Application UUID. + * @return List of email templates. + */ + public List getTemplatesListOfEmailTemplateType(String templateTypeId, + String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + List emailTemplates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + getTenantDomainFromContext(), applicationUuid); + return Util.buildEmailTemplateWithIDList(emailTemplates); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + /** + * Retrieves the list of organization SMS templates of the given template type. + * + * @param templateTypeId Template type ID. + * @return List of SMS templates. + */ + public List getTemplatesListOfSMSTemplateType(String templateTypeId) { + + return getTemplatesListOfSMSTemplateType(templateTypeId, null); + } + + /** + * Retrieves the list of application SMS templates of the given template type. + * + * @param templateTypeId Template type ID. + * @param applicationUuid Application UUID. + * @return List of SMS templates. + */ + public List getTemplatesListOfSMSTemplateType(String templateTypeId, + String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + List smsTemplates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, + getTenantDomainFromContext(), applicationUuid); + return Util.buildSMSTemplateWithIDList(smsTemplates); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + /** + * Retrieves the organization email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @return Email template. + */ + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId) { + + return getEmailTemplate(templateTypeId, templateId, null); + } + + /** + * Retrieves the application email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param applicationUuid Application UUID. + * @return Email template. + */ + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, templateId, + getTenantDomainFromContext(), applicationUuid); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalEmailTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildEmailTemplateWithID(internalEmailTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + /** + * Retrieves the organization SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @return SMS template. + */ + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId) { + + return getSMSTemplate(templateTypeId, templateId, null); + } + + /** + * Retrieves the application SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param applicationUuid Application UUID. + * @return SMS template. + */ + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, String applicationUuid) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, templateId, + getTenantDomainFromContext(), applicationUuid); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalEmailTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildSMSTemplateWithID(internalEmailTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + /** + * Updates the organization email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param emailTemplate Updated email template. + */ + public void updateEmailTemplate(String templateTypeId, String templateId, EmailTemplate emailTemplate) { + + updateEmailTemplate(templateTypeId, templateId, emailTemplate, null); + } + + /** + * Updates the application email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param emailTemplate Updated email template. + * @param applicationUuid Application UUID. + */ + public void updateEmailTemplate(String templateTypeId, String templateId, EmailTemplate emailTemplate, + String applicationUuid) { + + EmailTemplateWithID emailTemplateWithID = + Util.buildEmailTemplateWithIdUsingEmailTemplate(emailTemplate, templateId); + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithEmailTemplateWithID( + templateTypeId, emailTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().updateNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + } + + /** + * Updates the organization SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param smsTemplate Updated SMS template. + */ + public void updateSMSTemplate(String templateTypeId, String templateId, SMSTemplate smsTemplate) { + + updateSMSTemplate(templateTypeId, templateId, smsTemplate, null); + } + + /** + * Updates the application SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param smsTemplate Updated SMS template. + * @param applicationUuid Application UUID. + */ + public void updateSMSTemplate(String templateTypeId, String templateId, SMSTemplate smsTemplate, + String applicationUuid) { + + SMSTemplateWithID smsTemplateWithID = + Util.buildSMSTemplateWithIdUsingSMSTemplate(smsTemplate, templateId); + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithSMSTemplateWithID( + templateTypeId, smsTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().updateNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + } + + /** + * Deletes the organization email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param locale Template locale. + */ + public void deleteEmailTemplate(String templateTypeId, String locale) { + + deleteEmailTemplate(templateTypeId, locale, null); + } + + /** + * Deletes the application email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param locale Template locale. + * @param applicationUuid Application UUID. + */ + public void deleteEmailTemplate(String templateTypeId, String locale, String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName); + boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + locale, getTenantDomainFromContext(), applicationUuid); + if (notificationTemplateExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplate( + Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, locale, + getTenantDomainFromContext(), applicationUuid); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_EMAIL_TEMPLATE); + } + } + + /** + * Deletes the organization SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param locale Template ID. + */ + public void deleteSMSTemplate(String templateTypeId, String locale) { + + deleteSMSTemplate(templateTypeId, locale, null); + } + + /** + * Deletes the application SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param locale Template ID. + * @param applicationUuid Application UUID. + */ + public void deleteSMSTemplate(String templateTypeId, String locale, String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName); + boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, + locale, getTenantDomainFromContext(), applicationUuid); + if (notificationTemplateExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplate( + Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, locale, + getTenantDomainFromContext(), applicationUuid); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_SMS_TEMPLATE); + } + } + + private String getApplicationTemplateLocation(String templateTypeId, String applicationUuid, String locale, + String notificationType) { + + String templateLocation = Util.getTemplateTypeLocation(templateTypeId, notificationType); + return templateLocation + APP_TEMPLATES_PATH + PATH_SEPARATOR + applicationUuid + + PATH_SEPARATOR + locale; + } + + private String getOrgTemplateLocation(String templateTypeId, String templateId, String type) { + + String templateLocation = Util.getTemplateTypeLocation(templateTypeId, type); + return templateLocation + Constants.ORG_TEMPLATES_PATH + Constants.PATH_SEPARATOR + templateId; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java new file mode 100644 index 0000000000..68222e22b3 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; + +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; + +import java.util.ArrayList; +import java.util.List; + +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util.getTemplateTypeLocation; + +/** + * Service class for the template types. + */ +public class TemplateTypeService { + + /** + * Add a new template type for a given channel. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateTypeOverview Template type overview. + * @return TemplateTypeWithID object. + */ + public TemplateTypeWithID addNotificationTemplateType(String notificationChannel, + TemplateTypeOverview templateTypeOverview) { + + String templateTypeDisplayName = templateTypeOverview.getDisplayName(); + try { + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplateType(notificationChannel, + templateTypeDisplayName, getTenantDomainFromContext()); + // Build a response object and send if everything is successful. + TemplateTypeWithID response = new TemplateTypeWithID(); + response.setDisplayName(templateTypeDisplayName); + String templateTypeId = Util.resolveTemplateIdFromDisplayName(templateTypeDisplayName); + response.setId(templateTypeId); + response.setSelf(getTemplateTypeLocation(templateTypeId, notificationChannel)); + return response; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE_TYPE); + } + } + + /** + * Get all available notification template types for a notification chanel in the tenant. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @return List of TemplateTypeWithID objects. + */ + public List getAllNotificationTemplateTypes(String notificationChannel) { + + try { + List templateTypes = TemplatesServiceHolder.getNotificationTemplateManager() + .getAllNotificationTemplateTypes(notificationChannel, getTenantDomainFromContext()); + List templateTypeWithIDs = new ArrayList<>(); + if (templateTypes != null) { + for (String emailTemplateType : templateTypes) { + TemplateTypeWithID templateTypeWithID = new TemplateTypeWithID(); + templateTypeWithID.setDisplayName(emailTemplateType); + String templateTypeId = Util.resolveTemplateIdFromDisplayName(emailTemplateType); + templateTypeWithID.setId(templateTypeId); + templateTypeWithID.setSelf( + getTemplateTypeLocation(templateTypeId, notificationChannel)); + templateTypeWithIDs.add(templateTypeWithID); + } + } + return templateTypeWithIDs; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPES); + } + } + + /** + * Delete a notification template type from the tenant. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateId ID of the template type. + */ + public void deleteNotificationTemplateType(String notificationChannel, String templateId) { + + String templateTypeDisplayName; + try { + templateTypeDisplayName = Util.decodeTemplateTypeId(templateId); + } catch (APIError e) { + // Ignoring the delete operation and return 204 response code, since the resource does not exist. + return; + } + try { + boolean isTemplateTypeExists = + TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + if (isTemplateTypeExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplateType( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); + } + } + + /** + * Get a specific notification template type. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateTypeId ID of the template type. + * @return TemplateTypeWithID object. + */ + public TemplateTypeWithID getNotificationTemplateType(String notificationChannel, + String templateTypeId) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + boolean isTemplateTypeExists = + TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + if (isTemplateTypeExists) { + TemplateTypeWithID templateTypeWithID = new TemplateTypeWithID(); + templateTypeWithID.setDisplayName(templateTypeDisplayName); + templateTypeWithID.setId(templateTypeId); + templateTypeWithID.setSelf(getTemplateTypeLocation(templateTypeId, notificationChannel)); + return templateTypeWithID; + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java new file mode 100644 index 0000000000..24d96d2791 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.impl; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.ApplicationTemplatesService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplateTypeService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; + +import java.net.URI; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; +import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForHeader; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common. + Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common. + Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; +import static org.wso2.carbon.identity.api.server.notification.template.common. + Constants.NOTIFICATION_TEMPLATES_API_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.ORG_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.TEMPLATE_TYPES_PATH; + +/** + * This is the service implementation class for notification template management related operations. + */ +public class NotificationApiServiceImpl implements NotificationApiService { + + @Autowired + private ApplicationTemplatesService applicationTemplatesService; + @Autowired + private TemplateTypeService templateTypeService; + + @Override + public Response addAppEmailTemplate(String templateTypeId, String appUuid, + EmailTemplateWithID emailTemplateWithID) { + + SimpleTemplate simpleEmailTemplate = applicationTemplatesService.addEmailTemplate(templateTypeId, + emailTemplateWithID, appUuid); + URI headerLocation = buildURIForHeader(V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + TEMPLATE_TYPES_PATH + PATH_SEPARATOR + + templateTypeId + APP_TEMPLATES_PATH + PATH_SEPARATOR + appUuid + PATH_SEPARATOR + + simpleEmailTemplate.getLocale()); + return Response.created(headerLocation).entity(simpleEmailTemplate).build(); + } + + @Override + public Response addAppSMSTemplate(String templateTypeId, String appUuid, SMSTemplateWithID smSTemplateWithID) { + + SimpleTemplate simpleSMSTemplate = applicationTemplatesService.addSMSTemplate(templateTypeId, + smSTemplateWithID, appUuid); + URI headerLocation = buildURIForHeader(V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + TEMPLATE_TYPES_PATH + PATH_SEPARATOR + + templateTypeId + APP_TEMPLATES_PATH + PATH_SEPARATOR + appUuid + PATH_SEPARATOR + + smSTemplateWithID.getLocale()); + return Response.created(headerLocation).entity(simpleSMSTemplate).build(); + } + + @Override + public Response addEmailTemplateType(TemplateTypeOverview templateTypeOverview) { + + TemplateTypeWithID templateType = templateTypeService + .addNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeOverview); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + TEMPLATE_TYPES_PATH + + PATH_SEPARATOR + templateType.getId()); + return Response.created(headerLocation).entity(templateType).build(); + } + + @Override + public Response addOrgEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID) { + + SimpleTemplate simpleEmailTemplate = applicationTemplatesService.addEmailTemplate(templateTypeId, + emailTemplateWithID); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + PATH_SEPARATOR + templateTypeId + + ORG_TEMPLATES_PATH + PATH_SEPARATOR + simpleEmailTemplate.getLocale()); + return Response.created(headerLocation).entity(simpleEmailTemplate).build(); + } + + @Override + public Response addOrgSMSTemplate(String templateTypeId, SMSTemplateWithID smSTemplateWithID) { + + SimpleTemplate simpleSMSTemplate = applicationTemplatesService.addSMSTemplate(templateTypeId, + smSTemplateWithID); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + PATH_SEPARATOR + templateTypeId + + ORG_TEMPLATES_PATH + PATH_SEPARATOR + simpleSMSTemplate.getLocale()); + return Response.created(headerLocation).entity(simpleSMSTemplate).build(); + } + + @Override + public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview) { + + TemplateTypeWithID templateType = templateTypeService + .addNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeOverview); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + TEMPLATE_TYPES_PATH + + PATH_SEPARATOR + templateType.getId()); + return Response.created(headerLocation).entity(templateType).build(); + } + + @Override + public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + + applicationTemplatesService.deleteEmailTemplate(templateTypeId, locale, appUuid); + return Response.noContent().build(); + } + + @Override + public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + + applicationTemplatesService.deleteSMSTemplate(templateTypeId, locale, appUuid); + return Response.noContent().build(); + } + + @Override + public Response deleteEmailTemplateType(String templateTypeId) { + + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId); + return Response.noContent().build(); + } + + @Override + public Response deleteOrgEmailTemplate(String templateTypeId, String locale) { + + applicationTemplatesService.deleteEmailTemplate(templateTypeId, locale); + return Response.noContent().build(); + } + + @Override + public Response deleteOrgSMSTemplate(String templateTypeId, String locale) { + + applicationTemplatesService.deleteSMSTemplate(templateTypeId, locale); + return Response.noContent().build(); + } + + @Override + public Response deleteSMSTemplateType(String templateTypeId) { + + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeId); + return Response.noContent().build(); + } + + @Override + public Response getAllEmailTemplateTypes() { + + return Response.ok().entity(templateTypeService + .getAllNotificationTemplateTypes(Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + } + + @Override + public Response getAllSMSTemplateTypes() { + + return Response.ok().entity(templateTypeService + .getAllNotificationTemplateTypes(Constants.NOTIFICATION_CHANNEL_SMS)).build(); + } + + @Override + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + + return Response.ok().entity(applicationTemplatesService.getEmailTemplate(templateTypeId, locale, appUuid)) + .build(); + } + + @Override + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + + return Response.ok().entity(applicationTemplatesService.getSMSTemplate(templateTypeId, locale, appUuid)) + .build(); + } + + @Override + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid) { + + return Response.ok().entity( + applicationTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid)).build(); + } + + @Override + public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid) { + + return Response.ok().entity( + applicationTemplatesService.getTemplatesListOfSMSTemplateType(templateTypeId, appUuid)).build(); + } + + @Override + public Response getEmailTemplateType(String templateTypeId) { + + return Response.ok().entity(templateTypeService.getNotificationTemplateType( + Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId)).build(); + } + + @Override + public Response getOrgEmailTemplate(String templateTypeId, String locale) { + + return Response.ok().entity(applicationTemplatesService.getEmailTemplate(templateTypeId, locale)).build(); + } + + @Override + public Response getOrgSMSTemplate(String templateTypeId, String locale) { + + return Response.ok().entity(applicationTemplatesService.getSMSTemplate(templateTypeId, locale)).build(); + } + + @Override + public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId) { + + return Response.ok().entity(applicationTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId)) + .build(); + } + + @Override + public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId) { + + return Response.ok().entity(applicationTemplatesService.getTemplatesListOfSMSTemplateType(templateTypeId)) + .build(); + } + + @Override + public Response getSMSTemplateType(String templateTypeId) { + + return Response.ok().entity(templateTypeService.getNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, + templateTypeId)).build(); + } + + @Override + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, + EmailTemplate emailTemplate) { + + applicationTemplatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate, appUuid); + return Response.ok().build(); + } + + @Override + public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, + SMSTemplate smsTemplate) { + + applicationTemplatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); + return Response.ok().build(); + } + + @Override + public Response updateOrgEmailTemplate(String templateTypeId, String locale, + EmailTemplate emailTemplate) { + + applicationTemplatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate); + return Response.ok().build(); + } + + @Override + public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smsTemplate) { + + applicationTemplatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate); + return Response.ok().build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java new file mode 100644 index 0000000000..83f15392f6 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.email.mgt.util.I18nEmailUtil; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerClientException; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerServerException; +import org.wso2.carbon.identity.governance.model.NotificationTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.api.server.common.Util.base64URLDecode; +import static org.wso2.carbon.identity.api.server.common.Util.base64URLEncode; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.TEMPLATE_TYPES_PATH; + +/** + * Utility class for notification templates API + */ +public class Util { + + private static final Log log = LogFactory.getLog(Util.class); + + private static final String ERROR_CODE_DELIMITER = "-"; + + /** + * Converts a list of EmailTemplate objects to a list of NotificationTemplate objects. + * + * @param emailTemplates List of EmailTemplate objects. + * @return List of EmailTemplateWithID objects. + */ + public static List buildEmailTemplateWithIDList(List emailTemplates) { + + List emailTemplateWithIDs = new ArrayList<>(); + if (emailTemplates != null) { + for (NotificationTemplate emailTemplate : emailTemplates) { + EmailTemplateWithID emailTemplateWithID = new EmailTemplateWithID(); + emailTemplateWithID.setLocale(emailTemplate.getLocale()); + emailTemplateWithID.setContentType(emailTemplate.getContentType()); + emailTemplateWithID.setSubject(emailTemplate.getSubject()); + emailTemplateWithID.setBody(emailTemplate.getBody()); + emailTemplateWithID.setFooter(emailTemplate.getFooter()); + emailTemplateWithIDs.add(emailTemplateWithID); + } + } + return emailTemplateWithIDs; + } + + /** + * Converts a list of SMSTemplate objects to a list of SMSTemplateWithID objects. + * + * @param smsTemplates List of SMSTemplate objects. + * @return List of SMSTemplateWithID objects. + */ + public static List buildSMSTemplateWithIDList(List smsTemplates) { + + List smsTemplateWithIDs = new ArrayList<>(); + if (smsTemplates != null) { + for (NotificationTemplate smsTemplate : smsTemplates) { + SMSTemplateWithID emailTemplateWithID = new SMSTemplateWithID(); + emailTemplateWithID.setLocale(smsTemplate.getLocale()); + emailTemplateWithID.setBody(smsTemplate.getBody()); + smsTemplateWithIDs.add(emailTemplateWithID); + } + } + return smsTemplateWithIDs; + } + + /** + * Resolves templateID using the templateTypeDisplayName. + * + * @param templateTypeDisplayName Display name of the template type. + * @return templateID. + */ + public static String resolveTemplateIdFromDisplayName(String templateTypeDisplayName) { + + return base64URLEncode(templateTypeDisplayName); + } + + /** + * Decodes the template type ID. + * + * @param encodedTemplateTypeId Encoded template type ID. + * @return Decoded template type ID. + */ + public static String decodeTemplateTypeId(String encodedTemplateTypeId) { + + try { + return base64URLDecode(encodedTemplateTypeId); + } catch (Throwable e) { + throw handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } + + /** + * Handles the error and returns an APIError object. + * + * @param error Error message. + * @return APIError object. + */ + public static APIError handleError(Constants.ErrorMessage error) { + + return new APIError(error.getHttpStatus(), getErrorBuilder(error).build()); + } + + /** + * Handles the I18nEmailMgtException and returns an APIError object. + * + * @param exception I18nEmailMgtException. + * @param errorEnum Error message. + * @return APIError object. + */ + public static APIError handleNotificationTemplateManagerException(NotificationTemplateManagerException exception, + Constants.ErrorMessage errorEnum) { + + ErrorResponse errorResponse; + Response.Status status; + String errorCode = extractErrorCode(exception.getErrorCode()); + if (exception instanceof NotificationTemplateManagerServerException + && Constants.getNTMMappedErrorMessage(errorCode) != null) { + // Specific error with code is found. + Constants.ErrorMessage errorMessage = Constants.getNTMMappedErrorMessage(errorCode); + errorResponse = getErrorBuilder(errorMessage).build(log, exception, errorEnum.getDescription()); + status = errorMessage.getHttpStatus(); + } else if (exception instanceof NotificationTemplateManagerClientException) { + // Send client error with original exception message. + errorResponse = getErrorBuilder(errorEnum).build(log, exception.getMessage()); + errorResponse.setDescription(exception.getMessage()); + status = Response.Status.BAD_REQUEST; + } else { + // Server error + errorResponse = getErrorBuilder(errorEnum).build(log, exception, errorEnum.getDescription()); + status = Response.Status.INTERNAL_SERVER_ERROR; + } + return new APIError(status, errorResponse); + } + + /** + * Builds EmailTemplateWithID using NotificationTemplate. + * + * @param internalTemplate NotificationTemplate object. + * @return EmailTemplateWithID object. + */ + public static EmailTemplateWithID buildEmailTemplateWithID(NotificationTemplate internalTemplate) { + + EmailTemplateWithID templateWithID = new EmailTemplateWithID(); + templateWithID.setLocale(internalTemplate.getLocale()); + templateWithID.setContentType(internalTemplate.getContentType()); + templateWithID.setSubject(internalTemplate.getSubject()); + templateWithID.setBody(internalTemplate.getBody()); + templateWithID.setFooter(internalTemplate.getFooter()); + return templateWithID; + } + + /** + * Builds SMSTemplateWithID using NotificationTemplate. + * + * @param internalTemplate NotificationTemplate object. + * @return SMSTemplateWithID object. + */ + public static SMSTemplateWithID buildSMSTemplateWithID(NotificationTemplate internalTemplate) { + + SMSTemplateWithID templateWithID = new SMSTemplateWithID(); + templateWithID.setLocale(internalTemplate.getLocale()); + templateWithID.setBody(internalTemplate.getBody()); + return templateWithID; + } + + /** + * Builds NotificationTemplate object using SMSTemplateWithID object. + * @param templateTypeId Template type ID. + * @param smsTemplateWithID SMSTemplateWithID Object. + * @return NotificationTemplate object built using provided values. + */ + public static NotificationTemplate buildNotificationTemplateWithSMSTemplateWithID(String templateTypeId, + SMSTemplateWithID smsTemplateWithID) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate notificationTemplate = new NotificationTemplate(); + notificationTemplate.setNotificationChannel(Constants.NOTIFICATION_CHANNEL_SMS); + notificationTemplate.setLocale(smsTemplateWithID.getLocale()); + notificationTemplate.setBody(smsTemplateWithID.getBody()); + notificationTemplate.setDisplayName(templateTypeDisplayName); + notificationTemplate.setLocale(smsTemplateWithID.getLocale()); + notificationTemplate.setType(I18nEmailUtil.getNormalizedName(templateTypeDisplayName)); + return notificationTemplate; + } + + /** + * Builds NotificationTemplate object using EmailTemplateWithID object. + * @param templateTypeId Template type ID. + * @param emailTemplateWithID EmailTemplateWithID Object. + * @return NotificationTemplate object built using provided values. + */ + public static NotificationTemplate buildNotificationTemplateWithEmailTemplateWithID(String templateTypeId, + EmailTemplateWithID emailTemplateWithID) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate notificationTemplate = new NotificationTemplate(); + notificationTemplate.setNotificationChannel(Constants.NOTIFICATION_CHANNEL_EMAIL); + notificationTemplate.setLocale(emailTemplateWithID.getLocale()); + notificationTemplate.setBody(emailTemplateWithID.getBody()); + notificationTemplate.setDisplayName(templateTypeDisplayName); + notificationTemplate.setLocale(emailTemplateWithID.getLocale()); + notificationTemplate.setType(I18nEmailUtil.getNormalizedName(templateTypeDisplayName)); + notificationTemplate.setSubject(emailTemplateWithID.getSubject()); + notificationTemplate.setFooter(emailTemplateWithID.getFooter()); + notificationTemplate.setContentType(emailTemplateWithID.getContentType()); + return notificationTemplate; + } + + /** + * Asserts the existence of the template type. + * + * @param notificationChannel Notification channel. + * @param templateTypeDisplayName Template type display name. + */ + public static void assertTemplateTypeExistence(String notificationChannel, String templateTypeDisplayName) { + + try { + boolean isTemplateTypeExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateTypeExists(notificationChannel, templateTypeDisplayName, + getTenantDomainFromContext()); + if (!isTemplateTypeExists) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + /** + * Builds the location of the template type. + * + * @param templateTypeId Template type ID. + * @param templateType Notification channel type. + * @return Location of the template. + */ + public static String getTemplateTypeLocation(String templateTypeId, String templateType) { + + String templateTypePath; + // Only EMAIL and SMS are passed as the type. So, no need to check for other types. + if (templateType.equals(NOTIFICATION_CHANNEL_EMAIL)) { + templateTypePath = NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; + } else { + templateTypePath = NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; + } + String location = V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + templateTypePath + + TEMPLATE_TYPES_PATH + PATH_SEPARATOR + templateTypeId; + return ContextLoader.buildURIForBody(location).toString(); + } + + /** + * Generates EmailTemplateWithID using provided values. + * + * @param emailTemplate EmailTemplate object. + * @param locale Locale. + * @return EmailTemplateWithID object. + */ + public static EmailTemplateWithID buildEmailTemplateWithIdUsingEmailTemplate( + org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate emailTemplate, + String locale) { + EmailTemplateWithID emailTemplateWithID = new EmailTemplateWithID(); + emailTemplateWithID.setLocale(locale); + emailTemplateWithID.setContentType(emailTemplate.getContentType()); + emailTemplateWithID.setSubject(emailTemplate.getSubject()); + emailTemplateWithID.setBody(emailTemplate.getBody()); + emailTemplateWithID.setFooter(emailTemplate.getFooter()); + return emailTemplateWithID; + } + + /** + * Generates SMSTemplateWithID using provided values. + * + * @param smsTemplate SMSTemplate object. + * @param locale Locale. + * @return SMSTemplateWithID object. + */ + public static SMSTemplateWithID buildSMSTemplateWithIdUsingSMSTemplate( + org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate smsTemplate, + String locale) { + + SMSTemplateWithID smsTemplateWithID = new SMSTemplateWithID(); + smsTemplateWithID.setLocale(locale); + smsTemplateWithID.setBody(smsTemplate.getBody()); + return smsTemplateWithID; + } + + private static ErrorResponse.Builder getErrorBuilder(Constants.ErrorMessage errorMsg) { + + return new ErrorResponse.Builder().withCode(errorMsg.getCode()). + withMessage(errorMsg.getMessage()).withDescription(errorMsg.getDescription()); + } + + private static String extractErrorCode(String errorCodeWithScenario) { + + return errorCodeWithScenario.split(ERROR_CODE_DELIMITER)[1]; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml new file mode 100644 index 0000000000..35e871860e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml new file mode 100644 index 0000000000..acfbddea99 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -0,0 +1,1178 @@ +openapi: 3.0.0 +info: + title: "WSO2 Identity Server - Notification Template API" + version: 1.0.0 + description: >- + This is the RESTful API for managing notification templates inWSO2 Identity + Server. This API allows adding, retrieving, replacing, and removing email + templates and template types. +tags: + - name: Email Template Types + description: An email template type can have multiple email templates for different languages. + - name: Email Templates + description: An email template of a specific type and a language. + - name: Application Email Templates + description: An application email template of a specific type and a language. + - name: SMS Template Types + description: An sms template type can have multiple sms templates for different languages. + - name: SMS Templates + description: An SMS template of a specific type and a language. + - name: Application SMS Templates + description: An application email template of a specific type and a language. +security: + - OAuth2: [] + - BasicAuth: [] +paths: + /notification/email/template-types: + get: + tags: + - Email Template Types + summary: Retrieves all the email template types. + operationId: getAllEmailTemplateTypes + description: | + Retrieves all the email template types in the system.
+ +
+ Scopes required: +
* internal_email_mgt_view + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Email Template Types + summary: Adds a new email template type. + operationId: addEmailTemplateType + description: | + Adds a new email template type to the system. An email template type can have any number of + organization or application email templates.
+ + * Attribute _**displayName**_ of the template type should be unique.
+ + Scopes required: +
* internal_email_mgt_create + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateTypeOverview' + description: Email template type to be added. + responses: + '201': + description: Item Created + headers: + self: + description: Location of the newly created email template type. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}': + get: + tags: + - Email Template Types + summary: Retrieves the email template type corresponding to the template type id. + operationId: getEmailTemplateType + description: | + Retrieves the email template type in the system identified by the template-type-id.
+ + Scopes required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Email Template Types + summary: Removes an email template type. + operationId: deleteEmailTemplateType + description: | + Removes an existing email template type with all its email templates + from the system.
+ + Scopes required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/org-templates': + get: + tags: + - Email Templates + summary: Retrieves the list of organization email templates in the template type id. + operationId: getOrgTemplatesListOfEmailTemplateType + description: | + Retrieves the list of organization email templates in the template type id.
+ + Scope required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Email Templates + summary: Adds a new email template to an existing email template type. + operationId: addOrgEmailTemplate + description: | + Another email template with the same locale should not already exist in the + respective email template type.
+ + Scopes required:
* internal_email_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + description: Email template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created email template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}': + get: + tags: + - Application Email Templates + summary: Retrieves the list of application email templates in the template type id. + operationId: getAppTemplatesListOfEmailTemplateType + description: | + Retrieves the list of application email templates in the template type id.
+ + Scope required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Application Email Templates + summary: Adds a new application email template to an existing email template type. + operationId: addAppEmailTemplate + description: | + Another application email template with the same locale should not already exist in the + respective email template type.
+ + Scopes required:
* internal_email_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + description: Email template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created email template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/org-templates/{locale}': + get: + tags: + - Email Templates + summary: Retrieves a single email template. + operationId: getOrgEmailTemplate + description: | + Retrieves the email template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_email_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - Email Templates + summary: Replaces an existing email template. + operationId: updateOrgEmailTemplate + description: | + Replaces the email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplate' + description: Email templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Email Templates + summary: Removes an email template. + operationId: deleteOrgEmailTemplate + description: | + Removes an email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}': + get: + tags: + - Application Email Templates + summary: Retrieves a single email template of application. + operationId: getAppEmailTemplate + description: | + Retrieves the application email template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_email_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - Application Email Templates + summary: Replaces an existing application email template. + operationId: updateAppEmailTemplate + description: | + Replaces the application email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplate' + description: Email templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Application Email Templates + summary: Removes an email template. + operationId: deleteAppEmailTemplate + description: | + Removes an email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + /notification/sms/template-types: + get: + tags: + - SMS Template Types + summary: Retrieves all the sms template types. + operationId: getAllSMSTemplateTypes + description: | + Retrieves all the SMS template types in the system.
+ + Scopes required: +
* internal_sms_mgt_view + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - SMS Template Types + summary: Adds a new SMS template type. + operationId: addSMSTemplateType + description: | + Adds a new SMS template type to the system. An SMS template type can have any number of + organization or application SMS templates.
+ + * Attribute _**displayName**_ of the template type should be unique.
+ + Scopes required: +
* internal_sms_mgt_create + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateTypeOverview' + description: SMS template type to be added. + responses: + '201': + description: Item Created + headers: + self: + description: Location of the newly created SMS template type. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}': + get: + tags: + - SMS Template Types + summary: Retrieves the SMS template type corresponding to the template type id. + operationId: getSMSTemplateType + description: | + Retrieves the SMS template type in the system identified by the template-type-id.
+ + Scopes required:
+ * internal_sms_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - SMS Template Types + summary: Removes an SMS template type. + operationId: deleteSMSTemplateType + description: | + Removes an existing SMS template type with all its SMS templates + from the system.
+ + Scopes required:
+ * internal_sms_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}': + get: + tags: + - Application SMS Templates + summary: Retrieves the list of application SMS templates in the template type id. + operationId: getAppTemplatesListOfSMSTemplateType + description: | + Retrieves the list of application SMS templates in the template type id.
+ + Scope required:
+ * internal_sms_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Application SMS Templates + summary: Adds a new application SMS template to an existing SMS template type. + operationId: addAppSMSTemplate + description: | + Another application SMS template with the same locale should not already exist in the + respective SMS template type.
+ + Scopes required:
* internal_sms_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + description: SMS template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created SMS template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}': + get: + tags: + - Application SMS Templates + summary: Retrieves a single SMS template of application. + operationId: getAppSMSTemplate + description: | + Retrieves the application SMS template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_sms_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - Application SMS Templates + summary: Replaces an existing application SMS template. + operationId: updateAppSMSTemplate + description: | + Replaces the application SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplate' + description: Email templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Application SMS Templates + summary: Removes an SMS template. + operationId: deleteAppSMSTemplate + description: | + Removes an SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/org-templates': + get: + tags: + - SMS Templates + summary: Retrieves the list of organization SMS templates in the template type id. + operationId: getOrgTemplatesListOfSMSTemplateType + description: | + Retrieves the list of organization SMS templates in the template type id.
+ + Scope required:
+ * internal_sms_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - SMS Templates + summary: Adds a new organization SMS template to an existing SMS template type. + operationId: addOrgSMSTemplate + description: | + Another SMS organization template with the same locale should not already exist in the + respective SMS template type.
+ + Scopes required:
* internal_sms_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + description: SMS template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created SMS template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/org-templates/{locale}': + get: + tags: + - SMS Templates + summary: Retrieves a single organization SMS template. + operationId: getOrgSMSTemplate + description: | + Retrieves the SMS template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_sms_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - SMS Templates + summary: Replaces an existing organization SMS template. + operationId: updateOrgSMSTemplate + description: | + Replaces the organization SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplate' + description: SMS templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - SMS Templates + summary: Removes an organization SMS template. + operationId: deleteOrgSMSTemplate + description: | + Removes an organization SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + +servers: + # Added by API Auto Mocking Plugin + - description: SwaggerHub API Auto Mocking + url: https://virtserver.swaggerhub.com/RUSHANNANA/NotificationTemplateAPI/1.0.0 + - url: 'https://localhost:9443/t/{tenant-domain}/api/server/v1' + variables: + tenant-domain: + default: unknown + +components: + parameters: + templateTypeIdPathParam: + in: path + name: template-type-id + required: true + description: Email Template Type ID. + schema: + type: string + localePathParam: + in: path + name: locale + required: true + description: This should be a valid locale. + schema: + type: string + appUuidPathParam: + in: path + name: app-uuid + required: true + description: Application UUID. + schema: + type: string + offsetQueryParam: + in: query + name: offset + description: >- + Number of records to skip for pagination. _This option is not yet + supported._ + schema: + type: integer + format: int32 + minimum: 0 + limitQueryParam: + in: query + name: limit + description: >- + Maximum number of records to return. _This option is not yet + supported._ + schema: + type: integer + format: int32 + minimum: 0 + sortOrderQueryParam: + in: query + name: sortOrder + required: false + description: >- + Define the order in which the retrieved records should be sorted. _This + option is not yet supported._ + schema: + type: string + enum: + - asc + - desc + sortByQueryParam: + in: query + name: sortBy + required: false + description: >- + Attribute by which the retrieved records should be sorted. _This + option is not yet supported._ + schema: + type: string + responses: + NotFound: + description: The specified resource is not found. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Unauthorized: + description: Unauthorized. + Forbidden: + description: Forbidden. + ServerError: + description: Internal Server Error. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + InvalidInput: + description: Invalid input request. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Conflict: + description: Item Already Exists. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Deleted: + description: Item Deleted. + Updated: + description: Item Updated. + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'https://localhost:9443/oauth2/authorize' + tokenUrl: 'https://localhost:9443/oauth2/token' + scopes: {} + schemas: + TemplateType: + type: object + required: + - displayName + - self + properties: + displayName: + type: string + example: Account Confirmation + description: Display name of the email template type. + self: + type: string + example: /t/{tenant-domain}/api/server/v1/notification/email/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg + description: Location of the created/updated resource. + TemplateTypeOverview: + type: object + required: + - displayName + properties: + displayName: + type: string + example: Account Confirmation + description: Display name of the template type. + TemplateTypeWithID: + allOf: + - $ref: '#/components/schemas/TemplateType' + - required: + - id + properties: + id: + type: string + example: YWNjb3VudGNvbmZpcm1hdGlvbg + description: Unique ID of the template type. + EmailTemplate: + type: object + required: + - contentType + - subject + - body + properties: + contentType: + type: string + example: text/html + description: Content type of the email template. + subject: + type: string + example: WSO2 - Account Confirmation + description: The subject of the email. + body: + type: string + example: HTML Body + description: The body of the email. + footer: + type: string + example: WSO2 Identity Server Team + description: The footer of the email. + EmailTemplateWithID: + allOf: + - $ref: '#/components/schemas/EmailTemplate' + - required: + - locale + properties: + locale: + type: string + example: en_US + description: >- + Locale of the email template. + SMSTemplate: + type: object + required: + - body + properties: + body: + type: string + example: SMS Body + description: The body of the SMS. + SMSTemplateWithID: + allOf: + - $ref: '#/components/schemas/SMSTemplate' + - required: + - locale + properties: + locale: + type: string + example: en_US + description: >- + Locale of the SMS template. + SimpleTemplate: + type: object + required: + - locale + - self + properties: + locale: + type: string + example: en_US + description: >- + Locale of the template. + self: + type: string + example: /t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US + description: Location of the created/updated resource. + + Error: + type: object + required: + - code + - message + properties: + code: + type: string + example: NTM-50000 + message: + type: string + example: Some Error Message + description: + type: string + example: Some Error Description + traceId: + type: string + example: TR0001 \ No newline at end of file diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml new file mode 100644 index 0000000000..c1b2c6dded --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -0,0 +1,37 @@ + + + + + + org.wso2.carbon.identity.server.api + identity-api-server + 1.2.196-SNAPSHOT + ../../pom.xml + + 4.0.0 + + org.wso2.carbon.identity.api.server.notification.template + pom + + + org.wso2.carbon.identity.api.server.notification.template.common + org.wso2.carbon.identity.rest.api.server.notification.template.v1 + + + diff --git a/pom.xml b/pom.xml index 78baa84f0f..0f87d69e1e 100644 --- a/pom.xml +++ b/pom.xml @@ -287,6 +287,12 @@ provided ${project.version} + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template.common + provided + ${project.version} + org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.application.management.common @@ -859,6 +865,7 @@ components/org.wso2.carbon.identity.api.server.tenant.management components/org.wso2.carbon.identity.api.server.cors components/org.wso2.carbon.identity.api.server.notification.sender + components/org.wso2.carbon.identity.api.server.notification.template components/org.wso2.carbon.identity.api.server.authenticators components/org.wso2.carbon.identity.api.server.secret.management components/org.wso2.carbon.identity.api.server.branding.preference.management From 6df089f88601c9d650e2f628dd8f7a0dd881d854 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Thu, 26 Sep 2024 22:46:59 +0530 Subject: [PATCH 02/17] Add system template endpoints --- .../pom.xml | 2 +- .../template/common/Constants.java | 13 +- .../pom.xml | 2 +- .../template/v1/NotificationApi.java | 152 +++++++++++------ .../template/v1/NotificationApiService.java | 4 + ...atesService.java => TemplatesService.java} | 56 +++++- .../v1/impl/NotificationApiServiceImpl.java | 56 +++--- .../notification-template-server-v1-cxf.xml | 2 +- .../main/resources/notification-template.yml | 159 ++++++++++++------ .../pom.xml | 2 +- pom.xml | 4 +- 11 files changed, 320 insertions(+), 132 deletions(-) rename components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/{ApplicationTemplatesService.java => TemplatesService.java} (88%) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml index 41f71c6d5b..cd555002d7 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.196-SNAPSHOT + 1.2.228-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 11c15e7a9e..03d5206389 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.notification.template.common; +import org.wso2.carbon.email.mgt.constants.TemplateMgtConstants; + import java.util.HashMap; import java.util.Map; import javax.ws.rs.core.Response.Status; @@ -42,8 +44,8 @@ public class Constants { public static final String APP_TEMPLATES_PATH = "/app-templates"; public static final String ORG_TEMPLATES_PATH = "/org-templates"; public static final String PATH_SEPARATOR = "/"; - public static final String NOTIFICATION_CHANNEL_EMAIL = "email"; - public static final String NOTIFICATION_CHANNEL_SMS = "sms"; + public static final String NOTIFICATION_CHANNEL_EMAIL = "EMAIL"; + public static final String NOTIFICATION_CHANNEL_SMS = "SMS"; // ERROR MESSAGES private static final Map NTM_ERROR_CODE_MAP = new HashMap<>(); @@ -94,7 +96,10 @@ public enum ErrorMessage { "Server encountered an error while deleting the email template."), ERROR_ERROR_DELETING_SMS_TEMPLATE("60010", Status.INTERNAL_SERVER_ERROR, "Unable to delete the SMS template.", - "Server encountered an error while deleting the SMS template."); + "Server encountered an error while deleting the SMS template."), + ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED("60011", Status.FORBIDDEN, + "System resource deletion not allowed.", + "System resources are not eligible for deletion."); private final String message; private final Status httpStatus; @@ -143,6 +148,8 @@ public String toString() { NTM_ERROR_CODE_MAP.put(TEMPLATE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); NTM_ERROR_CODE_MAP.put(ERROR_ADDING_TEMPLATE, ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); NTM_ERROR_CODE_MAP.put(ERROR_UPDATING_TEMPLATE, ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + NTM_ERROR_CODE_MAP.put(TemplateMgtConstants.ErrorCodes.ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED, + ErrorMessage.ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED); } public static ErrorMessage getNTMMappedErrorMessage(String errorCode) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml index 0e5584f085..20d6e6a438 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.196-SNAPSHOT + 1.2.228-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index 96bcbbcda0..56fdf11b26 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -54,7 +54,7 @@ public class NotificationApi { @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scopes required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_notification_email_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -69,7 +69,7 @@ public class NotificationApi { @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response addAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { + public Response addAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { return delegate.addAppEmailTemplate(templateTypeId, appUuid, emailTemplateWithID ); } @@ -79,7 +79,7 @@ public Response addAppEmailTemplate(@ApiParam(value = "Email Template Type ID.", @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new application SMS template to an existing SMS template type.", notes = "Another application SMS template with the same locale should not already exist in the respective SMS template type.
Scopes required:
* internal_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new application SMS template to an existing SMS template type.", notes = "Another application SMS template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_notification_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -94,7 +94,7 @@ public Response addAppEmailTemplate(@ApiParam(value = "Email Template Type ID.", @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response addAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { + public Response addAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { return delegate.addAppSMSTemplate(templateTypeId, appUuid, smSTemplateWithID ); } @@ -104,7 +104,7 @@ public Response addAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",re @Path("/email/template-types") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scopes required:
* internal_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_notification_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -128,7 +128,7 @@ public Response addEmailTemplateType(@ApiParam(value = "Email template type to b @Path("/email/template-types/{template-type-id}/org-templates") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scopes required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_notification_email_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -143,7 +143,7 @@ public Response addEmailTemplateType(@ApiParam(value = "Email template type to b @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response addOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { + public Response addOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { return delegate.addOrgEmailTemplate(templateTypeId, emailTemplateWithID ); } @@ -153,7 +153,7 @@ public Response addOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.", @Path("/sms/template-types/{template-type-id}/org-templates") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scopes required:
* internal_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_notification_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -168,7 +168,7 @@ public Response addOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.", @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response addOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { + public Response addOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { return delegate.addOrgSMSTemplate(templateTypeId, smSTemplateWithID ); } @@ -178,7 +178,7 @@ public Response addOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",re @Path("/sms/template-types") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scopes required:
* internal_sms_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_notification_sms_mgt_create ", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -202,7 +202,7 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -216,7 +216,7 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.deleteAppEmailTemplate(templateTypeId, appUuid, locale ); } @@ -226,7 +226,7 @@ public Response deleteAppEmailTemplate(@ApiParam(value = "Email Template Type ID @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -240,7 +240,7 @@ public Response deleteAppEmailTemplate(@ApiParam(value = "Email Template Type ID @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.deleteAppSMSTemplate(templateTypeId, appUuid, locale ); } @@ -250,7 +250,7 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Email Template Type ID." @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scope required:
* internal_notification_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -264,7 +264,7 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Email Template Type ID." @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response deleteEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { return delegate.deleteEmailTemplateType(templateTypeId ); } @@ -274,7 +274,7 @@ public Response deleteEmailTemplateType(@ApiParam(value = "Email Template Type I @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -288,7 +288,7 @@ public Response deleteEmailTemplateType(@ApiParam(value = "Email Template Type I @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.deleteOrgEmailTemplate(templateTypeId, locale ); } @@ -298,7 +298,7 @@ public Response deleteOrgEmailTemplate(@ApiParam(value = "Email Template Type ID @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an organization SMS template.", notes = "Removes an organization SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an organization SMS template.", notes = "Removes an organization SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -312,7 +312,7 @@ public Response deleteOrgEmailTemplate(@ApiParam(value = "Email Template Type ID @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.deleteOrgSMSTemplate(templateTypeId, locale ); } @@ -322,7 +322,7 @@ public Response deleteOrgSMSTemplate(@ApiParam(value = "Email Template Type ID." @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scope required:
* internal_notification_sms_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -336,7 +336,7 @@ public Response deleteOrgSMSTemplate(@ApiParam(value = "Email Template Type ID." @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response deleteSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { return delegate.deleteSMSTemplateType(templateTypeId ); } @@ -346,7 +346,7 @@ public Response deleteSMSTemplateType(@ApiParam(value = "Email Template Type ID. @Path("/email/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scopes required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_notification_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -369,7 +369,7 @@ public Response getAllEmailTemplateTypes() { @Path("/sms/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scopes required:
* internal_sms_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_notification_sms_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -392,7 +392,7 @@ public Response getAllSMSTemplateTypes() { @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -406,7 +406,7 @@ public Response getAllSMSTemplateTypes() { @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); } @@ -416,7 +416,7 @@ public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.", @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -430,7 +430,7 @@ public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.", @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); } @@ -440,7 +440,7 @@ public Response getAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",re @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application email templates in the template type id.", notes = "Retrieves the list of application email templates in the template type id.
Scope required:
* internal_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application email templates in the template type id.", notes = "Retrieves the list of application email templates in the template type id.
Scope required:
* internal_notification_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -454,7 +454,7 @@ public Response getAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",re @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid ); } @@ -464,7 +464,7 @@ public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application SMS templates in the template type id.", notes = "Retrieves the list of application SMS templates in the template type id.
Scope required:
* internal_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application SMS templates in the template type id.", notes = "Retrieves the list of application SMS templates in the template type id.
Scope required:
* internal_notification_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -478,17 +478,65 @@ public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { return delegate.getAppTemplatesListOfSMSTemplateType(templateTypeId, appUuid ); } + @Valid + @GET + @Path("/email/template-types/{template-type-id}/system-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getDefaultEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getDefaultEmailTemplate(templateTypeId, locale ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/system-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getDefaultSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getDefaultSMSTemplate(templateTypeId, locale ); + } + @Valid @GET @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scopes required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_notification_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -502,7 +550,7 @@ public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Te @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { return delegate.getEmailTemplateType(templateTypeId ); } @@ -512,7 +560,7 @@ public Response getEmailTemplateType(@ApiParam(value = "Email Template Type ID." @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -526,7 +574,7 @@ public Response getEmailTemplateType(@ApiParam(value = "Email Template Type ID." @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.getOrgEmailTemplate(templateTypeId, locale ); } @@ -536,7 +584,7 @@ public Response getOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.", @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -550,7 +598,7 @@ public Response getOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.", @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { return delegate.getOrgSMSTemplate(templateTypeId, locale ); } @@ -560,7 +608,7 @@ public Response getOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",re @Path("/email/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization email templates in the template type id.", notes = "Retrieves the list of organization email templates in the template type id.
Scope required:
* internal_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of organization email templates in the template type id.", notes = "Retrieves the list of organization email templates in the template type id.
Scope required:
* internal_notification_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -574,7 +622,7 @@ public Response getOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",re @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { return delegate.getOrgTemplatesListOfEmailTemplateType(templateTypeId ); } @@ -584,7 +632,7 @@ public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Email @Path("/sms/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization SMS templates in the template type id.", notes = "Retrieves the list of organization SMS templates in the template type id.
Scope required:
* internal_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of organization SMS templates in the template type id.", notes = "Retrieves the list of organization SMS templates in the template type id.
Scope required:
* internal_notification_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -598,7 +646,7 @@ public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Email @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { return delegate.getOrgTemplatesListOfSMSTemplateType(templateTypeId ); } @@ -608,7 +656,7 @@ public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Te @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scopes required:
* internal_sms_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scope required:
* internal_notification_sms_mgt_view
", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -622,7 +670,7 @@ public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Te @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { return delegate.getSMSTemplateType(templateTypeId ); } @@ -632,7 +680,7 @@ public Response getSMSTemplateType(@ApiParam(value = "Email Template Type ID.",r @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -646,7 +694,7 @@ public Response getSMSTemplateType(@ApiParam(value = "Email Template Type ID.",r @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + public Response updateAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { return delegate.updateAppEmailTemplate(templateTypeId, appUuid, locale, emailTemplate ); } @@ -656,7 +704,7 @@ public Response updateAppEmailTemplate(@ApiParam(value = "Email Template Type ID @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing application SMS template.", notes = "Replaces the application SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing application SMS template.", notes = "Replaces the application SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -670,7 +718,7 @@ public Response updateAppEmailTemplate(@ApiParam(value = "Email Template Type ID @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid SMSTemplate smSTemplate) { + public Response updateAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid SMSTemplate smSTemplate) { return delegate.updateAppSMSTemplate(templateTypeId, appUuid, locale, smSTemplate ); } @@ -680,7 +728,7 @@ public Response updateAppSMSTemplate(@ApiParam(value = "Email Template Type ID." @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -694,7 +742,7 @@ public Response updateAppSMSTemplate(@ApiParam(value = "Email Template Type ID." @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + public Response updateOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { return delegate.updateOrgEmailTemplate(templateTypeId, locale, emailTemplate ); } @@ -704,7 +752,7 @@ public Response updateOrgEmailTemplate(@ApiParam(value = "Email Template Type ID @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing organization SMS template.", notes = "Replaces the organization SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing organization SMS template.", notes = "Replaces the organization SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -718,7 +766,7 @@ public Response updateOrgEmailTemplate(@ApiParam(value = "Email Template Type ID @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "SMS templates for the template type." ) @Valid SMSTemplate smSTemplate) { + public Response updateOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "SMS templates for the template type." ) @Valid SMSTemplate smSTemplate) { return delegate.updateOrgSMSTemplate(templateTypeId, locale, smSTemplate ); } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index 3548a1cfce..3fd361fce1 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -73,6 +73,10 @@ public interface NotificationApiService { public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid); + public Response getDefaultEmailTemplate(String templateTypeId, String locale); + + public Response getDefaultSMSTemplate(String templateTypeId, String locale); + public Response getEmailTemplateType(String templateTypeId); public Response getOrgEmailTemplate(String templateTypeId, String locale); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java similarity index 88% rename from components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java rename to components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java index 8609987e86..ed97e8e5d2 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java @@ -38,7 +38,7 @@ /** * Service class for application email templates. */ -public class ApplicationTemplatesService { +public class TemplatesService { /** * Adds a new organization email template to the given template type. Template ID should not exist in the system. @@ -274,6 +274,60 @@ public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId } } + /** + * Retrieves the default email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @return Default email template. + */ + public EmailTemplateWithID getSystemEmailTemplate(String templateTypeId, String templateId) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getSystemNotificationTemplate(Constants.NOTIFICATION_CHANNEL_EMAIL, + templateTypeDisplayName, templateId); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildEmailTemplateWithID(internalTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + /** + * Retrieves the default SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @return Default SMS template. + */ + public SMSTemplateWithID getSystemSmsTemplate(String templateTypeId, String templateId) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getSystemNotificationTemplate(Constants.NOTIFICATION_CHANNEL_SMS, + templateTypeDisplayName, templateId); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildSMSTemplateWithID(internalTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + /** * Updates the organization email template of the given template type and locale. * diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index 24d96d2791..5de5508572 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -22,8 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; -import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.ApplicationTemplatesService; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplateTypeService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplatesService; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; @@ -54,7 +54,7 @@ public class NotificationApiServiceImpl implements NotificationApiService { @Autowired - private ApplicationTemplatesService applicationTemplatesService; + private TemplatesService templatesService; @Autowired private TemplateTypeService templateTypeService; @@ -62,7 +62,7 @@ public class NotificationApiServiceImpl implements NotificationApiService { public Response addAppEmailTemplate(String templateTypeId, String appUuid, EmailTemplateWithID emailTemplateWithID) { - SimpleTemplate simpleEmailTemplate = applicationTemplatesService.addEmailTemplate(templateTypeId, + SimpleTemplate simpleEmailTemplate = templatesService.addEmailTemplate(templateTypeId, emailTemplateWithID, appUuid); URI headerLocation = buildURIForHeader(V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + TEMPLATE_TYPES_PATH + PATH_SEPARATOR @@ -74,7 +74,7 @@ public Response addAppEmailTemplate(String templateTypeId, String appUuid, @Override public Response addAppSMSTemplate(String templateTypeId, String appUuid, SMSTemplateWithID smSTemplateWithID) { - SimpleTemplate simpleSMSTemplate = applicationTemplatesService.addSMSTemplate(templateTypeId, + SimpleTemplate simpleSMSTemplate = templatesService.addSMSTemplate(templateTypeId, smSTemplateWithID, appUuid); URI headerLocation = buildURIForHeader(V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + TEMPLATE_TYPES_PATH + PATH_SEPARATOR @@ -98,7 +98,7 @@ public Response addEmailTemplateType(TemplateTypeOverview templateTypeOverview) @Override public Response addOrgEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID) { - SimpleTemplate simpleEmailTemplate = applicationTemplatesService.addEmailTemplate(templateTypeId, + SimpleTemplate simpleEmailTemplate = templatesService.addEmailTemplate(templateTypeId, emailTemplateWithID); URI headerLocation = buildURIForHeader( V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH @@ -110,7 +110,7 @@ public Response addOrgEmailTemplate(String templateTypeId, EmailTemplateWithID e @Override public Response addOrgSMSTemplate(String templateTypeId, SMSTemplateWithID smSTemplateWithID) { - SimpleTemplate simpleSMSTemplate = applicationTemplatesService.addSMSTemplate(templateTypeId, + SimpleTemplate simpleSMSTemplate = templatesService.addSMSTemplate(templateTypeId, smSTemplateWithID); URI headerLocation = buildURIForHeader( V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH @@ -134,14 +134,14 @@ public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview) { @Override public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { - applicationTemplatesService.deleteEmailTemplate(templateTypeId, locale, appUuid); + templatesService.deleteEmailTemplate(templateTypeId, locale, appUuid); return Response.noContent().build(); } @Override public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale) { - applicationTemplatesService.deleteSMSTemplate(templateTypeId, locale, appUuid); + templatesService.deleteSMSTemplate(templateTypeId, locale, appUuid); return Response.noContent().build(); } @@ -155,14 +155,14 @@ public Response deleteEmailTemplateType(String templateTypeId) { @Override public Response deleteOrgEmailTemplate(String templateTypeId, String locale) { - applicationTemplatesService.deleteEmailTemplate(templateTypeId, locale); + templatesService.deleteEmailTemplate(templateTypeId, locale); return Response.noContent().build(); } @Override public Response deleteOrgSMSTemplate(String templateTypeId, String locale) { - applicationTemplatesService.deleteSMSTemplate(templateTypeId, locale); + templatesService.deleteSMSTemplate(templateTypeId, locale); return Response.noContent().build(); } @@ -190,14 +190,14 @@ public Response getAllSMSTemplateTypes() { @Override public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { - return Response.ok().entity(applicationTemplatesService.getEmailTemplate(templateTypeId, locale, appUuid)) + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid)) .build(); } @Override public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { - return Response.ok().entity(applicationTemplatesService.getSMSTemplate(templateTypeId, locale, appUuid)) + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid)) .build(); } @@ -205,14 +205,14 @@ public Response getAppSMSTemplate(String templateTypeId, String appUuid, String public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid) { return Response.ok().entity( - applicationTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid)).build(); + templatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid)).build(); } @Override public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid) { return Response.ok().entity( - applicationTemplatesService.getTemplatesListOfSMSTemplateType(templateTypeId, appUuid)).build(); + templatesService.getTemplatesListOfSMSTemplateType(templateTypeId, appUuid)).build(); } @Override @@ -225,26 +225,26 @@ public Response getEmailTemplateType(String templateTypeId) { @Override public Response getOrgEmailTemplate(String templateTypeId, String locale) { - return Response.ok().entity(applicationTemplatesService.getEmailTemplate(templateTypeId, locale)).build(); + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale)).build(); } @Override public Response getOrgSMSTemplate(String templateTypeId, String locale) { - return Response.ok().entity(applicationTemplatesService.getSMSTemplate(templateTypeId, locale)).build(); + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale)).build(); } @Override public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId) { - return Response.ok().entity(applicationTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId)) + return Response.ok().entity(templatesService.getTemplatesListOfEmailTemplateType(templateTypeId)) .build(); } @Override public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId) { - return Response.ok().entity(applicationTemplatesService.getTemplatesListOfSMSTemplateType(templateTypeId)) + return Response.ok().entity(templatesService.getTemplatesListOfSMSTemplateType(templateTypeId)) .build(); } @@ -255,11 +255,23 @@ public Response getSMSTemplateType(String templateTypeId) { templateTypeId)).build(); } + @Override + public Response getDefaultEmailTemplate(String templateTypeId, String locale) { + + return Response.ok().entity(templatesService.getSystemEmailTemplate(templateTypeId, locale)).build(); + } + + @Override + public Response getDefaultSMSTemplate(String templateTypeId, String locale) { + + return Response.ok().entity(templatesService.getSystemSmsTemplate(templateTypeId, locale)).build(); + } + @Override public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate) { - applicationTemplatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate, appUuid); + templatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate, appUuid); return Response.ok().build(); } @@ -267,7 +279,7 @@ public Response updateAppEmailTemplate(String templateTypeId, String appUuid, St public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smsTemplate) { - applicationTemplatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); + templatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); return Response.ok().build(); } @@ -275,14 +287,14 @@ public Response updateAppSMSTemplate(String templateTypeId, String appUuid, Stri public Response updateOrgEmailTemplate(String templateTypeId, String locale, EmailTemplate emailTemplate) { - applicationTemplatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate); + templatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate); return Response.ok().build(); } @Override public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smsTemplate) { - applicationTemplatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate); + templatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate); return Response.ok().build(); } } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml index 35e871860e..27e3f3b5be 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml @@ -17,7 +17,7 @@ - + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index acfbddea99..4712690c51 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -33,8 +33,8 @@ paths: Retrieves all the email template types in the system.

- Scopes required: -
* internal_email_mgt_view + Scope required: +
* internal_notification_email_mgt_view responses: '200': description: Search results matching the given criteria. @@ -63,8 +63,8 @@ paths: * Attribute _**displayName**_ of the template type should be unique.
- Scopes required: -
* internal_email_mgt_create + Scope required: +
* internal_notification_email_mgt_create requestBody: content: application/json: @@ -102,8 +102,8 @@ paths: description: | Retrieves the email template type in the system identified by the template-type-id.
- Scopes required:
- * internal_email_mgt_view
+ Scope required:
+ * internal_notification_email_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -132,8 +132,8 @@ paths: Removes an existing email template type with all its email templates from the system.
- Scopes required:
- * internal_email_mgt_delete + Scope required:
+ * internal_notification_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -159,7 +159,7 @@ paths: Retrieves the list of organization email templates in the template type id.
Scope required:
- * internal_email_mgt_view
+ * internal_notification_email_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -190,7 +190,8 @@ paths: Another email template with the same locale should not already exist in the respective email template type.
- Scopes required:
* internal_email_mgt_create + Scope required:
+ * internal_notification_email_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' requestBody: @@ -233,7 +234,7 @@ paths: Retrieves the list of application email templates in the template type id.
Scope required:
- * internal_email_mgt_view
+ * internal_notification_email_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -265,7 +266,8 @@ paths: Another application email template with the same locale should not already exist in the respective email template type.
- Scopes required:
* internal_email_mgt_create + Scope required:
+ * internal_notification_email_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -309,7 +311,7 @@ paths: Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
- * internal_email_mgt_view + * internal_notification_email_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -338,8 +340,8 @@ paths: description: | Replaces the email template identified by the template-type-id and the locale.
- Scopes required:
- * internal_email_mgt_update + Scope required:
+ * internal_notification_email_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -370,8 +372,8 @@ paths: description: | Removes an email template identified by the template-type-id and the locale.
- Scopes required:
- * internal_email_mgt_delete + Scope required:
+ * internal_notification_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -388,6 +390,37 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/system-templates/{locale}': + get: + tags: + - Email Templates + summary: Retrieves the default email template for given type and locale. + operationId: getDefaultEmailTemplate + description: | + Retrieves the default email template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_notification_email_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}': get: tags: @@ -398,7 +431,7 @@ paths: Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
- * internal_email_mgt_view + * internal_notification_email_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -428,8 +461,8 @@ paths: description: | Replaces the application email template identified by the template-type-id and the locale.
- Scopes required:
- * internal_email_mgt_update + Scope required:
+ * internal_notification_email_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -461,8 +494,8 @@ paths: description: | Removes an email template identified by the template-type-id and the locale.
- Scopes required:
- * internal_email_mgt_delete + Scope required:
+ * internal_notification_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -489,8 +522,8 @@ paths: description: | Retrieves all the SMS template types in the system.
- Scopes required: -
* internal_sms_mgt_view + Scope required:
+ * internal_notification_sms_mgt_view responses: '200': description: Search results matching the given criteria. @@ -519,8 +552,8 @@ paths: * Attribute _**displayName**_ of the template type should be unique.
- Scopes required: -
* internal_sms_mgt_create + Scope required:
+ * internal_notification_sms_mgt_create requestBody: content: application/json: @@ -558,8 +591,8 @@ paths: description: | Retrieves the SMS template type in the system identified by the template-type-id.
- Scopes required:
- * internal_sms_mgt_view
+ Scope required:
+ * internal_notification_sms_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -588,8 +621,8 @@ paths: Removes an existing SMS template type with all its SMS templates from the system.
- Scopes required:
- * internal_sms_mgt_delete + Scope required:
+ * internal_notification_sms_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -615,7 +648,7 @@ paths: Retrieves the list of application SMS templates in the template type id.
Scope required:
- * internal_sms_mgt_view
+ * internal_notification_sms_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -647,7 +680,8 @@ paths: Another application SMS template with the same locale should not already exist in the respective SMS template type.
- Scopes required:
* internal_sms_mgt_create + Scope required:
+ * internal_notification_sms_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -691,7 +725,7 @@ paths: Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
- * internal_sms_mgt_view + * internal_notification_sms_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -721,8 +755,8 @@ paths: description: | Replaces the application SMS template identified by the template-type-id and the locale.
- Scopes required:
- * internal_sms_mgt_update + Scope required:
+ * internal_notification_sms_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -754,8 +788,8 @@ paths: description: | Removes an SMS template identified by the template-type-id and the locale.
- Scopes required:
- * internal_sms_mgt_delete + Scope required:
+ * internal_notification_sms_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -783,7 +817,7 @@ paths: Retrieves the list of organization SMS templates in the template type id.
Scope required:
- * internal_sms_mgt_view
+ * internal_notification_sms_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -814,7 +848,8 @@ paths: Another SMS organization template with the same locale should not already exist in the respective SMS template type.
- Scopes required:
* internal_sms_mgt_create + Scope required:
+ * internal_notification_sms_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' requestBody: @@ -857,7 +892,7 @@ paths: Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
- * internal_sms_mgt_view + * internal_notification_sms_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -886,8 +921,8 @@ paths: description: | Replaces the organization SMS template identified by the template-type-id and the locale.
- Scopes required:
- * internal_sms_mgt_update + Scope required:
+ * internal_notification_sms_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -918,8 +953,8 @@ paths: description: | Removes an organization SMS template identified by the template-type-id and the locale.
- Scopes required:
- * internal_sms_mgt_delete + Scope required:
+ * internal_notification_sms_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -936,11 +971,39 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/system-templates/{locale}': + get: + tags: + - SMS Templates + summary: Retrieves the default organization SMS template. + operationId: getDefaultSMSTemplate + description: | + Retrieves the default SMS template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_notification_sms_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' servers: - # Added by API Auto Mocking Plugin - - description: SwaggerHub API Auto Mocking - url: https://virtserver.swaggerhub.com/RUSHANNANA/NotificationTemplateAPI/1.0.0 - url: 'https://localhost:9443/t/{tenant-domain}/api/server/v1' variables: tenant-domain: @@ -952,7 +1015,7 @@ components: in: path name: template-type-id required: true - description: Email Template Type ID. + description: Template Type ID. schema: type: string localePathParam: diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml index c1b2c6dded..82c45c83c2 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.196-SNAPSHOT + 1.2.228-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 64b75fe247..e31f373ef4 100644 --- a/pom.xml +++ b/pom.xml @@ -808,12 +808,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.10.6 + 1.11.4-SNAPSHOT 7.5.0 3.0.5 1.12.0 **/gen/**/* - 1.8.19 + 1.9.5-SNAPSHOT 7.0.154 5.11.41 1.9.4 From ea76fd886cf9bb6b4261f0c6ef756467ada886f8 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Fri, 27 Sep 2024 08:36:07 +0530 Subject: [PATCH 03/17] Add empty line to end of swagger definition --- .../src/main/resources/notification-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index 4712690c51..7867aa2d44 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -1238,4 +1238,4 @@ components: example: Some Error Description traceId: type: string - example: TR0001 \ No newline at end of file + example: TR0001 From 885735a2c30e85de54a6bd95fba828f747fda860 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Sat, 28 Sep 2024 19:25:02 +0530 Subject: [PATCH 04/17] Remove ignoring wrong template type --- .../template/v1/core/TemplateTypeService.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 68222e22b3..1f379f871c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -18,7 +18,6 @@ package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; -import org.wso2.carbon.identity.api.server.common.error.APIError; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; @@ -103,12 +102,7 @@ public List getAllNotificationTemplateTypes(String notificat public void deleteNotificationTemplateType(String notificationChannel, String templateId) { String templateTypeDisplayName; - try { - templateTypeDisplayName = Util.decodeTemplateTypeId(templateId); - } catch (APIError e) { - // Ignoring the delete operation and return 204 response code, since the resource does not exist. - return; - } + templateTypeDisplayName = Util.decodeTemplateTypeId(templateId); try { boolean isTemplateTypeExists = TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( From 3235e66d3f289e6a3e39e6aef6afadfcdb2ae0a7 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Sat, 28 Sep 2024 19:42:30 +0530 Subject: [PATCH 05/17] Add bulk delete endpoints --- .../template/v1/NotificationApi.java | 282 ++++++++++++---- .../template/v1/NotificationApiService.java | 20 +- .../v1/impl/NotificationApiServiceImpl.java | 49 ++- .../main/resources/notification-template.yml | 315 ++++++++++++------ 4 files changed, 492 insertions(+), 174 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index 56fdf11b26..a92da1126e 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -54,7 +54,7 @@ public class NotificationApi { @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_notification_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -79,7 +79,7 @@ public Response addAppEmailTemplate(@ApiParam(value = "Template Type ID.",requir @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new application SMS template to an existing SMS template type.", notes = "Another application SMS template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_notification_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new application SMS template to an existing SMS template type.", notes = "Another application SMS template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_template_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -104,7 +104,7 @@ public Response addAppSMSTemplate(@ApiParam(value = "Template Type ID.",required @Path("/email/template-types") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_notification_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -128,7 +128,7 @@ public Response addEmailTemplateType(@ApiParam(value = "Email template type to b @Path("/email/template-types/{template-type-id}/org-templates") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_notification_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -153,7 +153,7 @@ public Response addOrgEmailTemplate(@ApiParam(value = "Template Type ID.",requir @Path("/sms/template-types/{template-type-id}/org-templates") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_notification_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_template_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -178,7 +178,7 @@ public Response addOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required @Path("/sms/template-types") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_notification_sms_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_template_mgt_create ", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -197,12 +197,60 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad return delegate.addSMSTemplateType(templateTypeOverview ); } + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/org-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes all org email templates.", notes = "Removes all existing organization email templates from the system.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAllOrgEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteAllOrgEmailTemplates(templateTypeId ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/org-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes all org SMS templates.", notes = "Removes all existing organization SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAllOrgSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteAllOrgSMSTemplates(templateTypeId ); + } + @Valid @DELETE @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an application email template.", notes = "Removes an applicationemail template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -221,12 +269,36 @@ public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",req return delegate.deleteAppEmailTemplate(templateTypeId, appUuid, locale ); } + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/app-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes all application email templates for the organization.", notes = "Removes all application email templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAppEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteAppEmailTemplates(templateTypeId ); + } + @Valid @DELETE @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -245,12 +317,36 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi return delegate.deleteAppSMSTemplate(templateTypeId, appUuid, locale ); } + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/app-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes all application SMS templates for the organization.", notes = "Removes all application SMS templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAppSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteAppSMSTemplates(templateTypeId, appUuid, locale ); + } + @Valid @DELETE @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scope required:
* internal_notification_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -274,7 +370,7 @@ public Response deleteEmailTemplateType(@ApiParam(value = "Template Type ID.",re @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -298,7 +394,7 @@ public Response deleteOrgEmailTemplate(@ApiParam(value = "Template Type ID.",req @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an organization SMS template.", notes = "Removes an organization SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an organization SMS template.", notes = "Removes an organization SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -322,7 +418,7 @@ public Response deleteOrgSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scope required:
* internal_notification_sms_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -346,7 +442,7 @@ public Response deleteSMSTemplateType(@ApiParam(value = "Template Type ID.",requ @Path("/email/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_notification_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -369,7 +465,7 @@ public Response getAllEmailTemplateTypes() { @Path("/sms/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_notification_sms_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_template_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -392,7 +488,7 @@ public Response getAllSMSTemplateTypes() { @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -416,7 +512,7 @@ public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",requir @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -440,14 +536,14 @@ public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application email templates in the template type id.", notes = "Retrieves the list of application email templates in the template type id.
Scope required:
* internal_notification_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application email templates under the provided template type.", notes = "Retrieves the list of application email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Application Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -464,14 +560,14 @@ public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Templa @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application SMS templates in the template type id.", notes = "Retrieves the list of application SMS templates in the template type id.
Scope required:
* internal_notification_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application SMS templates under the provided template type.", notes = "Retrieves the list of application SMS templates under the provided template type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Application SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -485,10 +581,34 @@ public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Template @Valid @GET - @Path("/email/template-types/{template-type-id}/system-templates/{locale}") + @Path("/email/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getEmailTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -502,17 +622,17 @@ public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Template @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getDefaultEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getDefaultEmailTemplate(templateTypeId, locale ); + return delegate.getOrgEmailTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/system-templates/{locale}") + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -526,153 +646,177 @@ public Response getDefaultEmailTemplate(@ApiParam(value = "Template Type ID.",re @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getDefaultSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getDefaultSMSTemplate(templateTypeId, locale ); + return delegate.getOrgSMSTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/email/template-types/{template-type-id}") + @Path("/email/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_notification_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the list of organization email templates under the provided template type.", notes = "Retrieves the list of organization email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Template Types", }) + }, tags={ "Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getEmailTemplateType(templateTypeId ); + return delegate.getOrgTemplatesListOfEmailTemplateType(templateTypeId ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + @Path("/sms/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the list of organization SMS templates under the provided template type.", notes = "Retrieves the list of organization SMS templates under the provided templalte type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Templates", }) + }, tags={ "SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getOrgEmailTemplate(templateTypeId, locale ); + return delegate.getOrgTemplatesListOfSMSTemplateType(templateTypeId ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scope required:
* internal_template_mgt_view
", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Templates", }) + }, tags={ "SMS Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getOrgSMSTemplate(templateTypeId, locale ); + return delegate.getSMSTemplateType(templateTypeId ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/org-templates") + @Path("/email/template-types/{template-type-id}/system-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization email templates in the template type id.", notes = "Retrieves the list of organization email templates in the template type id.
Scope required:
* internal_notification_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Templates", }) + }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getSystemEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getOrgTemplatesListOfEmailTemplateType(templateTypeId ); + return delegate.getSystemEmailTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/org-templates") + @Path("/sms/template-types/{template-type-id}/system-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization SMS templates in the template type id.", notes = "Retrieves the list of organization SMS templates in the template type id.
Scope required:
* internal_notification_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Templates", }) + }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getSystemSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getOrgTemplatesListOfSMSTemplateType(templateTypeId ); + return delegate.getSystemSMSTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}") + @Path("/email/template-types/{template-type-id}/system-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scope required:
* internal_notification_sms_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the system email templates of template type.", notes = "Retrieves the list of system default email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Template Types", }) + }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getSystemTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getSMSTemplateType(templateTypeId ); + return delegate.getSystemTemplatesListOfEmailTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/system-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of system SMS templates with the template type id.", notes = "Retrieves the list of system default SMS templates under the provided template type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "System Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getSystemTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getSystemTemplatesListOfSMSTemplateType(templateTypeId ); } @Valid @@ -680,7 +824,7 @@ public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",require @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -704,7 +848,7 @@ public Response updateAppEmailTemplate(@ApiParam(value = "Template Type ID.",req @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing application SMS template.", notes = "Replaces the application SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing application SMS template.", notes = "Replaces the application SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -718,7 +862,7 @@ public Response updateAppEmailTemplate(@ApiParam(value = "Template Type ID.",req @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid SMSTemplate smSTemplate) { + public Response updateAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Application SMS template for the template type and locale." ) @Valid SMSTemplate smSTemplate) { return delegate.updateAppSMSTemplate(templateTypeId, appUuid, locale, smSTemplate ); } @@ -728,7 +872,7 @@ public Response updateAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scope required:
* internal_notification_email_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -752,7 +896,7 @@ public Response updateOrgEmailTemplate(@ApiParam(value = "Template Type ID.",req @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing organization SMS template.", notes = "Replaces the organization SMS template identified by the template-type-id and the locale.
Scope required:
* internal_notification_sms_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing organization SMS template.", notes = "Replaces the organization SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index 3fd361fce1..33815cfaf3 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -49,10 +49,18 @@ public interface NotificationApiService { public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview); + public Response deleteAllOrgEmailTemplates(String templateTypeId); + + public Response deleteAllOrgSMSTemplates(String templateTypeId); + public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale); + public Response deleteAppEmailTemplates(String templateTypeId); + public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale); + public Response deleteAppSMSTemplates(String templateTypeId, String appUuid, String locale); + public Response deleteEmailTemplateType(String templateTypeId); public Response deleteOrgEmailTemplate(String templateTypeId, String locale); @@ -73,10 +81,6 @@ public interface NotificationApiService { public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid); - public Response getDefaultEmailTemplate(String templateTypeId, String locale); - - public Response getDefaultSMSTemplate(String templateTypeId, String locale); - public Response getEmailTemplateType(String templateTypeId); public Response getOrgEmailTemplate(String templateTypeId, String locale); @@ -89,6 +93,14 @@ public interface NotificationApiService { public Response getSMSTemplateType(String templateTypeId); + public Response getSystemEmailTemplate(String templateTypeId, String locale); + + public Response getSystemSMSTemplate(String templateTypeId, String locale); + + public Response getSystemTemplatesListOfEmailTemplateType(String templateTypeId); + + public Response getSystemTemplatesListOfSMSTemplateType(String templateTypeId); + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate); public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smSTemplate); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index 5de5508572..f90ab54fe0 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -131,6 +131,18 @@ public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview) { return Response.created(headerLocation).entity(templateType).build(); } + @Override + public Response deleteAllOrgEmailTemplates(String templateTypeId) { + + return Response.ok().entity("magic!").build(); + } + + @Override + public Response deleteAllOrgSMSTemplates(String templateTypeId) { + + return Response.ok().entity("magic!").build(); + } + @Override public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { @@ -138,6 +150,12 @@ public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, St return Response.noContent().build(); } + @Override + public Response deleteAppEmailTemplates(String templateTypeId) { + + return Response.ok().entity("magic!").build(); + } + @Override public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale) { @@ -145,6 +163,12 @@ public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, Stri return Response.noContent().build(); } + @Override + public Response deleteAppSMSTemplates(String templateTypeId, String appUuid, String locale) { + + return Response.ok().entity("magic!").build(); + } + @Override public Response deleteEmailTemplateType(String templateTypeId) { @@ -256,36 +280,45 @@ public Response getSMSTemplateType(String templateTypeId) { } @Override - public Response getDefaultEmailTemplate(String templateTypeId, String locale) { + public Response getSystemEmailTemplate(String templateTypeId, String locale) { return Response.ok().entity(templatesService.getSystemEmailTemplate(templateTypeId, locale)).build(); } @Override - public Response getDefaultSMSTemplate(String templateTypeId, String locale) { + public Response getSystemSMSTemplate(String templateTypeId, String locale) { return Response.ok().entity(templatesService.getSystemSmsTemplate(templateTypeId, locale)).build(); } @Override - public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, - EmailTemplate emailTemplate) { + public Response getSystemTemplatesListOfEmailTemplateType(String templateTypeId) { + + return Response.ok().entity("magic!").build(); + } + + @Override + public Response getSystemTemplatesListOfSMSTemplateType(String templateTypeId) { + + return Response.ok().entity("magic!").build(); + } + + @Override + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate) { templatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate, appUuid); return Response.ok().build(); } @Override - public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, - SMSTemplate smsTemplate) { + public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smsTemplate) { templatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); return Response.ok().build(); } @Override - public Response updateOrgEmailTemplate(String templateTypeId, String locale, - EmailTemplate emailTemplate) { + public Response updateOrgEmailTemplate(String templateTypeId, String locale, EmailTemplate emailTemplate) { templatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate); return Response.ok().build(); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index 7867aa2d44..2388641beb 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -3,8 +3,8 @@ info: title: "WSO2 Identity Server - Notification Template API" version: 1.0.0 description: >- - This is the RESTful API for managing notification templates inWSO2 Identity - Server. This API allows adding, retrieving, replacing, and removing email + This is the RESTful API for managing notification templates in the WSO2 Identity + Server. This API allows adding, retrieving, replacing, and removing notification templates and template types. tags: - name: Email Template Types @@ -19,6 +19,8 @@ tags: description: An SMS template of a specific type and a language. - name: Application SMS Templates description: An application email template of a specific type and a language. + - name: System Templates + description: A system default template of a specific type and a language. security: - OAuth2: [] - BasicAuth: [] @@ -34,7 +36,7 @@ paths:
Scope required: -
* internal_notification_email_mgt_view +
* internal_email_mgt_view responses: '200': description: Search results matching the given criteria. @@ -64,7 +66,7 @@ paths: * Attribute _**displayName**_ of the template type should be unique.
Scope required: -
* internal_notification_email_mgt_create +
* internal_email_mgt_create requestBody: content: application/json: @@ -103,7 +105,7 @@ paths: Retrieves the email template type in the system identified by the template-type-id.
Scope required:
- * internal_notification_email_mgt_view
+ * internal_email_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -133,7 +135,7 @@ paths: from the system.
Scope required:
- * internal_notification_email_mgt_delete + * internal_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -153,13 +155,13 @@ paths: get: tags: - Email Templates - summary: Retrieves the list of organization email templates in the template type id. + summary: Retrieves the list of organization email templates under the provided template type. operationId: getOrgTemplatesListOfEmailTemplateType description: | - Retrieves the list of organization email templates in the template type id.
+ Retrieves the list of organization email templates under the provided template type.
Scope required:
- * internal_notification_email_mgt_view
+ * internal_email_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -170,7 +172,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/EmailTemplateWithID' + $ref: '#/components/schemas/SimpleTemplate' '400': $ref: '#/components/responses/InvalidInput' '401': @@ -191,7 +193,7 @@ paths: respective email template type.
Scope required:
- * internal_notification_email_mgt_create + * internal_email_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' requestBody: @@ -224,17 +226,68 @@ paths: $ref: '#/components/responses/Conflict' '500': $ref: '#/components/responses/ServerError' + delete: + tags: + - Email Templates + summary: Removes all org email templates. + operationId: deleteAllOrgEmailTemplates + description: | + Removes all existing organization email templates from the system.
+ + Scope required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/app-templates': + delete: + tags: + - Application Email Templates + summary: Removes all application email templates for the organization. + operationId: deleteAppEmailTemplates + description: | + Removes all application email templates defined for all applications of the organization.
+ + Scope required:
+ * internal_template_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}': get: tags: - Application Email Templates - summary: Retrieves the list of application email templates in the template type id. + summary: Retrieves the list of application email templates under the provided template type. operationId: getAppTemplatesListOfEmailTemplateType description: | - Retrieves the list of application email templates in the template type id.
+ Retrieves the list of application email templates under the provided template type.
Scope required:
- * internal_notification_email_mgt_view
+ * internal_email_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -246,7 +299,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/EmailTemplateWithID' + $ref: '#/components/schemas/SimpleTemplate' '400': $ref: '#/components/responses/InvalidInput' '401': @@ -267,7 +320,7 @@ paths: respective email template type.
Scope required:
- * internal_notification_email_mgt_create + * internal_email_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -311,7 +364,7 @@ paths: Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_view + * internal_email_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -341,7 +394,7 @@ paths: Replaces the email template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_update + * internal_email_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -373,7 +426,7 @@ paths: Removes an email template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_delete + * internal_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -390,17 +443,49 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/system-templates': + get: + tags: + - System Templates + summary: Retrieves the system email templates of template type. + operationId: getSystemTemplatesListOfEmailTemplateType + description: | + Retrieves the list of system default email templates under the provided template type.
+ + Scope required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/email/template-types/{template-type-id}/system-templates/{locale}': get: tags: - - Email Templates + - System Templates summary: Retrieves the default email template for given type and locale. - operationId: getDefaultEmailTemplate + operationId: getSystemEmailTemplate description: | Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_view + * internal_email_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -431,7 +516,7 @@ paths: Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_view + * internal_email_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -462,7 +547,7 @@ paths: Replaces the application email template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_update + * internal_email_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -489,13 +574,13 @@ paths: delete: tags: - Application Email Templates - summary: Removes an email template. + summary: Removes an application email template. operationId: deleteAppEmailTemplate description: | - Removes an email template identified by the template-type-id and the locale.
+ Removes an applicationemail template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_email_mgt_delete + * internal_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -523,7 +608,7 @@ paths: Retrieves all the SMS template types in the system.
Scope required:
- * internal_notification_sms_mgt_view + * internal_template_mgt_view responses: '200': description: Search results matching the given criteria. @@ -553,7 +638,7 @@ paths: * Attribute _**displayName**_ of the template type should be unique.
Scope required:
- * internal_notification_sms_mgt_create + * internal_template_mgt_create requestBody: content: application/json: @@ -592,7 +677,7 @@ paths: Retrieves the SMS template type in the system identified by the template-type-id.
Scope required:
- * internal_notification_sms_mgt_view
+ * internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -622,7 +707,7 @@ paths: from the system.
Scope required:
- * internal_notification_sms_mgt_delete + * internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -638,17 +723,45 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/app-templates': + delete: + tags: + - Application SMS Templates + summary: Removes all application SMS templates for the organization. + operationId: deleteAppSMSTemplates + description: | + Removes all application SMS templates defined for all applications of the organization.
+ + Scope required:
+ * internal_template_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}': get: tags: - Application SMS Templates - summary: Retrieves the list of application SMS templates in the template type id. + summary: Retrieves the list of application SMS templates under the provided template type. operationId: getAppTemplatesListOfSMSTemplateType description: | - Retrieves the list of application SMS templates in the template type id.
+ Retrieves the list of application SMS templates under the provided template type.
Scope required:
- * internal_notification_sms_mgt_view
+ * internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -660,7 +773,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/SMSTemplateWithID' + $ref: '#/components/schemas/SimpleTemplate' '400': $ref: '#/components/responses/InvalidInput' '401': @@ -681,7 +794,7 @@ paths: respective SMS template type.
Scope required:
- * internal_notification_sms_mgt_create + * internal_template_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -725,7 +838,7 @@ paths: Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_view + * internal_template_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -756,7 +869,7 @@ paths: Replaces the application SMS template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_update + * internal_template_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -766,7 +879,7 @@ paths: application/json: schema: $ref: '#/components/schemas/SMSTemplate' - description: Email templates for the template type. + description: Application SMS template for the template type and locale. responses: '200': $ref: '#/components/responses/Updated' @@ -789,7 +902,7 @@ paths: Removes an SMS template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_delete + * internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -811,13 +924,13 @@ paths: get: tags: - SMS Templates - summary: Retrieves the list of organization SMS templates in the template type id. + summary: Retrieves the list of organization SMS templates under the provided template type. operationId: getOrgTemplatesListOfSMSTemplateType description: | - Retrieves the list of organization SMS templates in the template type id.
+ Retrieves the list of organization SMS templates under the provided templalte type.
Scope required:
- * internal_notification_sms_mgt_view
+ * internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -828,7 +941,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/SMSTemplateWithID' + $ref: '#/components/schemas/SimpleTemplate' '400': $ref: '#/components/responses/InvalidInput' '401': @@ -849,7 +962,7 @@ paths: respective SMS template type.
Scope required:
- * internal_notification_sms_mgt_create + * internal_template_mgt_create parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' requestBody: @@ -882,6 +995,31 @@ paths: $ref: '#/components/responses/Conflict' '500': $ref: '#/components/responses/ServerError' + delete: + tags: + - SMS Templates + summary: Removes all org SMS templates. + operationId: deleteAllOrgSMSTemplates + description: | + Removes all existing organization SMS templates from the system.
+ + Scope required:
+ * internal_template_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/sms/template-types/{template-type-id}/org-templates/{locale}': get: tags: @@ -892,7 +1030,7 @@ paths: Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_view + * internal_template_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -922,7 +1060,7 @@ paths: Replaces the organization SMS template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_update + * internal_template_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -954,7 +1092,7 @@ paths: Removes an organization SMS template identified by the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_delete + * internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -971,17 +1109,49 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/system-templates': + get: + tags: + - System Templates + summary: Retrieves the list of system SMS templates with the template type id. + operationId: getSystemTemplatesListOfSMSTemplateType + description: | + Retrieves the list of system default SMS templates under the provided template type.
+ + Scope required:
+ * internal_template_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/sms/template-types/{template-type-id}/system-templates/{locale}': get: tags: - - SMS Templates + - System Templates summary: Retrieves the default organization SMS template. - operationId: getDefaultSMSTemplate + operationId: getSystemSMSTemplate description: | Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
- * internal_notification_sms_mgt_view + * internal_template_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -1032,47 +1202,6 @@ components: description: Application UUID. schema: type: string - offsetQueryParam: - in: query - name: offset - description: >- - Number of records to skip for pagination. _This option is not yet - supported._ - schema: - type: integer - format: int32 - minimum: 0 - limitQueryParam: - in: query - name: limit - description: >- - Maximum number of records to return. _This option is not yet - supported._ - schema: - type: integer - format: int32 - minimum: 0 - sortOrderQueryParam: - in: query - name: sortOrder - required: false - description: >- - Define the order in which the retrieved records should be sorted. _This - option is not yet supported._ - schema: - type: string - enum: - - asc - - desc - sortByQueryParam: - in: query - name: sortBy - required: false - description: >- - Attribute by which the retrieved records should be sorted. _This - option is not yet supported._ - schema: - type: string responses: NotFound: description: The specified resource is not found. @@ -1238,4 +1367,4 @@ components: example: Some Error Description traceId: type: string - example: TR0001 + example: TR0001 \ No newline at end of file From 4bff0ad80676e8708c74b9566e393609e03236e9 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Sun, 29 Sep 2024 12:55:04 +0530 Subject: [PATCH 06/17] Change get all functions to return SimpleTemplates and add get all functions for system templates --- .../template/common/Constants.java | 9 +- .../template/v1/NotificationApi.java | 248 +++++++++--------- .../template/v1/NotificationApiService.java | 32 +-- .../template/v1/core/TemplateTypeService.java | 7 +- .../template/v1/core/TemplatesService.java | 103 +++----- .../v1/impl/NotificationApiServiceImpl.java | 108 ++++---- .../notification/template/v1/util/Util.java | 94 ++++--- .../main/resources/notification-template.yml | 18 +- 8 files changed, 314 insertions(+), 305 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 03d5206389..da7844675b 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -43,9 +43,13 @@ public class Constants { public static final String TEMPLATE_TYPES_PATH = "/template-types"; public static final String APP_TEMPLATES_PATH = "/app-templates"; public static final String ORG_TEMPLATES_PATH = "/org-templates"; + public static final String SYSTEM_TEMPLATES_PATH = "/system-templates"; public static final String PATH_SEPARATOR = "/"; public static final String NOTIFICATION_CHANNEL_EMAIL = "EMAIL"; public static final String NOTIFICATION_CHANNEL_SMS = "SMS"; + public static final String NOTIFICATION_TEMPLATE_OWNER_APP = "APP"; + public static final String NOTIFICATION_TEMPLATE_OWNER_ORG = "ORG"; + public static final String NOTIFICATION_TEMPLATE_OWNER_SYSTEM = "SYSTEM"; // ERROR MESSAGES private static final Map NTM_ERROR_CODE_MAP = new HashMap<>(); @@ -99,7 +103,10 @@ public enum ErrorMessage { "Server encountered an error while deleting the SMS template."), ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED("60011", Status.FORBIDDEN, "System resource deletion not allowed.", - "System resources are not eligible for deletion."); + "System resources are not eligible for deletion."), + ERROR_ERROR_RETRIEVING_TEMPLATES("60012", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve templates.", + "Server encountered an error while retrieving templates."); private final String message; private final Status httpStatus; diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index a92da1126e..02fe349df6 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -199,15 +199,15 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad @Valid @DELETE - @Path("/email/template-types/{template-type-id}/org-templates") + @Path("/email/template-types/{template-type-id}/app-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Removes all org email templates.", notes = "Removes all existing organization email templates from the system.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes all application email templates for the organization.", notes = "Removes all application email templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Templates", }) + }, tags={ "Application Email Templates", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @@ -216,22 +216,22 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAllOrgEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response deleteAllAppEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.deleteAllOrgEmailTemplates(templateTypeId ); + return delegate.deleteAllAppEmailTemplates(templateTypeId ); } @Valid @DELETE - @Path("/sms/template-types/{template-type-id}/org-templates") + @Path("/sms/template-types/{template-type-id}/app-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Removes all org SMS templates.", notes = "Removes all existing organization SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes all application SMS templates for the organization.", notes = "Removes all application SMS templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Templates", }) + }, tags={ "Application SMS Templates", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @@ -240,22 +240,22 @@ public Response deleteAllOrgEmailTemplates(@ApiParam(value = "Template Type ID." @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAllOrgSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response deleteAllAppSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.deleteAllOrgSMSTemplates(templateTypeId ); + return delegate.deleteAllAppSMSTemplates(templateTypeId, appUuid, locale ); } @Valid @DELETE - @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Path("/email/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an application email template.", notes = "Removes an applicationemail template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes all org email templates.", notes = "Removes all existing organization email templates from the system.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application Email Templates", }) + }, tags={ "Email Templates", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @@ -264,22 +264,22 @@ public Response deleteAllOrgSMSTemplates(@ApiParam(value = "Template Type ID.",r @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteAllOrgEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.deleteAppEmailTemplate(templateTypeId, appUuid, locale ); + return delegate.deleteAllOrgEmailTemplates(templateTypeId ); } @Valid @DELETE - @Path("/email/template-types/{template-type-id}/app-templates") + @Path("/sms/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Removes all application email templates for the organization.", notes = "Removes all application email templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes all org SMS templates.", notes = "Removes all existing organization SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application Email Templates", }) + }, tags={ "SMS Templates", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @@ -288,22 +288,22 @@ public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",req @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAppEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response deleteAllOrgSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.deleteAppEmailTemplates(templateTypeId ); + return delegate.deleteAllOrgSMSTemplates(templateTypeId ); } @Valid @DELETE - @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an application email template.", notes = "Removes an applicationemail template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application SMS Templates", }) + }, tags={ "Application Email Templates", }) @ApiResponses(value = { @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @@ -312,17 +312,17 @@ public Response deleteAppEmailTemplates(@ApiParam(value = "Template Type ID.",re @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.deleteAppSMSTemplate(templateTypeId, appUuid, locale ); + return delegate.deleteAppEmailTemplate(templateTypeId, appUuid, locale ); } @Valid @DELETE - @Path("/sms/template-types/{template-type-id}/app-templates") + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes all application SMS templates for the organization.", notes = "Removes all application SMS templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -336,9 +336,9 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response deleteAppSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.deleteAppSMSTemplates(templateTypeId, appUuid, locale ); + return delegate.deleteAppSMSTemplate(templateTypeId, appUuid, locale ); } @Valid @@ -439,109 +439,110 @@ public Response deleteSMSTemplateType(@ApiParam(value = "Template Type ID.",requ @Valid @GET - @Path("/email/template-types") + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application email templates under the provided template type.", notes = "Retrieves the list of application email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Template Types", }) + }, tags={ "Application Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllEmailTemplateTypes() { + public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { - return delegate.getAllEmailTemplateTypes(); + return delegate.getAllAppTemplatesOfEmailTemplateType(templateTypeId, appUuid ); } @Valid @GET - @Path("/sms/template-types") + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_template_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application SMS templates under the provided template type.", notes = "Retrieves the list of application SMS templates under the provided template type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Template Types", }) + }, tags={ "Application SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllSMSTemplateTypes() { + public Response getAllAppTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { - return delegate.getAllSMSTemplateTypes(); + return delegate.getAllAppTemplatesOfSMSTemplateType(templateTypeId, appUuid ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Path("/email/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application Email Templates", }) + }, tags={ "Email Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAllEmailTemplateTypes() { - return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); + return delegate.getAllEmailTemplateTypes(); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Path("/email/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the list of organization email templates under the provided template type.", notes = "Retrieves the list of organization email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application SMS Templates", }) + }, tags={ "Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); + return delegate.getAllOrgTemplatesOfEmailTemplateType(templateTypeId ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") + @Path("/sms/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application email templates under the provided template type.", notes = "Retrieves the list of application email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of organization SMS templates under the provided template type.", notes = "Retrieves the list of organization SMS templates under the provided templalte type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application Email Templates", }) + }, tags={ "SMS Templates", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @@ -550,273 +551,272 @@ public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAllOrgTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid ); + return delegate.getAllOrgTemplatesOfSMSTemplateType(templateTypeId ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") + @Path("/sms/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application SMS templates under the provided template type.", notes = "Retrieves the list of application SMS templates under the provided template type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_template_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Application SMS Templates", }) + }, tags={ "SMS Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAllSMSTemplateTypes() { - return delegate.getAppTemplatesListOfSMSTemplateType(templateTypeId, appUuid ); + return delegate.getAllSMSTemplateTypes(); } @Valid @GET - @Path("/email/template-types/{template-type-id}") + @Path("/email/template-types/{template-type-id}/system-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the system email templates of template type.", notes = "Retrieves the list of system default email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Template Types", }) + }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getAllSystemTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getEmailTemplateType(templateTypeId ); + return delegate.getAllSystemTemplatesOfEmailTemplateType(templateTypeId ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + @Path("/sms/template-types/{template-type-id}/system-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the list of system SMS templates with the template type id.", notes = "Retrieves the list of system default SMS templates under the provided template type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Templates", }) + }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAllSystemTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getOrgEmailTemplate(templateTypeId, locale ); + return delegate.getAllSystemTemplatesOfSMSTemplateType(templateTypeId ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Templates", }) + }, tags={ "Application Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getOrgSMSTemplate(templateTypeId, locale ); + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/org-templates") + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization email templates under the provided template type.", notes = "Retrieves the list of organization email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "Email Templates", }) + }, tags={ "Application SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getOrgTemplatesListOfEmailTemplateType(templateTypeId ); + return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/org-templates") + @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization SMS templates under the provided template type.", notes = "Retrieves the list of organization SMS templates under the provided templalte type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Templates", }) + }, tags={ "Email Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getOrgTemplatesListOfSMSTemplateType(templateTypeId ); + return delegate.getEmailTemplateType(templateTypeId ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}") + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scope required:
* internal_template_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Template Types", }) + }, tags={ "Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getSMSTemplateType(templateTypeId ); + return delegate.getOrgEmailTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/system-templates/{locale}") + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "System Templates", }) + }, tags={ "SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSystemEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getSystemEmailTemplate(templateTypeId, locale ); + return delegate.getOrgSMSTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/system-templates/{locale}") + @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scope required:
* internal_template_mgt_view
", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "System Templates", }) + }, tags={ "SMS Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSystemSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - return delegate.getSystemSMSTemplate(templateTypeId, locale ); + return delegate.getSMSTemplateType(templateTypeId ); } @Valid @GET - @Path("/email/template-types/{template-type-id}/system-templates") + @Path("/email/template-types/{template-type-id}/system-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the system email templates of template type.", notes = "Retrieves the list of system default email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSystemTemplatesListOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getSystemEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getSystemTemplatesListOfEmailTemplateType(templateTypeId ); + return delegate.getSystemEmailTemplate(templateTypeId, locale ); } @Valid @GET - @Path("/sms/template-types/{template-type-id}/system-templates") + @Path("/sms/template-types/{template-type-id}/system-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of system SMS templates with the template type id.", notes = "Retrieves the list of system default SMS templates under the provided template type.
Scope required:
* internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "System Templates", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SimpleTemplate.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getSystemTemplatesListOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getSystemSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - return delegate.getSystemTemplatesListOfSMSTemplateType(templateTypeId ); + return delegate.getSystemSMSTemplate(templateTypeId, locale ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index 33815cfaf3..15293a4223 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -49,18 +49,18 @@ public interface NotificationApiService { public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview); + public Response deleteAllAppEmailTemplates(String templateTypeId); + + public Response deleteAllAppSMSTemplates(String templateTypeId, String appUuid, String locale); + public Response deleteAllOrgEmailTemplates(String templateTypeId); public Response deleteAllOrgSMSTemplates(String templateTypeId); public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale); - public Response deleteAppEmailTemplates(String templateTypeId); - public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale); - public Response deleteAppSMSTemplates(String templateTypeId, String appUuid, String locale); - public Response deleteEmailTemplateType(String templateTypeId); public Response deleteOrgEmailTemplate(String templateTypeId, String locale); @@ -69,17 +69,25 @@ public interface NotificationApiService { public Response deleteSMSTemplateType(String templateTypeId); + public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid); + + public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid); + public Response getAllEmailTemplateTypes(); + public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId); + + public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId); + public Response getAllSMSTemplateTypes(); - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale); + public Response getAllSystemTemplatesOfEmailTemplateType(String templateTypeId); - public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale); + public Response getAllSystemTemplatesOfSMSTemplateType(String templateTypeId); - public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid); + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale); - public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid); + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale); public Response getEmailTemplateType(String templateTypeId); @@ -87,20 +95,12 @@ public interface NotificationApiService { public Response getOrgSMSTemplate(String templateTypeId, String locale); - public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId); - - public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId); - public Response getSMSTemplateType(String templateTypeId); public Response getSystemEmailTemplate(String templateTypeId, String locale); public Response getSystemSMSTemplate(String templateTypeId, String locale); - public Response getSystemTemplatesListOfEmailTemplateType(String templateTypeId); - - public Response getSystemTemplatesListOfSMSTemplateType(String templateTypeId); - public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate); public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smSTemplate); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 1f379f871c..8a9bda0b96 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -29,7 +29,6 @@ import java.util.List; import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; -import static org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util.getTemplateTypeLocation; /** * Service class for the template types. @@ -55,7 +54,7 @@ public TemplateTypeWithID addNotificationTemplateType(String notificationChannel response.setDisplayName(templateTypeDisplayName); String templateTypeId = Util.resolveTemplateIdFromDisplayName(templateTypeDisplayName); response.setId(templateTypeId); - response.setSelf(getTemplateTypeLocation(templateTypeId, notificationChannel)); + response.setSelf(Util.getTemplateTypeLocation(templateTypeId, notificationChannel)); return response; } catch (NotificationTemplateManagerException e) { throw Util.handleNotificationTemplateManagerException(e, @@ -82,7 +81,7 @@ public List getAllNotificationTemplateTypes(String notificat String templateTypeId = Util.resolveTemplateIdFromDisplayName(emailTemplateType); templateTypeWithID.setId(templateTypeId); templateTypeWithID.setSelf( - getTemplateTypeLocation(templateTypeId, notificationChannel)); + Util.getTemplateTypeLocation(templateTypeId, notificationChannel)); templateTypeWithIDs.add(templateTypeWithID); } } @@ -138,7 +137,7 @@ public TemplateTypeWithID getNotificationTemplateType(String notificationChannel TemplateTypeWithID templateTypeWithID = new TemplateTypeWithID(); templateTypeWithID.setDisplayName(templateTypeDisplayName); templateTypeWithID.setId(templateTypeId); - templateTypeWithID.setSelf(getTemplateTypeLocation(templateTypeId, notificationChannel)); + templateTypeWithID.setSelf(Util.getTemplateTypeLocation(templateTypeId, notificationChannel)); return templateTypeWithID; } else { throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java index ed97e8e5d2..3dca6ee292 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; +import org.apache.commons.lang.StringUtils; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; @@ -32,8 +33,6 @@ import java.util.List; import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; -import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; -import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; /** * Service class for application email templates. @@ -49,10 +48,7 @@ public class TemplatesService { */ public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID) { - SimpleTemplate simpleTemplate = addEmailTemplate(templateTypeId, emailTemplateWithID, null); - simpleTemplate.setSelf(getOrgTemplateLocation(templateTypeId, emailTemplateWithID.getLocale(), - Constants.NOTIFICATION_CHANNEL_EMAIL)); - return simpleTemplate; + return addEmailTemplate(templateTypeId, emailTemplateWithID, null); } /** @@ -72,10 +68,15 @@ public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithI TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, getTenantDomainFromContext(), applicationUuid); - // Create and send the location of the created object as the response. + String templateOwner = StringUtils.isNotBlank(applicationUuid) ? Constants.NOTIFICATION_TEMPLATE_OWNER_APP : + Constants.NOTIFICATION_TEMPLATE_OWNER_ORG; + String templateTypeLocation = Util.getTemplateTypeLocation(templateTypeId, + Constants.NOTIFICATION_CHANNEL_EMAIL); + String templateLocation = Util.getTemplateLocation(templateTypeLocation, applicationUuid, + emailTemplateWithID.getLocale(), templateOwner); + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); - simpleEmailTemplate.setSelf(getApplicationTemplateLocation(templateTypeId, applicationUuid, - notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_EMAIL)); + simpleEmailTemplate.setSelf(templateLocation); simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); return simpleEmailTemplate; } catch (NotificationTemplateManagerException e) { @@ -93,10 +94,7 @@ public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithI */ public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID smsTemplateWithID) { - SimpleTemplate simpleTemplate = addSMSTemplate(templateTypeId, smsTemplateWithID, null); - simpleTemplate.setSelf(getOrgTemplateLocation(templateTypeId, smsTemplateWithID.getLocale(), - Constants.NOTIFICATION_CHANNEL_SMS)); - return simpleTemplate; + return addSMSTemplate(templateTypeId, smsTemplateWithID, null); } /** @@ -116,12 +114,17 @@ public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID sm TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, getTenantDomainFromContext(), applicationUuid); - // Create and send the location of the created object as the response. - SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); - simpleEmailTemplate.setSelf(getApplicationTemplateLocation(templateTypeId, applicationUuid, - notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_SMS)); - simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); - return simpleEmailTemplate; + String templateOwner = StringUtils.isNotBlank(applicationUuid) ? Constants.NOTIFICATION_TEMPLATE_OWNER_APP : + Constants.NOTIFICATION_TEMPLATE_OWNER_ORG; + String templateTypeLocation = Util.getTemplateTypeLocation(templateTypeId, + Constants.NOTIFICATION_CHANNEL_SMS); + String templateLocation = Util.getTemplateLocation(templateTypeLocation, applicationUuid, + smsTemplateWithID.getLocale(), templateOwner); + + SimpleTemplate simpleSMSTemplate = new SimpleTemplate(); + simpleSMSTemplate.setSelf(templateLocation); + simpleSMSTemplate.setLocale(notificationTemplate.getLocale()); + return simpleSMSTemplate; } catch (NotificationTemplateManagerException e) { throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); @@ -134,9 +137,9 @@ public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID sm * @param templateTypeId Template type ID. * @return List of email templates. */ - public List getTemplatesListOfEmailTemplateType(String templateTypeId) { + public List getAllTemplatesOfTemplateType(String templateTypeId, String notificationChannel) { - return getTemplatesListOfEmailTemplateType(templateTypeId, null); + return getAllTemplatesOfTemplateType(templateTypeId, null, notificationChannel); } /** @@ -146,51 +149,41 @@ public List getTemplatesListOfEmailTemplateType(String temp * @param applicationUuid Application UUID. * @return List of email templates. */ - public List getTemplatesListOfEmailTemplateType(String templateTypeId, - String applicationUuid) { + public List getAllTemplatesOfTemplateType(String templateTypeId, String applicationUuid, + String notificationChannel) { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { - List emailTemplates = TemplatesServiceHolder.getNotificationTemplateManager() - .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + List templates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(notificationChannel, templateTypeDisplayName, getTenantDomainFromContext(), applicationUuid); - return Util.buildEmailTemplateWithIDList(emailTemplates); + String templateOwner = StringUtils.isNotBlank(applicationUuid) ? Constants.NOTIFICATION_TEMPLATE_OWNER_APP : + Constants.NOTIFICATION_TEMPLATE_OWNER_ORG; + return Util.buildSimpleTemplateList(templates, applicationUuid, templateOwner, notificationChannel); } catch (NotificationTemplateManagerException e) { throw Util.handleNotificationTemplateManagerException(e, - Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATES); } } /** - * Retrieves the list of organization SMS templates of the given template type. - * - * @param templateTypeId Template type ID. - * @return List of SMS templates. - */ - public List getTemplatesListOfSMSTemplateType(String templateTypeId) { - - return getTemplatesListOfSMSTemplateType(templateTypeId, null); - } - - /** - * Retrieves the list of application SMS templates of the given template type. + * Retrieves the list of application email templates of the given template type. * * @param templateTypeId Template type ID. - * @param applicationUuid Application UUID. - * @return List of SMS templates. + * @param notificationChannel Notification channel. + * @return List of email templates. */ - public List getTemplatesListOfSMSTemplateType(String templateTypeId, - String applicationUuid) { + public List getAllSystemTemplatesOfTemplateType(String templateTypeId, String notificationChannel) { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { - List smsTemplates = TemplatesServiceHolder.getNotificationTemplateManager() - .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, - getTenantDomainFromContext(), applicationUuid); - return Util.buildSMSTemplateWithIDList(smsTemplates); + List templates = TemplatesServiceHolder.getNotificationTemplateManager() + .getAllSystemNotificationTemplatesOfType(notificationChannel, templateTypeDisplayName); + return Util.buildSimpleTemplateList(templates, null, + Constants.NOTIFICATION_TEMPLATE_OWNER_SYSTEM, notificationChannel); } catch (NotificationTemplateManagerException e) { throw Util.handleNotificationTemplateManagerException(e, - Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATES); } } @@ -477,18 +470,4 @@ public void deleteSMSTemplate(String templateTypeId, String locale, String appli Constants.ErrorMessage.ERROR_ERROR_DELETING_SMS_TEMPLATE); } } - - private String getApplicationTemplateLocation(String templateTypeId, String applicationUuid, String locale, - String notificationType) { - - String templateLocation = Util.getTemplateTypeLocation(templateTypeId, notificationType); - return templateLocation + APP_TEMPLATES_PATH + PATH_SEPARATOR + applicationUuid - + PATH_SEPARATOR + locale; - } - - private String getOrgTemplateLocation(String templateTypeId, String templateId, String type) { - - String templateLocation = Util.getTemplateTypeLocation(templateTypeId, type); - return templateLocation + Constants.ORG_TEMPLATES_PATH + Constants.PATH_SEPARATOR + templateId; - } } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index f90ab54fe0..007bbec719 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -132,41 +132,43 @@ public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview) { } @Override - public Response deleteAllOrgEmailTemplates(String templateTypeId) { + public Response deleteAllAppEmailTemplates(String templateTypeId) { + // do some magic! return Response.ok().entity("magic!").build(); } @Override - public Response deleteAllOrgSMSTemplates(String templateTypeId) { + public Response deleteAllAppSMSTemplates(String templateTypeId, String appUuid, String locale) { + // do some magic! return Response.ok().entity("magic!").build(); } @Override - public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + public Response deleteAllOrgEmailTemplates(String templateTypeId) { - templatesService.deleteEmailTemplate(templateTypeId, locale, appUuid); - return Response.noContent().build(); + return Response.ok().entity("magic!").build(); } @Override - public Response deleteAppEmailTemplates(String templateTypeId) { + public Response deleteAllOrgSMSTemplates(String templateTypeId) { return Response.ok().entity("magic!").build(); } @Override - public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { - templatesService.deleteSMSTemplate(templateTypeId, locale, appUuid); + templatesService.deleteEmailTemplate(templateTypeId, locale, appUuid); return Response.noContent().build(); } @Override - public Response deleteAppSMSTemplates(String templateTypeId, String appUuid, String locale) { + public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale) { - return Response.ok().entity("magic!").build(); + templatesService.deleteSMSTemplate(templateTypeId, locale, appUuid); + return Response.noContent().build(); } @Override @@ -197,6 +199,22 @@ public Response deleteSMSTemplateType(String templateTypeId) { return Response.noContent().build(); } + @Override + public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid) { + + return Response.ok().entity( + templatesService.getAllTemplatesOfTemplateType(templateTypeId, appUuid, + Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + } + + @Override + public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid) { + + return Response.ok().entity( + templatesService.getAllTemplatesOfTemplateType(templateTypeId, appUuid, + Constants.NOTIFICATION_CHANNEL_SMS)).build(); + } + @Override public Response getAllEmailTemplateTypes() { @@ -204,6 +222,20 @@ public Response getAllEmailTemplateTypes() { .getAllNotificationTemplateTypes(Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); } + @Override + public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId) { + + return Response.ok().entity(templatesService.getAllTemplatesOfTemplateType(templateTypeId, + Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + } + + @Override + public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId) { + + return Response.ok().entity(templatesService.getAllTemplatesOfTemplateType(templateTypeId, + Constants.NOTIFICATION_CHANNEL_SMS)).build(); + } + @Override public Response getAllSMSTemplateTypes() { @@ -212,31 +244,31 @@ public Response getAllSMSTemplateTypes() { } @Override - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + public Response getAllSystemTemplatesOfEmailTemplateType(String templateTypeId) { - return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid)) - .build(); + return Response.ok().entity(templatesService + .getAllSystemTemplatesOfTemplateType(templateTypeId, Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); } @Override - public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + public Response getAllSystemTemplatesOfSMSTemplateType(String templateTypeId) { - return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid)) - .build(); + return Response.ok().entity(templatesService + .getAllSystemTemplatesOfTemplateType(templateTypeId, Constants.NOTIFICATION_CHANNEL_SMS)).build(); } @Override - public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid) { + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { - return Response.ok().entity( - templatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid)).build(); + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid)) + .build(); } @Override - public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid) { + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { - return Response.ok().entity( - templatesService.getTemplatesListOfSMSTemplateType(templateTypeId, appUuid)).build(); + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid)) + .build(); } @Override @@ -258,20 +290,6 @@ public Response getOrgSMSTemplate(String templateTypeId, String locale) { return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale)).build(); } - @Override - public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId) { - - return Response.ok().entity(templatesService.getTemplatesListOfEmailTemplateType(templateTypeId)) - .build(); - } - - @Override - public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId) { - - return Response.ok().entity(templatesService.getTemplatesListOfSMSTemplateType(templateTypeId)) - .build(); - } - @Override public Response getSMSTemplateType(String templateTypeId) { @@ -292,26 +310,16 @@ public Response getSystemSMSTemplate(String templateTypeId, String locale) { } @Override - public Response getSystemTemplatesListOfEmailTemplateType(String templateTypeId) { - - return Response.ok().entity("magic!").build(); - } - - @Override - public Response getSystemTemplatesListOfSMSTemplateType(String templateTypeId) { - - return Response.ok().entity("magic!").build(); - } - - @Override - public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate) { + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, + EmailTemplate emailTemplate) { templatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate, appUuid); return Response.ok().build(); } @Override - public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smsTemplate) { + public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, + SMSTemplate smsTemplate) { templatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); return Response.ok().build(); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java index 83f15392f6..ddc63d8bbd 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java @@ -32,6 +32,7 @@ import org.wso2.carbon.identity.governance.model.NotificationTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; import java.util.ArrayList; import java.util.List; @@ -41,11 +42,14 @@ import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; import static org.wso2.carbon.identity.api.server.common.Util.base64URLDecode; import static org.wso2.carbon.identity.api.server.common.Util.base64URLEncode; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_EMAIL; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.ORG_TEMPLATES_PATH; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.SYSTEM_TEMPLATES_PATH; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.TEMPLATE_TYPES_PATH; /** @@ -58,46 +62,31 @@ public class Util { private static final String ERROR_CODE_DELIMITER = "-"; /** - * Converts a list of EmailTemplate objects to a list of NotificationTemplate objects. + * Builds a list of SimpleTemplate objects using the provided NotificationTemplate list. * - * @param emailTemplates List of EmailTemplate objects. - * @return List of EmailTemplateWithID objects. + * @param templates NotificationTemplate list. + * @param applicationUuid Application UUID. + * @param templateOwner Template owner. + * @param notificationChannel Notification channel. + * @return List of SimpleTemplate objects. */ - public static List buildEmailTemplateWithIDList(List emailTemplates) { - - List emailTemplateWithIDs = new ArrayList<>(); - if (emailTemplates != null) { - for (NotificationTemplate emailTemplate : emailTemplates) { - EmailTemplateWithID emailTemplateWithID = new EmailTemplateWithID(); - emailTemplateWithID.setLocale(emailTemplate.getLocale()); - emailTemplateWithID.setContentType(emailTemplate.getContentType()); - emailTemplateWithID.setSubject(emailTemplate.getSubject()); - emailTemplateWithID.setBody(emailTemplate.getBody()); - emailTemplateWithID.setFooter(emailTemplate.getFooter()); - emailTemplateWithIDs.add(emailTemplateWithID); + public static List buildSimpleTemplateList(List templates, + String applicationUuid, String templateOwner, String notificationChannel) { + + List simpleTemplates = new ArrayList<>(); + if (templates != null) { + for (NotificationTemplate template : templates) { + SimpleTemplate simpleTemplate = new SimpleTemplate(); + String templateTypeId = base64URLEncode(template.getType()); + String templateTypeLocation = + getTemplateTypeLocation(templateTypeId, notificationChannel); + simpleTemplate.setSelf(getTemplateLocation(templateTypeLocation, applicationUuid, + template.getLocale(), templateOwner)); + simpleTemplate.setLocale(template.getLocale()); + simpleTemplates.add(simpleTemplate); } } - return emailTemplateWithIDs; - } - - /** - * Converts a list of SMSTemplate objects to a list of SMSTemplateWithID objects. - * - * @param smsTemplates List of SMSTemplate objects. - * @return List of SMSTemplateWithID objects. - */ - public static List buildSMSTemplateWithIDList(List smsTemplates) { - - List smsTemplateWithIDs = new ArrayList<>(); - if (smsTemplates != null) { - for (NotificationTemplate smsTemplate : smsTemplates) { - SMSTemplateWithID emailTemplateWithID = new SMSTemplateWithID(); - emailTemplateWithID.setLocale(smsTemplate.getLocale()); - emailTemplateWithID.setBody(smsTemplate.getBody()); - smsTemplateWithIDs.add(emailTemplateWithID); - } - } - return smsTemplateWithIDs; + return simpleTemplates; } /** @@ -202,6 +191,7 @@ public static SMSTemplateWithID buildSMSTemplateWithID(NotificationTemplate inte /** * Builds NotificationTemplate object using SMSTemplateWithID object. + * * @param templateTypeId Template type ID. * @param smsTemplateWithID SMSTemplateWithID Object. * @return NotificationTemplate object built using provided values. @@ -222,6 +212,7 @@ public static NotificationTemplate buildNotificationTemplateWithSMSTemplateWithI /** * Builds NotificationTemplate object using EmailTemplateWithID object. + * * @param templateTypeId Template type ID. * @param emailTemplateWithID EmailTemplateWithID Object. * @return NotificationTemplate object built using provided values. @@ -268,14 +259,14 @@ public static void assertTemplateTypeExistence(String notificationChannel, Strin * Builds the location of the template type. * * @param templateTypeId Template type ID. - * @param templateType Notification channel type. + * @param notificationChannel Notification channel type. * @return Location of the template. */ - public static String getTemplateTypeLocation(String templateTypeId, String templateType) { + public static String getTemplateTypeLocation(String templateTypeId, String notificationChannel) { String templateTypePath; // Only EMAIL and SMS are passed as the type. So, no need to check for other types. - if (templateType.equals(NOTIFICATION_CHANNEL_EMAIL)) { + if (NOTIFICATION_CHANNEL_EMAIL.equals(notificationChannel)) { templateTypePath = NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; } else { templateTypePath = NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; @@ -321,6 +312,31 @@ public static SMSTemplateWithID buildSMSTemplateWithIdUsingSMSTemplate( return smsTemplateWithID; } + + /** + * Generates self url for application templates. + * + * @param templateTypeLocation Template type ID. + * @param applicationUuid Application UUID. + * @param locale Locale. + * @return SimpleTemplate object. + */ + public static String getTemplateLocation(String templateTypeLocation, String applicationUuid, String locale, + String templateOwner) { + + switch (templateOwner) { + case Constants.NOTIFICATION_TEMPLATE_OWNER_APP: + return templateTypeLocation + APP_TEMPLATES_PATH + PATH_SEPARATOR + applicationUuid + + PATH_SEPARATOR + locale; + case Constants.NOTIFICATION_TEMPLATE_OWNER_ORG: + return templateTypeLocation + ORG_TEMPLATES_PATH + PATH_SEPARATOR + locale; + case Constants.NOTIFICATION_TEMPLATE_OWNER_SYSTEM: + return templateTypeLocation + SYSTEM_TEMPLATES_PATH + PATH_SEPARATOR + locale; + default: + return null; + } + } + private static ErrorResponse.Builder getErrorBuilder(Constants.ErrorMessage errorMsg) { return new ErrorResponse.Builder().withCode(errorMsg.getCode()). diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index 2388641beb..c519fcfd49 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -156,7 +156,7 @@ paths: tags: - Email Templates summary: Retrieves the list of organization email templates under the provided template type. - operationId: getOrgTemplatesListOfEmailTemplateType + operationId: getAllOrgTemplatesOfEmailTemplateType description: | Retrieves the list of organization email templates under the provided template type.
@@ -256,7 +256,7 @@ paths: tags: - Application Email Templates summary: Removes all application email templates for the organization. - operationId: deleteAppEmailTemplates + operationId: deleteAllAppEmailTemplates description: | Removes all application email templates defined for all applications of the organization.
@@ -282,7 +282,7 @@ paths: tags: - Application Email Templates summary: Retrieves the list of application email templates under the provided template type. - operationId: getAppTemplatesListOfEmailTemplateType + operationId: getAllAppTemplatesOfEmailTemplateType description: | Retrieves the list of application email templates under the provided template type.
@@ -448,7 +448,7 @@ paths: tags: - System Templates summary: Retrieves the system email templates of template type. - operationId: getSystemTemplatesListOfEmailTemplateType + operationId: getAllSystemTemplatesOfEmailTemplateType description: | Retrieves the list of system default email templates under the provided template type.
@@ -728,7 +728,7 @@ paths: tags: - Application SMS Templates summary: Removes all application SMS templates for the organization. - operationId: deleteAppSMSTemplates + operationId: deleteAllAppSMSTemplates description: | Removes all application SMS templates defined for all applications of the organization.
@@ -756,7 +756,7 @@ paths: tags: - Application SMS Templates summary: Retrieves the list of application SMS templates under the provided template type. - operationId: getAppTemplatesListOfSMSTemplateType + operationId: getAllAppTemplatesOfSMSTemplateType description: | Retrieves the list of application SMS templates under the provided template type.
@@ -925,7 +925,7 @@ paths: tags: - SMS Templates summary: Retrieves the list of organization SMS templates under the provided template type. - operationId: getOrgTemplatesListOfSMSTemplateType + operationId: getAllOrgTemplatesOfSMSTemplateType description: | Retrieves the list of organization SMS templates under the provided templalte type.
@@ -1114,7 +1114,7 @@ paths: tags: - System Templates summary: Retrieves the list of system SMS templates with the template type id. - operationId: getSystemTemplatesListOfSMSTemplateType + operationId: getAllSystemTemplatesOfSMSTemplateType description: | Retrieves the list of system default SMS templates under the provided template type.
@@ -1367,4 +1367,4 @@ components: example: Some Error Description traceId: type: string - example: TR0001 \ No newline at end of file + example: TR0001 From cc2d188d3c32f4a2f21d83228a750e3fd7ca842f Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Sun, 29 Sep 2024 17:18:47 +0530 Subject: [PATCH 07/17] Allow partial deletion for system template types. --- .../template/common/Constants.java | 9 -- .../template/v1/NotificationApi.java | 102 +-------------- .../template/v1/NotificationApiService.java | 8 -- .../template/v1/core/TemplateTypeService.java | 13 +- .../v1/impl/NotificationApiServiceImpl.java | 54 ++++---- .../main/resources/notification-template.yml | 121 ++---------------- 6 files changed, 55 insertions(+), 252 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index da7844675b..9c07b5fe1b 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -18,14 +18,11 @@ package org.wso2.carbon.identity.api.server.notification.template.common; -import org.wso2.carbon.email.mgt.constants.TemplateMgtConstants; - import java.util.HashMap; import java.util.Map; import javax.ws.rs.core.Response.Status; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_ADDING_TEMPLATE; -import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_UPDATING_TEMPLATE; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_ALREADY_EXISTS; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_NOT_FOUND; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_ALREADY_EXISTS; @@ -101,9 +98,6 @@ public enum ErrorMessage { ERROR_ERROR_DELETING_SMS_TEMPLATE("60010", Status.INTERNAL_SERVER_ERROR, "Unable to delete the SMS template.", "Server encountered an error while deleting the SMS template."), - ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED("60011", Status.FORBIDDEN, - "System resource deletion not allowed.", - "System resources are not eligible for deletion."), ERROR_ERROR_RETRIEVING_TEMPLATES("60012", Status.INTERNAL_SERVER_ERROR, "Unable to retrieve templates.", "Server encountered an error while retrieving templates."); @@ -154,9 +148,6 @@ public String toString() { NTM_ERROR_CODE_MAP.put(TEMPLATE_ALREADY_EXISTS, ErrorMessage.ERROR_TEMPLATE_ALREADY_EXISTS); NTM_ERROR_CODE_MAP.put(TEMPLATE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); NTM_ERROR_CODE_MAP.put(ERROR_ADDING_TEMPLATE, ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); - NTM_ERROR_CODE_MAP.put(ERROR_UPDATING_TEMPLATE, ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); - NTM_ERROR_CODE_MAP.put(TemplateMgtConstants.ErrorCodes.ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED, - ErrorMessage.ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED); } public static ErrorMessage getNTMMappedErrorMessage(String errorCode) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index 02fe349df6..c359ba820f 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -197,102 +197,6 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad return delegate.addSMSTemplateType(templateTypeOverview ); } - @Valid - @DELETE - @Path("/email/template-types/{template-type-id}/app-templates") - - @Produces({ "application/json" }) - @ApiOperation(value = "Removes all application email templates for the organization.", notes = "Removes all application email templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { - @Authorization(value = "BasicAuth"), - @Authorization(value = "OAuth2", scopes = { - - }) - }, tags={ "Application Email Templates", }) - @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), - @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), - @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), - @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), - @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) - }) - public Response deleteAllAppEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - - return delegate.deleteAllAppEmailTemplates(templateTypeId ); - } - - @Valid - @DELETE - @Path("/sms/template-types/{template-type-id}/app-templates") - - @Produces({ "application/json" }) - @ApiOperation(value = "Removes all application SMS templates for the organization.", notes = "Removes all application SMS templates defined for all applications of the organization.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { - @Authorization(value = "BasicAuth"), - @Authorization(value = "OAuth2", scopes = { - - }) - }, tags={ "Application SMS Templates", }) - @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), - @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), - @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), - @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), - @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) - }) - public Response deleteAllAppSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { - - return delegate.deleteAllAppSMSTemplates(templateTypeId, appUuid, locale ); - } - - @Valid - @DELETE - @Path("/email/template-types/{template-type-id}/org-templates") - - @Produces({ "application/json" }) - @ApiOperation(value = "Removes all org email templates.", notes = "Removes all existing organization email templates from the system.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { - @Authorization(value = "BasicAuth"), - @Authorization(value = "OAuth2", scopes = { - - }) - }, tags={ "Email Templates", }) - @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), - @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), - @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), - @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), - @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) - }) - public Response deleteAllOrgEmailTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - - return delegate.deleteAllOrgEmailTemplates(templateTypeId ); - } - - @Valid - @DELETE - @Path("/sms/template-types/{template-type-id}/org-templates") - - @Produces({ "application/json" }) - @ApiOperation(value = "Removes all org SMS templates.", notes = "Removes all existing organization SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { - @Authorization(value = "BasicAuth"), - @Authorization(value = "OAuth2", scopes = { - - }) - }, tags={ "SMS Templates", }) - @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), - @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), - @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), - @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), - @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) - }) - public Response deleteAllOrgSMSTemplates(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - - return delegate.deleteAllOrgSMSTemplates(templateTypeId ); - } - @Valid @DELETE @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @@ -346,13 +250,14 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its user defined email templates from the system.
**System template types are not eligible for deletion.** Attempt to delete a system template type will result in a partial deletion of only the user defined templates. Template type will not be deleted.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Email Template Types", }) @ApiResponses(value = { + @ApiResponse(code = 200, message = "Partial Deletion.", response = Void.class), @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @@ -418,13 +323,14 @@ public Response deleteOrgSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its user defined SMS templates from the system.
**System template types are not eligible for deletion.** Attempt to delete a system template type will result in a partial deletion of only the user defined templates. Template type will not be deleted.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "SMS Template Types", }) @ApiResponses(value = { + @ApiResponse(code = 200, message = "Partial Deletion.", response = Void.class), @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index 15293a4223..0674bcdc55 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -49,14 +49,6 @@ public interface NotificationApiService { public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview); - public Response deleteAllAppEmailTemplates(String templateTypeId); - - public Response deleteAllAppSMSTemplates(String templateTypeId, String appUuid, String locale); - - public Response deleteAllOrgEmailTemplates(String templateTypeId); - - public Response deleteAllOrgSMSTemplates(String templateTypeId); - public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale); public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 8a9bda0b96..34953b5b3b 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; +import org.apache.commons.lang.StringUtils; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; @@ -28,6 +29,8 @@ import java.util.ArrayList; import java.util.List; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes + .ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; /** @@ -98,7 +101,8 @@ public List getAllNotificationTemplateTypes(String notificat * @param notificationChannel Notification channel (Eg: sms, email). * @param templateId ID of the template type. */ - public void deleteNotificationTemplateType(String notificationChannel, String templateId) { + public void deleteNotificationTemplateType(String notificationChannel, String templateId) + throws NotificationTemplateManagerException { String templateTypeDisplayName; templateTypeDisplayName = Util.decodeTemplateTypeId(templateId); @@ -113,6 +117,13 @@ public void deleteNotificationTemplateType(String notificationChannel, String te throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); } } catch (NotificationTemplateManagerException e) { + String errorCode = StringUtils.EMPTY; + if (StringUtils.isNotBlank(e.getErrorCode()) && e.getErrorCode().split("-").length > 1) { + errorCode = e.getErrorCode().split("-")[1]; + } + if (ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED.equals(errorCode)) { + throw e; + } throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index 007bbec719..378947ba3d 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -18,9 +18,9 @@ package org.wso2.carbon.identity.rest.api.server.notification.template.v1.impl; - import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplateTypeService; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplatesService; @@ -31,10 +31,12 @@ import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; import java.net.URI; import javax.ws.rs.core.Response; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForHeader; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; @@ -131,32 +133,6 @@ public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview) { return Response.created(headerLocation).entity(templateType).build(); } - @Override - public Response deleteAllAppEmailTemplates(String templateTypeId) { - - // do some magic! - return Response.ok().entity("magic!").build(); - } - - @Override - public Response deleteAllAppSMSTemplates(String templateTypeId, String appUuid, String locale) { - - // do some magic! - return Response.ok().entity("magic!").build(); - } - - @Override - public Response deleteAllOrgEmailTemplates(String templateTypeId) { - - return Response.ok().entity("magic!").build(); - } - - @Override - public Response deleteAllOrgSMSTemplates(String templateTypeId) { - - return Response.ok().entity("magic!").build(); - } - @Override public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { @@ -174,7 +150,17 @@ public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, Stri @Override public Response deleteEmailTemplateType(String templateTypeId) { - templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId); + try { + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId); + } catch (NotificationTemplateManagerException e) { + String partiallyDeletedErrorCode = Constants.NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX + + ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; + if (partiallyDeletedErrorCode.equals(e.getErrorCode())) { + return Response.ok().build(); + } + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); + } return Response.noContent().build(); } @@ -195,7 +181,17 @@ public Response deleteOrgSMSTemplate(String templateTypeId, String locale) { @Override public Response deleteSMSTemplateType(String templateTypeId) { - templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeId); + try { + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeId); + } catch (NotificationTemplateManagerException e) { + String partiallyDeletedErrorCode = Constants.NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX + + ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; + if (partiallyDeletedErrorCode.equals(e.getErrorCode())) { + return Response.ok().build(); + } + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); + } return Response.noContent().build(); } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index c519fcfd49..7899e9a70a 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -131,14 +131,20 @@ paths: summary: Removes an email template type. operationId: deleteEmailTemplateType description: | - Removes an existing email template type with all its email templates + Removes an existing email template type with all its user defined email templates from the system.
+ **System template types are not eligible for deletion.** + Attempt to delete a system template type will result + in a partial deletion of only the user defined templates. + Template type will not be deleted.
Scope required:
* internal_email_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: + '200': + description: 'Partial Deletion.' '204': $ref: '#/components/responses/Deleted' '400': @@ -226,57 +232,6 @@ paths: $ref: '#/components/responses/Conflict' '500': $ref: '#/components/responses/ServerError' - delete: - tags: - - Email Templates - summary: Removes all org email templates. - operationId: deleteAllOrgEmailTemplates - description: | - Removes all existing organization email templates from the system.
- - Scope required:
- * internal_email_mgt_delete - parameters: - - $ref: '#/components/parameters/templateTypeIdPathParam' - responses: - '204': - $ref: '#/components/responses/Deleted' - '400': - $ref: '#/components/responses/InvalidInput' - '401': - $ref: '#/components/responses/Unauthorized' - '403': - $ref: '#/components/responses/Forbidden' - '404': - $ref: '#/components/responses/NotFound' - '500': - $ref: '#/components/responses/ServerError' - '/notification/email/template-types/{template-type-id}/app-templates': - delete: - tags: - - Application Email Templates - summary: Removes all application email templates for the organization. - operationId: deleteAllAppEmailTemplates - description: | - Removes all application email templates defined for all applications of the organization.
- - Scope required:
- * internal_template_mgt_delete - parameters: - - $ref: '#/components/parameters/templateTypeIdPathParam' - responses: - '204': - $ref: '#/components/responses/Deleted' - '400': - $ref: '#/components/responses/InvalidInput' - '401': - $ref: '#/components/responses/Unauthorized' - '403': - $ref: '#/components/responses/Forbidden' - '404': - $ref: '#/components/responses/NotFound' - '500': - $ref: '#/components/responses/ServerError' '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}': get: tags: @@ -703,42 +658,20 @@ paths: summary: Removes an SMS template type. operationId: deleteSMSTemplateType description: | - Removes an existing SMS template type with all its SMS templates + Removes an existing SMS template type with all its user defined SMS templates from the system.
+ **System template types are not eligible for deletion.** + Attempt to delete a system template type will result + in a partial deletion of only the user defined templates. + Template type will not be deleted.
Scope required:
* internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: - '204': - $ref: '#/components/responses/Deleted' - '400': - $ref: '#/components/responses/InvalidInput' - '401': - $ref: '#/components/responses/Unauthorized' - '403': - $ref: '#/components/responses/Forbidden' - '404': - $ref: '#/components/responses/NotFound' - '500': - $ref: '#/components/responses/ServerError' - '/notification/sms/template-types/{template-type-id}/app-templates': - delete: - tags: - - Application SMS Templates - summary: Removes all application SMS templates for the organization. - operationId: deleteAllAppSMSTemplates - description: | - Removes all application SMS templates defined for all applications of the organization.
- - Scope required:
- * internal_template_mgt_delete - parameters: - - $ref: '#/components/parameters/templateTypeIdPathParam' - - $ref: '#/components/parameters/appUuidPathParam' - - $ref: '#/components/parameters/localePathParam' - responses: + '200': + description: 'Partial Deletion.' '204': $ref: '#/components/responses/Deleted' '400': @@ -995,31 +928,6 @@ paths: $ref: '#/components/responses/Conflict' '500': $ref: '#/components/responses/ServerError' - delete: - tags: - - SMS Templates - summary: Removes all org SMS templates. - operationId: deleteAllOrgSMSTemplates - description: | - Removes all existing organization SMS templates from the system.
- - Scope required:
- * internal_template_mgt_delete - parameters: - - $ref: '#/components/parameters/templateTypeIdPathParam' - responses: - '204': - $ref: '#/components/responses/Deleted' - '400': - $ref: '#/components/responses/InvalidInput' - '401': - $ref: '#/components/responses/Unauthorized' - '403': - $ref: '#/components/responses/Forbidden' - '404': - $ref: '#/components/responses/NotFound' - '500': - $ref: '#/components/responses/ServerError' '/notification/sms/template-types/{template-type-id}/org-templates/{locale}': get: tags: @@ -1349,7 +1257,6 @@ components: type: string example: /t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US description: Location of the created/updated resource. - Error: type: object required: From 5ffcd2e0e4b51fbc443bf0eb4d6780e01dc03be6 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Sat, 5 Oct 2024 09:31:03 +0530 Subject: [PATCH 08/17] Add reset template type endpoints and minor fixes in template definition. --- .../template/common/Constants.java | 5 +- .../template/v1/NotificationApi.java | 98 ++++++++--- .../template/v1/NotificationApiService.java | 4 + .../template/v1/model/SimpleTemplate.java | 2 +- .../template/v1/model/TemplateType.java | 6 +- .../template/v1/core/TemplateTypeService.java | 44 +++-- .../v1/impl/NotificationApiServiceImpl.java | 43 ++--- .../main/resources/notification-template.yml | 156 ++++++++++++------ 8 files changed, 232 insertions(+), 126 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 9c07b5fe1b..26fc573d2a 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -100,7 +100,10 @@ public enum ErrorMessage { "Server encountered an error while deleting the SMS template."), ERROR_ERROR_RETRIEVING_TEMPLATES("60012", Status.INTERNAL_SERVER_ERROR, "Unable to retrieve templates.", - "Server encountered an error while retrieving templates."); + "Server encountered an error while retrieving templates."), + ERROR_ERROR_RESETTING_TEMPLATE_TYPE("60005", Status.INTERNAL_SERVER_ERROR, + "Unable to reset the template type.", + "Server encountered an error while deleting the templates of the template type."); private final String message; private final Status httpStatus; diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index c359ba820f..f20d2fd0b2 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -54,7 +54,7 @@ public class NotificationApi { @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_email_mgt_create / internal_template_mgt_update ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -104,7 +104,7 @@ public Response addAppSMSTemplate(@ApiParam(value = "Template Type ID.",required @Path("/email/template-types") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_email_mgt_create / internal_template_mgt_update ", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -128,7 +128,7 @@ public Response addEmailTemplateType(@ApiParam(value = "Email template type to b @Path("/email/template-types/{template-type-id}/org-templates") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new organization email template to an existing email template type.", notes = "Another organization email template with the same locale should not already exist in the respective email template type.
Scope required:
* internal_email_mgt_create / internal_template_mgt_update ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -153,7 +153,7 @@ public Response addOrgEmailTemplate(@ApiParam(value = "Template Type ID.",requir @Path("/sms/template-types/{template-type-id}/org-templates") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_template_mgt_create ", response = SimpleTemplate.class, authorizations = { + @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another organization SMS template with the same locale should not already exist in the respective SMS template type.
Scope required:
* internal_template_mgt_create ", response = SimpleTemplate.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -178,7 +178,7 @@ public Response addOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required @Path("/sms/template-types") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_template_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. A SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scope required:
* internal_template_mgt_create ", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -202,7 +202,7 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an application email template.", notes = "Removes an applicationemail template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an application email template.", notes = "Removes an application email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete / internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -226,7 +226,7 @@ public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",req @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes a SMS template.", notes = "Removes a SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -250,14 +250,13 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its user defined email templates from the system.
**System template types are not eligible for deletion.** Attempt to delete a system template type will result in a partial deletion of only the user defined templates. Template type will not be deleted.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
**Note : System resources are not eligible for deletion.**
Attempt to delete a system resource will result in a 403 Forbidden error.
Scope required:
* internal_email_mgt_delete / internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Email Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Partial Deletion.", response = Void.class), @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @@ -275,7 +274,7 @@ public Response deleteEmailTemplateType(@ApiParam(value = "Template Type ID.",re @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes an organization email template.", notes = "Removes an organization email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_delete / internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -323,14 +322,13 @@ public Response deleteOrgSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/sms/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its user defined SMS templates from the system.
**System template types are not eligible for deletion.** Attempt to delete a system template type will result in a partial deletion of only the user defined templates. Template type will not be deleted.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Removes a SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
**Note : System resources are not eligible for deletion.**
Attempt to delete a system resource will result in a 403 Forbidden error.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "SMS Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Partial Deletion.", response = Void.class), @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @@ -348,7 +346,7 @@ public Response deleteSMSTemplateType(@ApiParam(value = "Template Type ID.",requ @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of application email templates under the provided template type.", notes = "Retrieves the list of application email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of application email templates under the provided template type.", notes = "Retrieves the list of application email templates under the provided template type.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -396,7 +394,7 @@ public Response getAllAppTemplatesOfSMSTemplateType(@ApiParam(value = "Template @Path("/email/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scope required:
* internal_email_mgt_view / internal_template_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -419,7 +417,7 @@ public Response getAllEmailTemplateTypes() { @Path("/email/template-types/{template-type-id}/org-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the list of organization email templates under the provided template type.", notes = "Retrieves the list of organization email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the list of organization email templates under the provided template type.", notes = "Retrieves the list of organization email templates under the provided template type.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -467,7 +465,7 @@ public Response getAllOrgTemplatesOfSMSTemplateType(@ApiParam(value = "Template @Path("/sms/template-types") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_template_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves all the SMS template types.", notes = "Retrieves all the SMS template types in the system.
Scope required:
* internal_template_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -490,7 +488,7 @@ public Response getAllSMSTemplateTypes() { @Path("/email/template-types/{template-type-id}/system-templates") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the system email templates of template type.", notes = "Retrieves the list of system default email templates under the provided template type.
Scope required:
* internal_email_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Retrieves the system email templates of template type.", notes = "Retrieves the list of system default email templates under the provided template type.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view
", response = SimpleTemplate.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -538,7 +536,7 @@ public Response getAllSystemTemplatesOfSMSTemplateType(@ApiParam(value = "Templa @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -586,7 +584,7 @@ public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required @Path("/email/template-types/{template-type-id}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view
", response = TemplateTypeWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -610,7 +608,7 @@ public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",requi @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single organization email template.", notes = "Retrieves the organization email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -634,7 +632,7 @@ public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",requir @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the organization SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -682,7 +680,7 @@ public Response getSMSTemplateType(@ApiParam(value = "Template Type ID.",require @Path("/email/template-types/{template-type-id}/system-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the default email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the default email template for given type and locale.", notes = "Retrieves the system default email template that matches the template-type-id and the locale.
Scope required:
* internal_email_mgt_view / internal_template_mgt_view ", response = EmailTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -706,7 +704,7 @@ public Response getSystemEmailTemplate(@ApiParam(value = "Template Type ID.",req @Path("/sms/template-types/{template-type-id}/system-templates/{locale}") @Produces({ "application/json" }) - @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @ApiOperation(value = "Retrieves the default organization SMS template.", notes = "Retrieves the system default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view ", response = SMSTemplateWithID.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -725,12 +723,58 @@ public Response getSystemSMSTemplate(@ApiParam(value = "Template Type ID.",requi return delegate.getSystemSMSTemplate(templateTypeId, locale ); } + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/reset") + + @Produces({ "application/json" }) + @ApiOperation(value = "Resets an email template type.", notes = "Resets an existing email template type by deleting all its **user defined** email templates from the system.
Scope required:
* internal_email_mgt_delete / internal_template_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response resetEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.resetEmailTemplateType(templateTypeId ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/reset") + + @Produces({ "application/json" }) + @ApiOperation(value = "Resets a SMS template type.", notes = "Resets an existing SMS template type by deleting all its **user defined** SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response resetSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.resetSMSTemplateType(templateTypeId ); + } + @Valid @PUT @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_update / internal_template_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -778,7 +822,7 @@ public Response updateAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi @Path("/email/template-types/{template-type-id}/org-templates/{locale}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @ApiOperation(value = "Replaces an existing organization email template.", notes = "Replaces the organization email template identified by the template-type-id and the locale.
Scope required:
* internal_email_mgt_update / internal_template_mgt_update ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -792,7 +836,7 @@ public Response updateAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + public Response updateOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Updated email template for the template type." ) @Valid EmailTemplate emailTemplate) { return delegate.updateOrgEmailTemplate(templateTypeId, locale, emailTemplate ); } @@ -816,7 +860,7 @@ public Response updateOrgEmailTemplate(@ApiParam(value = "Template Type ID.",req @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response updateOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "SMS templates for the template type." ) @Valid SMSTemplate smSTemplate) { + public Response updateOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Updated SMS template for the template type." ) @Valid SMSTemplate smSTemplate) { return delegate.updateOrgSMSTemplate(templateTypeId, locale, smSTemplate ); } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index 0674bcdc55..9690accf7a 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -93,6 +93,10 @@ public interface NotificationApiService { public Response getSystemSMSTemplate(String templateTypeId, String locale); + public Response resetEmailTemplateType(String templateTypeId); + + public Response resetSMSTemplateType(String templateTypeId); + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate); public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smSTemplate); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java index e47e891a59..5dfa9ee8a5 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java @@ -65,7 +65,7 @@ public SimpleTemplate self(String self) { return this; } - @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US", required = true, value = "Location of the created/updated resource.") + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/{{org|app|system}}templates/en_US", required = true, value = "Location of the created/updated resource.") @JsonProperty("self") @Valid @NotNull(message = "Property self cannot be null.") diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java index a054eb72c2..17aa11ab4a 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java @@ -36,7 +36,7 @@ public class TemplateType { private String self; /** - * Display name of the email template type. + * Display name of the template type. **/ public TemplateType displayName(String displayName) { @@ -44,7 +44,7 @@ public TemplateType displayName(String displayName) { return this; } - @ApiModelProperty(example = "Account Confirmation", required = true, value = "Display name of the email template type.") + @ApiModelProperty(example = "Account Confirmation", required = true, value = "Display name of the template type.") @JsonProperty("displayName") @Valid @NotNull(message = "Property displayName cannot be null.") @@ -65,7 +65,7 @@ public TemplateType self(String self) { return this; } - @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/email/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Location of the created/updated resource.") + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Location of the created/updated resource.") @JsonProperty("self") @Valid @NotNull(message = "Property self cannot be null.") diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 34953b5b3b..5e4938d3af 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -18,7 +18,6 @@ package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; -import org.apache.commons.lang.StringUtils; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; @@ -29,8 +28,6 @@ import java.util.ArrayList; import java.util.List; -import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes - .ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; /** @@ -99,13 +96,12 @@ public List getAllNotificationTemplateTypes(String notificat * Delete a notification template type from the tenant. * * @param notificationChannel Notification channel (Eg: sms, email). - * @param templateId ID of the template type. + * @param templateTypeId ID of the template type. */ - public void deleteNotificationTemplateType(String notificationChannel, String templateId) - throws NotificationTemplateManagerException { + public void deleteNotificationTemplateType(String notificationChannel, String templateTypeId) { String templateTypeDisplayName; - templateTypeDisplayName = Util.decodeTemplateTypeId(templateId); + templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { boolean isTemplateTypeExists = TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( @@ -117,18 +113,38 @@ public void deleteNotificationTemplateType(String notificationChannel, String te throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); } } catch (NotificationTemplateManagerException e) { - String errorCode = StringUtils.EMPTY; - if (StringUtils.isNotBlank(e.getErrorCode()) && e.getErrorCode().split("-").length > 1) { - errorCode = e.getErrorCode().split("-")[1]; - } - if (ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED.equals(errorCode)) { - throw e; - } throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); } } + /** + * Reset a specific template type. Deletes all org and app templates under the type. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateTypeId ID of the template type. + */ + public void resetTemplateType(String notificationChannel, String templateTypeId) { + + String templateTypeDisplayName; + templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + boolean isTemplateTypeExists = + TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + if (isTemplateTypeExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteCustomizedNotificationTemplates( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext() + ); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RESETTING_TEMPLATE_TYPE); + } + } + /** * Get a specific notification template type. * diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index 378947ba3d..622e5d6a90 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.server.notification.template.common.Constants; -import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplateTypeService; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplatesService; @@ -31,15 +30,15 @@ import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; -import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; import java.net.URI; import javax.ws.rs.core.Response; -import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForHeader; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_SMS; import static org.wso2.carbon.identity.api.server.notification.template.common. Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; import static org.wso2.carbon.identity.api.server.notification.template.common. @@ -150,17 +149,7 @@ public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, Stri @Override public Response deleteEmailTemplateType(String templateTypeId) { - try { - templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId); - } catch (NotificationTemplateManagerException e) { - String partiallyDeletedErrorCode = Constants.NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX - + ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; - if (partiallyDeletedErrorCode.equals(e.getErrorCode())) { - return Response.ok().build(); - } - throw Util.handleNotificationTemplateManagerException(e, - Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); - } + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId); return Response.noContent().build(); } @@ -181,17 +170,7 @@ public Response deleteOrgSMSTemplate(String templateTypeId, String locale) { @Override public Response deleteSMSTemplateType(String templateTypeId) { - try { - templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeId); - } catch (NotificationTemplateManagerException e) { - String partiallyDeletedErrorCode = Constants.NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX - + ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; - if (partiallyDeletedErrorCode.equals(e.getErrorCode())) { - return Response.ok().build(); - } - throw Util.handleNotificationTemplateManagerException(e, - Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); - } + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeId); return Response.noContent().build(); } @@ -305,6 +284,20 @@ public Response getSystemSMSTemplate(String templateTypeId, String locale) { return Response.ok().entity(templatesService.getSystemSmsTemplate(templateTypeId, locale)).build(); } + @Override + public Response resetEmailTemplateType(String templateTypeId) { + + templateTypeService.resetTemplateType(NOTIFICATION_CHANNEL_EMAIL, templateTypeId); + return Response.noContent().build(); + } + + @Override + public Response resetSMSTemplateType(String templateTypeId) { + + templateTypeService.resetTemplateType(NOTIFICATION_CHANNEL_SMS, templateTypeId); + return Response.noContent().build(); + } + @Override public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index 7899e9a70a..dde965070a 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -14,9 +14,9 @@ tags: - name: Application Email Templates description: An application email template of a specific type and a language. - name: SMS Template Types - description: An sms template type can have multiple sms templates for different languages. + description: A SMS template type can have multiple SMS templates for different languages. - name: SMS Templates - description: An SMS template of a specific type and a language. + description: A SMS template of a specific type and a language. - name: Application SMS Templates description: An application email template of a specific type and a language. - name: System Templates @@ -36,7 +36,7 @@ paths:
Scope required: -
* internal_email_mgt_view +
* internal_email_mgt_view / internal_template_mgt_view responses: '200': description: Search results matching the given criteria. @@ -66,7 +66,7 @@ paths: * Attribute _**displayName**_ of the template type should be unique.
Scope required: -
* internal_email_mgt_create +
* internal_email_mgt_create / internal_template_mgt_update requestBody: content: application/json: @@ -105,7 +105,7 @@ paths: Retrieves the email template type in the system identified by the template-type-id.
Scope required:
- * internal_email_mgt_view
+ * internal_email_mgt_view / internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -131,20 +131,16 @@ paths: summary: Removes an email template type. operationId: deleteEmailTemplateType description: | - Removes an existing email template type with all its user defined email templates + Removes an existing email template type with all its email templates from the system.
- **System template types are not eligible for deletion.** - Attempt to delete a system template type will result - in a partial deletion of only the user defined templates. - Template type will not be deleted.
+ **Note : System resources are not eligible for deletion.**
+ Attempt to delete a system resource will result in a 403 Forbidden error.
Scope required:
- * internal_email_mgt_delete + * internal_email_mgt_delete / internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: - '200': - description: 'Partial Deletion.' '204': $ref: '#/components/responses/Deleted' '400': @@ -157,6 +153,31 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/reset': + delete: + tags: + - Email Template Types + summary: Resets an email template type. + operationId: resetEmailTemplateType + description: | + Resets an existing email template type by deleting all its **user defined** email templates + from the system.
+ + Scope required:
+ * internal_email_mgt_delete / internal_template_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/email/template-types/{template-type-id}/org-templates': get: tags: @@ -167,7 +188,7 @@ paths: Retrieves the list of organization email templates under the provided template type.
Scope required:
- * internal_email_mgt_view
+ * internal_email_mgt_view / internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -192,14 +213,14 @@ paths: post: tags: - Email Templates - summary: Adds a new email template to an existing email template type. + summary: Adds a new organization email template to an existing email template type. operationId: addOrgEmailTemplate description: | - Another email template with the same locale should not already exist in the + Another organization email template with the same locale should not already exist in the respective email template type.
Scope required:
- * internal_email_mgt_create + * internal_email_mgt_create / internal_template_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' requestBody: @@ -242,7 +263,7 @@ paths: Retrieves the list of application email templates under the provided template type.
Scope required:
- * internal_email_mgt_view
+ * internal_email_mgt_view / internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -275,7 +296,7 @@ paths: respective email template type.
Scope required:
- * internal_email_mgt_create + * internal_email_mgt_create / internal_template_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -313,13 +334,13 @@ paths: get: tags: - Email Templates - summary: Retrieves a single email template. + summary: Retrieves a single organization email template. operationId: getOrgEmailTemplate description: | - Retrieves the email template that matches to the template-type-id and the locale.
+ Retrieves the organization email template that matches to the template-type-id and the locale.
Scope required:
- * internal_email_mgt_view + * internal_email_mgt_view / internal_template_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -343,13 +364,13 @@ paths: put: tags: - Email Templates - summary: Replaces an existing email template. + summary: Replaces an existing organization email template. operationId: updateOrgEmailTemplate description: | - Replaces the email template identified by the template-type-id and the locale.
+ Replaces the organization email template identified by the template-type-id and the locale.
Scope required:
- * internal_email_mgt_update + * internal_email_mgt_update / internal_template_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -358,7 +379,7 @@ paths: application/json: schema: $ref: '#/components/schemas/EmailTemplate' - description: Email templates for the template type. + description: Updated email template for the template type. responses: '200': $ref: '#/components/responses/Updated' @@ -375,13 +396,13 @@ paths: delete: tags: - Email Templates - summary: Removes an email template. + summary: Removes an organization email template. operationId: deleteOrgEmailTemplate description: | - Removes an email template identified by the template-type-id and the locale.
+ Removes an organization email template identified by the template-type-id and the locale.
Scope required:
- * internal_email_mgt_delete + * internal_email_mgt_delete / internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -408,7 +429,7 @@ paths: Retrieves the list of system default email templates under the provided template type.
Scope required:
- * internal_email_mgt_view
+ * internal_email_mgt_view / internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: @@ -437,10 +458,10 @@ paths: summary: Retrieves the default email template for given type and locale. operationId: getSystemEmailTemplate description: | - Retrieves the default email template that matches to the template-type-id and the locale.
+ Retrieves the system default email template that matches the template-type-id and the locale.
Scope required:
- * internal_email_mgt_view + * internal_email_mgt_view / internal_template_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' @@ -471,7 +492,7 @@ paths: Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
- * internal_email_mgt_view + * internal_email_mgt_view / internal_template_mgt_view parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -502,7 +523,7 @@ paths: Replaces the application email template identified by the template-type-id and the locale.
Scope required:
- * internal_email_mgt_update + * internal_email_mgt_update / internal_template_mgt_update parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -532,10 +553,10 @@ paths: summary: Removes an application email template. operationId: deleteAppEmailTemplate description: | - Removes an applicationemail template identified by the template-type-id and the locale.
+ Removes an application email template identified by the template-type-id and the locale.
Scope required:
- * internal_email_mgt_delete + * internal_email_mgt_delete / internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' @@ -557,7 +578,7 @@ paths: get: tags: - SMS Template Types - summary: Retrieves all the sms template types. + summary: Retrieves all the SMS template types. operationId: getAllSMSTemplateTypes description: | Retrieves all the SMS template types in the system.
@@ -587,7 +608,7 @@ paths: summary: Adds a new SMS template type. operationId: addSMSTemplateType description: | - Adds a new SMS template type to the system. An SMS template type can have any number of + Adds a new SMS template type to the system. A SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
@@ -655,23 +676,19 @@ paths: delete: tags: - SMS Template Types - summary: Removes an SMS template type. + summary: Removes a SMS template type. operationId: deleteSMSTemplateType description: | - Removes an existing SMS template type with all its user defined SMS templates + Removes an existing SMS template type with all its SMS templates from the system.
- **System template types are not eligible for deletion.** - Attempt to delete a system template type will result - in a partial deletion of only the user defined templates. - Template type will not be deleted.
+ **Note : System resources are not eligible for deletion.**
+ Attempt to delete a system resource will result in a 403 Forbidden error.
Scope required:
* internal_template_mgt_delete parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' responses: - '200': - description: 'Partial Deletion.' '204': $ref: '#/components/responses/Deleted' '400': @@ -684,6 +701,32 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' + + '/notification/sms/template-types/{template-type-id}/reset': + delete: + tags: + - SMS Template Types + summary: Resets a SMS template type. + operationId: resetSMSTemplateType + description: | + Resets an existing SMS template type by deleting all its **user defined** SMS templates + from the system.
+ + Scope required:
+ * internal_template_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}': get: tags: @@ -829,10 +872,10 @@ paths: delete: tags: - Application SMS Templates - summary: Removes an SMS template. + summary: Removes a SMS template. operationId: deleteAppSMSTemplate description: | - Removes an SMS template identified by the template-type-id and the locale.
+ Removes a SMS template identified by the template-type-id and the locale.
Scope required:
* internal_template_mgt_delete @@ -891,7 +934,7 @@ paths: summary: Adds a new organization SMS template to an existing SMS template type. operationId: addOrgSMSTemplate description: | - Another SMS organization template with the same locale should not already exist in the + Another organization SMS template with the same locale should not already exist in the respective SMS template type.
Scope required:
@@ -935,7 +978,7 @@ paths: summary: Retrieves a single organization SMS template. operationId: getOrgSMSTemplate description: | - Retrieves the SMS template that matches to the template-type-id and the locale.
+ Retrieves the organization SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view @@ -977,7 +1020,7 @@ paths: application/json: schema: $ref: '#/components/schemas/SMSTemplate' - description: SMS templates for the template type. + description: Updated SMS template for the template type. responses: '200': $ref: '#/components/responses/Updated' @@ -1056,7 +1099,7 @@ paths: summary: Retrieves the default organization SMS template. operationId: getSystemSMSTemplate description: | - Retrieves the default SMS template that matches to the template-type-id and the locale.
+ Retrieves the system default SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_template_mgt_view @@ -1082,6 +1125,9 @@ paths: $ref: '#/components/responses/ServerError' servers: + # Added by API Auto Mocking Plugin + - description: SwaggerHub API Auto Mocking + url: https://virtserver.swaggerhub.com/RUSHANNANA/NotificationTemplateAPI/1.0.0 - url: 'https://localhost:9443/t/{tenant-domain}/api/server/v1' variables: tenant-domain: @@ -1164,10 +1210,10 @@ components: displayName: type: string example: Account Confirmation - description: Display name of the email template type. + description: Display name of the template type. self: type: string - example: /t/{tenant-domain}/api/server/v1/notification/email/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg + example: /t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg description: Location of the created/updated resource. TemplateTypeOverview: type: object @@ -1255,7 +1301,7 @@ components: Locale of the template. self: type: string - example: /t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US + example: /t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/{{org|app|system}}templates/en_US description: Location of the created/updated resource. Error: type: object From a9d3c1f99c35f50776b30665b38b1f620fa91abf Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 15 Oct 2024 19:19:06 +0530 Subject: [PATCH 09/17] Add resetTemplateType function common to all channels. --- .../pom.xml | 2 +- .../template/common/Constants.java | 12 +- .../pom.xml | 2 +- .../template/v1/NotificationApi.java | 52 +++----- .../template/v1/NotificationApiService.java | 5 +- .../template/v1/model/SimpleTemplate.java | 4 +- .../v1/model/SimpleTemplateTypeID.java | 125 ++++++++++++++++++ .../template/v1/core/TemplateTypeService.java | 8 ++ .../v1/impl/NotificationApiServiceImpl.java | 23 ++-- .../main/resources/notification-template.yml | 65 ++++----- .../pom.xml | 2 +- pom.xml | 6 +- 12 files changed, 204 insertions(+), 102 deletions(-) create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplateTypeID.java diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml index cd555002d7..ae508c9072 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.228-SNAPSHOT + 1.2.236-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 26fc573d2a..29d05ef2d6 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -23,6 +23,7 @@ import javax.ws.rs.core.Response.Status; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_ADDING_TEMPLATE; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_RESOLVING_MAIN_APPLICATION; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_ALREADY_EXISTS; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_NOT_FOUND; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_ALREADY_EXISTS; @@ -101,9 +102,15 @@ public enum ErrorMessage { ERROR_ERROR_RETRIEVING_TEMPLATES("60012", Status.INTERNAL_SERVER_ERROR, "Unable to retrieve templates.", "Server encountered an error while retrieving templates."), - ERROR_ERROR_RESETTING_TEMPLATE_TYPE("60005", Status.INTERNAL_SERVER_ERROR, + ERROR_ERROR_RESETTING_TEMPLATE_TYPE("60013", Status.INTERNAL_SERVER_ERROR, "Unable to reset the template type.", - "Server encountered an error while deleting the templates of the template type."); + "Server encountered an error while deleting the templates of the template type."), + ERROR_ERROR_RESOLVING_MAIN_APPLICATION("60014", Status.INTERNAL_SERVER_ERROR, + "Unable to resolve the main application.", + "Server encountered an error while resolving the main application."), + ERROR_ERROR_INVALID_NOTIFICATION_CHANNEL("60015", Status.BAD_REQUEST, + "Invalid notification channel.", + "Notification channel can only be either 'EMAIL' or 'SMS'."); private final String message; private final Status httpStatus; @@ -151,6 +158,7 @@ public String toString() { NTM_ERROR_CODE_MAP.put(TEMPLATE_ALREADY_EXISTS, ErrorMessage.ERROR_TEMPLATE_ALREADY_EXISTS); NTM_ERROR_CODE_MAP.put(TEMPLATE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); NTM_ERROR_CODE_MAP.put(ERROR_ADDING_TEMPLATE, ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + NTM_ERROR_CODE_MAP.put(ERROR_RESOLVING_MAIN_APPLICATION, ErrorMessage.ERROR_ERROR_RESOLVING_MAIN_APPLICATION); } public static ErrorMessage getNTMMappedErrorMessage(String errorCode) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml index 20d6e6a438..266f248957 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.228-SNAPSHOT + 1.2.236-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index f20d2fd0b2..59c6729372 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -30,6 +30,7 @@ import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplateTypeID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; @@ -209,7 +210,7 @@ public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be ad }) }, tags={ "Application Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -233,7 +234,7 @@ public Response deleteAppEmailTemplate(@ApiParam(value = "Template Type ID.",req }) }, tags={ "Application SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -257,7 +258,7 @@ public Response deleteAppSMSTemplate(@ApiParam(value = "Template Type ID.",requi }) }, tags={ "Email Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -281,7 +282,7 @@ public Response deleteEmailTemplateType(@ApiParam(value = "Template Type ID.",re }) }, tags={ "Email Templates", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -305,7 +306,7 @@ public Response deleteOrgEmailTemplate(@ApiParam(value = "Template Type ID.",req }) }, tags={ "SMS Templates", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -329,7 +330,7 @@ public Response deleteOrgSMSTemplate(@ApiParam(value = "Template Type ID.",requi }) }, tags={ "SMS Template Types", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), @@ -724,49 +725,26 @@ public Response getSystemSMSTemplate(@ApiParam(value = "Template Type ID.",requi } @Valid - @DELETE - @Path("/email/template-types/{template-type-id}/reset") - - @Produces({ "application/json" }) - @ApiOperation(value = "Resets an email template type.", notes = "Resets an existing email template type by deleting all its **user defined** email templates from the system.
Scope required:
* internal_email_mgt_delete / internal_template_mgt_delete ", response = Void.class, authorizations = { - @Authorization(value = "BasicAuth"), - @Authorization(value = "OAuth2", scopes = { - - }) - }, tags={ "Email Template Types", }) - @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), - @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), - @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), - @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), - @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) - }) - public Response resetEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { - - return delegate.resetEmailTemplateType(templateTypeId ); - } - - @Valid - @DELETE - @Path("/sms/template-types/{template-type-id}/reset") - + @POST + @Path("/reset-template-type") + @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Resets a SMS template type.", notes = "Resets an existing SMS template type by deleting all its **user defined** SMS templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Resets an template type.", notes = "Resets an existing template type by deleting all its **user defined** templates from the system.
Scope required:
* internal_template_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) - }, tags={ "SMS Template Types", }) + }, tags={ "Functions", }) @ApiResponses(value = { - @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 204, message = "Item/s Deleted.", response = Void.class), @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response resetSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response resetTemplateType(@ApiParam(value = "" ) @Valid SimpleTemplateTypeID simpleTemplateTypeID) { - return delegate.resetSMSTemplateType(templateTypeId ); + return delegate.resetTemplateType(simpleTemplateTypeID ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index 9690accf7a..feb3334c4d 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -30,6 +30,7 @@ import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplateTypeID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; import javax.ws.rs.core.Response; @@ -93,9 +94,7 @@ public interface NotificationApiService { public Response getSystemSMSTemplate(String templateTypeId, String locale); - public Response resetEmailTemplateType(String templateTypeId); - - public Response resetSMSTemplateType(String templateTypeId); + public Response resetTemplateType(SimpleTemplateTypeID simpleTemplateTypeID); public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java index 5dfa9ee8a5..eb735186b1 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java @@ -57,7 +57,7 @@ public void setLocale(String locale) { } /** - * Location of the created/updated resource. + * Location of the created/updated resource. resource. **/ public SimpleTemplate self(String self) { @@ -65,7 +65,7 @@ public SimpleTemplate self(String self) { return this; } - @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/{{org|app|system}}templates/en_US", required = true, value = "Location of the created/updated resource.") + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/{{org|app|system}}templates/en_US", required = true, value = "Location of the created/updated resource. resource.") @JsonProperty("self") @Valid @NotNull(message = "Property self cannot be null.") diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplateTypeID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplateTypeID.java new file mode 100644 index 0000000000..20503f763a --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplateTypeID.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SimpleTemplateTypeID { + + private String templateTypeId; + private String channel; + + /** + * Unique ID of the template type. + **/ + public SimpleTemplateTypeID templateTypeId(String templateTypeId) { + + this.templateTypeId = templateTypeId; + return this; + } + + @ApiModelProperty(example = "YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Unique ID of the template type.") + @JsonProperty("templateTypeId") + @Valid + @NotNull(message = "Property templateTypeId cannot be null.") + + public String getTemplateTypeId() { + return templateTypeId; + } + public void setTemplateTypeId(String templateTypeId) { + this.templateTypeId = templateTypeId; + } + + /** + * Notification channel of the template type (SMS or EMAIL). + **/ + public SimpleTemplateTypeID channel(String channel) { + + this.channel = channel; + return this; + } + + @ApiModelProperty(example = "EMAIL", required = true, value = "Notification channel of the template type (SMS or EMAIL).") + @JsonProperty("channel") + @Valid + @NotNull(message = "Property channel cannot be null.") + + public String getChannel() { + return channel; + } + public void setChannel(String channel) { + this.channel = channel; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SimpleTemplateTypeID simpleTemplateTypeID = (SimpleTemplateTypeID) o; + return Objects.equals(this.templateTypeId, simpleTemplateTypeID.templateTypeId) && + Objects.equals(this.channel, simpleTemplateTypeID.channel); + } + + @Override + public int hashCode() { + return Objects.hash(templateTypeId, channel); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SimpleTemplateTypeID {\n"); + + sb.append(" templateTypeId: ").append(toIndentedString(templateTypeId)).append("\n"); + sb.append(" channel: ").append(toIndentedString(channel)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 5e4938d3af..89be9fd673 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -29,6 +29,7 @@ import java.util.List; import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_EMAIL; /** * Service class for the template types. @@ -126,6 +127,13 @@ public void deleteNotificationTemplateType(String notificationChannel, String te */ public void resetTemplateType(String notificationChannel, String templateTypeId) { + if (NOTIFICATION_CHANNEL_EMAIL.equalsIgnoreCase(notificationChannel)) { + notificationChannel = NOTIFICATION_CHANNEL_EMAIL; + } else if (Constants.NOTIFICATION_CHANNEL_SMS.equalsIgnoreCase(notificationChannel)) { + notificationChannel = Constants.NOTIFICATION_CHANNEL_SMS; + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_ERROR_INVALID_NOTIFICATION_CHANNEL); + } String templateTypeDisplayName; templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index 622e5d6a90..e83134c6a7 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -28,6 +28,7 @@ import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplateTypeID; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; @@ -37,8 +38,6 @@ import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForHeader; import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; -import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_EMAIL; -import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_SMS; import static org.wso2.carbon.identity.api.server.notification.template.common. Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; import static org.wso2.carbon.identity.api.server.notification.template.common. @@ -285,16 +284,10 @@ public Response getSystemSMSTemplate(String templateTypeId, String locale) { } @Override - public Response resetEmailTemplateType(String templateTypeId) { + public Response resetTemplateType(SimpleTemplateTypeID simpleTemplateTypeID) { - templateTypeService.resetTemplateType(NOTIFICATION_CHANNEL_EMAIL, templateTypeId); - return Response.noContent().build(); - } - - @Override - public Response resetSMSTemplateType(String templateTypeId) { - - templateTypeService.resetTemplateType(NOTIFICATION_CHANNEL_SMS, templateTypeId); + templateTypeService.resetTemplateType(simpleTemplateTypeID.getChannel(), + simpleTemplateTypeID.getTemplateTypeId()); return Response.noContent().build(); } @@ -308,9 +301,9 @@ public Response updateAppEmailTemplate(String templateTypeId, String appUuid, St @Override public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, - SMSTemplate smsTemplate) { + SMSTemplate smSTemplate) { - templatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); + templatesService.updateSMSTemplate(templateTypeId, locale, smSTemplate, appUuid); return Response.ok().build(); } @@ -322,9 +315,9 @@ public Response updateOrgEmailTemplate(String templateTypeId, String locale, Ema } @Override - public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smsTemplate) { + public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smSTemplate) { - templatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate); + templatesService.updateSMSTemplate(templateTypeId, locale, smSTemplate); return Response.ok().build(); } } diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index dde965070a..fb82fcfa60 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -153,20 +153,23 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' - '/notification/email/template-types/{template-type-id}/reset': - delete: + '/notification/reset-template-type': + post: tags: - - Email Template Types - summary: Resets an email template type. - operationId: resetEmailTemplateType + - Functions + summary: Resets an template type. + operationId: resetTemplateType description: | - Resets an existing email template type by deleting all its **user defined** email templates + Resets an existing template type by deleting all its **user defined** templates from the system.
Scope required:
- * internal_email_mgt_delete / internal_template_mgt_delete - parameters: - - $ref: '#/components/parameters/templateTypeIdPathParam' + * internal_template_mgt_delete + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SimpleTemplateTypeID' responses: '204': $ref: '#/components/responses/Deleted' @@ -701,32 +704,6 @@ paths: $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' - - '/notification/sms/template-types/{template-type-id}/reset': - delete: - tags: - - SMS Template Types - summary: Resets a SMS template type. - operationId: resetSMSTemplateType - description: | - Resets an existing SMS template type by deleting all its **user defined** SMS templates - from the system.
- - Scope required:
- * internal_template_mgt_delete - parameters: - - $ref: '#/components/parameters/templateTypeIdPathParam' - responses: - '204': - $ref: '#/components/responses/Deleted' - '400': - $ref: '#/components/responses/InvalidInput' - '401': - $ref: '#/components/responses/Unauthorized' - '404': - $ref: '#/components/responses/NotFound' - '500': - $ref: '#/components/responses/ServerError' '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}': get: tags: @@ -1186,7 +1163,7 @@ components: schema: $ref: '#/components/schemas/Error' Deleted: - description: Item Deleted. + description: Item/s Deleted. Updated: description: Item Updated. securitySchemes: @@ -1302,7 +1279,21 @@ components: self: type: string example: /t/{tenant-domain}/api/server/v1/notification/{{email|sms}}/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/{{org|app|system}}templates/en_US - description: Location of the created/updated resource. + description: Location of the created/updated resource. resource. + SimpleTemplateTypeID: + type: object + required: + - templateTypeId + - channel + properties: + templateTypeId: + type: string + example: YWNjb3VudGNvbmZpcm1hdGlvbg + description: Unique ID of the template type. + channel: + type: string + example: EMAIL + description: Notification channel of the template type (SMS or EMAIL). Error: type: object required: diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml index 82c45c83c2..9a978cc39e 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.228-SNAPSHOT + 1.2.236-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index b1fe2fac93..3ab3f15bbc 100644 --- a/pom.xml +++ b/pom.xml @@ -808,12 +808,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.10.6 - 7.5.46 + 1.11.9-SNAPSHOT + 7.5.67-SNAPSHOT 3.0.5 1.12.0 **/gen/**/* - 1.8.19 + 1.9.12-SNAPSHOT 7.0.162 5.11.41 1.9.4 From c1f3065e42741b71a5295eea8c81b6418761b6a0 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Fri, 18 Oct 2024 07:15:19 +0530 Subject: [PATCH 10/17] Add unauthorized deletion error mapping. --- .../server/notification/template/common/Constants.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 29d05ef2d6..6f438f00bd 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -24,6 +24,8 @@ import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_ADDING_TEMPLATE; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_RESOLVING_MAIN_APPLICATION; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes + .ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_ALREADY_EXISTS; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_NOT_FOUND; import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_ALREADY_EXISTS; @@ -110,7 +112,10 @@ public enum ErrorMessage { "Server encountered an error while resolving the main application."), ERROR_ERROR_INVALID_NOTIFICATION_CHANNEL("60015", Status.BAD_REQUEST, "Invalid notification channel.", - "Notification channel can only be either 'EMAIL' or 'SMS'."); + "Notification channel can only be either 'EMAIL' or 'SMS'."), + ERROR_ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED("60016", Status.BAD_REQUEST, + "System resource deletion not allowed.", + "System resources cannot be deleted."); private final String message; private final Status httpStatus; @@ -159,6 +164,8 @@ public String toString() { NTM_ERROR_CODE_MAP.put(TEMPLATE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); NTM_ERROR_CODE_MAP.put(ERROR_ADDING_TEMPLATE, ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); NTM_ERROR_CODE_MAP.put(ERROR_RESOLVING_MAIN_APPLICATION, ErrorMessage.ERROR_ERROR_RESOLVING_MAIN_APPLICATION); + NTM_ERROR_CODE_MAP.put(ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED, + ErrorMessage.ERROR_ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED); } public static ErrorMessage getNTMMappedErrorMessage(String errorCode) { From 080ae50b1c1f2eae461c3b36c388f28c5395caee Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Fri, 18 Oct 2024 07:39:10 +0530 Subject: [PATCH 11/17] Code refactoring --- .../notification/template/v1/core/TemplateTypeService.java | 2 +- findbugs-exclude-filter.xml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 89be9fd673..134a813a36 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -141,7 +141,7 @@ public void resetTemplateType(String notificationChannel, String templateTypeId) TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); if (isTemplateTypeExists) { - TemplatesServiceHolder.getNotificationTemplateManager().deleteCustomizedNotificationTemplates( + TemplatesServiceHolder.getNotificationTemplateManager().resetNotificationTemplateType( notificationChannel, templateTypeDisplayName, getTenantDomainFromContext() ); } else { diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml index 3eadbe5996..d1ddd22da7 100644 --- a/findbugs-exclude-filter.xml +++ b/findbugs-exclude-filter.xml @@ -133,4 +133,11 @@ + + + + + + + From 8c09b8270ed5481fc672f6de6b07cfad3c06fe1f Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Fri, 18 Oct 2024 08:22:33 +0530 Subject: [PATCH 12/17] Fix invalid status code for system resource deletion --- .../api/server/notification/template/common/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 6f438f00bd..87be79600c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -113,7 +113,7 @@ public enum ErrorMessage { ERROR_ERROR_INVALID_NOTIFICATION_CHANNEL("60015", Status.BAD_REQUEST, "Invalid notification channel.", "Notification channel can only be either 'EMAIL' or 'SMS'."), - ERROR_ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED("60016", Status.BAD_REQUEST, + ERROR_ERROR_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED("60016", Status.FORBIDDEN, "System resource deletion not allowed.", "System resources cannot be deleted."); From 544ac6d97fc8c3def9264cf966f156155998a9e3 Mon Sep 17 00:00:00 2001 From: Rushan Nanayakkara Date: Mon, 21 Oct 2024 13:24:29 +0530 Subject: [PATCH 13/17] Apply style suggestions from code review Co-authored-by: AmshikaH <66556626+AmshikaH@users.noreply.github.com> --- .../notification/template/common/TemplatesServiceHolder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java index 60b7d34f8b..b6b55a70aa 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java @@ -15,6 +15,7 @@ public class TemplatesServiceHolder { * @return TemplateManager */ public static NotificationTemplateManager getNotificationTemplateManager() { + return notificationTemplateManager; } @@ -23,6 +24,7 @@ public static NotificationTemplateManager getNotificationTemplateManager() { * @param notificationTemplateManager TemplateManager */ public static void setNotificationTemplateManager(NotificationTemplateManager notificationTemplateManager) { + TemplatesServiceHolder.notificationTemplateManager = notificationTemplateManager; } } From 88287e941c2437c3dbabe58a81f0851f3d73f6e0 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 22 Oct 2024 14:32:49 +0530 Subject: [PATCH 14/17] add valid licence header --- .../pom.xml | 30 +++++++++-------- .../template/common/Constants.java | 2 +- .../common/TemplatesServiceHolder.java | 18 +++++++++++ .../common/factory/OSGIServiceFactory.java | 2 +- .../pom.xml | 31 +++++++++--------- .../template/v1/core/TemplateTypeService.java | 2 +- .../template/v1/core/TemplatesService.java | 2 +- .../notification/template/v1/util/Util.java | 2 +- .../pom.xml | 32 +++++++++---------- 9 files changed, 71 insertions(+), 50 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml index ae508c9072..b8703caaa7 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -1,19 +1,21 @@ +~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +~ +~ WSO2 LLC. licenses this file to you under the Apache License, +~ Version 2.0 (the "License"); you may not use this file except +~ in compliance with the License. +~ You may obtain a copy of the License at +~ +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, +~ software distributed under the License is distributed on an +~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~ KIND, either express or implied. See the License for the +~ specific language governing permissions and limitations +~ under the License. +--> diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java index 87be79600c..33b18b13e2 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java index b6b55a70aa..257949be90 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.identity.api.server.notification.template.common; diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java index f2a067ac23..f591b1cb7c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml index 266f248957..a94149bcf3 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -1,20 +1,21 @@ - +~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +~ +~ WSO2 LLC. licenses this file to you under the Apache License, +~ Version 2.0 (the "License"); you may not use this file except +~ in compliance with the License. +~ You may obtain a copy of the License at +~ +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, +~ software distributed under the License is distributed on an +~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~ KIND, either express or implied. See the License for the +~ specific language governing permissions and limitations +~ under the License. +--> diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java index 134a813a36..626192e4d1 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java index 3dca6ee292..7570d205f6 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java index ddc63d8bbd..9c2fb7e4c0 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml index 9a978cc39e..479c97c692 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -1,21 +1,21 @@ +~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +~ +~ WSO2 LLC. licenses this file to you under the Apache License, +~ Version 2.0 (the "License"); you may not use this file except +~ in compliance with the License. +~ You may obtain a copy of the License at +~ +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, +~ software distributed under the License is distributed on an +~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +~ KIND, either express or implied. See the License for the +~ specific language governing permissions and limitations +~ under the License. +--> From d4df259f15fdad63db051f2ed29160d53e091aec Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 22 Oct 2024 14:58:41 +0530 Subject: [PATCH 15/17] Addressing comments --- .../template/common/factory/OSGIServiceFactory.java | 4 +++- .../notification/template/v1/core/TemplatesService.java | 4 ++-- .../api/server/notification/template/v1/util/Util.java | 7 +++---- .../src/main/resources/notification-template.yml | 2 -- findbugs-exclude-filter.xml | 3 ++- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java index f591b1cb7c..72d43c991e 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.email.mgt.constants.I18nMgtConstants; import org.wso2.carbon.identity.governance.service.notification.NotificationTemplateManager; import java.util.Hashtable; @@ -42,7 +43,8 @@ protected NotificationTemplateManager createInstance() throws Exception { if (this.notificationTemplateManager == null) { Hashtable serviceProperties = new Hashtable<>(); - serviceProperties.put("service.name", "NotificationTemplateManager"); + serviceProperties.put(I18nMgtConstants.SERVICE_PROPERTY_KEY_SERVICE_NAME, + I18nMgtConstants.SERVICE_PROPERTY_VAL_NOTIFICATION_TEMPLATE_MANAGER); NotificationTemplateManager taskOperationService = (NotificationTemplateManager) PrivilegedCarbonContext. getThreadLocalCarbonContext().getOSGiService(NotificationTemplateManager.class, serviceProperties); if (taskOperationService != null) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java index 7570d205f6..22a5b8d575 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java @@ -415,7 +415,7 @@ public void deleteEmailTemplate(String templateTypeId, String locale, String app String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { - Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName); + Util.verifyTemplateTypeExists(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName); boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, locale, getTenantDomainFromContext(), applicationUuid); @@ -454,7 +454,7 @@ public void deleteSMSTemplate(String templateTypeId, String locale, String appli String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { - Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName); + Util.verifyTemplateTypeExists(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName); boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, locale, getTenantDomainFromContext(), applicationUuid); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java index 9c2fb7e4c0..fe126c04e5 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java @@ -77,7 +77,7 @@ public static List buildSimpleTemplateList(List From 94789ca7486a1b1c3ac53e297ad96e1c16779cbf Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 22 Oct 2024 19:52:39 +0530 Subject: [PATCH 16/17] Add notification template api module to pom --- pom.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3a54be5c99..a8db8c4d42 100644 --- a/pom.xml +++ b/pom.xml @@ -496,6 +496,12 @@ ${project.version} provided
+ + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template.common + ${project.version} + provided + org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.secret.management.common @@ -802,12 +808,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.10.6 + 1.11.9-SNAPSHOT 7.5.71 3.0.5 1.12.0 **/gen/**/* - 1.8.19 + 1.9.12-SNAPSHOT 7.0.162 5.11.41 1.9.4 @@ -875,6 +881,7 @@ components/org.wso2.carbon.identity.api.server.organization.configs components/org.wso2.carbon.identity.api.server.organization.selfservice components/org.wso2.carbon.identity.api.server.action.management + components/org.wso2.carbon.identity.api.server.notification.template From 2a1b58f923aff5a7aa2ebb7ebf263ce94cf7fb3c Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Thu, 24 Oct 2024 00:53:25 +0530 Subject: [PATCH 17/17] Bump pom versions --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml index b8703caaa7..3d5c2f73d1 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.236-SNAPSHOT + 1.2.241-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml index a94149bcf3..65b93eb30c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.236-SNAPSHOT + 1.2.241-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml index 479c97c692..ae78585bef 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.236-SNAPSHOT + 1.2.241-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index a8db8c4d42..980e46eea7 100644 --- a/pom.xml +++ b/pom.xml @@ -808,12 +808,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.11.9-SNAPSHOT + 1.11.11 7.5.71 3.0.5 1.12.0 **/gen/**/* - 1.9.12-SNAPSHOT + 1.9.12 7.0.162 5.11.41 1.9.4