diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index 6a552079236..a080208de25 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -188,6 +188,13 @@ import java.util.List;
roles = {"Internal/devicemgt-user"},
permissions = {"/device-mgt/devices/owning-device/add"}
),
+ @Scope(
+ name = "Viewing Enrollment Guide",
+ description = "Show enrollment guide to users",
+ key = "perm:devices:enrollment-guide:view",
+ roles = {"Internal/devicemgt-user"},
+ permissions = {"/device-mgt/devices/enrollment-guide/view"}
+ ),
}
)
@Path("/devices")
@@ -553,12 +560,12 @@ public interface DeviceManagementService {
required = false,
defaultValue = "0")
@QueryParam("offset") int offset,
- @ApiParam(
- name = "limit",
- value = "Provide how many device details you require from the starting pagination index/offset.",
- required = false,
- defaultValue = "100")
- @QueryParam("limit") int limit
+ @ApiParam(
+ name = "limit",
+ value = "Provide how many device details you require from the starting pagination index/offset.",
+ required = false,
+ defaultValue = "100")
+ @QueryParam("limit") int limit
);
@GET
@@ -802,6 +809,59 @@ public interface DeviceManagementService {
@QueryParam("requireDeviceInfo")
boolean requireDeviceInfo);
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Path("/enrollment/guide")
+ @ApiOperation(
+ consumes = MediaType.MULTIPART_FORM_DATA,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Sending Enrollment Mode chosen by customer",
+ notes = "Enrollment mode selected and path is sent as parameters",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:enrollment-guide:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully mailed the Enrollment Guide of customer.",
+ response = Device.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while sending mail of the Enrollment Guide.",
+ response = ErrorResponse.class)
+ })
+ Response sendEnrollmentGuide(
+ @ApiParam(
+ name = "enrolmentGuide",
+ value = "The details of the enrolment path suggested.",
+ required = true)
+ String enrolmentGuide);
+
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/type/any/list")
@@ -1475,15 +1535,15 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified. \n" +
- "Used by caches, or in conditional requests.")}),
+ "Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
- "Empty body because the client already has the latest version of the requested resource.\n"),
+ "Empty body because the client already has the latest version of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -1501,7 +1561,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while getting the device details.",
+ "Server error occurred while getting the device details.",
response = ErrorResponse.class)
})
Response queryDevicesByProperties(
@@ -1523,7 +1583,7 @@ public interface DeviceManagementService {
name = "device property map",
value = "properties by which devices need filtered",
required = true)
- PropertyMap map);
+ PropertyMap map);
@GET
@Produces(MediaType.APPLICATION_JSON)
@@ -1949,140 +2009,141 @@ public interface DeviceManagementService {
@Size(max = 45)
String id);
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/{type}/{id}/getstatushistory")
- @ApiOperation(
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "GET",
- value = "Get Device status history",
- notes = "Get a list of status history associated with the device type and id",
- tags = "Device Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
- })
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully fetched the status history of matching devices.",
- response = List.class,
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Type",
- description = "The content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource was last modified.\n" +
- "Used by caches, or in conditional requests."),
- }),
- @ApiResponse(
- code = 304,
- message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n A device with the specified device type and id was not found.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
- response = ErrorResponse.class)
- })
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{type}/{id}/status-history")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Get Device status history",
+ notes = "Get a list of status history associated with the device type and id",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the status history of matching devices.",
+ response = List.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. Empty body because the client already has the latest version" +
+ " of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n A device with the specified device type and id was not found.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the device details.",
+ response = ErrorResponse.class)
+ })
Response getDeviceStatusHistory(
- @ApiParam(
- name = "type",
- value = "The device type, such as ios, android, or windows.",
- required = true)
- @PathParam("type")
- @Size(max = 45)
- String type,
- @ApiParam(
- name = "id",
- value = "Device ID.",
- required = true)
- @PathParam("id")
- @Size(max = 45)
- String id);
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/{type}/{id}/getenrolmentstatushistory")
- @ApiOperation(
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "GET",
- value = "Get Device Current Enrolment status history",
- notes = "Get a list of status history associated with the device type and id for the current enrolment",
- tags = "Device Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
- })
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully fetched the status history of matching devices.",
- response = List.class,
- responseHeaders = {
- @ResponseHeader(
- name = "Content-Type",
- description = "The content type of the body"),
- @ResponseHeader(
- name = "ETag",
- description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
- @ResponseHeader(
- name = "Last-Modified",
- description = "Date and time the resource was last modified.\n" +
- "Used by caches, or in conditional requests."),
- }),
- @ApiResponse(
- code = 304,
- message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n A device with the specified device type and id was not found.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
- response = ErrorResponse.class)
- })
+ @ApiParam(
+ name = "type",
+ value = "The device type, such as ios, android, or windows.",
+ required = true)
+ @PathParam("type")
+ @Size(max = 45)
+ String type,
+ @ApiParam(
+ name = "id",
+ value = "Device ID.",
+ required = true)
+ @PathParam("id")
+ @Size(max = 45)
+ String id);
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{type}/{id}/enrolment-status-history")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Get Device Current Enrolment status history",
+ notes = "Get a list of status history associated with the device type and id for the current enrolment",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the status history of matching devices.",
+ response = List.class,
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource was last modified.\n" +
+ "Used by caches, or in conditional requests."),
+ }),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. Empty body because the client already has the latest version" +
+ " of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n A device with the specified device type and id was not found.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the device details.",
+ response = ErrorResponse.class)
+ })
Response getCurrentEnrolmentDeviceStatusHistory(
- @ApiParam(
- name = "type",
- value = "The device type, such as ios, android, or windows.",
- required = true)
- @PathParam("type")
- @Size(max = 45)
- String type,
- @ApiParam(
- name = "id",
- value = "Device ID.",
- required = true)
- @PathParam("id")
- @Size(max = 45)
- String id);
+ @ApiParam(
+ name = "type",
+ value = "The device type, such as ios, android, or windows.",
+ required = true)
+ @PathParam("type")
+ @Size(max = 45)
+ String type,
+ @ApiParam(
+ name = "id",
+ value = "Device ID.",
+ required = true)
+ @PathParam("id")
+ @Size(max = 45)
+ String id);
@PUT
@Produces(MediaType.APPLICATION_JSON)
@@ -2247,16 +2308,16 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
+ " of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -2268,7 +2329,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
+ "Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response getDeviceCountByStatus(
@@ -2316,16 +2377,16 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
+ " of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -2337,7 +2398,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
+ "Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response getDeviceIdentifiersByStatus(
@@ -2386,16 +2447,16 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest " +
- "version of the requested resource."),
+ "version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -2407,7 +2468,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while retrieving information requested device.",
+ "Server error occurred while retrieving information requested device.",
response = ErrorResponse.class)
})
Response bulkUpdateDeviceStatus(
@@ -2718,11 +2779,11 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 500,
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index b21eb4bcf8d..6d0696df84e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -80,6 +80,8 @@ import org.wso2.carbon.device.mgt.common.search.PropertyMap;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceStatus;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
+import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
+import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
import org.wso2.carbon.device.mgt.core.dao.TrackerManagementDAOException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
@@ -784,6 +786,32 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.OK).entity(device).build();
}
+ @POST
+ @Path("/enrollment/guide")
+ @Override
+ public Response sendEnrollmentGuide(String enrolmentGuide) {
+ if (log.isDebugEnabled()) {
+ log.debug("Sending enrollment invitation mail to existing user.");
+ }
+ DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
+ if (!config.getEnrollmentGuideConfiguration().isEnabled()) {
+ String msg = "Sending enrollment guide config is not enabled.";
+ log.error(msg);
+ return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
+ }
+ DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
+ try {
+ dms.sendEnrolmentGuide(enrolmentGuide);
+ return Response.status(Response.Status.OK).entity("Invitation mails have been sent.").build();
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred sending mail to group in enrollment guide";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ }
+
+
@POST
@Path("/type/any/list")
@Override
@@ -1331,7 +1359,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
* @return {@link Response} object
*/
@GET
- @Path("/{type}/{id}/getstatushistory")
+ @Path("/{type}/{id}/status-history")
public Response getDeviceStatusHistory(@PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id) {
//TODO check authorization for this
@@ -1363,7 +1391,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
* @return {@link Response} object
*/
@GET
- @Path("/{type}/{id}/getenrolmentstatushistory")
+ @Path("/{type}/{id}/enrolment-status-history")
public Response getCurrentEnrolmentDeviceStatusHistory(@PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id) {
//TODO check authorization for this or current enrolment should be based on for the enrolment associated with the user
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
index 9ba76f99fb9..0d45a2efc1d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
@@ -136,6 +136,7 @@ public final class DeviceManagementConstants {
public static final String POLICY_VIOLATE_TEMPLATE = "policy-violating-notifier";
public static final String USER_WELCOME_TEMPLATE = "user-welcome";
public static final String DEFAULT_ENROLLMENT_TEMPLATE = "default-enrollment-invitation";
+ public static final String ENROLLMENT_GUIDE_TEMPLATE = "enrollment-guide";
}
public static final class OperationAttributes {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java
index f2ad40abb70..cc3a3dc5b4f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java
@@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.core.config.cache.BillingCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.GeoFenceCacheConfiguration;
+import org.wso2.carbon.device.mgt.core.config.enrollment.guide.EnrollmentGuideConfiguration;
import org.wso2.carbon.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration;
import org.wso2.carbon.device.mgt.core.event.config.EventOperationTaskConfiguration;
import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration;
@@ -70,6 +71,7 @@ public final class DeviceManagementConfig {
private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration;
private DefaultRoles defaultRoles;
private OperationTimeoutConfiguration operationTimeoutConfiguration;
+ private EnrollmentGuideConfiguration enrollmentGuideConfiguration;
@XmlElement(name = "ManagementRepository", required = true)
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
@@ -265,5 +267,14 @@ public final class DeviceManagementConfig {
public void setOperationTimeoutConfiguration(OperationTimeoutConfiguration operationTimeoutConfiguration) {
this.operationTimeoutConfiguration = operationTimeoutConfiguration;
}
+
+ @XmlElement(name = "EnrollmentGuideConfiguration", required = true)
+ public EnrollmentGuideConfiguration getEnrollmentGuideConfiguration() {
+ return enrollmentGuideConfiguration;
+ }
+
+ public void setEnrollmentGuideConfiguration(EnrollmentGuideConfiguration enrollmentGuideConfiguration) {
+ this.enrollmentGuideConfiguration = enrollmentGuideConfiguration;
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java
new file mode 100644
index 00000000000..5f54cf79d41
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java
@@ -0,0 +1,30 @@
+package org.wso2.carbon.device.mgt.core.config.enrollment.guide;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "EnrollmentGuideConfiguration")
+public class EnrollmentGuideConfiguration {
+
+ private boolean isEnabled;
+ private String mail;
+
+ @XmlElement(name = "Enable", required = true)
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ isEnabled = enabled;
+ }
+
+ @XmlElement(name = "Mail", required = true)
+ public String getMail() {
+ return mail;
+ }
+
+ public void setMail(String mail) {
+ this.mail = mail;
+ }
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
index 4e12d2cf1a4..3dedb8d5511 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
@@ -645,6 +645,8 @@ public interface DeviceManagementProviderService {
void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException,
ConfigurationManagementException;
+ void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException;
+
void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException, ConfigurationManagementException;
FeatureManager getFeatureManager(String deviceType) throws DeviceTypeNotFoundException;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
index 9b287756878..6257e0b34d2 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
@@ -198,6 +198,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
private final ApplicationDAO applicationDAO;
private MetadataDAO metadataDAO;
private final DeviceStatusDAO deviceStatusDAO;
+ int count = 0;
public DeviceManagementProviderServiceImpl() {
this.pluginRepository = new DeviceManagementPluginRepository();
@@ -1555,6 +1556,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
}
+ @Override
+ public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException {
+
+ DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
+ String recipientMail = config.getEnrollmentGuideConfiguration().getMail();
+ Properties props = new Properties();
+ props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")");
+ props.setProperty("enrollment-guide", enrolmentGuide);
+
+ try {
+ EmailMetaInfo metaInfo = new EmailMetaInfo(recipientMail, props);
+ sendEnrolmentInvitation(DeviceManagementConstants.EmailAttributes.ENROLLMENT_GUIDE_TEMPLATE, metaInfo);
+ } catch (ConfigurationManagementException e) {
+ String msg = "Error occurred while sending the mail.";
+ log.error(msg, e);
+ throw new DeviceManagementException(msg, e);
+ }
+ }
+
@Override
public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException,
ConfigurationManagementException {
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml
index 340b22802b7..f0ebf0de840 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml
@@ -187,5 +187,9 @@
+
+ false
+ Replace with mail
+
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml
index d30f414885b..4867c665c04 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml
@@ -109,6 +109,7 @@
perm:devices:details
perm:devices:update
perm:devices:view
+ perm:devices:enrollment-guide:view
perm:view-configuration
perm:manage-configuration
perm:policies:remove
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2
index f567bb9dd2b..09e3fad19be 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2
@@ -322,7 +322,7 @@
-
+
@@ -350,6 +350,15 @@
{% endfor %}
{% endif%}
-
+
+
+ {% if device_mgt_conf.enrollment_guide_conf is defined %}
+ {{device_mgt_conf.enrollment_guide_conf.enable}}
+ {{device_mgt_conf.enrollment_guide_conf.mail}}
+ {% else %}
+ false
+ Replace with mail
+ {% endif %}
+
diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm
new file mode 100644
index 00000000000..f4f16cc8d7b
--- /dev/null
+++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm
@@ -0,0 +1,34 @@
+#*
+ Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+
+ WSO2 Inc. 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.
+*#
+
+ $mail-subject
+
+
+
+ Enrollment Questions and Answers
+
+
+
+ $enrollment-guide
+
+
+
+ ]]>
+